sync.order.cs 632 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695
  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. namespace SiteCore.Handler
  48. {
  49. public partial class sync
  50. {
  51. public void get_erp_orderlist()
  52. {
  53. string poscode = CurrentUser.UserPost.Post.Code;
  54. DataStruct dStruct = GetPostStruct();
  55. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\扇子.xls");
  56. //apiHelper.Api_SyncOrderByTime("598825");
  57. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  58. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  59. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  60. //banniuApiHelper.sendLogisticsInfo(null);
  61. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  62. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  63. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  64. //int sid = commonHelper.autoDistributeToSupplier(entity);
  65. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  66. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1747793700000,\"deliveryType\":\"OFFLINE\",\"discountFee\":15.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1748015999000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":85.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2200806677467/O1CN01aEDI6s251wFlRwWHL_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4348532702415998633\",\"refSkuId\":\"0\",\"refSpuId\":\"620901028368\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":42.5,\"singleFee\":42.5,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【狂欢价】水晶标贴金属标签LOGO贴纸定制车热uv转印贴透明商标打印设备移丝印广告自粘刻字烫金定做公司防水不干胶印刷\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1747794079000,\"openBuyerId\":\"AAEmRHraABkUZRPgSx1NTPcZ\",\"openBuyerNick\":\"排**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1747793522000,\"payTime\":1747793695000,\"payment\":85.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"梅州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"梅江区\",\"receiverId\":\"c01bdfe140ea76155b427e6b00424547$\",\"receiverState\":\"广东省\",\"receiverTown\":\"三角镇\",\"refOid\":\"4348532702415998633\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"34.5x25.5mm-210个-UV转印贴-彩色-模切-排排坐唱山歌歌-小钰-()-老客户改稿\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0,\"type\":\"SALE\"}}");
  67. //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}}");
  68. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  69. //commonHelper.loginGetOrder(2152);
  70. List<string> lw = new List<string>();
  71. string tid = GetPostString("ctid");
  72. string date1 = GetPostString("date1");
  73. //12-1 修改
  74. string urgent = GetPostString("urgent");
  75. string back = GetPostString("back");
  76. string offlineSearch = GetPostString("offlineSearch");
  77. int paramsCount = 0;
  78. if (!string.IsNullOrWhiteSpace(urgent))
  79. {
  80. if (urgent.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(back))
  86. {
  87. if (back.Equals("true"))
  88. {
  89. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  90. }
  91. }
  92. if (!string.IsNullOrWhiteSpace(offlineSearch))
  93. {
  94. if (offlineSearch.Equals("true"))
  95. {
  96. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  97. }
  98. }
  99. //end
  100. string date2 = GetPostString("date2");
  101. string buyernick = GetPostString("buyer_nick");
  102. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  103. {
  104. if (tid.Length <= 0 && buyernick.Length <= 0)
  105. {
  106. return;
  107. }
  108. }
  109. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  110. {
  111. if (tid.Length > 0)
  112. {
  113. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  114. if (ceErpTradeCell != null)
  115. {
  116. tid = ceErpTradeCell.tid;
  117. }
  118. List<string> select_tid = getTidByCtidMore(tid);
  119. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  120. }
  121. if (buyernick.Length > 0)
  122. {
  123. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  124. }
  125. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  126. if (dw.Length > 0)
  127. {
  128. lw.Add(dw);
  129. }
  130. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  131. {
  132. string usershop = CurrentUser.User.pemShop;
  133. lw.Add(string.Format("ShopId in ({0})", usershop));
  134. }
  135. }
  136. else
  137. {
  138. if (ex_psize == 0)
  139. {
  140. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  141. }
  142. if (PKey != "admin")
  143. {
  144. string usershop = CurrentUser.User.pemShop;
  145. lw.Add(string.Format("ShopId in ({0})", usershop));
  146. paramsCount++;
  147. }
  148. }
  149. string uploaddate1 = GetPostString("uploaddate1");
  150. string uploaddate2 = GetPostString("uploaddate2");
  151. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  152. if (update.Length > 0) lw.Add(update);
  153. string deliverydate1 = GetPostString("deliverydate1");
  154. string deliverydate2 = GetPostString("deliverydate2");
  155. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  156. if (deliverydate.Length > 0)
  157. {
  158. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  159. };
  160. string shopname = GetPostString("shopname");
  161. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  162. string addwechat = GetPostString("addwechat");
  163. if (addwechat.Length > 0)
  164. {
  165. int addWt = Convert.ToInt32(addwechat);
  166. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  167. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  168. }
  169. string customer = GetPostString("customer");
  170. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  171. string design = GetPostString("design");
  172. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  173. string orderState = GetPostString("orderState");
  174. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  175. string address = GetPostString("address");
  176. 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));
  177. string sellermemo = GetPostString("seller_memo");
  178. if (sellermemo.Length > 0)
  179. {
  180. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  181. }
  182. string backReason = GetPostString("backReason");
  183. if (backReason.Length > 0)
  184. {
  185. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  186. }
  187. string apdate1 = GetPostString("apdate1");
  188. string apdate2 = GetPostString("apdate2");
  189. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  190. if (dwap.Length > 0) lw.Add(dwap);
  191. string price1 = GetPostString("price1");
  192. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  193. string price2 = GetPostString("price2");
  194. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  195. string isoldcustomer = GetPostString("isoldcus");
  196. string spudata = GetPostString("spudata");
  197. if ("0".Equals(spudata))
  198. {
  199. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  200. }
  201. if ("1".Equals(spudata))
  202. {
  203. lw.Add(string.Format("spu_id <> ''"));
  204. }
  205. string finishdate1 = GetPostString("finishdate1");
  206. string finishdate2 = GetPostString("finishdate2");
  207. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  208. bool isFinish = false;
  209. if (finishdate.Length > 0)
  210. {
  211. lw.Add(finishdate);
  212. isFinish = true;
  213. paramsCount++;
  214. }
  215. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  216. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  217. if (ex_psize > 0)
  218. {
  219. int UserID = CurrentUser.UserID;
  220. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  221. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  222. {
  223. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  224. }
  225. dStruct.Order = "pay_time desc";
  226. }
  227. string isNew = GetPostString("isNew");
  228. if (isNew == "true")
  229. {
  230. lw.Add(string.Format("IsNew = {0}", 1));
  231. }
  232. string overtime = GetPostString("overtime");
  233. if (overtime == "1")
  234. {
  235. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  236. }
  237. String usePost = CurrentUser.UserPost.Post.Code;
  238. if (usePost.Equals("Operation") == true)
  239. {
  240. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  241. }
  242. else
  243. {
  244. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  245. }
  246. //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";
  247. if (dStruct.PageSize == 100000)
  248. {
  249. dStruct.Order = "";
  250. }
  251. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  252. DataTable dt = null;
  253. string tablename = "view_orderlist";
  254. if (isFinish)
  255. {
  256. tablename = "view_orderlist_end";
  257. }
  258. dt = WebCache.GetData(tablename, dStruct);
  259. if (dt != null && dt.Rows.Count > 0)
  260. {
  261. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  262. foreach (DataRow dr in dt.Rows)
  263. {
  264. try
  265. {
  266. if (dr["refund_fees"] != null)
  267. {
  268. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  269. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  270. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  271. if (payment == refund_fees)
  272. {
  273. dr["refund_fees"] = Math.Round(refund_fees, 2);
  274. }
  275. else if (refund_fees == total_fee)
  276. {
  277. dr["refund_fees"] = payment;
  278. }
  279. else
  280. {
  281. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  282. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  283. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  284. }
  285. }
  286. // 对象操作
  287. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  288. ceErpTradeCell.ctid = dr["ctid"].ToString();
  289. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  290. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  291. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  292. if (dStruct.PageSize != 100000)
  293. {
  294. if (dr["DispatchSort"].ToString() == "2")
  295. {
  296. dr["gongchuang"] = 200;
  297. }
  298. else if ("外协".Equals(dr["ToType"].ToString()))
  299. {
  300. dr["gongchuang"] = 200;
  301. }
  302. else if ("内部".Equals(dr["ToType"].ToString()))
  303. {
  304. dr["gongchuang"] = -1;
  305. }
  306. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  307. {
  308. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  309. dr["gongchuang"] = response.code;
  310. }
  311. }
  312. }
  313. catch (NullReferenceException ex)
  314. {
  315. // 处理空引用异常
  316. dr["refund_fees"] = "0.00";
  317. }
  318. }
  319. }
  320. writeGridDataTableJson(dStruct.TotalCount, dt);
  321. }
  322. public void get_erp_orderlist_sumprice()
  323. {
  324. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  325. return;
  326. List<string> lw = new List<string>();
  327. string tid = GetPostString("ctid");
  328. string date1 = GetPostString("date1");
  329. string date2 = GetPostString("date2");
  330. if (tid.Length > 0 || date1.Length > 0)
  331. {
  332. lw.Add(string.Format("ctid like '%{0}%'", tid));
  333. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  334. if (dw.Length > 0) lw.Add(dw);
  335. }
  336. else
  337. {
  338. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  339. }
  340. string shopname = GetPostString("shopname");
  341. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  342. string buyernick = GetPostString("buyer_nick");
  343. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  344. string customer = GetPostString("customer");
  345. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  346. string design = GetPostString("design");
  347. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  348. string orderState = GetPostString("orderState");
  349. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  350. string address = GetPostString("address");
  351. 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));
  352. string sellermemo = GetPostString("seller_memo");
  353. if (sellermemo.Length > 0)
  354. {
  355. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  356. }
  357. string apdate1 = GetPostString("apdate1");
  358. string apdate2 = GetPostString("apdate2");
  359. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  360. if (dwap.Length > 0) lw.Add(dwap);
  361. string price1 = GetPostString("price1");
  362. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  363. string price2 = GetPostString("price2");
  364. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  365. string isoldcustomer = GetPostString("isoldcus");
  366. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  367. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  368. if (PKey != "admin")
  369. {
  370. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  371. lw.Add(string.Format("shopId in ({0})", usershop));
  372. }
  373. //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";
  374. string mainWhere = string.Join(" and ", lw.ToArray());
  375. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  376. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  377. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  378. decimal total = 0;
  379. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  380. {
  381. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  382. }
  383. var res = new
  384. {
  385. data = total
  386. };
  387. string ro_jsond = JsonConvert.SerializeObject(res);
  388. returnSuccess(ro_jsond);
  389. return;
  390. }
  391. public void get_erp_CustomerServiceGather()
  392. {
  393. string userWhere = "", orderWhere = "";
  394. List<string> lw = new List<string>();
  395. string customer = GetPostString("customer");
  396. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  397. string shopname = GetPostString("shopname");
  398. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  399. string date1 = GetPostString("date1");
  400. string date2 = GetPostString("date2");
  401. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  402. if (dw.Length > 0) lw.Add(dw);
  403. orderWhere = string.Join(" and ", lw.ToArray());
  404. 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 " +
  405. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  406. "left join " +
  407. "( " +
  408. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  409. ") as b on a.ID = b.CustomerUserId " +
  410. "left join " +
  411. "( " +
  412. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  413. ") as d on a.ID = d.CustomerUserId " +
  414. "left join " +
  415. "( " +
  416. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  417. ") as e on a.ID = e.CustomerUserId " +
  418. "left join " +
  419. "( " +
  420. " select CustomerUserId, RefundCount, RefundSum from " +
  421. " ( " +
  422. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  423. " from CE_ErpTradeRefund a " +
  424. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  425. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  426. " group by CustomerUserId " +
  427. " ) as a " +
  428. ") as f on a.ID = f.CustomerUserId " +
  429. "where a.PostCode = 'CustomerService'",
  430. userWhere, orderWhere);
  431. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  432. writeGridDataTableJson(dt.Rows.Count, dt);
  433. //writeGridDataTableJson(dt.Rows.Count, dt);
  434. }
  435. //设计汇总
  436. public void get_erp_DesignerGather()
  437. {
  438. string userWhere = "", orderWhere = "";
  439. List<string> lw = new List<string>();
  440. string Designer = GetPostString("designer");
  441. int org = GetPostInt("org");
  442. if (Designer.Length > 0)
  443. {
  444. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  445. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  446. }
  447. else if (org > 0)
  448. {
  449. userWhere = string.Format(" where OrgID ={0}", org);
  450. }
  451. string shopname = GetPostString("shopname");
  452. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  453. string state = GetPostString("state");
  454. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  455. string OrderArea = GetPostString("order_area");
  456. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  457. string date1 = GetPostString("date1");
  458. string date2 = GetPostString("date2");
  459. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  460. if (dw.Length > 0) lw.Add(dw);
  461. string UpDate1 = GetPostString("UpDate1");
  462. string UpDate2 = GetPostString("UpDate2");
  463. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  464. if (dw.Length > 0) lw.Add(dw);
  465. orderWhere = string.Join(" and ", lw.ToArray());
  466. 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 (" +
  467. "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 " +
  468. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  469. "left join " +
  470. "( " +
  471. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  472. ") as b on a.ID = b.DesignUserId " +
  473. "left join " +
  474. "( " +
  475. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  476. ") as d on a.ID = d.DesignUserId " +
  477. "left join " +
  478. "( " +
  479. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  480. ") as e on a.ID = e.DesignUserId " +
  481. "left join " +
  482. "( " +
  483. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  484. ") as g on a.ID = g.DesignUserId " +
  485. "left join " +
  486. "( " +
  487. " select CustomerUserId, RefundCount, RefundSum from " +
  488. " ( " +
  489. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  490. " from CE_ErpTradeRefund a " +
  491. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  492. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  493. " group by CustomerUserId " +
  494. " ) as a " +
  495. ") as f on a.ID = f.CustomerUserId " +
  496. "where a.PostCode = 'Designer') as z",
  497. userWhere, orderWhere);
  498. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  499. writeGridDataTableJson(dt.Rows.Count, dt);
  500. }
  501. //删除tradecell的订单
  502. public void del_erp_cellorder()
  503. {
  504. if (UrlPostParmsCheck("ctid"))
  505. {
  506. string eid = GetPostString("ctid");
  507. CeErpTradeCell.DelByCtid(eid);
  508. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  509. returnSuccessMsg("删除成功");
  510. }
  511. }
  512. public void clear_erp_refundstate()
  513. {
  514. if (UrlPostParmsCheck("ids"))
  515. {
  516. string eids = GetPostString("ids");
  517. string[] ctidList = eids.Split(',');
  518. foreach (string ctid in ctidList)
  519. {
  520. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  521. if (entity != null)
  522. {
  523. entity.IsRefund = 0;
  524. entity.Update();
  525. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  526. }
  527. else
  528. continue;
  529. }
  530. returnSuccessMsg("操作成功");
  531. return;
  532. }
  533. returnErrorMsg("缺少必要参数");
  534. }
  535. public void set_erp_urgency()
  536. {
  537. if (UrlPostParmsCheck("ctid"))
  538. {
  539. string eid = GetPostString("ctid");
  540. CeErpTradeCell entity = null;
  541. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  542. if (entity != null)
  543. {
  544. double prices = commonHelper.calculationPrice(entity);
  545. if (prices <= 100)
  546. {
  547. returnErrorMsg("此订单金额不足100元,无法加急。");
  548. return;
  549. }
  550. string utime = GetPostString("urgencytime");
  551. if (utime.Length > 0)
  552. {
  553. entity.UrgencyTime = Convert.ToDateTime(utime);
  554. }
  555. else
  556. {
  557. returnErrorMsg("请选择加急时间");
  558. return;
  559. }
  560. if (entity.OrderState <= 4)
  561. {
  562. //entity.seller_memo = entity.seller_memo + "-加急";
  563. string smemo = entity.seller_memo;
  564. int kindex = smemo.IndexOf(")");
  565. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  566. if (lastoneStr != "-")
  567. {
  568. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  569. }
  570. string prememo = smemo.Substring(0, kindex + 2);
  571. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  572. int lastkindex = lastmemo.IndexOf("(");
  573. DateTime urgtime = Convert.ToDateTime(utime);
  574. string newlastmemo = "";
  575. if (lastkindex == 0)
  576. {
  577. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  578. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  579. }
  580. else
  581. {
  582. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  583. }
  584. entity.seller_memo = prememo + newlastmemo;
  585. }
  586. entity.IsUrgency = true;
  587. entity.UpdateTime = DateTime.Now;
  588. entity.Update();
  589. ApiVo apiVo = new ApiVo();
  590. apiVo.orderNumber = entity.ctid;
  591. apiVo.actionName = "changeDesign";
  592. apiVo.orderRemarks = entity.seller_memo;
  593. apiVo.remarkSign = 3;
  594. designHelper.API_WorkCore(apiVo); //changeDesign
  595. CeErpSukuraData.createInfo(entity.ctid, 7);
  596. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  597. returnSuccessMsg("设置成功!");
  598. return;
  599. }
  600. returnErrorMsg("找不到记录");
  601. }
  602. }
  603. public void set_erp_reset()
  604. {
  605. if (UrlPostParmsCheck("ctid"))
  606. {
  607. string eid = GetPostString("ctid");
  608. CeErpTradeCell entity = null;
  609. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  610. if (entity != null)
  611. {
  612. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  613. {
  614. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  615. {
  616. returnErrorMsg("财务要求已下单已发货无法重置");
  617. return;
  618. }
  619. }
  620. entity.IsUrgency = false;
  621. entity.seller_memo = "";
  622. entity.OtherMemo = "";
  623. entity.OrderState = 0;
  624. entity.IsReturn = 0;
  625. //entity.IsRefund = 0;
  626. entity.MemoOpt = 0;
  627. entity.AfterSaleState = 0;
  628. entity.AfterSaleResponsible = "";
  629. entity.AfterSaleUserId = 0;
  630. entity.IsNeedBill = 0;
  631. entity.CustomerUserId = 0;
  632. entity.DesignUserId = 0;
  633. entity.SupplierId = 0;
  634. entity.PlaceUserId = 0;
  635. entity.ptid = "";
  636. entity.IsSample = 0;
  637. entity.IsXianHuo = 0;
  638. entity.isDianziOrder = 0;
  639. entity.DispatchSort = 0;
  640. entity.FinishPlaceTime = null;
  641. entity.Update();
  642. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  643. if (trade != null)
  644. {
  645. trade.seller_memo = "";
  646. trade.Update();
  647. }
  648. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  649. returnSuccessMsg("重置成功!");
  650. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  651. if (desginBill != null)
  652. {
  653. desginBill.isDel = 1;
  654. desginBill.Update();
  655. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  656. }
  657. ApiVo apiVo = new ApiVo();
  658. apiVo.orderNumber = entity.ctid;
  659. apiVo.actionName = "resetDesign";
  660. designHelper.API_WorkCore(apiVo);//resetDesign
  661. return;
  662. }
  663. returnErrorMsg("找不到记录");
  664. }
  665. }
  666. public void save_erp_sellermemo()
  667. {
  668. if (UrlPostParmsCheck("ctid"))
  669. {
  670. string ctid = GetPostString("ctid");
  671. CeErpTradeCell entity = null;
  672. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  673. if (entity != null)
  674. {
  675. string memo = GetPostString("seller_memo");
  676. memo = memo.Replace(" ", "");
  677. if (memo.Contains("补差"))
  678. {
  679. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  680. return;
  681. }
  682. List<string> bitList = new List<string>
  683. {
  684. "\\","/",":","*","?", "\"","<" ,">","|"
  685. };
  686. bool isIn = false;
  687. foreach (string bit in bitList)
  688. {
  689. if (memo.Contains(bit))
  690. {
  691. isIn = true;
  692. }
  693. }
  694. if (isIn)
  695. {
  696. returnErrorMsg("不能使用 一些符合作为文件名");
  697. return;
  698. }
  699. if (entity.seller_memo != memo)
  700. {
  701. if (entity.IsSample == 2)
  702. {
  703. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  704. return;
  705. }
  706. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  707. {
  708. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  709. {
  710. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  711. return;
  712. }
  713. /*if (CurrentUser.UserPost.Post.Code != "Place")
  714. {
  715. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  716. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  717. {
  718. returnErrorMsg("售前系统订单无法再此修改!");
  719. return;
  720. }
  721. }*/
  722. }
  723. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  724. }
  725. commonHelper.getCytPrice(entity);
  726. int memoopt = GetPostInt("MemoOpt");
  727. Boolean ismemoopt = false;
  728. if (memoopt > 0)
  729. {
  730. string stropt = "";
  731. if (memoopt == 1)
  732. {
  733. stropt = "“改稿”";
  734. ismemoopt = true;
  735. }
  736. else if (memoopt == 2)
  737. {
  738. stropt = "“定稿”";
  739. }
  740. else if (memoopt == 3)
  741. {
  742. stropt = "“查货”";
  743. CeErpSukuraData.createInfo(entity.ctid, 6);
  744. }
  745. entity.MemoOpt = Convert.ToInt32(memoopt);
  746. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  747. }
  748. if (entity.OrderState < 5)
  749. {
  750. memo = memo.Replace("(", "(");
  751. memo = memo.Replace(")", ")");
  752. }
  753. if (entity.OrderState < 3)
  754. {
  755. entity.DispatchSort = 0;
  756. }
  757. entity.seller_memo = memo;
  758. entity.UpdateTime = DateTime.Now;
  759. entity.Update();
  760. ApiVo apiVo = new ApiVo();
  761. apiVo.orderNumber = entity.ctid;
  762. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  763. apiVo.orderRemarks = memo;
  764. apiVo.remarkSign = memoopt;
  765. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  766. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  767. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  768. {
  769. dataHelper.api_orderBack(entity.ctid, "0", "");
  770. }
  771. if (entity.seller_memo.Contains("改稿"))
  772. {
  773. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  774. }
  775. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  776. returnSuccessMsg("保存成功!");
  777. return;
  778. }
  779. returnErrorMsg("找不到记录");
  780. }
  781. }
  782. public void ins_erp_checkorder()
  783. {
  784. if (UrlPostParmsCheck("ctid"))
  785. {
  786. string ctid = GetPostString("ctid");
  787. CeErpTradeCell entity = null;
  788. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  789. if (entity != null)
  790. {
  791. if (entity.OrderState < 6)
  792. {
  793. returnErrorMsg("下单完成后才可查货");
  794. return;
  795. }
  796. /*if (entity.OrderState > 6)
  797. {
  798. returnErrorMsg("订单已发货");
  799. return;
  800. }*/
  801. if (entity.FinishPlaceTime != null)
  802. {
  803. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  804. {
  805. returnErrorMsg("下单时间不足,无法查货");
  806. return;
  807. }
  808. }
  809. entity.MemoOpt = 3;
  810. entity.CheckOrderTime = DateTime.Now;
  811. entity.UpdateTime = DateTime.Now;
  812. entity.Update();
  813. CeErpSukuraData.createInfo(entity.ctid, 6);
  814. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  815. returnSuccessMsg("操作成功!");
  816. return;
  817. }
  818. returnErrorMsg("找不到记录");
  819. }
  820. }
  821. public void save_erp_othermemo()
  822. {
  823. if (UrlPostParmsCheck("ctid"))
  824. {
  825. string ctid = GetPostString("ctid");
  826. CeErpTradeCell entity = null;
  827. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  828. if (entity != null)
  829. {
  830. entity.OtherMemo = GetPostString("otherMemo");
  831. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  832. {
  833. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  834. StringBuilder sql = new StringBuilder();
  835. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  836. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  837. if (dt != null && dt.Rows.Count > 0)
  838. {
  839. foreach (DataRow dr in dt.Rows)
  840. {
  841. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  842. {
  843. //品类一直
  844. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  845. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  846. if (ceErpSampleCustomer == null)
  847. {
  848. ceErpSampleCustomer = new CeErpSampleCustomer();
  849. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  850. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  851. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  852. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  853. ceErpSampleCustomer.shopId = entity.ShopId;
  854. }
  855. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  856. ceErpSampleCustomer.lastTid = entity.tid;
  857. if (ceErpSampleCustomer.ID > 0)
  858. {
  859. ceErpSampleCustomer.Update();
  860. }
  861. else
  862. {
  863. ceErpSampleCustomer.Create();
  864. }
  865. }
  866. }
  867. }
  868. }
  869. //if (entity.IsOldCustomer == 1)
  870. //{
  871. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  872. //{
  873. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  874. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  875. //}
  876. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  877. //{
  878. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  879. // {
  880. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  881. // {
  882. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  883. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  884. // }
  885. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  886. // {
  887. // entity.OrderState = 2;
  888. // entity.DesignUserId = 0;
  889. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  890. // }
  891. // else
  892. // {
  893. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  894. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  895. // }
  896. // }
  897. //}
  898. //}
  899. entity.UpdateTime = DateTime.Now;
  900. entity.Update();
  901. returnSuccessMsg("保存成功!");
  902. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  903. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  904. if (entity.OtherMemo.Contains("改稿"))
  905. {
  906. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  907. }
  908. return;
  909. }
  910. returnErrorMsg("找不到记录");
  911. }
  912. }
  913. public void save_erp_customermemo()
  914. {
  915. if (UrlPostParmsCheck("ctid"))
  916. {
  917. string ctid = GetPostString("ctid");
  918. CeErpTradeCell entity = null;
  919. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  920. if (entity != null)
  921. {
  922. entity.UpdateTime = DateTime.Now;
  923. entity.CustomerMemo = GetPostString("CustomerMemo");
  924. entity.Update();
  925. ApiVo apiVo = new ApiVo();
  926. apiVo.orderNumber = entity.ctid;
  927. apiVo.actionName = "followRemarks";
  928. apiVo.orderRemarks = entity.CustomerMemo;
  929. designHelper.API_WorkCore(apiVo);//followRemarks
  930. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  931. returnSuccessMsg("保存成功!");
  932. return;
  933. }
  934. returnErrorMsg("找不到记录");
  935. }
  936. }
  937. public void upd_erp_addmemotag()
  938. {
  939. if (UrlPostParmsCheck("ctid"))
  940. {
  941. ;
  942. string eid = GetPostString("ctid");
  943. string sfTagstr = GetPostString("memotag");
  944. CeErpTradeCell entity = null;
  945. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  946. if (entity != null)
  947. {
  948. ApiVo apiVo = new ApiVo();
  949. if (entity.OrderState == 0)
  950. {
  951. returnErrorMsg("请先领单");
  952. return;
  953. }
  954. //撤销顺丰
  955. if (sfTagstr == "撤销顺丰")
  956. {
  957. entity.IsSF = 0;
  958. string reMsg = "";
  959. string oldmemo = entity.seller_memo;
  960. if (entity.OrderState < 5)
  961. {
  962. oldmemo = oldmemo.Replace("顺丰到付", "");
  963. oldmemo = oldmemo.Replace("顺丰寄付", "");
  964. entity.seller_memo = oldmemo;
  965. }
  966. else
  967. {
  968. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  969. {
  970. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  971. }
  972. }
  973. entity.Update();
  974. apiVo.orderNumber = entity.ctid;
  975. apiVo.actionName = "orderRemarks";
  976. apiVo.orderRemarks = entity.seller_memo;
  977. apiVo.isSf = entity.IsSF.ToString();
  978. designHelper.API_WorkCore(apiVo);//orderRemarks
  979. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  980. returnSuccessMsg("撤销成功!" + reMsg);
  981. return;
  982. }
  983. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  984. {
  985. //string oldmemo = entity.seller_memo;
  986. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  987. string sfStr = GetPostString("memotag");
  988. string smemo = entity.seller_memo;
  989. int kindex = smemo.IndexOf(")");
  990. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  991. if (lastoneStr != "-")
  992. {
  993. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  994. }
  995. string prememo = smemo.Substring(0, kindex + 2);
  996. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  997. int lastkindex = lastmemo.IndexOf("(");
  998. string newlastmemo = "";
  999. if (lastkindex == 0)
  1000. {
  1001. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1002. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1003. }
  1004. else
  1005. {
  1006. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1007. }
  1008. entity.seller_memo = prememo + newlastmemo;
  1009. }
  1010. string sfTagMSg = "";
  1011. if (sfTagstr == "顺丰寄付")
  1012. {
  1013. entity.IsSF = 1;
  1014. sfTagMSg = "顺丰寄付";
  1015. }
  1016. else if (sfTagstr == "顺丰到付")
  1017. {
  1018. entity.IsSF = 2;
  1019. sfTagMSg = "顺丰到付";
  1020. }
  1021. entity.Update();
  1022. apiVo = new ApiVo();
  1023. apiVo.orderNumber = entity.ctid;
  1024. apiVo.actionName = "orderRemarks";
  1025. apiVo.orderRemarks = entity.seller_memo;
  1026. apiVo.isSf = entity.IsSF.ToString();
  1027. designHelper.API_WorkCore(apiVo);//orderRemarks
  1028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1029. returnSuccessMsg("标记成功!");
  1030. return;
  1031. }
  1032. returnErrorMsg("找不到记录");
  1033. }
  1034. }
  1035. public void upd_erp_ordertag()
  1036. {
  1037. if (UrlPostParmsCheck("ctid"))
  1038. {
  1039. string eid = GetPostString("ctid");
  1040. CeErpTradeCell entity = null;
  1041. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1042. if (entity != null)
  1043. {
  1044. int tag = GetPostInt("wechattag");
  1045. //if(tag==4 && entity.IsSample == 2)
  1046. //{
  1047. // returnErrorMsg("补差价单不能标记微信单");
  1048. // return;
  1049. //}
  1050. entity.wechatTag = tag;
  1051. entity.Update();
  1052. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1053. if (tag == 1)
  1054. {
  1055. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1056. if (cash == null)
  1057. {
  1058. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1059. cash = new CeErpReturnCash();
  1060. cash.tid = entity.tid;
  1061. cash.seller_nick = main.seller_nick;
  1062. cash.payment = trade.payment;
  1063. cash.buyer_nick = main.buyer_nick;
  1064. cash.cashstate = 0;
  1065. cash.rtype = "微信返现";
  1066. cash.returnprice = 0;
  1067. cash.created = DateTime.Now;
  1068. cash.con = "订单标记微信单";
  1069. cash.img = "";
  1070. cash.applyuserid = CurrentUser.UserID;
  1071. cash.Create();
  1072. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1073. }
  1074. else
  1075. {
  1076. cash.cashstate = 0;
  1077. cash.Update();
  1078. }
  1079. CeErpSukuraData.createInfo(entity.ctid, 9);
  1080. }
  1081. else if (tag == 2)
  1082. {
  1083. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1084. if (cash == null)
  1085. {
  1086. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1087. cash = new CeErpReturnCash();
  1088. cash.tid = entity.tid;
  1089. cash.seller_nick = main.seller_nick;
  1090. cash.payment = trade.payment;
  1091. cash.buyer_nick = main.buyer_nick;
  1092. cash.cashstate = 0;
  1093. cash.rtype = "推购返现";
  1094. cash.returnprice = 5;
  1095. cash.created = DateTime.Now;
  1096. cash.con = "订单标记推购单";
  1097. cash.img = "";
  1098. cash.applyuserid = CurrentUser.UserID;
  1099. cash.Create();
  1100. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1101. }
  1102. else
  1103. {
  1104. cash.cashstate = 0;
  1105. cash.Update();
  1106. }
  1107. CeErpSukuraData.createInfo(entity.ctid, 9);
  1108. }
  1109. else if (tag == 3)
  1110. {
  1111. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1112. if (pers == null)
  1113. {
  1114. pers = new CeErpPersuade();
  1115. pers.ctid = entity.ctid;
  1116. pers.pstate = 0;
  1117. pers.created = DateTime.Now;
  1118. pers.applyuserid = CurrentUser.UserID;
  1119. pers.Create();
  1120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1121. }
  1122. else
  1123. {
  1124. pers.pstate = 0;
  1125. pers.Update();
  1126. }
  1127. }
  1128. else if (tag == 4 || tag == 5)
  1129. {
  1130. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1131. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1132. if (pers == null)
  1133. {
  1134. pers = new CeErpStayGoods();
  1135. pers.t_id = entity.tid;
  1136. pers.status = "待审核";
  1137. pers.audit_type = 0;
  1138. if (tag == 4)
  1139. {
  1140. pers.stay_type = "微信推购";
  1141. }
  1142. else
  1143. {
  1144. pers.stay_type = "旺旺推购";
  1145. }
  1146. if (entity.IsXianHuo == 0)
  1147. {
  1148. pers.product_id = entity.ProductId;
  1149. }
  1150. pers.wangwang = main.buyer_nick;
  1151. pers.shop_name = main.seller_nick;
  1152. pers.creata_time = DateTime.Now;
  1153. pers.create_u_id = CurrentUser.UserID;
  1154. pers.create_u_name = CurrentUser.UserName;
  1155. pers.Create();
  1156. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1157. }
  1158. else
  1159. {
  1160. pers.audit_type = 0;
  1161. pers.Update();
  1162. }
  1163. CeErpSukuraData.createInfo(entity.ctid, 10);
  1164. }
  1165. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1166. returnSuccessMsg("标记成功!");
  1167. return;
  1168. }
  1169. returnErrorMsg("找不到记录");
  1170. }
  1171. }
  1172. public void upd_erp_ordertag_cancel()
  1173. {
  1174. if (UrlPostParmsCheck("ctid"))
  1175. {
  1176. string eid = GetPostString("ctid");
  1177. CeErpTradeCell entity = null;
  1178. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1179. if (entity != null)
  1180. {
  1181. entity.wechatTag = 0;
  1182. entity.Update();
  1183. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1184. if (pers != null)
  1185. {
  1186. pers.status = "取消推购";
  1187. pers.audit_type = 3;
  1188. pers.Update();
  1189. }
  1190. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1191. returnSuccessMsg("标记成功!");
  1192. return;
  1193. }
  1194. returnErrorMsg("找不到记录");
  1195. }
  1196. }
  1197. public void upd_erp_addweichattag()
  1198. {
  1199. if (UrlPostParmsCheck("ctid"))
  1200. {
  1201. ;
  1202. string eid = GetPostString("ctid");
  1203. CeErpTradeCell entity = null;
  1204. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1205. if (entity != null)
  1206. {
  1207. if (entity.IsAddWechat > 0)
  1208. {
  1209. returnErrorMsg("此单已经标记过了");
  1210. return;
  1211. }
  1212. 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);
  1213. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1214. if (dt.Rows.Count > 0)
  1215. {
  1216. entity.IsAddWechat = 2;
  1217. }
  1218. else
  1219. {
  1220. entity.IsAddWechat = 1;
  1221. }
  1222. entity.Update();
  1223. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1224. returnSuccessMsg("标记成功!");
  1225. return;
  1226. }
  1227. returnErrorMsg("找不到记录");
  1228. }
  1229. }
  1230. public void upd_erp_getmyorder()
  1231. {
  1232. if (UrlPostParmsCheck("ctid"))
  1233. {
  1234. ;
  1235. string eid = GetPostString("ctid");
  1236. CeErpTradeCell entity = null;
  1237. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1238. if (entity != null)
  1239. {
  1240. if (entity.ctid.IndexOf("C") != -1)
  1241. {
  1242. StringBuilder sql = new StringBuilder();
  1243. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1244. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1245. if (dt.Rows.Count > 0)
  1246. {
  1247. decimal total = 0;
  1248. foreach (DataRow dr in dt.Rows)
  1249. {
  1250. total += Convert.ToDecimal(dr["payment"]);
  1251. }
  1252. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1253. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1254. {
  1255. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1256. return;
  1257. }
  1258. }
  1259. }
  1260. if (entity.OrderState == -1)
  1261. {
  1262. returnErrorMsg("待审核订单无法领取!");
  1263. return;
  1264. }
  1265. entity.CustomerUserId = CurrentUser.UserID;
  1266. if (entity.OrderState < 2)
  1267. {
  1268. entity.OrderState = 2;
  1269. if (entity.ShopId != 0)
  1270. {
  1271. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1272. }
  1273. }
  1274. entity.UpdateTime = DateTime.Now;
  1275. entity.Update();
  1276. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1277. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1278. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1279. {
  1280. dataHelper.api_orderBack(entity.ctid, "0", "");
  1281. }
  1282. returnSuccessMsg("领单成功!");
  1283. return;
  1284. }
  1285. returnErrorMsg("找不到记录");
  1286. }
  1287. }
  1288. public void getmyorder_from_init()
  1289. {
  1290. if (UrlPostParmsCheck("ctid"))
  1291. {
  1292. string eid = GetPostString("ctid");
  1293. CeErpTradeCell entity = null;
  1294. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1295. if (entity != null)
  1296. {
  1297. string sellerMemo = GetPostString("sellerMemo");
  1298. if (sellerMemo.Length > 0)
  1299. {
  1300. entity.seller_memo = sellerMemo;
  1301. }
  1302. string oterhMemo = GetPostString("otherMemo");
  1303. if (oterhMemo.Length > 0)
  1304. {
  1305. entity.OtherMemo = oterhMemo;
  1306. }
  1307. int urg = GetPostInt("urgency");
  1308. entity.IsUrgency = (urg == 1 ? true : false);
  1309. int wechat = GetPostInt("wechat");
  1310. int command = GetPostInt("command");
  1311. if (wechat == 1)
  1312. {
  1313. entity.wechatTag = 1;
  1314. }
  1315. if (command == 1)
  1316. {
  1317. entity.wechatTag = 2;
  1318. }
  1319. string pPro = GetPostString("pprofession");
  1320. if (pPro.Length > 0)
  1321. {
  1322. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1323. string spro = GetPostString("profession");
  1324. if (spro.Length > 0)
  1325. {
  1326. entity.ProfessionId = Convert.ToInt32(spro);
  1327. }
  1328. }
  1329. string proId = GetPostString("productId");
  1330. if (proId.Length > 0)
  1331. {
  1332. entity.ProductId = Convert.ToInt32(proId);
  1333. }
  1334. entity.Material = GetPostString("material");
  1335. entity.Craft = GetPostString("craft");
  1336. entity.CustomerUserId = CurrentUser.UserID;
  1337. if (entity.OrderState < 2)
  1338. {
  1339. entity.OrderState = 2;
  1340. if (entity.ShopId != 0)
  1341. {
  1342. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1343. }
  1344. }
  1345. entity.Update();
  1346. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1347. returnSuccessMsg("领单成功!");
  1348. return;
  1349. }
  1350. returnErrorMsg("找不到记录");
  1351. }
  1352. }
  1353. public void upd_erp_setrelationorder()
  1354. {
  1355. if (UrlPostParmsCheck("ctid"))
  1356. {
  1357. ;
  1358. string eid = GetPostString("ctid");
  1359. string ftid = GetPostString("ftid");
  1360. CeErpTradeCell entity = null;
  1361. CeErpTradeCell fentity = null;
  1362. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1363. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1364. if (fentity == null)
  1365. {
  1366. returnErrorMsg("找不到关联的主订单");
  1367. return;
  1368. }
  1369. if (entity != null)
  1370. {
  1371. if (entity.OrderState >= 5)
  1372. {
  1373. returnErrorMsg("本单已经设计完成无法关联");
  1374. return;
  1375. }
  1376. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1377. {
  1378. returnErrorMsg("线下单续审核后才能关联!");
  1379. return;
  1380. }
  1381. entity.ptid = ftid;
  1382. entity.OrderState = fentity.OrderState;
  1383. //entity.status = fentity.status;
  1384. entity.CustomerUserId = fentity.CustomerUserId;
  1385. entity.DesignUserId = fentity.DesignUserId;
  1386. entity.seller_memo = "补差价单:" + ftid;
  1387. entity.IsSample = 2;
  1388. entity.Update();
  1389. ApiVo apiVo = new ApiVo();
  1390. apiVo.orderNumber = ftid;
  1391. apiVo.payment = entity.payment;
  1392. apiVo.actionName = "repairDesign";
  1393. designHelper.API_WorkCore(apiVo);//repairDesign
  1394. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1395. returnSuccessMsg("关联成功!");
  1396. return;
  1397. }
  1398. else
  1399. returnErrorMsg("找不到记录");
  1400. }
  1401. }
  1402. public void download_erp_neworder()
  1403. {
  1404. string seller = GetPostString("seller_nick");
  1405. string tid = GetPostString("tid");
  1406. if (seller.Length <= 0 || tid.Length <= 0)
  1407. {
  1408. returnErrorMsg("数据错误");
  1409. }
  1410. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1411. //{
  1412. // returnErrorMsg("找不到店铺Sessionkey");
  1413. //}
  1414. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1415. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1416. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1417. if (res.IndexOf("refOid") == -1)
  1418. {
  1419. returnErrorMsg("下载订单数据失败");
  1420. return;
  1421. }
  1422. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1423. returnSuccessMsg("下载完成");
  1424. //tmcHelper.createNewOrder(res);
  1425. //CeErpTrade entr = null;
  1426. //entr = CeErpTrade.Get(tid);
  1427. //if (entr != null)
  1428. //{
  1429. // returnSuccess("下载成功");
  1430. // //下载成功之后,Cell表生成对应的订单;
  1431. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1432. //}
  1433. //else
  1434. //{
  1435. // returnErrorMsg("下载失败或者创建订单失败");
  1436. //}
  1437. }
  1438. public void set_erp_atersale()
  1439. {
  1440. if (UrlPostParmsCheck("ctid"))
  1441. {
  1442. string eid = GetPostString("ctid");
  1443. string reason = GetPostString("AfterSaleReason");
  1444. CeErpTradeCell entity = null;
  1445. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1446. if (entity != null)
  1447. {
  1448. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1449. {
  1450. returnErrorMsg("此订单已经在售后");
  1451. return;
  1452. }
  1453. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1454. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1455. entity.AfterSaleTime = DateTime.Now;
  1456. entity.Update();
  1457. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1458. returnSuccessMsg("转售后成功!");
  1459. return;
  1460. }
  1461. returnErrorMsg("找不到记录");
  1462. }
  1463. }
  1464. public void set_erp_withdraw()
  1465. {
  1466. if (UrlPostParmsCheck("ctid"))
  1467. {
  1468. try
  1469. {
  1470. string eid = GetPostString("ctid");//商品id
  1471. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1472. CeWithdraw ceWithdrawSelect = null;
  1473. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1474. if (ceWithdrawSelect != null)
  1475. {
  1476. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1477. {
  1478. ceWithdrawSelect.status = -1;
  1479. ceWithdrawSelect.Update();
  1480. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1481. returnSuccessMsg("重新发起审核成功");
  1482. return;
  1483. }
  1484. else
  1485. {
  1486. returnSuccessMsg("请勿重复申请!");
  1487. return;
  1488. }
  1489. }
  1490. else
  1491. {
  1492. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1493. if (string.IsNullOrEmpty(CustomerUserId))
  1494. {
  1495. CustomerUserId = "-1";
  1496. }
  1497. int Userid = CurrentUser.UserID;//用户id
  1498. CeWithdraw ceWithdraw = new CeWithdraw();
  1499. ceWithdraw.tid = eid;
  1500. ceWithdraw.userid = Userid;
  1501. ceWithdraw.providerid = CustomerUserId;
  1502. ceWithdraw.status = 3;
  1503. ceWithdraw.creationtime = DateTime.Now;
  1504. ceWithdraw.Create();
  1505. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1506. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1507. return;
  1508. }
  1509. }
  1510. catch
  1511. {
  1512. returnErrorMsg("申请撤回订单失败");
  1513. return;
  1514. }
  1515. }
  1516. }
  1517. public void ins_erp_billinfo()
  1518. {
  1519. if (UrlPostParmsCheck("ctid"))
  1520. {
  1521. string eid = GetPostString("ctid");
  1522. CeErpTradeCell entity = null;
  1523. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1524. if (entity != null)
  1525. {
  1526. CeErpBill bill = CeErpBill.GetByTid(eid);
  1527. bool isHave = false;
  1528. if (bill != null)
  1529. {
  1530. isHave = true;
  1531. if (bill.state != 4)
  1532. {
  1533. returnErrorMsg("此单已经申请过发票了");
  1534. return;
  1535. }
  1536. }
  1537. if (entity.IsNeedBill == 0)
  1538. {
  1539. entity.IsNeedBill = 1;
  1540. }
  1541. entity.Update();
  1542. string errjson = "";
  1543. try
  1544. {
  1545. CeErpBill bill_entity = new CeErpBill();
  1546. bill_entity.tid = entity.tid;
  1547. bill_entity.title = GetPostString("title");
  1548. string taxstr = GetPostString("tax");
  1549. taxstr = taxstr.Replace(" ", "");
  1550. bill_entity.tax = taxstr;
  1551. bill_entity.bank = GetPostString("bank");
  1552. string bankacstr = GetPostString("bankac");
  1553. bankacstr = bankacstr.Replace(" ", "");
  1554. bill_entity.bankac = bankacstr;
  1555. bill_entity.address = GetPostString("address");
  1556. bill_entity.phone = GetPostString("phone");
  1557. bill_entity.price = GetPostString("price");
  1558. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1559. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1560. {
  1561. billCount += 1;
  1562. }
  1563. string prebill = "ltb";
  1564. for (int idx = 1; idx <= billCount; idx++)
  1565. {
  1566. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1567. string billoid = prebill + idx + dtstr;
  1568. bill_entity.billOrderId += billoid;
  1569. if (idx < billCount)
  1570. {
  1571. bill_entity.billOrderId += ",";
  1572. }
  1573. }
  1574. bill_entity.productId = GetPostInt("ProductName");
  1575. bill_entity.num = GetPostInt("num");
  1576. bill_entity.unit = GetPostString("unit");
  1577. bill_entity.type = GetPostString("type");
  1578. bill_entity.sendType = GetPostString("SendType");
  1579. bill_entity.email = GetPostString("email");
  1580. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1581. bill_entity.shopName = GetPostString("ShopName");
  1582. bill_entity.applymemo = GetPostString("applyMemo");
  1583. bill_entity.createTime = DateTime.Now;
  1584. bill_entity.state = 0;
  1585. bill_entity.userId = CurrentUser.UserID;
  1586. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1587. bill_entity.Create();
  1588. }
  1589. catch (Exception ex)
  1590. {
  1591. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1592. returnErrorMsg("创建发票出错!");
  1593. return;
  1594. }
  1595. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1596. returnSuccessMsg("发票申请成功!");
  1597. return;
  1598. }
  1599. returnErrorMsg("找不到记录");
  1600. }
  1601. }
  1602. public void ins_erp_neworder()
  1603. {
  1604. if (UrlPostParmsCheck("receiver_name"))
  1605. {
  1606. CeErpTrade entity = new CeErpTrade();
  1607. string plat_form = GetPostString("platform");
  1608. string preStr = "N_";
  1609. if (plat_form == "拼多多")
  1610. {
  1611. preStr = "P_";
  1612. }
  1613. else if (plat_form == "阿里巴巴")
  1614. {
  1615. preStr = "A_";
  1616. }
  1617. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1618. entity.seller_nick = GetPostString("seller_nick");
  1619. entity.buyer_nick = GetPostString("buyer_nick");
  1620. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1621. entity.total_fee = entity.payment;
  1622. entity.pay_time = DateTime.Now;
  1623. entity.status = "NOT_SHIPPED";
  1624. entity.receiver_name = GetPostString("receiver_name");
  1625. entity.receiver_mobile = GetPostString("receiver_mobile");
  1626. entity.receiver_state = GetPostString("receiver_state");
  1627. entity.receiver_city = GetPostString("receiver_city");
  1628. entity.receiver_district = GetPostString("receiver_district");
  1629. entity.receiver_address = GetPostString("receiver_address");
  1630. if (entity.receiver_state == "" || entity.receiver_city == "")
  1631. {
  1632. returnErrorMsg("收件地址不能为空");
  1633. return;
  1634. }
  1635. int shopId = 0;
  1636. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1637. if (nShop != null)
  1638. {
  1639. shopId = nShop.ID;
  1640. }
  1641. if (shopId != 34 && entity.payment == 0)
  1642. {
  1643. returnErrorMsg("公司自用的单金额才能为0");
  1644. return;
  1645. }
  1646. entity.Create();
  1647. CeErpTradeCell entitycell = new CeErpTradeCell();
  1648. entitycell.ctid = entity.tid;
  1649. entitycell.tid = entity.tid;
  1650. entitycell.ShopId = shopId;
  1651. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1652. entitycell.OrderState = 0;
  1653. entitycell.pay_time = entity.pay_time;
  1654. entitycell.IsOffLineOrder = 1;
  1655. entitycell.Create();
  1656. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1657. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1658. return;
  1659. }
  1660. }
  1661. public void ins_erp_neworder2()
  1662. {
  1663. if (UrlPostParmsCheck("receiver_name"))
  1664. {
  1665. //string plat_form = GetPostString("platform");
  1666. string preStr = "X_";
  1667. string memo = GetPostString("memo");
  1668. string productId = GetPostString("productId");
  1669. string primg = GetPostString("proofimg");
  1670. string sellerNick = GetPostString("seller_nick");
  1671. string addFrom = GetPostString("addfrom");
  1672. if (addFrom == "1")
  1673. {
  1674. preStr = "N_";
  1675. }
  1676. int shopId = 0;
  1677. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1678. if (nShop != null)
  1679. {
  1680. shopId = nShop.ID;
  1681. }
  1682. else
  1683. {
  1684. returnErrorMsg("找不到对应店铺");
  1685. return;
  1686. }
  1687. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1688. {
  1689. returnErrorMsg("必须上传付款凭证");
  1690. return;
  1691. }
  1692. CeErpTrade entity = new CeErpTrade();
  1693. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1694. entity.seller_nick = sellerNick;
  1695. entity.buyer_nick = GetPostString("buyer_nick");
  1696. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1697. entity.total_fee = entity.payment;
  1698. entity.pay_time = DateTime.Now;
  1699. entity.status = "NOT_SHIPPED";
  1700. entity.receiver_name = GetPostString("receiver_name");
  1701. entity.receiver_mobile = GetPostString("receiver_mobile");
  1702. entity.receiver_state = GetPostString("receiver_state");
  1703. entity.receiver_city = GetPostString("receiver_city");
  1704. entity.receiver_district = GetPostString("receiver_district");
  1705. entity.receiver_address = GetPostString("receiver_address");
  1706. entity.seller_memo = memo;
  1707. entity.orderFrom = 20;
  1708. entity.orderType = 15;
  1709. if (entity.receiver_state == "" || entity.receiver_city == "")
  1710. {
  1711. returnErrorMsg("收件地址不能为空");
  1712. return;
  1713. }
  1714. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1715. {
  1716. returnErrorMsg("公司自用的单金额才能为0");
  1717. return;
  1718. }
  1719. entity.Create();
  1720. string toWhere = GetPostString("towhere");
  1721. CeErpTradeCell entitycell = new CeErpTradeCell();
  1722. entitycell.ctid = entity.tid;
  1723. //唯一标识
  1724. entitycell.OrderSn = entity.tid;
  1725. string orderSn = dataHelper.getSaleOrderSn();
  1726. if (orderSn != "")
  1727. {
  1728. entitycell.OrderSn = orderSn;
  1729. }
  1730. entitycell.tid = entity.tid;
  1731. //if (preStr == "X_")
  1732. //{
  1733. entitycell.IsOffLineOrder = 1;
  1734. //}
  1735. entitycell.CustomerUserId = CurrentUser.UserID;
  1736. entitycell.PayProofImg = primg;
  1737. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1738. entitycell.ProductId = Convert.ToInt32(productId);
  1739. entitycell.ShopId = shopId;
  1740. entitycell.UpdateTime = DateTime.Now;
  1741. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1742. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1743. {
  1744. entitycell.IsXianHuo = 1;
  1745. }
  1746. entitycell.pay_time = entity.pay_time;
  1747. if (toWhere == "1")
  1748. {
  1749. entitycell.OrderState = 2;
  1750. }
  1751. else
  1752. {
  1753. entitycell.OrderState = 6;
  1754. entitycell.FinishPlaceTime = entitycell.pay_time;
  1755. }
  1756. if (shopId == 94)
  1757. {
  1758. entitycell.OrderState = 4;
  1759. entitycell.WaitDesignTime = entitycell.pay_time;
  1760. entitycell.StartDesignTime = entitycell.pay_time;
  1761. entitycell.DesignUserId = 218;
  1762. }
  1763. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1764. {
  1765. entitycell.OrderState = -1;//修改12-5
  1766. CeWithdraw ceWithdraw = new CeWithdraw();
  1767. ceWithdraw.tid = entity.tid;
  1768. ceWithdraw.providerid = "-1";
  1769. ceWithdraw.status = -1;
  1770. ceWithdraw.creationtime = DateTime.Now;
  1771. ceWithdraw.userid = 1337;
  1772. ceWithdraw.Create();
  1773. }
  1774. entitycell.Create();
  1775. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1776. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1777. {
  1778. addPlaceRegist(entitycell, CurrentUser.UserID);
  1779. }
  1780. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1781. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1782. return;
  1783. }
  1784. }
  1785. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1786. {
  1787. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1788. entity.PlactTime = tradecell.pay_time;
  1789. entity.AddUserId = userid;
  1790. entity.FileName = tradecell.seller_memo;
  1791. entity.Supplier = 24;
  1792. entity.CreateTime = DateTime.Now;
  1793. entity.Did = tradecell.ctid;
  1794. entity.tid = tradecell.tid;
  1795. entity.splitTag = tradecell.SplitTag;
  1796. entity.CurState = "未完成";
  1797. entity.Create();
  1798. }
  1799. public void get_erp_offlinelist()
  1800. {
  1801. DataStruct dStruct = GetPostStruct();
  1802. List<string> lw = new List<string>();
  1803. string tid = GetPostString("ctid");
  1804. string date1 = GetPostString("date1");
  1805. string date2 = GetPostString("date2");
  1806. if (tid.Length > 0 || date1.Length > 0)
  1807. {
  1808. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1809. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1810. if (dw.Length > 0) lw.Add(dw);
  1811. }
  1812. else
  1813. {
  1814. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1815. }
  1816. string shopname = GetPostString("shopname");
  1817. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1818. string buyernick = GetPostString("buyer_nick");
  1819. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1820. string customer = GetPostString("customer");
  1821. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1822. string design = GetPostString("design");
  1823. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1824. string orderState = GetPostString("orderState");
  1825. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1826. string address = GetPostString("address");
  1827. 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));
  1828. string sellermemo = GetPostString("seller_memo");
  1829. if (sellermemo.Length > 0)
  1830. {
  1831. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1832. }
  1833. string price1 = GetPostString("price1");
  1834. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1835. string price2 = GetPostString("price2");
  1836. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1837. //if (PKey != "admin")
  1838. //{
  1839. // string usershop = CurrentUser.User.pemShop;
  1840. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1841. //}
  1842. //if (ex_psize > 0)
  1843. //{
  1844. dStruct.Order = "pay_time desc";
  1845. //}
  1846. //else
  1847. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1848. lw.Add(string.Format("IsOffLineOrder=1"));
  1849. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1850. DataTable dt = null;
  1851. dt = WebCache.GetData("view_erptradecell", dStruct);
  1852. writeGridDataTableJson(dStruct.TotalCount, dt);
  1853. }
  1854. public void get_erp_returncashrecord()
  1855. {
  1856. DataStruct dStruct = GetPostStruct();
  1857. List<string> lw = new List<string>();
  1858. string tid = GetPostString("ctid");
  1859. if (tid.Length > 0)
  1860. {
  1861. lw.Add(string.Format("tid like '%{0}%'", tid));
  1862. dStruct.Order = "id desc";
  1863. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1864. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1865. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1866. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1867. return;
  1868. }
  1869. returnErrorMsg("id数据错误!");
  1870. }
  1871. public void ins_erp_returncashrecord()
  1872. {
  1873. if (UrlPostParmsCheck("tid"))
  1874. {
  1875. string tid = GetPostString("tid");
  1876. string retype = GetPostString("type");
  1877. StringBuilder sql = new StringBuilder();
  1878. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1879. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1880. if (dt.Rows.Count > 0)
  1881. {
  1882. returnErrorMsg("相同返现类型记录已存在");
  1883. return;
  1884. }
  1885. CeErpReturnCash entity = new CeErpReturnCash();
  1886. entity.tid = tid;
  1887. entity.seller_nick = GetPostString("seller_nick");
  1888. string pment = GetPostString("payment");
  1889. if (pment.Length > 0)
  1890. {
  1891. entity.payment = Convert.ToDouble(pment);
  1892. }
  1893. entity.buyer_nick = GetPostString("buyer_nick");
  1894. entity.cashstate = 0;
  1895. entity.rtype = retype;
  1896. string rPrice = GetPostString("returnprice");
  1897. if (rPrice.Length > 0)
  1898. {
  1899. entity.returnprice = Convert.ToDouble(rPrice);
  1900. }
  1901. entity.created = DateTime.Now;
  1902. entity.con = GetPostString("con");
  1903. entity.img = GetPostString("img");
  1904. entity.applyuserid = CurrentUser.UserID;
  1905. entity.Create();
  1906. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1907. returnSuccessMsg("操作成功!");
  1908. return;
  1909. }
  1910. }
  1911. public void set_erp_predelivery()
  1912. {
  1913. if (UrlPostParmsCheck("ctid"))
  1914. {
  1915. string eid = GetPostString("ctid");
  1916. CeErpTradeCell entity = null;
  1917. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1918. if (entity != null)
  1919. {
  1920. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1921. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1922. //{
  1923. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1924. // return;
  1925. //}
  1926. entity.IsPreDelivery = 1;
  1927. entity.Update();
  1928. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1929. returnSuccessMsg("预发货成功!");
  1930. return;
  1931. //string shop = GetPostString("seller_nick");
  1932. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1933. //string comName = GetPostString("comName");
  1934. //string comCode = GetPostString("comCode");
  1935. //string outSid = GetPostString("outSid");//运单号
  1936. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1937. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1938. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1939. //string apires = "";
  1940. //if (deliveryType == "虚拟发货")
  1941. //{
  1942. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1943. //}
  1944. //else
  1945. //{
  1946. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1947. //}
  1948. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1949. ////{
  1950. //if (apires.IndexOf("发货成功") != -1)
  1951. //{
  1952. // if (deliveryType != "虚拟发货")
  1953. // {
  1954. // //还要插入快递信息到 快递信息表
  1955. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1956. // exinfo.tid = eid;
  1957. // exinfo.out_sid = outSid;
  1958. // exinfo.company_code = comCode;
  1959. // exinfo.company_name = comName;
  1960. // exinfo.delivery_memo = deliveryMemo;
  1961. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1962. // exinfo.deliveryType = deliveryType;
  1963. // exinfo.Create();
  1964. // }
  1965. // returnSuccessMsg("发货成功!");
  1966. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1967. //}
  1968. //else
  1969. //{
  1970. // returnErrorMsg("淘宝发货失败!!");
  1971. //}
  1972. //return;
  1973. }
  1974. returnErrorMsg("找不到订单记录");
  1975. }
  1976. }
  1977. public void get_erp_unusuallist()
  1978. {
  1979. DataStruct dStruct = GetPostStruct();
  1980. List<string> lw = new List<string>();
  1981. string tid = GetPostString("ctid");
  1982. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1983. string shopname = GetPostString("shopname");
  1984. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1985. string buyernick = GetPostString("buyer_nick");
  1986. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1987. string ResponsibleMan = GetPostString("responsible");
  1988. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1989. string date1 = GetPostString("date1");
  1990. string date2 = GetPostString("date2");
  1991. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1992. if (dw.Length > 0) lw.Add(dw);
  1993. string price1 = GetPostString("price1");
  1994. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1995. string price2 = GetPostString("price2");
  1996. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1997. string orderState = GetPostString("orderState");
  1998. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1999. string sellermemo = GetPostString("seller_memo");
  2000. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2001. lw.Add(string.Format("UnusualTag > 0"));
  2002. lw.Add(string.Format("IsRefund<={0}", 1));
  2003. dStruct.Order = "pay_time desc";
  2004. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2005. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2006. writeGridDataTableJson(dStruct.TotalCount, dt);
  2007. }
  2008. public void set_erp_unusualtonomal()
  2009. {
  2010. if (UrlPostParmsCheck("ctid"))
  2011. {
  2012. string eid = GetPostString("ctid");
  2013. CeErpTradeCell entity = null;
  2014. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2015. if (entity != null)
  2016. {
  2017. entity.UnusualTag = -1;
  2018. entity.Update();
  2019. returnSuccessMsg("忽略成功!");
  2020. return;
  2021. }
  2022. returnErrorMsg("找不到记录");
  2023. }
  2024. }
  2025. public void ins_erp_unusualreason()
  2026. {
  2027. if (UrlPostParmsCheck("ctid"))
  2028. {
  2029. string eid = GetPostString("ctid");
  2030. CeErpTradeCell entity = null;
  2031. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2032. if (entity != null)
  2033. {
  2034. entity.MemoOpt = 4;
  2035. entity.UnusualCon = GetPostString("con");
  2036. entity.Update();
  2037. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2038. if (trade != null)
  2039. {
  2040. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2041. }
  2042. //查货是否超时
  2043. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2044. if (ceErpTradeCellExtend == null)
  2045. {
  2046. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2047. ceErpTradeCellExtend.ctid = entity.ctid;
  2048. }
  2049. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2050. {
  2051. ceErpTradeCellExtend.CheckOut += 1;
  2052. }
  2053. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2054. if (ceErpTradeCellExtend.ID > 0)
  2055. {
  2056. ceErpTradeCellExtend.Update();
  2057. }
  2058. else
  2059. {
  2060. ceErpTradeCellExtend.Create();
  2061. }
  2062. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2063. returnSuccessMsg("操作成功!");
  2064. return;
  2065. }
  2066. returnErrorMsg("找不到记录");
  2067. }
  2068. }
  2069. public void upd_erp_sampleorder()
  2070. {
  2071. if (UrlPostParmsCheck("ctid"))
  2072. {
  2073. string eid = GetPostString("ctid");
  2074. string[] eArr = eid.Split(',');
  2075. if (eArr.Length > 1)
  2076. {
  2077. List<string> eLst = new List<string>();
  2078. for (int i = 0; i < eArr.Length; i++)
  2079. {
  2080. eLst.Add("'" + eArr[i] + "'");
  2081. }
  2082. eid = string.Join(",", eLst.ToArray());
  2083. }
  2084. else
  2085. {
  2086. eid = "'" + eid + "'";
  2087. }
  2088. StringBuilder sql = new StringBuilder();
  2089. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2090. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2091. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2092. if (dt.Rows.Count > 0)
  2093. {
  2094. string errmsg = "";
  2095. foreach (DataRow dr in dt.Rows)
  2096. {
  2097. StringBuilder sqlsb = new StringBuilder();
  2098. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2099. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2100. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2101. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2102. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2103. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2104. {
  2105. continue;
  2106. }
  2107. else
  2108. {
  2109. string emsg = commonHelper.KeepChinese(apires);
  2110. errmsg += emsg;
  2111. }
  2112. }
  2113. if (errmsg.Length > 0)
  2114. {
  2115. returnErrorMsg(errmsg);
  2116. return;
  2117. }
  2118. returnSuccessMsg("操作成功");
  2119. return;
  2120. }
  2121. returnErrorMsg("找不到记录");
  2122. }
  2123. }
  2124. public void upd_erp_transcustomer()
  2125. {
  2126. if (UrlPostParmsCheck("ctid"))
  2127. {
  2128. string eid = GetPostString("ctid");
  2129. int userid = GetPostInt("CustomerUserId");
  2130. CeErpTradeCell entity = null;
  2131. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2132. if (entity != null)
  2133. {
  2134. //string[] mlist = entity.seller_memo.Split('-');
  2135. //string sql = "select * from view_erpuser where id=" + userid;
  2136. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2137. //if (dt != null && dt.Rows.Count > 0)
  2138. //{
  2139. // string nmemo = "";
  2140. // for(int i = 0; i < mlist.Length - 1; i++)
  2141. // {
  2142. // nmemo += mlist[i];
  2143. // nmemo += "-";
  2144. // }
  2145. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2146. // entity.seller_memo = nmemo;
  2147. //}
  2148. entity.CustomerUserId = userid;
  2149. entity.Update();
  2150. returnSuccessMsg("操作成功!");
  2151. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2152. return;
  2153. }
  2154. returnErrorMsg("找不到记录");
  2155. }
  2156. }
  2157. public void upd_erp_transdesigner()
  2158. {
  2159. if (UrlPostParmsCheck("ctid"))
  2160. {
  2161. string eids = GetPostString("ctid");
  2162. string[] ctidList = eids.Split(',');
  2163. int userid = GetPostInt("DesignUserId");
  2164. foreach (string ctid in ctidList)
  2165. {
  2166. CeErpTradeCell entity = null;
  2167. CeErpDesignerBill entitys = null;
  2168. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2169. entitys = CeErpDesignerBill.GetByTid(ctid);
  2170. if (entity != null)
  2171. {
  2172. if (entity.OrderState > 4)
  2173. {
  2174. continue;
  2175. }
  2176. //存在退款不能流转
  2177. if (entity.IsRefund > 0)
  2178. {
  2179. continue;
  2180. }
  2181. entity.DesignUserId = userid;
  2182. entity.WaitDesignTime = DateTime.Now;
  2183. entity.Update();
  2184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2185. }
  2186. }
  2187. returnSuccessMsg("操作成功!");
  2188. }
  2189. }
  2190. public void upd_erp_distributedesigner()
  2191. {
  2192. if (UrlPostParmsCheck("ctid"))
  2193. {
  2194. string eid = GetPostString("ctid");
  2195. int userid = GetPostInt("DesignUserId");
  2196. string[] idlist = eid.Split(',');
  2197. if (idlist.Length <= 0)
  2198. {
  2199. returnErrorMsg("订单不能为空");
  2200. return;
  2201. }
  2202. foreach (string ctid in idlist)
  2203. {
  2204. CeErpTradeCell entity = null;
  2205. CeErpDesignerBill entitys = null;
  2206. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2207. else continue;
  2208. if (entity != null)
  2209. {
  2210. if (userid == 2125 || userid == 3542)
  2211. { }
  2212. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2213. {
  2214. returnErrorMsg("金额错误的订单无法指派");
  2215. return;
  2216. }
  2217. if (entity.OrderState >= 5)
  2218. {
  2219. returnErrorMsg("已经设计完成无法指派");
  2220. return;
  2221. }
  2222. if (entity.OrderState == -1)
  2223. {
  2224. returnErrorMsg("审核中的订单无法指派");
  2225. return;
  2226. }
  2227. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2228. {
  2229. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2230. return;
  2231. }
  2232. //157赖橙帆 159林晨 73 静之颖
  2233. 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)
  2234. {
  2235. returnErrorMsg("指派设计共创无法再次指派!");
  2236. return;
  2237. }
  2238. entity.OrderState = 3;
  2239. if (entity.SupplierId == 0)
  2240. {
  2241. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2242. entity.SupplierId = suid;
  2243. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2244. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2245. }
  2246. if (userid == 2125 && entity.seller_memo != "")
  2247. {
  2248. apiDesign.API_GetPrintData_CreateOrder(entity);
  2249. }
  2250. if (userid == 3542 && entity.seller_memo != "")
  2251. {
  2252. string userPost = CurrentUser.UserPost.Post.Code;
  2253. if (CurrentUser.UserID == 73)
  2254. {
  2255. userPost = "SysAdmin";
  2256. }
  2257. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2258. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2259. if (response.msg != "设计共创:成功")
  2260. {
  2261. returnErrorMsg(response.msg);
  2262. return;
  2263. }
  2264. entity.DispatchSort = 2;
  2265. }
  2266. else
  2267. {
  2268. if (entity.DispatchSort == 2)
  2269. {
  2270. ApiVo apiVo = new ApiVo();
  2271. apiVo.actionName = "closeDesign";
  2272. apiVo.orderNumber = entity.ctid;
  2273. designHelper.API_WorkCore(apiVo);//closeDesign
  2274. }
  2275. entity.DispatchSort = 0;
  2276. }
  2277. entity.DesignUserId = userid;
  2278. entity.WaitDesignTime = DateTime.Now;
  2279. entity.UpdateTime = DateTime.Now;
  2280. entity.Update();
  2281. string name = commonHelper.getUserNameById(userid);
  2282. commonHelper.UpdateRelationOrder(entity.ctid);
  2283. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2284. }
  2285. }
  2286. returnSuccessMsg("操作成功!");
  2287. return;
  2288. }
  2289. }
  2290. public string getTidByCtid(string ctid)
  2291. {
  2292. string tid = "";
  2293. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2294. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2295. if (dataTable != null && dataTable.Rows.Count > 0)
  2296. {
  2297. tid = dataTable.Rows[0]["tid"].ToString();
  2298. }
  2299. return tid;
  2300. }
  2301. public List<string> getTidByCtidMore(string ctid)
  2302. {
  2303. 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);
  2304. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2305. List<string> list = new List<string>();
  2306. if (dataTable != null && dataTable.Rows.Count > 0)
  2307. {
  2308. foreach (DataRow item in dataTable.Rows)
  2309. {
  2310. list.Add("'" + item["tid"].ToString() + "'");
  2311. }
  2312. }
  2313. return list;
  2314. }
  2315. public List<string> getTidByCtidLike(string ctid)
  2316. {
  2317. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2318. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2319. List<string> list = new List<string>();
  2320. if (dataTable != null && dataTable.Rows.Count > 0)
  2321. {
  2322. foreach (DataRow item in dataTable.Rows)
  2323. {
  2324. list.Add("'" + item["tid"].ToString() + "'");
  2325. }
  2326. }
  2327. return list;
  2328. }
  2329. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2330. {
  2331. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2332. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2333. List<string> list = new List<string>();
  2334. if (dataTable != null && dataTable.Rows.Count > 0)
  2335. {
  2336. foreach (DataRow item in dataTable.Rows)
  2337. {
  2338. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2339. {
  2340. continue;
  2341. }
  2342. list.Add("'" + item["receiverId"].ToString() + "'");
  2343. }
  2344. }
  2345. return list;
  2346. }
  2347. public void get_erp_myorderlist()
  2348. {
  2349. DataStruct dStruct = GetPostStruct();
  2350. List<string> lw = new List<string>();
  2351. string tid = GetPostString("ctid");
  2352. if (tid.Length > 0)
  2353. {
  2354. string select_tid = getTidByCtid(tid);
  2355. lw.Add(string.Format("tid='{0}'", select_tid));
  2356. }
  2357. else
  2358. {
  2359. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2360. }
  2361. //12-1 修改
  2362. string urgent = GetPostString("urgent");
  2363. string back = GetPostString("back");
  2364. string offlineSearch = GetPostString("offlineSearch");
  2365. if (!string.IsNullOrWhiteSpace(urgent))
  2366. {
  2367. if (urgent.Equals("true"))
  2368. {
  2369. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2370. }
  2371. }
  2372. if (!string.IsNullOrWhiteSpace(back))
  2373. {
  2374. if (back.Equals("true"))
  2375. {
  2376. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2377. }
  2378. }
  2379. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2380. {
  2381. if (offlineSearch.Equals("true"))
  2382. {
  2383. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2384. }
  2385. }
  2386. //end
  2387. string shopname = GetPostString("shopname");
  2388. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2389. string buyernick = GetPostString("buyer_nick");
  2390. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2391. string design = GetPostString("design");
  2392. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2393. string orderState = GetPostString("orderState");
  2394. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2395. string sellermemo = GetPostString("seller_memo");
  2396. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2397. string date1 = GetPostString("date1");
  2398. string date2 = GetPostString("date2");
  2399. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2400. if (dw.Length > 0) lw.Add(dw);
  2401. string price1 = GetPostString("price1");
  2402. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2403. string price2 = GetPostString("price2");
  2404. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2405. string urgency = GetPostString("urgency");
  2406. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2407. string after = GetPostString("after");
  2408. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2409. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2410. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2411. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2412. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2413. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2414. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2415. if (dt != null && dt.Rows.Count > 0)
  2416. {
  2417. foreach (DataRow dr in dt.Rows)
  2418. {
  2419. try
  2420. {
  2421. // 对象操作
  2422. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2423. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2424. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2425. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2426. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2427. if (dStruct.PageSize != 100000)
  2428. {
  2429. if (dr["DispatchSort"].ToString() == "2")
  2430. {
  2431. dr["gongchuang"] = 200;
  2432. }
  2433. else if ("外协".Equals(dr["ToType"].ToString()))
  2434. {
  2435. dr["gongchuang"] = 200;
  2436. }
  2437. else if ("内部".Equals(dr["ToType"].ToString()))
  2438. {
  2439. dr["gongchuang"] = -1;
  2440. }
  2441. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2442. {
  2443. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2444. dr["gongchuang"] = response.code;
  2445. }
  2446. }
  2447. }
  2448. catch (NullReferenceException ex)
  2449. {
  2450. }
  2451. }
  2452. }
  2453. writeGridDataTableJson(dStruct.TotalCount, dt);
  2454. }
  2455. public void get_erp_myreturnorderlist()
  2456. {
  2457. DataStruct dStruct = GetPostStruct();
  2458. List<string> lw = new List<string>();
  2459. string tid = GetPostString("ctid");
  2460. if (tid.Length > 0)
  2461. {
  2462. string select_tid = getTidByCtid(tid);
  2463. lw.Add(string.Format("tid='{0}'", select_tid));
  2464. }
  2465. else
  2466. {
  2467. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2468. }
  2469. string shopname = GetPostString("shopname");
  2470. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2471. string buyernick = GetPostString("buyer_nick");
  2472. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2473. string design = GetPostString("design");
  2474. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2475. string orderState = GetPostString("orderState");
  2476. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2477. string sellermemo = GetPostString("seller_memo");
  2478. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2479. string date1 = GetPostString("date1");
  2480. string date2 = GetPostString("date2");
  2481. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2482. if (dw.Length > 0) lw.Add(dw);
  2483. string price1 = GetPostString("price1");
  2484. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2485. string price2 = GetPostString("price2");
  2486. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2487. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2488. {
  2489. lw.Add(string.Format("CusOrgID = 94"));
  2490. }
  2491. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2492. {
  2493. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2494. }
  2495. else
  2496. {
  2497. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2498. }
  2499. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2500. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2501. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2503. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2504. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2505. if (dt != null && dt.Rows.Count > 0)
  2506. {
  2507. foreach (DataRow dr in dt.Rows)
  2508. {
  2509. try
  2510. {
  2511. // 对象操作
  2512. if (dStruct.PageSize != 100000)
  2513. {
  2514. if (dr["DispatchSort"].ToString() == "2")
  2515. {
  2516. dr["gongchuang"] = 200;
  2517. }
  2518. else if ("外协".Equals(dr["ToType"].ToString()))
  2519. {
  2520. dr["gongchuang"] = 200;
  2521. }
  2522. else if ("内部".Equals(dr["ToType"].ToString()))
  2523. {
  2524. dr["gongchuang"] = -1;
  2525. }
  2526. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2527. {
  2528. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2529. dr["gongchuang"] = response.code;
  2530. }
  2531. }
  2532. }
  2533. catch (NullReferenceException ex)
  2534. {
  2535. // 处理空引用异常
  2536. }
  2537. }
  2538. }
  2539. writeGridDataTableJson(dStruct.TotalCount, dt);
  2540. }
  2541. public void get_erp_myorderlist_pregather()
  2542. {
  2543. string date1 = GetPostString("date1");
  2544. string date2 = GetPostString("date2");
  2545. int userId = CurrentUser.UserID; //客服id
  2546. string orderWhere = "";
  2547. List<string> lw = new List<string>();
  2548. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2549. if (dw.Length > 0) lw.Add(dw);
  2550. lw.Add(string.Format("CustomerUserId={0}", userId));
  2551. lw.Add(string.Format("OrderState<9"));
  2552. orderWhere = string.Join(" and ", lw.ToArray());
  2553. string orderWhere2 = "";
  2554. List<string> lw2 = new List<string>();
  2555. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2556. if (dw2.Length > 0) lw2.Add(dw2);
  2557. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2558. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2559. string sql = string.Format("select *" +
  2560. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2561. "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 " +
  2562. "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 " +
  2563. "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");
  2564. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2565. //writeGridDataTableJson(dt.Rows.Count, dt);
  2566. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2567. }
  2568. public void upd_erp_publishorder()
  2569. {
  2570. if (UrlPostParmsCheck("ctid"))
  2571. {
  2572. string eid = GetPostString("ctid");
  2573. CeErpTradeCell entity = null;
  2574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2575. if (entity != null)
  2576. {
  2577. entity.OrderState = 0; //发布后,变为待抢单
  2578. entity.Update();
  2579. commonHelper.UpdateRelationOrder(entity.ctid);
  2580. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2581. returnSuccessMsg("发布成功!");
  2582. return;
  2583. }
  2584. returnErrorMsg("找不到记录");
  2585. }
  2586. }
  2587. public void get_erp_my_tiporder()
  2588. {
  2589. StringBuilder sql = new StringBuilder();
  2590. int userId = 0;
  2591. if (CurrentUser != null) userId = CurrentUser.UserID;
  2592. string posCode = CurrentUser.UserPost.Post.Code;
  2593. string isTipedAfterSaleVerify = GetPostString("af");
  2594. DataTable dt = new DataTable();
  2595. if (posCode != "Supplier")
  2596. {
  2597. if (posCode == "CustomerService" || posCode == "Director")
  2598. {
  2599. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2600. }
  2601. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2602. {
  2603. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2604. }
  2605. else
  2606. {
  2607. string teamIds = CurrentUser.User.TeamIds;
  2608. if (teamIds == "")
  2609. {
  2610. teamIds = "0";
  2611. }
  2612. 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);
  2613. }
  2614. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2615. }
  2616. if (dt.Rows.Count <= 0)
  2617. {
  2618. string key = "aftersale_order_" + userId;
  2619. if (RedisHelper.HasKey(key))
  2620. {
  2621. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2622. dt.Columns.Add("ctid", typeof(string));
  2623. dt.Columns.Add("IsReadTag", typeof(int));
  2624. foreach (var i in list)
  2625. {
  2626. DataRow data = dt.NewRow();
  2627. data["ctid"] = i;
  2628. data["IsReadTag"] = 4;
  2629. dt.Rows.Add(data);
  2630. }
  2631. RedisHelper.StringDelete(key);
  2632. }
  2633. }
  2634. if (dt.Rows.Count <= 0)
  2635. {
  2636. sql = new StringBuilder();
  2637. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2638. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2639. }
  2640. if (posCode == "Supplier")
  2641. {
  2642. string ids = CurrentUser.User.pemVend;
  2643. if (ids != null && ids.Length > 0)
  2644. {
  2645. string[] ids_list = ids.Split(',');
  2646. foreach (var item in ids_list)
  2647. {
  2648. string key = "return_order_" + item;
  2649. if (RedisHelper.HasKey(key))
  2650. {
  2651. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2652. dt.Columns.Add("ctid", typeof(string));
  2653. dt.Columns.Add("IsReadTag", typeof(int));
  2654. foreach (var i in list)
  2655. {
  2656. DataRow data = dt.NewRow();
  2657. data["ctid"] = i;
  2658. data["IsReadTag"] = 1;
  2659. dt.Rows.Add(data);
  2660. }
  2661. RedisHelper.StringDelete(key);
  2662. }
  2663. }
  2664. }
  2665. if (dt.Rows.Count <= 0)
  2666. {
  2667. sql = new StringBuilder();
  2668. 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);
  2669. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2670. }
  2671. }
  2672. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2673. }
  2674. public void reset_erp_tiporder()
  2675. {
  2676. string ids = GetPostString("ids");
  2677. string[] ctidList = ids.Split(',');
  2678. foreach (string ctid in ctidList)
  2679. {
  2680. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2681. if (enty != null)
  2682. {
  2683. enty.IsReadTag = 0;
  2684. enty.Update();
  2685. }
  2686. }
  2687. returnSuccessMsg("成功!");
  2688. return;
  2689. }
  2690. public void get_erp_designlist()
  2691. {
  2692. DataStruct dStruct = GetPostStruct();
  2693. List<string> lw = new List<string>();
  2694. string tid = GetPostString("ctid");
  2695. if (tid.Length > 0)
  2696. {
  2697. string select_tid = getTidByCtid(tid);
  2698. lw.Add(string.Format("tid='{0}'", select_tid));
  2699. }
  2700. string shopname = GetPostString("shopname");
  2701. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2702. string buyernick = GetPostString("buyer_nick");
  2703. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2704. string customer = GetPostString("customer");
  2705. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2706. string design = GetPostString("design");
  2707. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2708. string orderState = GetPostString("orderState");
  2709. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2710. lw.Add(string.Format("OrderState<6"));
  2711. string address = GetPostString("address");
  2712. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2713. string sellermemo = GetPostString("seller_memo");
  2714. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2715. string date1 = GetPostString("date1");
  2716. string date2 = GetPostString("date2");
  2717. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2718. if (dw.Length > 0) lw.Add(dw);
  2719. string apdate1 = GetPostString("apdate1");
  2720. string apdate2 = GetPostString("apdate2");
  2721. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2722. if (dwap.Length > 0) lw.Add(dwap);
  2723. string price1 = GetPostString("price1");
  2724. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2725. string price2 = GetPostString("price2");
  2726. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2727. string designTime = GetPostString("designtime");
  2728. if (designTime.Length > 0)
  2729. {
  2730. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2731. }
  2732. string usershop = CurrentUser.User.pemShop;
  2733. if (usershop.Length > 0)
  2734. {
  2735. lw.Add(string.Format("shopId in ({0})", usershop));
  2736. }
  2737. int myOrgid = CurrentUser.UserPost.OrgID;
  2738. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2739. if (myOrgCode.IndexOf("Designer") != -1)
  2740. {
  2741. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2742. {
  2743. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2744. }
  2745. else
  2746. {
  2747. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2748. }
  2749. }
  2750. else
  2751. {
  2752. string orgId = GetPostString("designerhd");
  2753. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2754. }
  2755. if (tid.Length > 0 || buyernick.Length > 0)
  2756. {
  2757. lw.Add(string.Format("OrderState >= 3"));
  2758. }
  2759. else
  2760. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2761. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2762. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2763. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2764. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2765. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2766. if (dt != null && dt.Rows.Count > 0)
  2767. {
  2768. foreach (DataRow dr in dt.Rows)
  2769. {
  2770. try
  2771. {
  2772. // 对象操作
  2773. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2774. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2775. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2776. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2777. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2778. if (dStruct.PageSize != 100000)
  2779. {
  2780. if (dr["DispatchSort"].ToString() == "2")
  2781. {
  2782. dr["gongchuang"] = 200;
  2783. }
  2784. else if ("外协".Equals(dr["ToType"].ToString()))
  2785. {
  2786. dr["gongchuang"] = 200;
  2787. }
  2788. else if ("内部".Equals(dr["ToType"].ToString()))
  2789. {
  2790. dr["gongchuang"] = -1;
  2791. }
  2792. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2793. {
  2794. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2795. dr["gongchuang"] = response.code;
  2796. }
  2797. }
  2798. }
  2799. catch (NullReferenceException ex)
  2800. {
  2801. }
  2802. }
  2803. }
  2804. writeGridDataTableJson(dStruct.TotalCount, dt);
  2805. }
  2806. public void get_erp_mydesignlist()
  2807. {
  2808. DataStruct dStruct = GetPostStruct();
  2809. List<string> lw = new List<string>();
  2810. string tid = GetPostString("ctid");
  2811. if (tid.Length > 0)
  2812. {
  2813. string select_tid = getTidByCtid(tid);
  2814. lw.Add(string.Format("tid='{0}'", select_tid));
  2815. }
  2816. string shopname = GetPostString("shopname");
  2817. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2818. string buyernick = GetPostString("buyer_nick");
  2819. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2820. string customer = GetPostString("customer");
  2821. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2822. string orderState = GetPostString("orderState");
  2823. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2824. //lw.Add(string.Format("OrderState<6"));
  2825. string date1 = GetPostString("date1");
  2826. string date2 = GetPostString("date2");
  2827. string dw = GetDateWhere("pay_time", date1, date2);
  2828. if (dw.Length > 0) lw.Add(dw);
  2829. string apdate1 = GetPostString("apdate1");
  2830. string apdate2 = GetPostString("apdate2");
  2831. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2832. if (dwap.Length > 0) lw.Add(dwap);
  2833. string price1 = GetPostString("price1");
  2834. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2835. string price2 = GetPostString("price2");
  2836. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2837. string olddownload = GetPostString("olddown");
  2838. if (olddownload == "1")
  2839. {
  2840. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2841. }
  2842. else if (olddownload == "2")
  2843. {
  2844. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2845. }
  2846. string sellermemo = GetPostString("seller_memo");
  2847. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2848. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2849. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2850. {
  2851. if (CurrentUser.User.TeamIds.Length > 0)
  2852. {
  2853. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2854. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2855. else
  2856. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2857. }
  2858. else
  2859. {
  2860. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2861. }
  2862. }
  2863. if (tid.Length <= 0)
  2864. {
  2865. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2866. }
  2867. lw.Add(string.Format("IsReturn!=3"));
  2868. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2869. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2870. string teamids = CurrentUser.User.TeamIds.ToString();
  2871. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2872. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2873. if (dt != null && dt.Rows.Count > 0)
  2874. {
  2875. foreach (DataRow dr in dt.Rows)
  2876. {
  2877. try
  2878. {
  2879. // 对象操作
  2880. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2881. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2882. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2883. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2884. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2885. if (dStruct.PageSize != 100000)
  2886. {
  2887. if (dr["DispatchSort"].ToString() == "2")
  2888. {
  2889. dr["gongchuang"] = 200;
  2890. }
  2891. else if ("外协".Equals(dr["ToType"].ToString()))
  2892. {
  2893. dr["gongchuang"] = 200;
  2894. }
  2895. else if ("内部".Equals(dr["ToType"].ToString()))
  2896. {
  2897. dr["gongchuang"] = -1;
  2898. }
  2899. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2900. {
  2901. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2902. dr["gongchuang"] = response.code;
  2903. }
  2904. }
  2905. }
  2906. catch (NullReferenceException ex)
  2907. {
  2908. }
  2909. }
  2910. }
  2911. writeGridDataTableJson(dStruct.TotalCount, dt);
  2912. }
  2913. public void set_erp_startdesign()
  2914. {
  2915. if (UrlPostParmsCheck("ctid"))
  2916. {
  2917. string eid = GetPostString("ctid");
  2918. CeErpTradeCell entity = null;
  2919. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2920. if (entity != null)
  2921. {
  2922. if (entity.OrderState != 3)
  2923. {
  2924. returnErrorMsg("请刷新,订单已经设计了");
  2925. return;
  2926. }
  2927. entity.StartDesignTime = DateTime.Now;
  2928. entity.OrderState = 4;
  2929. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2930. {
  2931. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2932. entity.SupplierId = suid;
  2933. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2934. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2935. }
  2936. entity.UpdateTime = DateTime.Now;
  2937. //entity.MakeSupplier = suname;
  2938. entity.Update();
  2939. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2940. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2941. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2942. commonHelper.getCytPrice(entity);
  2943. returnSuccessMsg("操作成功!");
  2944. return;
  2945. }
  2946. returnErrorMsg("找不到记录");
  2947. }
  2948. }
  2949. public void ins_erp_designselfmemo()
  2950. {
  2951. if (UrlPostParmsCheck("ctid"))
  2952. {
  2953. string eid = GetPostString("ctid");
  2954. string con = GetPostString("con");
  2955. CeErpTradeCell entity = null;
  2956. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2957. if (entity != null)
  2958. {
  2959. entity.DesignSelfMemo = con;
  2960. entity.Update();
  2961. returnSuccessMsg("操作成功!");
  2962. return;
  2963. }
  2964. returnErrorMsg("找不到记录");
  2965. }
  2966. }
  2967. public void ins_erp_designprice()
  2968. {
  2969. if (UrlPostParmsCheck("ctid"))
  2970. {
  2971. string eid = GetPostString("ctid");
  2972. int uid = CurrentUser.UserID;
  2973. string userName = CurrentUser.UserName;
  2974. CeErpTradeCell entity = null;
  2975. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2976. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2977. if (entitys == null)
  2978. {
  2979. entitys = new CeErpDesignerBill();
  2980. }
  2981. if (entity != null)
  2982. {
  2983. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2984. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2985. entity.StartDesignTime = DateTime.Now;
  2986. entity.OrderState = 4;
  2987. string suname = "";
  2988. if (entity.SupplierId == 0)
  2989. {
  2990. int sid = commonHelper.autoDistributeToSupplier(entity);
  2991. entity.SupplierId = sid;
  2992. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2993. }
  2994. entity.Update();
  2995. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2996. if (ceErpUserPost != null)
  2997. {
  2998. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2999. if (ceErpPost != null)
  3000. {
  3001. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3002. {
  3003. entitys.tid = entity.ctid;
  3004. entitys.oid = entity.tid;
  3005. entitys.uid = uid;
  3006. entitys.userName = userName;
  3007. entitys.designerType = 1;
  3008. entitys.designerTypeText = "内部设计师";
  3009. entitys.price = Convert.ToDouble(GetPostString("price"));
  3010. entitys.designNum = GetPostInt("designNum");
  3011. entitys.modifyNum = GetPostInt("modifyNum");
  3012. entitys.designSize = GetPostString("designSize");
  3013. entitys.modifySize = GetPostString("modifySize");
  3014. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3015. {
  3016. entitys.create_time = DateTime.Now;
  3017. entitys.create_u_id = uid;
  3018. entitys.create_u_name = userName;
  3019. entitys.Save();
  3020. }
  3021. else
  3022. {
  3023. entitys.update_time = DateTime.Now;
  3024. entitys.update_u_id = uid;
  3025. entitys.update_u_name = userName;
  3026. entitys.Update();
  3027. }
  3028. }
  3029. }
  3030. }
  3031. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3032. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3033. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3034. if (suname != "")
  3035. {
  3036. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3037. }
  3038. commonHelper.getCytPrice(entity);
  3039. returnSuccessMsg("操作成功!");
  3040. return;
  3041. }
  3042. returnErrorMsg("找不到记录");
  3043. }
  3044. }
  3045. public void upload_erp_filecomplete()
  3046. {
  3047. if (UrlPostParmsCheck("ctid"))
  3048. {
  3049. string eid = GetPostString("ctid");
  3050. CeErpTradeCell entity = null;
  3051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3052. if (entity != null)
  3053. {
  3054. entity.OrderState = 5; //设计完成
  3055. entity.Update();
  3056. returnSuccessMsg(eid + "上传成功,设计完成!");
  3057. return;
  3058. }
  3059. returnErrorMsg("找不到订单记录");
  3060. }
  3061. }
  3062. public void get_erp_designovertimelist()
  3063. {
  3064. DataStruct dStruct = GetPostStruct();
  3065. List<string> lw = new List<string>();
  3066. string tid = GetPostString("ctid");
  3067. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3068. string shopname = GetPostString("shopname");
  3069. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3070. string buyernick = GetPostString("buyer_nick");
  3071. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3072. string ResponsibleMan = GetPostString("responsible");
  3073. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3074. string date1 = GetPostString("date1");
  3075. string date2 = GetPostString("date2");
  3076. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3077. if (dw.Length > 0) lw.Add(dw);
  3078. string price1 = GetPostString("price1");
  3079. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3080. string price2 = GetPostString("price2");
  3081. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3082. string orderState = GetPostString("orderState");
  3083. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3084. string sellermemo = GetPostString("seller_memo");
  3085. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3086. lw.Add(string.Format("UnusualTag=3"));
  3087. lw.Add(string.Format("IsRefund<={0}", 1));
  3088. dStruct.Order = "WaitDesignTime desc";
  3089. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3090. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3091. writeGridDataTableJson(dStruct.TotalCount, dt);
  3092. }
  3093. //设计管理 获取抢单大厅列表
  3094. public void get_erp_grabinglist()
  3095. {
  3096. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3097. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3098. bool oldOrder = false;
  3099. if (org != null)
  3100. {
  3101. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3102. }
  3103. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3104. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3105. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3106. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3107. //先处理订单数据
  3108. if (dt.Rows.Count > 0)
  3109. {
  3110. Dictionary<string, int> design = null;
  3111. int count = 0;
  3112. foreach (DataRow row in dt.Rows)
  3113. {
  3114. if (map.ContainsKey(row["ShopId"].ToString()))
  3115. {
  3116. map.TryGetValue(row["ShopId"].ToString(), out design);
  3117. }
  3118. else
  3119. {
  3120. design = new Dictionary<string, int>();
  3121. }
  3122. if (design.ContainsKey(row["ProductId"].ToString()))
  3123. {
  3124. design.TryGetValue(row["ProductId"].ToString(), out count);
  3125. }
  3126. count++;
  3127. design[row["ProductId"].ToString()] = count;
  3128. map[row["ShopId"].ToString()] = design;
  3129. }
  3130. }
  3131. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3132. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3133. //把店铺排序和技能排序分类
  3134. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3135. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3136. if (design_dt.Rows.Count > 0)
  3137. {
  3138. Dictionary<string, string> design = null;
  3139. List<string> shopIds = null;
  3140. foreach (DataRow row in design_dt.Rows)
  3141. {
  3142. if ("0".Equals(row["designId"].ToString()))
  3143. {
  3144. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3145. {
  3146. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3147. }
  3148. else
  3149. {
  3150. shopIds = new List<string>();
  3151. }
  3152. shopIds.Add(row["shopId"].ToString());
  3153. shop_orders[row["orders"].ToString()] = shopIds;
  3154. }
  3155. else
  3156. {
  3157. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3158. {
  3159. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3160. }
  3161. else
  3162. {
  3163. design = new Dictionary<string, string>();
  3164. }
  3165. design[row["orders"].ToString()] = row["designId"].ToString();
  3166. design_orders[row["shopId"].ToString()] = design;
  3167. }
  3168. }
  3169. //处理成key value后根据key排序
  3170. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3171. foreach (List<string> val in shop_orders.Values)
  3172. {
  3173. if (val != null)
  3174. {
  3175. foreach (string key in val)
  3176. {
  3177. if (design_orders.ContainsKey(key.ToString()))
  3178. {
  3179. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3180. }
  3181. }
  3182. }
  3183. }
  3184. }
  3185. //校验哪个优先级有订单
  3186. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3187. foreach (string key in shop_orders.Keys)
  3188. {
  3189. List<string> ids = null;
  3190. shop_orders.TryGetValue(key, out ids);
  3191. //id为shopid
  3192. foreach (string id in ids)
  3193. {
  3194. Dictionary<string, int> list = null;
  3195. Dictionary<string, string> desing = null;
  3196. map.TryGetValue(id, out list);
  3197. design_orders.TryGetValue(id, out desing);
  3198. if (list != null && desing != null)
  3199. {
  3200. foreach (var item in desing)
  3201. {
  3202. int count = 0;
  3203. if (list.ContainsKey(item.Value))
  3204. {
  3205. list.TryGetValue(item.Value, out count);
  3206. if (count > 0)
  3207. {
  3208. designIds[id] = item.Value;
  3209. break;
  3210. }
  3211. }
  3212. }
  3213. }
  3214. }
  3215. if (designIds.Count > 0)
  3216. {
  3217. break;
  3218. }
  3219. }
  3220. DataTable table = new DataTable();
  3221. table.Columns.Add("tid", typeof(string));
  3222. table.Columns.Add("ctid", typeof(string));
  3223. table.Columns.Add("seller_nick", typeof(string));
  3224. table.Columns.Add("productName", typeof(string));
  3225. table.Columns.Add("pay_time", typeof(string));
  3226. table.Columns.Add("seller_memo", typeof(string));
  3227. if (designIds.Count > 0)
  3228. {
  3229. string shopId = "";
  3230. string productId = "";
  3231. foreach (var designInfo in designIds)
  3232. {
  3233. shopId = designInfo.Key;
  3234. productId = designInfo.Value;
  3235. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3236. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3237. if (dt.Rows.Count > 0)
  3238. {
  3239. foreach (DataRow row in dt.Rows)
  3240. {
  3241. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3242. {
  3243. DataRow data = table.NewRow();
  3244. data["ctid"] = row["ctid"].ToString();
  3245. data["tid"] = row["tid"].ToString();
  3246. data["seller_nick"] = ceErpShop.ShopName;
  3247. data["pay_time"] = row["pay_time"].ToString();
  3248. data["seller_memo"] = row["seller_memo"].ToString();
  3249. data["productName"] = ceErpProduct.PType;
  3250. table.Rows.Add(data);
  3251. }
  3252. }
  3253. }
  3254. }
  3255. }
  3256. writeGridDataTableJson(table.Rows.Count, table);
  3257. }
  3258. private object rushLockObject = new object();
  3259. public void set_erp_grabingorder()
  3260. {
  3261. if (UrlPostParmsCheck("ctid"))
  3262. {
  3263. int total = CurrentUser.User.Person.Total;
  3264. int userId = CurrentUser.User.ID;
  3265. int noFinish = CurrentUser.User.Person.NoFinish;
  3266. int finalization = CurrentUser.User.Person.Finalization;
  3267. string eids = GetPostString("ctid");
  3268. string key = "RushKey_" + userId;
  3269. int count = 0;
  3270. if (erpRedis.RedisHelper.KeyExists(key))
  3271. {
  3272. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3273. if (redisCount != null)
  3274. {
  3275. count = Convert.ToInt32(redisCount);
  3276. }
  3277. }
  3278. if (count >= total)
  3279. {
  3280. returnErrorMsg("半小时内已经抢" + total + "单");
  3281. return;
  3282. }
  3283. string[] ctidlist = eids.Split(',');
  3284. if (count + ctidlist.Length > total)
  3285. {
  3286. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3287. return;
  3288. }
  3289. int itag = 0;
  3290. lock (rushLockObject)
  3291. {
  3292. if (ctidlist.Length > 0)
  3293. {
  3294. string[] dtList = new string[ctidlist.Length];
  3295. for (int i = 0; i < ctidlist.Length; i++)
  3296. {
  3297. dtList[i] = "'" + ctidlist[i] + "'";
  3298. }
  3299. 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"));
  3300. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3301. if (dt_user.Rows.Count > 0)
  3302. {
  3303. int doing = 0;//未定稿
  3304. int finish = 0;//已完成
  3305. foreach (DataRow dr in dt_user.Rows)
  3306. {
  3307. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3308. {
  3309. doing++;
  3310. }
  3311. else
  3312. {
  3313. finish++;
  3314. }
  3315. }
  3316. if (doing >= noFinish)
  3317. {
  3318. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3319. return;
  3320. }
  3321. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3322. {
  3323. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3324. return;
  3325. }
  3326. }
  3327. //校验选择单子状态
  3328. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3329. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3330. if (dt.Rows.Count > 0)
  3331. {
  3332. List<string> list = new List<string>();
  3333. foreach (DataRow dr in dt.Rows)
  3334. {
  3335. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3336. {
  3337. list.Add(dr["ctid"].ToString());
  3338. }
  3339. }
  3340. if (list.Count > 0)
  3341. {
  3342. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3343. return;
  3344. }
  3345. }
  3346. foreach (string ctid in ctidlist)
  3347. {
  3348. CeErpTradeCell entity = null;
  3349. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3350. if (entity != null)
  3351. {
  3352. entity.OrderState = 3;
  3353. entity.DesignUserId = CurrentUser.UserID;
  3354. entity.WaitDesignTime = DateTime.Now;
  3355. entity.StartDesignTime = DateTime.Now;
  3356. entity.Update();
  3357. commonHelper.UpdateRelationOrder(entity.ctid);
  3358. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3359. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3360. itag++;
  3361. }
  3362. }
  3363. }
  3364. }
  3365. count += ctidlist.Length;
  3366. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3367. if (itag == 0)
  3368. returnErrorMsg("没有找到相关订单");
  3369. else
  3370. returnSuccessMsg("抢单成功!");
  3371. return;
  3372. }
  3373. }
  3374. public void get_erp_waitorderlist()
  3375. {
  3376. DataStruct dStruct = GetPostStruct();
  3377. List<string> lw = new List<string>();
  3378. string tid = GetPostString("ctid");
  3379. if (tid.Length > 0)
  3380. {
  3381. string select_tid = getTidByCtid(tid);
  3382. lw.Add(string.Format("tid='{0}'", select_tid));
  3383. }
  3384. string shopname = GetPostString("shopname");
  3385. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3386. string buyernick = GetPostString("buyer_nick");
  3387. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3388. string customer = GetPostString("customer");
  3389. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3390. string design = GetPostString("design");
  3391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3392. string orderState = GetPostString("orderState");
  3393. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3394. string supplier = GetPostString("supplier");
  3395. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3396. string sellermemo = GetPostString("seller_memo");
  3397. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3398. string otherMemo = GetPostString("otherMemo");
  3399. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3400. string address = GetPostString("address");
  3401. 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));
  3402. string date1 = GetPostString("date1");
  3403. string date2 = GetPostString("date2");
  3404. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3405. if (dw.Length > 0) lw.Add(dw);
  3406. string price1 = GetPostString("price1");
  3407. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3408. string price2 = GetPostString("price2");
  3409. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3410. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3411. lw.Add(string.Format("IsSample != 2 "));
  3412. lw.Add(string.Format("OrderState = 5 "));
  3413. lw.Add(string.Format("IsRefund<={0}", 1));
  3414. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3415. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3416. string pagesize = GetPostString("pagesize");
  3417. if (pagesize != null)
  3418. {
  3419. dStruct.PageSize = 200;
  3420. }
  3421. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3422. if (dt != null)
  3423. {
  3424. foreach (DataRow dr in dt.Rows)
  3425. {
  3426. 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();
  3427. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3428. {
  3429. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3430. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3431. entity.SupplierId = suid;
  3432. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3433. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3434. entity.Update();
  3435. }
  3436. }
  3437. }
  3438. writeGridDataTableJson(dStruct.TotalCount, dt);
  3439. }
  3440. public void get_erp_supplierwaitorderlist()
  3441. {
  3442. DataStruct dStruct = GetPostStruct();
  3443. List<string> lw = new List<string>();
  3444. string tid = GetPostString("ctid");
  3445. if (tid.Length > 0)
  3446. {
  3447. string select_tid = getTidByCtid(tid);
  3448. lw.Add(string.Format("tid='{0}'", select_tid));
  3449. }
  3450. string shopname = GetPostString("shopname");
  3451. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3452. string sellermemo = GetPostString("seller_memo");
  3453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3454. string date1 = GetPostString("date1");
  3455. string date2 = GetPostString("date2");
  3456. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3457. if (dw.Length > 0) lw.Add(dw);
  3458. lw.Add(string.Format("OrderState = 5 "));
  3459. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3460. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3461. {
  3462. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3463. }
  3464. string supplier = GetPostString("supplier");
  3465. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3466. {
  3467. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3468. }
  3469. lw.Add(string.Format("IsRefund<={0}", 1));
  3470. dStruct.Order = "FinishDesignTime desc";
  3471. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3472. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3473. if (dt != null)
  3474. {
  3475. foreach (DataRow dr in dt.Rows)
  3476. {
  3477. 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();
  3478. }
  3479. }
  3480. writeGridDataTableJson(dStruct.TotalCount, dt);
  3481. }
  3482. public void upd_erp_verifytosupplier()
  3483. {
  3484. if (UrlPostParmsCheck("ctid"))
  3485. {
  3486. string eids = GetPostString("ctid");
  3487. CeErpTradeCell entity = null;
  3488. string[] eidsList = eids.Split(',');
  3489. if (eidsList.Length <= 0)
  3490. {
  3491. returnErrorMsg("订单号不能空");
  3492. return;
  3493. }
  3494. List<string> tLst = new List<string>();
  3495. foreach (string ctidstr in eidsList)
  3496. {
  3497. tLst.Add("'" + ctidstr + "'");
  3498. CeErpDataSendOrderInfo.createObject(ctidstr);
  3499. }
  3500. string needtids = string.Join(",", tLst.ToArray());
  3501. StringBuilder sql = new StringBuilder();
  3502. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3503. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3504. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3505. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3506. returnSuccessMsg("操作成功!");
  3507. return;
  3508. /**foreach (string ctidstr in eidsList)
  3509. {
  3510. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3511. if (entity != null)
  3512. {
  3513. if (entity.SupplierId == 0)
  3514. {
  3515. continue;
  3516. }
  3517. entity.IsVerifyToSupplier = true;
  3518. if (entity.IsReturn == 1) //1是供应商打回
  3519. {
  3520. entity.IsReturn = 0;
  3521. }
  3522. entity.FinishPlaceTime = DateTime.Now;
  3523. entity.PlaceUserId = CurrentUser.UserID;
  3524. entity.Update();
  3525. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3526. }
  3527. }
  3528. returnSuccessMsg("操作成功!");
  3529. return;**/
  3530. }
  3531. }
  3532. public void upd_erp_supplierback()
  3533. {
  3534. if (UrlPostParmsCheck("ctid"))
  3535. {
  3536. string eid = GetPostString("ctid");
  3537. string reason = GetPostString("returnreason");
  3538. CeErpTradeCell entity = null;
  3539. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3540. if (entity != null)
  3541. {
  3542. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3543. {
  3544. string key = "return_order_" + entity.SupplierId;
  3545. List<string> list = new List<string>();
  3546. if (RedisHelper.HasKey(key))
  3547. {
  3548. object data = RedisHelper.StringGet(key);
  3549. list = Convert.ToString(data).Split(',').ToList();
  3550. }
  3551. list.Add(eid);
  3552. RedisHelper.StringSet(key, string.Join(",", list));
  3553. }
  3554. entity.IsVerifyToSupplier = false;
  3555. entity.IsReturn = 1;
  3556. entity.ReturnTime = DateTime.Now;
  3557. entity.ReturnReason = reason;
  3558. if (entity.OrderState == 6)
  3559. {
  3560. entity.OrderState = 5;
  3561. }
  3562. entity.Update();
  3563. CeErpSukuraData.createInfo(entity.ctid, 5);
  3564. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3565. returnSuccessMsg("操作成功!");
  3566. return;
  3567. }
  3568. returnErrorMsg("找不到订单记录");
  3569. }
  3570. }
  3571. public void upd_erp_toaftersaleorder()
  3572. {
  3573. if (UrlPostParmsCheck("ctid"))
  3574. {
  3575. string eid = GetPostString("ctid");
  3576. string reason = GetPostString("returnreason");
  3577. CeErpTradeCell entity = null;
  3578. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3579. if (entity != null)
  3580. {
  3581. if (entity.isAfterSaleOrder != 1)
  3582. {
  3583. returnErrorMsg("带S的售后单才能打回给售后");
  3584. return;
  3585. }
  3586. if (entity.OrderState >= 5)
  3587. {
  3588. returnErrorMsg("已经设计完成了不能打回给售后");
  3589. return;
  3590. }
  3591. entity.OrderState = 0;
  3592. entity.IsReturn = 3;
  3593. entity.ReturnTime = DateTime.Now;
  3594. entity.UpdateTime = DateTime.Now;
  3595. entity.ReturnReason = reason;
  3596. entity.Update();
  3597. CeErpSukuraData.createInfo(entity.ctid, 5);
  3598. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3599. returnSuccessMsg("操作成功!");
  3600. return;
  3601. }
  3602. returnErrorMsg("找不到订单记录");
  3603. }
  3604. }
  3605. public void upd_erp_aftersaletodesign()
  3606. {
  3607. if (UrlPostParmsCheck("ctid"))
  3608. {
  3609. string eid = GetPostString("ctid");
  3610. CeErpTradeCell entity = null;
  3611. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3612. if (entity != null)
  3613. {
  3614. entity.OrderState = 3;
  3615. entity.IsReturn = 0;
  3616. entity.UpdateTime = DateTime.Now;
  3617. entity.Update();
  3618. CeErpSukuraData.createInfo(entity.ctid, 5);
  3619. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3620. returnSuccessMsg("操作成功!");
  3621. return;
  3622. }
  3623. returnErrorMsg("找不到订单记录");
  3624. }
  3625. }
  3626. public void assign_erp_supplier()
  3627. {
  3628. if (UrlPostParmsCheck("ctid"))
  3629. {
  3630. string eids = GetPostString("ctid");
  3631. int sid = GetPostInt("SupplierName");
  3632. string fromTag = GetPostString("tag");
  3633. string[] eidList = eids.Split(',');
  3634. if (eidList.Length <= 0)
  3635. {
  3636. returnErrorMsg("指派不能为空");
  3637. return;
  3638. }
  3639. string errMsg = "";
  3640. string suname = commonHelper.getSupplierNameById(sid);
  3641. foreach (string ctid in eidList)
  3642. {
  3643. CeErpTradeCell entity = null;
  3644. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3645. if (entity != null)
  3646. {
  3647. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3648. {
  3649. errMsg += (ctid + "指派失败!!!");
  3650. continue;
  3651. }
  3652. entity.SupplierId = sid;
  3653. entity.Update();
  3654. commonHelper.UpdateRelationOrder(entity.ctid);
  3655. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3656. if (entity.OrderState >= 6)
  3657. {
  3658. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3659. //{
  3660. // string msl = entity.MakeSupplier;
  3661. // string[] mslist = msl.Split(',');
  3662. // 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);
  3663. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3664. //}
  3665. //else
  3666. //{
  3667. StringBuilder sql = new StringBuilder();
  3668. 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);
  3669. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3670. //}
  3671. }
  3672. }
  3673. else
  3674. {
  3675. continue;
  3676. }
  3677. }
  3678. if (errMsg.Length > 0)
  3679. {
  3680. returnErrorMsg(errMsg);
  3681. return;
  3682. }
  3683. returnSuccessMsg("操作成功!");
  3684. return;
  3685. }
  3686. }
  3687. public void assign_erp_makesupplier()
  3688. {
  3689. if (UrlPostParmsCheck("ctid"))
  3690. {
  3691. string eids = GetPostString("ctid");
  3692. string sname = GetPostString("SupplierName");
  3693. string[] eidList = eids.Split(',');
  3694. if (eidList.Length <= 0)
  3695. {
  3696. returnErrorMsg("指派不能为空");
  3697. return;
  3698. }
  3699. List<string> tLst = new List<string>();
  3700. foreach (string ctid in eidList)
  3701. {
  3702. CeErpTradeCell entity = null;
  3703. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3704. if (entity != null)
  3705. {
  3706. entity.MakeSupplier = sname;
  3707. entity.Update();
  3708. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3709. tLst.Add("'" + ctid + "'");
  3710. }
  3711. else
  3712. {
  3713. continue;
  3714. }
  3715. }
  3716. string ctids = string.Join(",", tLst.ToArray());
  3717. StringBuilder sql2 = new StringBuilder();
  3718. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3719. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3720. returnSuccessMsg("操作成功!");
  3721. return;
  3722. }
  3723. }
  3724. public void ins_erp_returnreason()
  3725. {
  3726. if (UrlPostParmsCheck("ctid"))
  3727. {
  3728. string eid = GetPostString("ctid");
  3729. CeErpTradeCell entity = null;
  3730. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3731. string userpost = CurrentUser.UserPost.Post.Code;
  3732. if (entity != null)
  3733. {
  3734. bool isPlace = false;
  3735. if (entity.OrderState > 6)
  3736. {
  3737. returnErrorMsg("已发货无法打回!");
  3738. return;
  3739. }
  3740. if (entity.OrderState == 6)
  3741. {
  3742. isPlace = true;
  3743. }
  3744. bool isNeedUpdateCell2 = false;
  3745. if (entity.OrderState >= 6)
  3746. {
  3747. isNeedUpdateCell2 = true;
  3748. }
  3749. int returnTag = 2;
  3750. if (userpost == "Supplier")
  3751. {
  3752. returnTag = 1;
  3753. }
  3754. int toType = GetPostInt("totype");
  3755. string fromType = "3";
  3756. if (entity.OrderState < 5)
  3757. {
  3758. fromType = "3";
  3759. }
  3760. else
  3761. {
  3762. fromType = "4";
  3763. }
  3764. if (entity.IsXianHuo == 0)
  3765. {
  3766. if (returnTag == 2)
  3767. {
  3768. if (toType == 1)
  3769. {
  3770. entity.OrderState = 0;
  3771. entity.ReturnUserType = 1;
  3772. string clearman = GetPostString("clearman");
  3773. if (!string.IsNullOrEmpty(clearman))
  3774. {
  3775. entity.DesignUserId = 0;
  3776. }
  3777. }
  3778. else
  3779. {
  3780. entity.OrderState = 3;
  3781. entity.ReturnUserType = 2;
  3782. }
  3783. entity.IsReadTag = 1;
  3784. }
  3785. else if (returnTag == 1)
  3786. {
  3787. entity.OrderState = 5;
  3788. }
  3789. entity.IsVerifyToSupplier = false;
  3790. }
  3791. if (entity.IsXianHuo == 1)
  3792. {
  3793. entity.OrderState = 5;
  3794. }
  3795. entity.UnusualTag = 0;
  3796. entity.UnusualTime = null;
  3797. entity.UnusualCon = "";
  3798. entity.IsReturn = returnTag;
  3799. entity.ReturnTime = DateTime.Now;
  3800. entity.UpdateTime = DateTime.Now;
  3801. entity.ReturnReason = GetPostString("returnreason");
  3802. entity.Update();
  3803. if (entity.OrderState == 3)
  3804. {
  3805. ApiVo apiVo = new ApiVo();
  3806. apiVo.orderNumber = entity.ctid;
  3807. apiVo.actionName = "rebutDesign";
  3808. apiVo.orderRemarks = entity.ReturnReason;
  3809. designHelper.API_WorkCore(apiVo);//rebutDesign
  3810. }
  3811. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3812. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3813. {
  3814. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3815. }
  3816. CeErpSukuraData.createInfo(entity.ctid, 5);
  3817. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3819. if (isPlace)
  3820. {
  3821. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3822. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3823. if (dth != null && dth.Rows.Count > 0)
  3824. {
  3825. dataSendOrderBean dataSendOrderBean = null;
  3826. foreach (DataRow item in dth.Rows)
  3827. {
  3828. try
  3829. {
  3830. dataSendOrderBean = new dataSendOrderBean();
  3831. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3832. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3833. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3834. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3835. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3836. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3837. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3838. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3839. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3840. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3841. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3842. dataSendOrderBean.Radio1723534706288 = "打回";
  3843. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3844. if (result != null)
  3845. {
  3846. if ("0".Equals(result.errcode))
  3847. {
  3848. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3849. }
  3850. else
  3851. {
  3852. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3853. }
  3854. }
  3855. }
  3856. catch (Exception ex)
  3857. {
  3858. }
  3859. }
  3860. }
  3861. }
  3862. if (isNeedUpdateCell2)
  3863. {
  3864. if (entity.MakeSupplier.IndexOf(",") != -1)
  3865. {
  3866. StringBuilder sql2 = new StringBuilder();
  3867. 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);
  3868. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3869. }
  3870. else
  3871. {
  3872. StringBuilder sql2 = new StringBuilder();
  3873. 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);
  3874. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3875. }
  3876. }
  3877. returnSuccessMsg("操作成功!");
  3878. return;
  3879. }
  3880. returnErrorMsg("找不到订单记录");
  3881. }
  3882. }
  3883. public void cyt_erp_returnreason()
  3884. {
  3885. if (UrlPostParmsCheck("ctid"))
  3886. {
  3887. string eid = GetPostString("ctid");
  3888. CeErpTradeCell entity = null;
  3889. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3890. string userpost = CurrentUser.UserPost.Post.Code;
  3891. if (entity != null)
  3892. {
  3893. if (entity.OrderState > 6)
  3894. {
  3895. returnErrorMsg("已发货无法打回!");
  3896. return;
  3897. }
  3898. JObject jsonObject = new JObject
  3899. {
  3900. { "Userid", "77886" },
  3901. { "Pwd", "lt666888" },
  3902. { "LTOrderId",eid }
  3903. };
  3904. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3905. JObject jsonObjects = JObject.Parse(response);
  3906. string msg = (string)jsonObjects["msg"];
  3907. if (msg != "取消成功")
  3908. {
  3909. returnErrorMsg(msg);
  3910. return;
  3911. }
  3912. bool isNeedUpdateCell2 = false;
  3913. if (entity.OrderState >= 6)
  3914. {
  3915. isNeedUpdateCell2 = true;
  3916. }
  3917. int returnTag = 2;
  3918. if (userpost == "Supplier")
  3919. {
  3920. returnTag = 1;
  3921. }
  3922. if (entity.IsXianHuo == 0)
  3923. {
  3924. if (returnTag == 2)
  3925. {
  3926. int toType = GetPostInt("totype");
  3927. if (toType == 1)
  3928. {
  3929. entity.OrderState = 0;
  3930. entity.ReturnUserType = 1;
  3931. }
  3932. else
  3933. {
  3934. entity.OrderState = 4;
  3935. entity.ReturnUserType = 2;
  3936. }
  3937. entity.IsReadTag = 1;
  3938. }
  3939. else if (returnTag == 1)
  3940. {
  3941. entity.OrderState = 5;
  3942. }
  3943. entity.IsVerifyToSupplier = false;
  3944. }
  3945. entity.UnusualTag = 0;
  3946. entity.UnusualTime = null;
  3947. entity.UnusualCon = "";
  3948. entity.IsReturn = returnTag;
  3949. entity.ReturnTime = DateTime.Now;
  3950. entity.ReturnReason = GetPostString("returnreason");
  3951. entity.Update();
  3952. if (entity.OrderState == 4)
  3953. {
  3954. ApiVo apiVo = new ApiVo();
  3955. apiVo.orderNumber = entity.ctid;
  3956. apiVo.actionName = "rebutDesign";
  3957. apiVo.orderRemarks = entity.ReturnReason;
  3958. designHelper.API_WorkCore(apiVo);//rebutDesign
  3959. }
  3960. CeErpSukuraData.createInfo(entity.ctid, 5);
  3961. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3962. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3963. if (isNeedUpdateCell2)
  3964. {
  3965. if (entity.MakeSupplier.IndexOf(",") != -1)
  3966. {
  3967. StringBuilder sql2 = new StringBuilder();
  3968. 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);
  3969. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3970. }
  3971. else
  3972. {
  3973. StringBuilder sql2 = new StringBuilder();
  3974. 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);
  3975. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3976. }
  3977. }
  3978. returnSuccessMsg("操作成功!");
  3979. return;
  3980. }
  3981. returnErrorMsg("找不到订单记录");
  3982. }
  3983. }
  3984. public void upd_erp_xianhuoreturntag()
  3985. {
  3986. if (UrlPostParmsCheck("ctid"))
  3987. {
  3988. string eids = GetPostString("ctid");
  3989. string[] ctids = eids.Split(',');
  3990. foreach (string ctid in ctids)
  3991. {
  3992. CeErpTradeCell entity = null;
  3993. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3994. if (entity != null)
  3995. {
  3996. entity.IsReturn = 0;
  3997. entity.Update();
  3998. CeErpSukuraData.createInfo(entity.ctid, 5);
  3999. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4000. }
  4001. }
  4002. returnSuccessMsg("操作成功!");
  4003. return;
  4004. }
  4005. }
  4006. public void get_erp_waitdeliverylist()
  4007. {
  4008. DataStruct dStruct = GetPostStruct();
  4009. List<string> lw = new List<string>();
  4010. string tid = GetPostString("ctid");
  4011. if (tid.Length > 0)
  4012. {
  4013. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4014. if (tid.Length > 5)
  4015. {
  4016. List<string> tids = getTidByCtidLike(tid);
  4017. if (tids.Count > 0 && tids.Count < 10)
  4018. {
  4019. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4020. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4021. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4022. {
  4023. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4024. }
  4025. }
  4026. }
  4027. lw.Add(tid_sql);
  4028. }
  4029. string shopname = GetPostString("shopname");
  4030. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4031. string buyernick = GetPostString("buyer_nick");
  4032. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4033. //if (tid.Length == 0 && buyernick.Length == 0)
  4034. //{
  4035. // lw.Add(string.Format("IsRefund<={0}", 1));
  4036. //}
  4037. string customer = GetPostString("customer");
  4038. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4039. string design = GetPostString("design");
  4040. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4041. string orderState = GetPostString("orderState");
  4042. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4043. string address = GetPostString("address");
  4044. 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));
  4045. string sellermemo = GetPostString("seller_memo");
  4046. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4047. string supplier = GetPostString("supplier");
  4048. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4049. string OrderArea = GetPostString("order_area");
  4050. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4051. string placedate1 = GetPostString("placedate1");
  4052. string placedate2 = GetPostString("placedate2");
  4053. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4054. if (fdw.Length > 0) lw.Add(fdw);
  4055. string price1 = GetPostString("price1");
  4056. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4057. string price2 = GetPostString("price2");
  4058. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4059. string unusualCon = GetPostString("unusualcon");
  4060. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4061. string otherMemo = GetPostString("otherMemo");
  4062. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4063. string posTag = CurrentUser.UserPost.Post.Code;
  4064. if (posTag == "Supplier")
  4065. {
  4066. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4067. }
  4068. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4069. lw.Add(string.Format("type != 'PDD' "));
  4070. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4071. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4073. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4074. writeGridDataTableJson(dStruct.TotalCount, dt);
  4075. }
  4076. public void get_erp_changedeliverylist()
  4077. {
  4078. DataStruct dStruct = GetPostStruct();
  4079. List<string> lw = new List<string>();
  4080. string tid = GetPostString("ctid");
  4081. if (tid.Length > 0)
  4082. {
  4083. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4084. if (tid.Length > 5)
  4085. {
  4086. List<string> tids = getTidByCtidLike(tid);
  4087. if (tids.Count > 0 && tids.Count < 10)
  4088. {
  4089. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4090. }
  4091. }
  4092. lw.Add(tid_sql);
  4093. }
  4094. string shopname = GetPostString("shopname");
  4095. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4096. string buyernick = GetPostString("buyer_nick");
  4097. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4098. //if (tid.Length == 0 && buyernick.Length == 0)
  4099. //{
  4100. // lw.Add(string.Format("IsRefund<={0}", 1));
  4101. //}
  4102. string customer = GetPostString("customer");
  4103. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4104. string design = GetPostString("design");
  4105. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4106. string orderState = GetPostString("orderState");
  4107. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4108. string address = GetPostString("address");
  4109. 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));
  4110. string sellermemo = GetPostString("seller_memo");
  4111. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4112. string supplier = GetPostString("supplier");
  4113. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4114. string OrderArea = GetPostString("order_area");
  4115. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4116. string placedate1 = GetPostString("placedate1");
  4117. string placedate2 = GetPostString("placedate2");
  4118. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4119. if (fdw.Length > 0) lw.Add(fdw);
  4120. string price1 = GetPostString("price1");
  4121. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4122. string price2 = GetPostString("price2");
  4123. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4124. string unusualCon = GetPostString("unusualcon");
  4125. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4126. string otherMemo = GetPostString("otherMemo");
  4127. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4128. string posTag = CurrentUser.UserPost.Post.Code;
  4129. if (posTag == "Supplier")
  4130. {
  4131. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4132. }
  4133. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4134. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4135. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4136. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4137. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4138. /*if (tid.Length > 0)
  4139. {
  4140. List<string> tids = new List<string>();
  4141. if (dt != null && dt.Rows.Count > 0)
  4142. {
  4143. foreach (DataRow item in dt.Rows)
  4144. {
  4145. tids.Add("'" + item["tid"] + "'");
  4146. }
  4147. }
  4148. if (tids.Count > 0)
  4149. {
  4150. lw.RemoveAt(0);
  4151. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4152. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4153. dt = WebCache.GetData("view_erptradecell", dStruct);
  4154. }
  4155. }*/
  4156. writeGridDataTableJson(dStruct.TotalCount, dt);
  4157. }
  4158. public void get_erp_pddderiving()
  4159. {
  4160. DataStruct dStruct = GetPostStruct();
  4161. List<string> lw = new List<string>();
  4162. string tid = GetPostString("ctid");
  4163. if (tid.Length > 0)
  4164. {
  4165. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4166. if (tid.Length > 5)
  4167. {
  4168. List<string> tids = getTidByCtidLike(tid);
  4169. if (tids.Count > 0 && tids.Count < 10)
  4170. {
  4171. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4172. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4173. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4174. {
  4175. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4176. }
  4177. }
  4178. }
  4179. lw.Add(tid_sql);
  4180. }
  4181. string shopname = GetPostString("shopname");
  4182. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4183. string buyernick = GetPostString("buyer_nick");
  4184. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4185. //if (tid.Length == 0 && buyernick.Length == 0)
  4186. //{
  4187. // lw.Add(string.Format("IsRefund<={0}", 1));
  4188. //}
  4189. string customer = GetPostString("customer");
  4190. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4191. string design = GetPostString("design");
  4192. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4193. string orderState = GetPostString("orderState");
  4194. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4195. string address = GetPostString("address");
  4196. 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));
  4197. string sellermemo = GetPostString("seller_memo");
  4198. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4199. string supplier = GetPostString("supplier");
  4200. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4201. string OrderArea = GetPostString("order_area");
  4202. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4203. string placedate1 = GetPostString("placedate1");
  4204. string placedate2 = GetPostString("placedate2");
  4205. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4206. if (fdw.Length > 0) lw.Add(fdw);
  4207. string price1 = GetPostString("price1");
  4208. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4209. string price2 = GetPostString("price2");
  4210. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4211. string unusualCon = GetPostString("unusualcon");
  4212. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4213. string posTag = CurrentUser.UserPost.Post.Code;
  4214. if (posTag == "Supplier")
  4215. {
  4216. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4217. }
  4218. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4219. lw.Add(string.Format("type = 'PDD' "));
  4220. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4221. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4223. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4224. /*if (tid.Length > 0)
  4225. {
  4226. List<string> tids = new List<string>();
  4227. if (dt != null && dt.Rows.Count > 0)
  4228. {
  4229. foreach (DataRow item in dt.Rows)
  4230. {
  4231. tids.Add("'" + item["tid"] + "'");
  4232. }
  4233. }
  4234. if (tids.Count > 0)
  4235. {
  4236. lw.RemoveAt(0);
  4237. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4239. dt = WebCache.GetData("view_erptradecell", dStruct);
  4240. }
  4241. }*/
  4242. writeGridDataTableJson(dStruct.TotalCount, dt);
  4243. }
  4244. public void get_erp_jdderiving()
  4245. {
  4246. DataStruct dStruct = GetPostStruct();
  4247. List<string> lw = new List<string>();
  4248. string tid = GetPostString("ctid");
  4249. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4250. string shopname = GetPostString("shopname");
  4251. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4252. string buyernick = GetPostString("buyer_nick");
  4253. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4254. //if (tid.Length == 0 && buyernick.Length == 0)
  4255. //{
  4256. // lw.Add(string.Format("IsRefund<={0}", 1));
  4257. //}
  4258. string customer = GetPostString("customer");
  4259. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4260. string design = GetPostString("design");
  4261. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4262. string orderState = GetPostString("orderState");
  4263. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4264. string address = GetPostString("address");
  4265. 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));
  4266. string sellermemo = GetPostString("seller_memo");
  4267. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4268. string supplier = GetPostString("supplier");
  4269. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4270. string OrderArea = GetPostString("order_area");
  4271. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4272. string placedate1 = GetPostString("placedate1");
  4273. string placedate2 = GetPostString("placedate2");
  4274. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4275. if (fdw.Length > 0) lw.Add(fdw);
  4276. string price1 = GetPostString("price1");
  4277. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4278. string price2 = GetPostString("price2");
  4279. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4280. string unusualCon = GetPostString("unusualcon");
  4281. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4282. string posTag = CurrentUser.UserPost.Post.Code;
  4283. if (posTag == "Supplier")
  4284. {
  4285. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4286. }
  4287. lw.Add(string.Format("OrderState = 6 "));
  4288. lw.Add(string.Format("type = 'JD' "));
  4289. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4290. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4291. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4292. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4293. writeGridDataTableJson(dStruct.TotalCount, dt);
  4294. }
  4295. public void get_erp_demoorderlist()
  4296. {
  4297. DataStruct dStruct = GetPostStruct();
  4298. List<string> lw = new List<string>();
  4299. string tid = GetPostString("ctid");
  4300. if (tid.Length > 0)
  4301. {
  4302. string select_tid = getTidByCtid(tid);
  4303. lw.Add(string.Format("tid='{0}'", select_tid));
  4304. }
  4305. string shopname = GetPostString("shopname");
  4306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4307. string buyernick = GetPostString("buyer_nick");
  4308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4309. string customer = GetPostString("customer");
  4310. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4311. string design = GetPostString("design");
  4312. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4313. string orderState = GetPostString("orderState");
  4314. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4315. string address = GetPostString("address");
  4316. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4317. string sellermemo = GetPostString("seller_memo");
  4318. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4319. string supplier = GetPostString("supplier");
  4320. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4321. string OrderArea = GetPostString("order_area");
  4322. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4323. string date1 = GetPostString("date1");
  4324. string date2 = GetPostString("date2");
  4325. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4326. if (dw.Length > 0) lw.Add(dw);
  4327. string price1 = GetPostString("price1");
  4328. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4329. string price2 = GetPostString("price2");
  4330. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4331. string posTag = CurrentUser.UserPost.Post.Code;
  4332. if (posTag == "Supplier")
  4333. {
  4334. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4335. }
  4336. //lw.Add(string.Format("OrderState = 6 "));
  4337. lw.Add(string.Format("IsSample={0}", 3));
  4338. lw.Add(string.Format("IsRefund<={0}", 1));
  4339. dStruct.Order = "pay_time desc";
  4340. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4341. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4342. writeGridDataTableJson(dStruct.TotalCount, dt);
  4343. }
  4344. public void save_erp_checkmemo()
  4345. {
  4346. if (UrlPostParmsCheck("ctid"))
  4347. {
  4348. string ctid = GetPostString("ctid");
  4349. CeErpTradeCell entity = null;
  4350. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4351. if (entity != null)
  4352. {
  4353. entity.CheckMemo = GetPostString("CheckMemo");
  4354. entity.Update();
  4355. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4356. if (trade != null)
  4357. {
  4358. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4359. }
  4360. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4361. returnSuccessMsg("保存成功!");
  4362. return;
  4363. }
  4364. returnErrorMsg("找不到记录");
  4365. }
  4366. }
  4367. public void get_erp_returnlist()
  4368. {
  4369. DataStruct dStruct = GetPostStruct();
  4370. List<string> lw = new List<string>();
  4371. string tid = GetPostString("ctid");
  4372. if (tid.Length > 0)
  4373. {
  4374. string select_tid = getTidByCtid(tid);
  4375. lw.Add(string.Format("tid='{0}'", select_tid));
  4376. }
  4377. string shopname = GetPostString("shopname");
  4378. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4379. string buyernick = GetPostString("buyer_nick");
  4380. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4381. string customer = GetPostString("customer");
  4382. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4383. string design = GetPostString("design");
  4384. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4385. string orderState = GetPostString("orderState");
  4386. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4387. string address = GetPostString("address");
  4388. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4389. string sellermemo = GetPostString("seller_memo");
  4390. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4391. string supplier = GetPostString("supplier");
  4392. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4393. string date1 = GetPostString("date1");
  4394. string date2 = GetPostString("date2");
  4395. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4396. if (dw.Length > 0) lw.Add(dw);
  4397. string bdate1 = GetPostString("backdate1");
  4398. string bdate2 = GetPostString("backdate2");
  4399. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4400. if (dw_back.Length > 0) lw.Add(dw_back);
  4401. string price1 = GetPostString("price1");
  4402. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4403. string price2 = GetPostString("price2");
  4404. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4405. lw.Add(string.Format("IsReturn>0"));
  4406. lw.Add(string.Format("IsXianHuo=0"));
  4407. lw.Add(string.Format("IsReturn!=3"));
  4408. string backtype = GetPostString("backtype");
  4409. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4410. dStruct.Order = "FinishDesignTime desc";
  4411. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4412. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4413. writeGridDataTableJson(dStruct.TotalCount, dt);
  4414. }
  4415. public void get_erp_today_sumreturn()
  4416. {
  4417. DataStruct dStruct = GetPostStruct();
  4418. List<string> lw = new List<string>();
  4419. string bdate1 = GetPostString("returnTimeS");
  4420. string bdate2 = GetPostString("returnTimeE");
  4421. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4422. if (dw_back.Length > 0) lw.Add(dw_back);
  4423. lw.Add(string.Format("IsReturn=0"));
  4424. lw.Add(string.Format("IsXianHuo=0"));
  4425. string mainWhere = string.Join(" and ", lw.ToArray());
  4426. string sql = "";
  4427. if (dw_back.Length > 0)
  4428. {
  4429. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4430. }
  4431. else
  4432. {
  4433. 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 + "'";
  4434. }
  4435. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4436. decimal total = 0, today_finish = 0;
  4437. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4438. {
  4439. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4440. }
  4441. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4442. {
  4443. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4444. }
  4445. var res = new
  4446. {
  4447. data = total,
  4448. data1 = today_finish,
  4449. };
  4450. string ro_jsond = JsonConvert.SerializeObject(res);
  4451. returnSuccess(ro_jsond);
  4452. return;
  4453. }
  4454. public void get_erp_allreturnlist()
  4455. {
  4456. DataStruct dStruct = GetPostStruct();
  4457. List<string> lw = new List<string>();
  4458. string tid = GetPostString("ctid");
  4459. if (tid.Length > 0)
  4460. {
  4461. string select_tid = getTidByCtid(tid);
  4462. lw.Add(string.Format("tid='{0}'", select_tid));
  4463. }
  4464. string shopname = GetPostString("shopname");
  4465. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4466. string buyernick = GetPostString("buyer_nick");
  4467. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4468. string customer = GetPostString("customer");
  4469. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4470. string design = GetPostString("design");
  4471. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4472. string orderState = GetPostString("orderState");
  4473. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4474. string address = GetPostString("address");
  4475. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4476. string sellermemo = GetPostString("seller_memo");
  4477. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4478. string supplier = GetPostString("supplier");
  4479. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4480. string date1 = GetPostString("date1");
  4481. string date2 = GetPostString("date2");
  4482. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4483. if (dw.Length > 0) lw.Add(dw);
  4484. string bdate1 = GetPostString("backdate1");
  4485. string bdate2 = GetPostString("backdate2");
  4486. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4487. if (dw_back.Length > 0) lw.Add(dw_back);
  4488. string price1 = GetPostString("price1");
  4489. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4490. string price2 = GetPostString("price2");
  4491. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4492. string backreason = GetPostString("backreason");
  4493. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4494. lw.Add(string.Format("IsXianHuo=0"));
  4495. lw.Add(string.Format("ReturnTime != ''"));
  4496. string backtype = GetPostString("backtype");
  4497. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4498. dStruct.Order = "FinishDesignTime desc";
  4499. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4500. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4501. writeGridDataTableJson(dStruct.TotalCount, dt);
  4502. }
  4503. public void get_erp_aftersalereturnlist()
  4504. {
  4505. DataStruct dStruct = GetPostStruct();
  4506. List<string> lw = new List<string>();
  4507. string tid = GetPostString("ctid");
  4508. if (tid.Length > 0)
  4509. {
  4510. string select_tid = getTidByCtid(tid);
  4511. lw.Add(string.Format("tid='{0}'", select_tid));
  4512. }
  4513. string shopname = GetPostString("shopname");
  4514. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4515. string buyernick = GetPostString("buyer_nick");
  4516. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4517. string customer = GetPostString("customer");
  4518. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4519. string design = GetPostString("design");
  4520. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4521. string orderState = GetPostString("orderState");
  4522. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4523. string address = GetPostString("address");
  4524. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4525. string sellermemo = GetPostString("seller_memo");
  4526. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4527. string supplier = GetPostString("supplier");
  4528. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4529. string date1 = GetPostString("date1");
  4530. string date2 = GetPostString("date2");
  4531. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4532. if (dw.Length > 0) lw.Add(dw);
  4533. string bdate1 = GetPostString("backdate1");
  4534. string bdate2 = GetPostString("backdate2");
  4535. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4536. if (dw_back.Length > 0) lw.Add(dw_back);
  4537. string price1 = GetPostString("price1");
  4538. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4539. string price2 = GetPostString("price2");
  4540. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4541. lw.Add(string.Format("IsReturn=3"));
  4542. string backtype = GetPostString("backtype");
  4543. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4544. string backreason = GetPostString("backreason");
  4545. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4546. dStruct.Order = "ReturnTime desc";
  4547. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4548. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4549. writeGridDataTableJson(dStruct.TotalCount, dt);
  4550. }
  4551. public void get_erp_xianhuoreturnlist()
  4552. {
  4553. DataStruct dStruct = GetPostStruct();
  4554. List<string> lw = new List<string>();
  4555. string tid = GetPostString("ctid");
  4556. if (tid.Length > 0)
  4557. {
  4558. string select_tid = getTidByCtid(tid);
  4559. lw.Add(string.Format("tid='{0}'", select_tid));
  4560. }
  4561. string shopname = GetPostString("shopname");
  4562. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4563. string buyernick = GetPostString("buyer_nick");
  4564. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4565. string customer = GetPostString("customer");
  4566. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4567. string design = GetPostString("design");
  4568. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4569. string orderState = GetPostString("orderState");
  4570. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4571. string address = GetPostString("address");
  4572. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4573. string sellermemo = GetPostString("seller_memo");
  4574. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4575. string supplier = GetPostString("supplier");
  4576. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4577. string OrderArea = GetPostString("order_area");
  4578. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4579. string date1 = GetPostString("date1");
  4580. string date2 = GetPostString("date2");
  4581. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4582. if (dw.Length > 0) lw.Add(dw);
  4583. string price1 = GetPostString("price1");
  4584. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4585. string price2 = GetPostString("price2");
  4586. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4587. string posTag = CurrentUser.UserPost.Post.Code;
  4588. if (posTag == "Supplier")
  4589. {
  4590. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4591. }
  4592. lw.Add(string.Format("OrderState=6 "));
  4593. lw.Add(string.Format("IsXianHuo=1 "));
  4594. lw.Add(string.Format("IsReturn>0 "));
  4595. lw.Add(string.Format("IsReturn!=3"));
  4596. lw.Add(string.Format("IsRefund<={0}", 1));
  4597. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4598. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4599. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4600. writeGridDataTableJson(dStruct.TotalCount, dt);
  4601. }
  4602. public void set_erp_orderdelivery()
  4603. {
  4604. if (UrlPostParmsCheck("ctid"))
  4605. {
  4606. string eid = GetPostString("ctid");
  4607. CeErpTradeCell entity = null;
  4608. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4609. if (entity != null)
  4610. {
  4611. if (entity.OrderState >= 7)
  4612. {
  4613. returnErrorMsg("此单已发货,无需重复发货");
  4614. return;
  4615. }
  4616. if (entity.OrderState != 6)
  4617. {
  4618. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4619. return;
  4620. }
  4621. string shop = GetPostString("seller_nick");
  4622. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4623. string comName = GetPostString("comName");
  4624. string comCode = GetPostString("comCode");
  4625. string outSid = GetPostString("outSid");
  4626. string deliveryType = GetPostString("deliveryType");
  4627. string deliveryMemo = GetPostString("deliveryMemo");
  4628. outSid = outSid.Trim();
  4629. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4630. if (mainEn == null)
  4631. {
  4632. returnErrorMsg("找不到原始订单记录");
  4633. return;
  4634. }
  4635. bool isInitOrderDeliv = false;
  4636. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4637. {
  4638. isInitOrderDeliv = true;
  4639. }
  4640. string apires = "";
  4641. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4642. 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)
  4643. {
  4644. apires = "发货成功true";
  4645. }
  4646. else
  4647. {
  4648. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4649. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4650. }
  4651. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4652. {
  4653. entity.OrderState = 7;//发货后订单已发货
  4654. entity.OutSid = outSid;
  4655. entity.MemoOpt = 0;
  4656. entity.UpdateTime = DateTime.Now;
  4657. entity.FinishDeliveryTime = DateTime.Now;
  4658. entity.Update();
  4659. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4660. commonHelper.UpdateRelationOrder(entity.ctid);
  4661. //还要插入快递信息到 快递信息表
  4662. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4663. exinfo.tid = eid;
  4664. exinfo.out_sid = outSid;
  4665. exinfo.company_code = comCode;
  4666. exinfo.company_name = comName;
  4667. exinfo.delivery_memo = deliveryMemo;
  4668. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4669. exinfo.deliveryType = deliveryType;
  4670. exinfo.Create();
  4671. returnSuccessMsg("发货操作成功!");
  4672. commonHelper.UpdateRelationOrder(entity.ctid);
  4673. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4674. CeErpSukuraData.createInfo(entity.ctid, 4);
  4675. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4676. {
  4677. commonHelper.sendCytExpress(exinfo);
  4678. }
  4679. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4681. }
  4682. else
  4683. {
  4684. string errmsg = commonHelper.KeepChinese(apires);
  4685. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4686. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4687. }
  4688. return;
  4689. }
  4690. returnErrorMsg("找不到订单记录");
  4691. }
  4692. }
  4693. public void set_erp_multidelivery()
  4694. {
  4695. string eids = GetPostString("tids");
  4696. string[] eidList = eids.Split(',');
  4697. if (eidList.Length <= 0)
  4698. {
  4699. returnErrorMsg("发货不能为空");
  4700. return;
  4701. }
  4702. foreach (string ctid in eidList)
  4703. {
  4704. if (ctid.Length <= 0) continue;
  4705. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4706. if (expInfo != null)
  4707. {
  4708. StringBuilder sql = new StringBuilder();
  4709. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4710. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4711. if (dt.Rows.Count > 0)
  4712. {
  4713. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4714. {
  4715. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4716. expInfo.state = "异常";
  4717. expInfo.isMultiDelivery = 1;
  4718. expInfo.Update();
  4719. continue;
  4720. }
  4721. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4722. {
  4723. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4724. expInfo.state = "异常";
  4725. expInfo.Update();
  4726. continue;
  4727. }
  4728. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4729. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4730. bool isInitOrderDeliv = false;
  4731. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4732. {
  4733. isInitOrderDeliv = true;
  4734. expInfo.isMultiDelivery = 1;
  4735. }
  4736. if (ctid.IndexOf("N") != -1)
  4737. {
  4738. StringBuilder sqlbucha = new StringBuilder();
  4739. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4740. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4741. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4742. commonHelper.UpdateRelationOrder(ctid);
  4743. expInfo.delivery_memo = "发货成功";
  4744. expInfo.state = "发货成功";
  4745. expInfo.isMultiDelivery = 1;
  4746. expInfo.Update();
  4747. }
  4748. else
  4749. {
  4750. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4751. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4752. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4753. {
  4754. expInfo.delivery_memo = "发货成功";
  4755. expInfo.state = "发货成功";
  4756. expInfo.isMultiDelivery = 1;
  4757. expInfo.Update();
  4758. commonHelper.UpdateRelationOrder(ctid);
  4759. CeErpSukuraData.createInfo(ctid, 4);
  4760. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4761. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4762. }
  4763. else
  4764. {
  4765. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4766. expInfo.state = "异常";
  4767. expInfo.Update();
  4768. }
  4769. }
  4770. }
  4771. }
  4772. }
  4773. returnSuccessMsg("操作完成");
  4774. }
  4775. public void reset_erp_memoopt()
  4776. {
  4777. if (UrlPostParmsCheck("ctid"))
  4778. {
  4779. string eid = GetPostString("ctid");
  4780. CeErpTradeCell entity = null;
  4781. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4782. if (entity != null)
  4783. {
  4784. string stropt = "";
  4785. if (entity.MemoOpt == 1)
  4786. {
  4787. stropt = "“改稿”";
  4788. }
  4789. else if (entity.MemoOpt == 2)
  4790. {
  4791. stropt = "“定稿”";
  4792. }
  4793. else if (entity.MemoOpt == 3)
  4794. {
  4795. stropt = "“完成查货”";
  4796. CeErpSukuraData.createInfo(entity.ctid, 6);
  4797. }
  4798. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4799. entity.UpdateTime = DateTime.Now;
  4800. entity.MemoOpt = 0;
  4801. entity.Update();
  4802. returnSuccessMsg("操作成功!");
  4803. return;
  4804. }
  4805. returnErrorMsg("找不到记录");
  4806. }
  4807. }
  4808. public void get_erp_deliveryunusual()
  4809. {
  4810. DataStruct dStruct = GetPostStruct();
  4811. List<string> lw = new List<string>();
  4812. string tid = GetPostString("ctid");
  4813. if (tid.Length > 0)
  4814. {
  4815. string select_tid = getTidByCtid(tid);
  4816. lw.Add(string.Format("tid='{0}'", select_tid));
  4817. }
  4818. string shopname = GetPostString("shopname");
  4819. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4820. string buyernick = GetPostString("buyer_nick");
  4821. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4822. string customer = GetPostString("customer");
  4823. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4824. string design = GetPostString("design");
  4825. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4826. string sellermemo = GetPostString("seller_memo");
  4827. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4828. string supplier = GetPostString("supplier");
  4829. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4830. string date1 = GetPostString("date1");
  4831. string date2 = GetPostString("date2");
  4832. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4833. if (dw.Length > 0) lw.Add(dw);
  4834. string placedate1 = GetPostString("placedate1");
  4835. string placedate2 = GetPostString("placedate2");
  4836. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4837. if (dw_place.Length > 0) lw.Add(dw_place);
  4838. string price1 = GetPostString("price1");
  4839. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4840. string price2 = GetPostString("price2");
  4841. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4842. string unusualCon = GetPostString("unusualcon");
  4843. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4844. string posTag = CurrentUser.UserPost.Post.Code;
  4845. if (posTag == "Supplier")
  4846. {
  4847. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4848. }
  4849. lw.Add(string.Format("OrderState = 6"));
  4850. lw.Add(string.Format("UnusualTag = 5"));
  4851. lw.Add(string.Format("IsRefund<={0}", 1));
  4852. dStruct.Order = "FinishPlaceTime desc";
  4853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4854. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4855. writeGridDataTableJson(dStruct.TotalCount, dt);
  4856. }
  4857. public void get_erp_deliveryedlist()
  4858. {
  4859. DataStruct dStruct = GetPostStruct();
  4860. List<string> lw = new List<string>();
  4861. string tid = GetPostString("ctid");
  4862. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4863. string shopname = GetPostString("shopname");
  4864. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4865. string buyernick = GetPostString("buyer_nick");
  4866. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4867. string customer = GetPostString("customer");
  4868. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4869. string design = GetPostString("design");
  4870. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4871. string sellermemo = GetPostString("seller_memo");
  4872. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4873. string logistics = GetPostString("logistics");
  4874. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4875. string date1 = GetPostString("date1");
  4876. string date2 = GetPostString("date2");
  4877. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4878. //if (dw.Length > 0) lw.Add(dw);
  4879. string placedate1 = GetPostString("placedate1");
  4880. string placedate2 = GetPostString("placedate2");
  4881. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4882. if (fdw.Length > 0) lw.Add(fdw);
  4883. string devdate1 = GetPostString("deliverydate1");
  4884. string devdate2 = GetPostString("deliverydate2");
  4885. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4886. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4887. string price1 = GetPostString("price1");
  4888. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4889. string price2 = GetPostString("price2");
  4890. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4891. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4892. {
  4893. if (tid.Length > 0)
  4894. {
  4895. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4896. if (tid.Length > 5)
  4897. {
  4898. List<string> tids = getTidByCtidLike(tid);
  4899. if (tids.Count > 0 && tids.Count < 10)
  4900. {
  4901. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4902. }
  4903. }
  4904. lw.Add(tid_sql);
  4905. }
  4906. if (buyernick.Length > 0)
  4907. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4908. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4909. if (dw.Length > 0) lw.Add(dw);
  4910. }
  4911. else
  4912. {
  4913. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4914. }
  4915. string posTag = CurrentUser.UserPost.Post.Code;
  4916. if (posTag == "Supplier")
  4917. {
  4918. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4919. }
  4920. else
  4921. {
  4922. string supplier = GetPostString("supplier");
  4923. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4924. }
  4925. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4926. lw.Add(string.Format("type != 'PDD' "));
  4927. lw.Add(string.Format("IsRefund!={0}", 2));
  4928. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4929. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4930. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4931. /*if (tid.Length > 0)
  4932. {
  4933. List<string> tids = new List<string>();
  4934. if (dt != null && dt.Rows.Count > 0)
  4935. {
  4936. foreach (DataRow item in dt.Rows)
  4937. {
  4938. tids.Add("'" + item["tid"] + "'");
  4939. }
  4940. }
  4941. if (tids.Count > 0)
  4942. {
  4943. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4944. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4946. dt = WebCache.GetData("view_erptradecell", dStruct);
  4947. }
  4948. }*/
  4949. if (dt != null)
  4950. {
  4951. foreach (DataRow dr in dt.Rows)
  4952. {
  4953. 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();
  4954. }
  4955. }
  4956. writeGridDataTableJson(dStruct.TotalCount, dt);
  4957. }
  4958. public void get_erp_pdddeliveryed()
  4959. {
  4960. DataStruct dStruct = GetPostStruct();
  4961. List<string> lw = new List<string>();
  4962. string tid = GetPostString("ctid");
  4963. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4964. string shopname = GetPostString("shopname");
  4965. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4966. string buyernick = GetPostString("buyer_nick");
  4967. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4968. string customer = GetPostString("customer");
  4969. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4970. string design = GetPostString("design");
  4971. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4972. string sellermemo = GetPostString("seller_memo");
  4973. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4974. string logistics = GetPostString("logistics");
  4975. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4976. string date1 = GetPostString("date1");
  4977. string date2 = GetPostString("date2");
  4978. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4979. //if (dw.Length > 0) lw.Add(dw);
  4980. string placedate1 = GetPostString("placedate1");
  4981. string placedate2 = GetPostString("placedate2");
  4982. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4983. if (fdw.Length > 0) lw.Add(fdw);
  4984. string devdate1 = GetPostString("deliverydate1");
  4985. string devdate2 = GetPostString("deliverydate2");
  4986. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4987. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4988. string price1 = GetPostString("price1");
  4989. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4990. string price2 = GetPostString("price2");
  4991. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4992. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4993. {
  4994. if (tid.Length > 0)
  4995. {
  4996. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4997. if (tid.Length > 5)
  4998. {
  4999. List<string> tids = getTidByCtidLike(tid);
  5000. if (tids.Count > 0 && tids.Count < 10)
  5001. {
  5002. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5003. }
  5004. }
  5005. lw.Add(tid_sql);
  5006. }
  5007. if (buyernick.Length > 0)
  5008. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5009. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5010. if (dw.Length > 0) lw.Add(dw);
  5011. }
  5012. else
  5013. {
  5014. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5015. }
  5016. string posTag = CurrentUser.UserPost.Post.Code;
  5017. if (posTag == "Supplier")
  5018. {
  5019. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5020. }
  5021. else
  5022. {
  5023. string supplier = GetPostString("supplier");
  5024. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5025. }
  5026. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5027. lw.Add(string.Format("type = 'PDD' "));
  5028. lw.Add(string.Format("IsRefund!={0}", 2));
  5029. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5030. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5031. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5032. /* if (tid.Length > 0)
  5033. {
  5034. List<string> tids = new List<string>();
  5035. if (dt != null && dt.Rows.Count > 0)
  5036. {
  5037. foreach (DataRow item in dt.Rows)
  5038. {
  5039. tids.Add("'" + item["tid"] + "'");
  5040. }
  5041. }
  5042. if (tids.Count > 0)
  5043. {
  5044. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5045. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5046. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5047. dt = WebCache.GetData("view_erptradecell", dStruct);
  5048. }
  5049. }*/
  5050. foreach (DataRow dr in dt.Rows)
  5051. {
  5052. 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();
  5053. }
  5054. writeGridDataTableJson(dStruct.TotalCount, dt);
  5055. }
  5056. public void get_erp_jddeliveryed()
  5057. {
  5058. DataStruct dStruct = GetPostStruct();
  5059. List<string> lw = new List<string>();
  5060. string tid = GetPostString("ctid");
  5061. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5062. string shopname = GetPostString("shopname");
  5063. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5064. string buyernick = GetPostString("buyer_nick");
  5065. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5066. string customer = GetPostString("customer");
  5067. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5068. string design = GetPostString("design");
  5069. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5070. string sellermemo = GetPostString("seller_memo");
  5071. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5072. string date1 = GetPostString("date1");
  5073. string date2 = GetPostString("date2");
  5074. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5075. //if (dw.Length > 0) lw.Add(dw);
  5076. string placedate1 = GetPostString("placedate1");
  5077. string placedate2 = GetPostString("placedate2");
  5078. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5079. if (fdw.Length > 0) lw.Add(fdw);
  5080. string devdate1 = GetPostString("deliverydate1");
  5081. string devdate2 = GetPostString("deliverydate2");
  5082. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5083. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5084. string price1 = GetPostString("price1");
  5085. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5086. string price2 = GetPostString("price2");
  5087. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5088. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5089. {
  5090. if (tid.Length > 0)
  5091. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5092. if (buyernick.Length > 0)
  5093. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5094. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5095. if (dw.Length > 0) lw.Add(dw);
  5096. }
  5097. else
  5098. {
  5099. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5100. }
  5101. string posTag = CurrentUser.UserPost.Post.Code;
  5102. if (posTag == "Supplier")
  5103. {
  5104. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5105. }
  5106. else
  5107. {
  5108. string supplier = GetPostString("supplier");
  5109. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5110. }
  5111. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5112. lw.Add(string.Format("type = 'JD' "));
  5113. lw.Add(string.Format("IsRefund!={0}", 2));
  5114. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5116. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5117. foreach (DataRow dr in dt.Rows)
  5118. {
  5119. 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();
  5120. }
  5121. writeGridDataTableJson(dStruct.TotalCount, dt);
  5122. }
  5123. public void get_erp_allplacelist()
  5124. {
  5125. DataStruct dStruct = GetPostStruct();
  5126. List<string> lw = new List<string>();
  5127. string tid = GetPostString("ctid");
  5128. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5129. string shopname = GetPostString("shopname");
  5130. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5131. string buyernick = GetPostString("buyer_nick");
  5132. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5133. string customer = GetPostString("customer");
  5134. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5135. string design = GetPostString("design");
  5136. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5137. string sellermemo = GetPostString("seller_memo");
  5138. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5139. string supplier = GetPostString("supplier");
  5140. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5141. string date1 = GetPostString("date1");
  5142. string date2 = GetPostString("date2");
  5143. string pldate1 = GetPostString("placedate1");
  5144. string pldate2 = GetPostString("placedate2");
  5145. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5146. //if (dw.Length > 0) lw.Add(dw);
  5147. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5148. {
  5149. if (tid.Length > 0)
  5150. {
  5151. string select_tid = getTidByCtid(tid);
  5152. lw.Add(string.Format("tid='{0}'", select_tid));
  5153. }
  5154. if (buyernick.Length > 0)
  5155. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5156. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5157. if (dw.Length > 0) lw.Add(dw);
  5158. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5159. if (dw_place.Length > 0) lw.Add(dw_place);
  5160. }
  5161. else
  5162. {
  5163. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5164. {
  5165. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5166. }
  5167. }
  5168. string price1 = GetPostString("price1");
  5169. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5170. string price2 = GetPostString("price2");
  5171. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5172. string posTag = CurrentUser.UserPost.Post.Code;
  5173. if (posTag == "Supplier")
  5174. {
  5175. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5176. }
  5177. lw.Add(string.Format("OrderState >= 6"));
  5178. lw.Add(string.Format("IsSample != 2 "));
  5179. //lw.Add(string.Format("isDianziOrder = 0 "));
  5180. lw.Add(string.Format("SupplierId > 0 "));
  5181. //lw.Add(string.Format("IsRefund<={0}", 1));
  5182. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5183. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5184. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5185. foreach (DataRow dr in dt.Rows)
  5186. {
  5187. 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();
  5188. }
  5189. writeGridDataTableJson(dStruct.TotalCount, dt);
  5190. }
  5191. public void get_erp_financeallplacelist()
  5192. {
  5193. DataStruct dStruct = GetPostStruct();
  5194. List<string> lw = new List<string>();
  5195. string tid = GetPostString("ctid");
  5196. string shopname = GetPostString("shopname");
  5197. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5198. string buyernick = GetPostString("buyer_nick");
  5199. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5200. string customer = GetPostString("customer");
  5201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5202. string design = GetPostString("design");
  5203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5204. string sellermemo = GetPostString("seller_memo");
  5205. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5206. string supplier = GetPostString("supplier");
  5207. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5208. string date1 = GetPostString("date1");
  5209. string date2 = GetPostString("date2");
  5210. string pldate1 = GetPostString("placedate1");
  5211. string pldate2 = GetPostString("placedate2");
  5212. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5213. {
  5214. if (tid.Length > 0)
  5215. {
  5216. string select_tid = getTidByCtid(tid);
  5217. lw.Add(string.Format("tid='{0}'", select_tid));
  5218. }
  5219. if (buyernick.Length > 0)
  5220. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5221. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5222. if (dw.Length > 0) lw.Add(dw);
  5223. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5224. if (dw_place.Length > 0) lw.Add(dw_place);
  5225. }
  5226. else
  5227. {
  5228. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5229. {
  5230. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5231. }
  5232. }
  5233. string price1 = GetPostString("price1");
  5234. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5235. string price2 = GetPostString("price2");
  5236. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5237. string posTag = CurrentUser.UserPost.Post.Code;
  5238. if (posTag == "Supplier")
  5239. {
  5240. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5241. }
  5242. //lw.Add(string.Format("OrderState >= 6"));
  5243. lw.Add(string.Format("IsSample != 2 "));
  5244. lw.Add(string.Format("isDianziOrder = 0 "));
  5245. //lw.Add(string.Format("IsRefund<={0}", 1));
  5246. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5247. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5248. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5249. foreach (DataRow dr in dt.Rows)
  5250. {
  5251. 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();
  5252. }
  5253. writeGridDataTableJson(dStruct.TotalCount, dt);
  5254. }
  5255. public void get_erp_expresslist()
  5256. {
  5257. int listtype = GetInt("ltype");
  5258. DataStruct dStruct = GetPostStruct();
  5259. List<string> lw = new List<string>();
  5260. string tid = GetPostString("tid");
  5261. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5262. string outsid = GetPostString("out_sid");
  5263. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5264. string importer = GetPostString("ImportUserName");
  5265. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5266. string file = GetPostString("import_file");
  5267. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5268. string printman = GetPostString("printman");
  5269. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5270. string date1 = GetPostString("date1");
  5271. string date2 = GetPostString("date2");
  5272. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5273. if (dw.Length > 0) lw.Add(dw);
  5274. string fdate1 = GetPostString("finishdate1");
  5275. string fdate2 = GetPostString("finishdate2");
  5276. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5277. if (fdw.Length > 0) lw.Add(fdw);
  5278. string supplierId = GetPostString("supplierId");
  5279. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5280. if (listtype == 1)
  5281. {
  5282. lw.Add(string.Format("importUserId !=0"));
  5283. }
  5284. string posTag = CurrentUser.UserPost.Post.Code;
  5285. if (posTag == "Supplier")
  5286. {
  5287. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5288. }
  5289. if (dStruct.PageSize != 100000)
  5290. {
  5291. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5292. }
  5293. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5294. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5295. writeGridDataTableJson(dStruct.TotalCount, dt);
  5296. }
  5297. public void set_erp_buchaorderdelivery()
  5298. {
  5299. if (UrlPostParmsCheck("ctid"))
  5300. {
  5301. string eid = GetPostString("ctid");
  5302. CeErpTradeCell entity = null;
  5303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5304. if (entity != null)
  5305. {
  5306. if (entity.IsSample != 2)
  5307. {
  5308. returnErrorMsg("补差价单才能标记为已发货");
  5309. return;
  5310. }
  5311. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5312. entity.OrderState = 7;
  5313. entity.Update();
  5314. returnSuccessMsg("操作成功!");
  5315. return;
  5316. }
  5317. returnErrorMsg("找不到记录");
  5318. }
  5319. }
  5320. public void get_stdtemplates()
  5321. {
  5322. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5323. //string res = taobaoHelper.test();
  5324. string res = apiHelper.API_PrintTemplate();
  5325. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5326. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5327. {
  5328. int sidx = res.IndexOf("error_code");
  5329. int eidx = res.IndexOf("success");
  5330. string msg = res.Substring(sidx, eidx - sidx);
  5331. returnErrorMsg(msg);
  5332. return;
  5333. }
  5334. if (res.Length <= 0)
  5335. {
  5336. returnErrorMsg("模板数据为空!");
  5337. return;
  5338. }
  5339. ReturnSuccess(res);
  5340. }
  5341. public void cancel_print_order()
  5342. {
  5343. if (UrlPostParmsCheck("ctid"))
  5344. {
  5345. string ctid = GetPostString("ctid");
  5346. CeErpTradeCell entity = null;
  5347. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5348. if (entity != null)
  5349. {
  5350. string res = "";
  5351. string code = entity.LastBillWaybillCode;
  5352. if (code == "")
  5353. {
  5354. code = entity.OutSid;
  5355. }
  5356. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5357. XLog.SaveLog(0, "取消面单" + res);
  5358. }
  5359. }
  5360. }
  5361. public void set_erp_printwaybill()
  5362. {
  5363. if (UrlPostParmsCheck("ctid"))
  5364. {
  5365. string ctid = GetPostString("ctid");
  5366. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5367. string cpName = GetPostString("cpname");
  5368. string isTogether = GetPostString("together");
  5369. string printType = GetPostString("printType");
  5370. //var res_obj = new
  5371. //{
  5372. // restype = 1,
  5373. // 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\"}"
  5374. //};
  5375. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5376. //ReturnSuccess(ro_json);
  5377. //return;
  5378. bool isUseLastWayBillCode = false;
  5379. CeErpTradeCell entity = null;
  5380. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5381. if (entity != null)
  5382. {
  5383. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5384. {
  5385. isUseLastWayBillCode = true;
  5386. }
  5387. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5388. {
  5389. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5390. return;
  5391. }
  5392. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5393. {
  5394. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5395. return;
  5396. }
  5397. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5398. {
  5399. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5400. return;
  5401. }
  5402. }
  5403. string res = "";
  5404. Api_waybill_code_response_Obj fullObj = null;
  5405. string pData_str = "";
  5406. string curUseWayBillCode = "";
  5407. if (isUseLastWayBillCode == false)
  5408. {
  5409. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5410. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5411. if (res.IndexOf("failure") != -1)
  5412. {
  5413. //int idx = res.IndexOf("sub_message");
  5414. //int idx2 = res.IndexOf("flag");
  5415. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5416. string errMsgNeed = commonHelper.KeepChinese(res);
  5417. var res_objd = new
  5418. {
  5419. restype = 0,
  5420. data = "获取面单失败" + errMsgNeed
  5421. };
  5422. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5423. returnSuccess(ro_jsond);
  5424. if (res.IndexOf("停发") != -1)
  5425. {
  5426. entity.UnusualCon = "物流停发";
  5427. entity.Update();
  5428. }
  5429. //returnErrorMsg("获取面单失败,"+emsg);
  5430. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5431. return;
  5432. }
  5433. else if (res.IndexOf("errorMsg") != -1)
  5434. {
  5435. //int idx = res.IndexOf("errorMsg");
  5436. //int idx2 = res.IndexOf("}]}");
  5437. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5438. string errMsgNeed = commonHelper.KeepChinese(res);
  5439. var res_objf = new
  5440. {
  5441. restype = 0,
  5442. data = "获取面单失败2" + errMsgNeed
  5443. };
  5444. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5445. if (res.IndexOf("停发") != -1)
  5446. {
  5447. entity.UnusualCon = "物流停发";
  5448. entity.Update();
  5449. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5450. if (trade != null)
  5451. {
  5452. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5453. }
  5454. }
  5455. returnSuccess(ro_jsonf);
  5456. //returnErrorMsg("获取面单失败," + emsg);
  5457. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5458. return;
  5459. }
  5460. try
  5461. {
  5462. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5463. //res = res.Replace(" ", "");
  5464. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5465. }
  5466. catch (Exception ex)
  5467. {
  5468. XLog.SaveLog(0, "生成fullObj" + res);
  5469. var res_objf = new
  5470. {
  5471. restype = 0,
  5472. data = "生成fullObj发生错误" + ex.Message
  5473. };
  5474. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5475. returnSuccess(ro_jsonf);
  5476. return;
  5477. }
  5478. if (fullObj.response.data.content.Count > 0)
  5479. {
  5480. ContentItem codeObj = fullObj.response.data.content[0];
  5481. if (cpCode.IndexOf("SFFQ-") != -1)
  5482. {
  5483. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5484. }
  5485. else
  5486. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5487. curUseWayBillCode = codeObj.waybillCode;
  5488. }
  5489. else
  5490. {
  5491. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5492. var res_objf = new
  5493. {
  5494. restype = 0,
  5495. data = "生成fullObj找不到快递单号waybillCode"
  5496. };
  5497. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5498. returnSuccess(ro_jsonf);
  5499. return;
  5500. }
  5501. }
  5502. else
  5503. {
  5504. //使用上次打印的快递单号
  5505. if (cpCode == "SFFQ-LY")
  5506. {
  5507. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5508. }
  5509. else
  5510. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5511. curUseWayBillCode = entity.LastBillWaybillCode;
  5512. }
  5513. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5514. {
  5515. var res_obje = new
  5516. {
  5517. restype = 0,
  5518. data = "获取加密打印数据失败"
  5519. };
  5520. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5521. returnSuccess(ro_jsone);
  5522. entity.LastBillCpCode = cpCode;
  5523. entity.LastBillWaybillCode = curUseWayBillCode;
  5524. entity.Update();
  5525. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5526. //returnErrorMsg("获取加密打印数据失败");
  5527. return;
  5528. }
  5529. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5530. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5531. string btnType = "";
  5532. string errorMsg = "";
  5533. if (entity != null)
  5534. {
  5535. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5536. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5537. //cpcode是 YTO-CAINIAO
  5538. //string comCode = cpCode.Split('-')[0].ToString();
  5539. string apires = "";
  5540. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5541. //isTogether=2是新的合包弹窗
  5542. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5543. {
  5544. if (ctid.IndexOf("N") != -1)
  5545. {
  5546. apires = "发货成功";
  5547. }
  5548. else
  5549. {
  5550. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5551. }
  5552. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5553. //打单后发货
  5554. StringBuilder sql = new StringBuilder();
  5555. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5556. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5557. {
  5558. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5559. }
  5560. else
  5561. {
  5562. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5563. }
  5564. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5565. foreach (DataRow row in dt.Rows)
  5566. {
  5567. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5568. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5569. {
  5570. try
  5571. {
  5572. btnType = "待发货";
  5573. entity.OutSid = curUseWayBillCode;
  5574. entity.OrderState = 7;
  5575. entity.IsUrgency = false;
  5576. entity.LastBillCpCode = "";
  5577. entity.LastBillWaybillCode = "";
  5578. entity.FinishDeliveryTime = DateTime.Now;
  5579. entity.IsReturn = 0;
  5580. entity.MemoOpt = 0;
  5581. entity.UpdateTime = DateTime.Now;
  5582. entity.Update();
  5583. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5584. //还要插入快递信息到 快递信息表
  5585. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5586. exinfo.tid = entity.ctid;
  5587. exinfo.out_sid = curUseWayBillCode;
  5588. exinfo.company_code = cpCode;
  5589. exinfo.company_name = cpName;
  5590. exinfo.supplierUserName = supplierName;
  5591. exinfo.deliveryType = "发货成功";
  5592. exinfo.print_time = DateTime.Now;
  5593. exinfo.printUser = CurrentUser.UserName;
  5594. exinfo.postData = pData_str;
  5595. exinfo.Create();
  5596. commonHelper.UpdateRelationOrder(entity.ctid);
  5597. CeErpSukuraData.createInfo(ctid, 4);
  5598. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5599. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5600. {
  5601. commonHelper.sendCytExpress(exinfo);
  5602. }
  5603. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5604. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5605. }
  5606. catch (Exception ex)
  5607. {
  5608. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5609. }
  5610. }
  5611. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5612. {
  5613. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5614. if (entity.OrderState == 6)
  5615. {
  5616. entity.OrderState = 7;
  5617. }
  5618. entity.UpdateTime = DateTime.Now;
  5619. entity.FinishDeliveryTime = DateTime.Now;
  5620. btnType = "已发货";
  5621. entity.Update();
  5622. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5623. exinfo.tid = entity.ctid;
  5624. exinfo.out_sid = curUseWayBillCode;
  5625. exinfo.company_code = cpCode;
  5626. exinfo.company_name = cpName;
  5627. exinfo.supplierUserName = supplierName;
  5628. exinfo.deliveryType = "发货成功";
  5629. exinfo.print_time = DateTime.Now;
  5630. exinfo.printUser = CurrentUser.UserName;
  5631. exinfo.postData = pData_str;
  5632. exinfo.Create();
  5633. commonHelper.UpdateRelationOrder(entity.ctid);
  5634. CeErpSukuraData.createInfo(entity.ctid, 4);
  5635. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5636. {
  5637. commonHelper.sendCytExpress(exinfo);
  5638. }
  5639. //不处理
  5640. }
  5641. else
  5642. {
  5643. entity.UpdateTime = DateTime.Now;
  5644. entity.LastBillCpCode = cpCode;
  5645. entity.LastBillWaybillCode = curUseWayBillCode;
  5646. entity.Update();
  5647. string errmsg = commonHelper.KeepChinese(apires);
  5648. var res_objz = new
  5649. {
  5650. restype = 0,
  5651. data = "打单后发货失败"
  5652. };
  5653. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5654. returnSuccess(ro_jsonz);
  5655. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5656. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5657. return;
  5658. }
  5659. }
  5660. }
  5661. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5662. {
  5663. string ctids = GetPostString("ctids");
  5664. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5665. List<string> list = new List<string>();
  5666. List<string> send_list = new List<string>();
  5667. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5668. CeErpTrade ceErpTrade = new CeErpTrade();
  5669. //可合包的合并一起发货
  5670. if (dt == null && string.IsNullOrEmpty(ctids))
  5671. {
  5672. var res_objz = new
  5673. {
  5674. restype = 0,
  5675. data = "打单后发货失败"
  5676. };
  5677. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5678. returnSuccess(ro_jsonz);
  5679. return;
  5680. }
  5681. if (!string.IsNullOrEmpty(ctids))
  5682. {
  5683. StringBuilder sql = new StringBuilder();
  5684. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5685. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5686. }
  5687. foreach (DataRow row in dt.Rows)
  5688. {
  5689. list.Add("'" + row["ctid"] + "'");
  5690. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5691. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5692. if (ctid.IndexOf("N") != -1)
  5693. {
  5694. apires = "发货成功";
  5695. }
  5696. else
  5697. {
  5698. if (!send_list.Contains(ceErpTrade.tid))
  5699. {
  5700. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5701. }
  5702. else
  5703. {
  5704. apires = "发货成功";
  5705. }
  5706. }
  5707. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5708. {
  5709. send_list.Add(ceErpTrade.tid);
  5710. try
  5711. {
  5712. btnType = "待发货";
  5713. ceErpTradeCell.OutSid = curUseWayBillCode;
  5714. ceErpTradeCell.OrderState = 7;
  5715. ceErpTradeCell.IsUrgency = false;
  5716. ceErpTradeCell.LastBillCpCode = "";
  5717. ceErpTradeCell.LastBillWaybillCode = "";
  5718. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5719. ceErpTradeCell.IsReturn = 0;
  5720. ceErpTradeCell.MemoOpt = 0;
  5721. ceErpTradeCell.UpdateTime = DateTime.Now;
  5722. ceErpTradeCell.Update();
  5723. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5724. //还要插入快递信息到 快递信息表
  5725. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5726. exinfo.tid = ceErpTradeCell.ctid;
  5727. exinfo.out_sid = curUseWayBillCode;
  5728. exinfo.company_code = cpCode;
  5729. exinfo.company_name = cpName;
  5730. exinfo.supplierUserName = supplierName;
  5731. exinfo.deliveryType = "发货成功";
  5732. exinfo.print_time = DateTime.Now;
  5733. exinfo.printUser = CurrentUser.UserName;
  5734. exinfo.postData = pData_str;
  5735. exinfo.Create();
  5736. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5737. CeErpSukuraData.createInfo(ctid, 4);
  5738. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5739. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5740. {
  5741. commonHelper.sendCytExpress(exinfo);
  5742. }
  5743. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5744. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5745. }
  5746. catch (Exception ex)
  5747. {
  5748. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5749. }
  5750. }
  5751. else
  5752. {
  5753. ceErpTradeCell.UpdateTime = DateTime.Now;
  5754. ceErpTradeCell.LastBillCpCode = cpCode;
  5755. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5756. ceErpTradeCell.Update();
  5757. string errmsg = commonHelper.KeepChinese(apires);
  5758. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5759. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5760. }
  5761. }
  5762. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5763. }
  5764. }
  5765. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5766. var res_obj = new
  5767. {
  5768. restype = 1,
  5769. data = pData_str,
  5770. errorMsg
  5771. };
  5772. string ro_json = JsonConvert.SerializeObject(res_obj);
  5773. ReturnSuccess(ro_json);
  5774. return;
  5775. }
  5776. }
  5777. private string GetUTF8String(byte[] vs)
  5778. {
  5779. throw new NotImplementedException();
  5780. }
  5781. public void set_erp_printwaybill_cn()
  5782. {
  5783. if (UrlPostParmsCheck("ctid"))
  5784. {
  5785. string ctid = GetPostString("ctid");
  5786. string cpCode = GetPostString("cpcode");
  5787. string cpName = GetPostString("cpname");
  5788. string tempUrl = GetPostString("tempurl");
  5789. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5790. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5791. //string res = taobaoHelper.test();
  5792. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5793. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5794. {
  5795. int sidx = res.IndexOf("errorMsg");
  5796. int eidx = res.IndexOf("}");
  5797. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5798. var res_objzxx = new
  5799. {
  5800. restype = 0,
  5801. data = msg
  5802. };
  5803. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5804. returnSuccess(ro_jsonzxx);
  5805. //returnErrorMsg(msg);
  5806. return;
  5807. }
  5808. int idx = res.IndexOf("waybillCode");
  5809. int idx2 = res.IndexOf("printData");
  5810. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5811. string eid = GetPostString("ctid");
  5812. CeErpTradeCell entity = null;
  5813. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5814. if (entity != null)
  5815. {
  5816. string osid = entity.OutSid;
  5817. entity.OutSid = osid + "," + outsid;
  5818. entity.FinishDeliveryTime = DateTime.Now;
  5819. entity.OrderState = 7;
  5820. entity.UpdateTime = DateTime.Now;
  5821. entity.IsReturn = 0;
  5822. entity.Update();
  5823. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5824. exinfo.tid = entity.ctid;
  5825. exinfo.out_sid = outsid;
  5826. exinfo.company_code = cpCode;
  5827. exinfo.company_name = cpName;
  5828. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5829. exinfo.deliveryType = "发货成功";
  5830. exinfo.print_time = DateTime.Now;
  5831. exinfo.printUser = CurrentUser.UserName;
  5832. exinfo.Create();
  5833. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5834. {
  5835. commonHelper.sendCytExpress(exinfo);
  5836. }
  5837. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5838. }
  5839. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5840. var res_objz = new
  5841. {
  5842. restype = 1,
  5843. data = res
  5844. };
  5845. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5846. returnSuccess(ro_jsonz);
  5847. //ReturnSuccess(res);
  5848. }
  5849. }
  5850. ////打单,打印面单 获取面单号
  5851. //public void set_erp_printwaybill()
  5852. //{
  5853. // if (UrlPostParmsCheck("ctid"))
  5854. // {
  5855. // string ctid = GetPostString("ctid");
  5856. // string cpCode = GetPostString("cpcode");
  5857. // string tempUrl = GetPostString("tempurl");
  5858. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5859. // //string res = taobaoHelper.test();
  5860. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5861. // if (res.IndexOf("error_response") != -1)
  5862. // {
  5863. // int sidx = res.IndexOf("sub_msg");
  5864. // int eidx = res.IndexOf("request_id");
  5865. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5866. // returnErrorMsg(msg);
  5867. // return;
  5868. // }
  5869. // int idx = res.IndexOf("waybill_code");
  5870. // int idx2 = res.IndexOf("}]}");
  5871. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5872. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5873. // ReturnSuccess(res);
  5874. // }
  5875. //}
  5876. public void cancel_erp_aftersale()
  5877. {
  5878. if (UrlPostParmsCheck("ctid"))
  5879. {
  5880. string eid = GetPostString("ctid");
  5881. CeErpTradeCell entity = null;
  5882. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5883. if (entity != null)
  5884. {
  5885. //有过处理的售后,取消也不能删除 售 字,保留
  5886. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5887. {
  5888. entity.AfterSaleState = 4;
  5889. }
  5890. else
  5891. entity.AfterSaleState = 0;
  5892. entity.UpdateTime = DateTime.Now;
  5893. entity.Update();
  5894. returnSuccessMsg("操作成功!");
  5895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5896. return;
  5897. }
  5898. returnErrorMsg("找不到订单记录");
  5899. }
  5900. }
  5901. public void get_erp_aftersalelist()
  5902. {
  5903. DataStruct dStruct = GetPostStruct();
  5904. List<string> lw = new List<string>();
  5905. int st = GetInt("st");
  5906. string tid = GetPostString("ctid");
  5907. if (st == 3)
  5908. {
  5909. if (tid.Length > 0)
  5910. {
  5911. string select_tid = getTidByCtid(tid);
  5912. lw.Add(string.Format("tid='{0}'", select_tid));
  5913. }
  5914. }
  5915. else
  5916. {
  5917. if (tid.Length > 0)
  5918. {
  5919. string select_tid = getTidByCtid(tid);
  5920. lw.Add(string.Format("tid='{0}'", select_tid));
  5921. }
  5922. }
  5923. string shopname = GetPostString("shopname");
  5924. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5925. string buyernick = GetPostString("buyer_nick");
  5926. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5927. string sellermemo = GetPostString("seller_memo");
  5928. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5929. string orderState = GetPostString("orderState");
  5930. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5931. string afterState = GetPostString("afterstate");
  5932. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5933. string date1 = GetPostString("date1");
  5934. string date2 = GetPostString("date2");
  5935. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5936. if (dw.Length > 0) lw.Add(dw);
  5937. string price1 = GetPostString("price1");
  5938. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5939. string price2 = GetPostString("price2");
  5940. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5941. //lw.Add(string.Format("IsRefund!={0}", 1));
  5942. string reason = GetPostString("reason");
  5943. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5944. string method = GetPostString("method");
  5945. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5946. string handler = GetPostString("handler");
  5947. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5948. string handledate1 = GetPostString("handledate1");
  5949. string handledate2 = GetPostString("handledate2");
  5950. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5951. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5952. string finish1 = GetPostString("finishdate1");
  5953. string finish2 = GetPostString("finishdate2");
  5954. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5955. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5956. string afterdate1 = GetPostString("afterdate1");
  5957. string afterdate2 = GetPostString("afterdate2");
  5958. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5959. if (afterDate.Length > 0) lw.Add(afterDate);
  5960. string supplier = GetPostString("supplier");
  5961. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5962. string responsible = GetPostString("responsibleman");
  5963. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5964. string customer = GetPostString("customer");
  5965. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5966. string design = GetPostString("design");
  5967. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5968. string afterMemoType = GetPostString("aftermemotype");
  5969. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5970. string posCode = CurrentUser.UserPost.Post.Code;
  5971. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5972. //{
  5973. // string vstate = GetPostString("vstate");
  5974. // if (vstate.Length > 0)
  5975. // {
  5976. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5977. // }
  5978. // if (posCode == "Supplier")
  5979. // {
  5980. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5981. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5982. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5983. // }
  5984. // else
  5985. // {
  5986. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5987. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5988. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5989. // {
  5990. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5991. // }
  5992. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5993. // {
  5994. // int orgid = CurrentUser.UserPost.OrgID;
  5995. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5996. // }
  5997. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5998. // {
  5999. // string shopid = CurrentUser.User.pemShop;
  6000. // lw.Add(string.Format("shopId in ({0})", shopid));
  6001. // }
  6002. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6003. // //{
  6004. // // int org_id = CurrentUser.UserPost.OrgID;
  6005. // // lw.Add(string.Format("OrgID={0}", org_id));
  6006. // //}
  6007. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6008. // }
  6009. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6010. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6011. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6012. //}
  6013. if (st == 5)
  6014. {
  6015. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6016. {
  6017. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6018. {
  6019. string shopid = CurrentUser.User.pemShop;
  6020. lw.Add(string.Format("shopId in ({0})", shopid));
  6021. }
  6022. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6023. {
  6024. int mrOrgid = CurrentUser.UserPost.OrgID;
  6025. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6026. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6027. }
  6028. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6029. //{
  6030. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6031. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6032. //}
  6033. else
  6034. {
  6035. string userIdStr = "";
  6036. if (posCode == "CustomerService")
  6037. {
  6038. userIdStr = CurrentUser.UserID + "_k";
  6039. }
  6040. else if (posCode == "Designer" || posCode == "wxDesigner")
  6041. {
  6042. userIdStr = CurrentUser.UserID + "_s";
  6043. }
  6044. else if (posCode == "Place")
  6045. {
  6046. userIdStr = CurrentUser.UserID + "_x";
  6047. }
  6048. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6049. }
  6050. }
  6051. string placedate1 = GetPostString("placedate1");
  6052. string placedate2 = GetPostString("placedate2");
  6053. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6054. if (dwplace.Length > 0) lw.Add(dwplace);
  6055. string supState = GetPostString("supState");
  6056. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6057. string searchType = GetPostString("searchType");
  6058. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6059. {
  6060. lw.Add(string.Format("BackNum>1"));
  6061. }
  6062. lw.Add(string.Format("AfterSaleState>0"));
  6063. if (ex_psize > 0)
  6064. {
  6065. if (CurrentUser.UserPost.Post.Code == "Finance")
  6066. dStruct.Order = "pay_time desc";
  6067. else
  6068. dStruct.Order = "HandleTime desc";
  6069. }
  6070. else
  6071. dStruct.Order = "HandleTime desc";
  6072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6073. DataTable dt = WebCache.GetData("view_test", dStruct);
  6074. writeGridDataTableJson(dStruct.TotalCount, dt);
  6075. }
  6076. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6077. //{
  6078. // lw.Add(string.Format("AfterSaleState=4"));
  6079. // string code = CurrentUser.UserPost.Post.Code;
  6080. // if (code == "CustomerService")
  6081. // {
  6082. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6083. // }
  6084. // else if (code == "Designer" || code == "DesignerMr")
  6085. // {
  6086. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6087. // }
  6088. // else if (code == "Place" || code == "PlaceMr")
  6089. // {
  6090. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6091. // }
  6092. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6093. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6094. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6095. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6096. //}
  6097. //else //处理中的售后,待处理和处理中合并
  6098. //{
  6099. // if (afterState.Length <= 0)
  6100. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6101. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6102. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6103. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6104. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6105. //}
  6106. }
  6107. public void get_erp_disagreeftersalelist()
  6108. {
  6109. DataStruct dStruct = GetPostStruct();
  6110. List<string> lw = new List<string>();
  6111. int st = 2;
  6112. string tid = GetPostString("ctid");
  6113. if (tid.Length > 0)
  6114. {
  6115. string select_tid = getTidByCtid(tid);
  6116. lw.Add(string.Format("tid='{0}'", select_tid));
  6117. }
  6118. string shopname = GetPostString("shopname");
  6119. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6120. string buyernick = GetPostString("buyer_nick");
  6121. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6122. string sellermemo = GetPostString("seller_memo");
  6123. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6124. string orderState = GetPostString("orderState");
  6125. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6126. string afterState = GetPostString("afterstate");
  6127. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6128. string date1 = GetPostString("date1");
  6129. string date2 = GetPostString("date2");
  6130. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6131. if (dw.Length > 0) lw.Add(dw);
  6132. string price1 = GetPostString("price1");
  6133. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6134. string price2 = GetPostString("price2");
  6135. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6136. //lw.Add(string.Format("IsRefund!={0}", 1));
  6137. string reason = GetPostString("reason");
  6138. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6139. string method = GetPostString("method");
  6140. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6141. string handler = GetPostString("handler");
  6142. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6143. string handledate1 = GetPostString("handledate1");
  6144. string handledate2 = GetPostString("handledate2");
  6145. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6146. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6147. string afterdate1 = GetPostString("afterdate1");
  6148. string afterdate2 = GetPostString("afterdate2");
  6149. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6150. if (afterDate.Length > 0) lw.Add(afterDate);
  6151. string backdate1 = GetPostString("backdate1");
  6152. string backdate2 = GetPostString("backdate2");
  6153. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6154. if (backDate.Length > 0) lw.Add(backDate);
  6155. string supplier = GetPostString("supplier");
  6156. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6157. string responsible = GetPostString("responsibleman");
  6158. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6159. string customer = GetPostString("customer");
  6160. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6161. string design = GetPostString("design");
  6162. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6163. string afterSaleMemo = GetPostString("afterSaleMemo");
  6164. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6165. string afterMemoType = GetPostString("aftermemotype");
  6166. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6167. string aftersakereason = GetPostString("aftersakereason");
  6168. if (aftersakereason.Length > 0)
  6169. {
  6170. if (aftersakereason == "1")
  6171. {
  6172. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6173. }
  6174. if (aftersakereason == "2")
  6175. {
  6176. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6177. }
  6178. }
  6179. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6180. string poscode = CurrentUser.UserPost.Post.Code;
  6181. if (poscode != "SysAdmin")
  6182. {
  6183. string shopid = CurrentUser.User.pemShop;
  6184. lw.Add(string.Format("shopId in ({0})", shopid));
  6185. }
  6186. string searchType = GetPostString("searchType");
  6187. if (searchType == "wait")
  6188. {
  6189. lw.Add(string.Format("HandleTime is null"));
  6190. }
  6191. if (searchType == "handling")
  6192. {
  6193. lw.Add(string.Format("HandleTime is not null "));
  6194. }
  6195. if (searchType == "back" || searchType == "puBack")
  6196. {
  6197. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6198. }
  6199. if (searchType == "reBack")
  6200. {
  6201. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6202. }
  6203. if (searchType == "moreBack")
  6204. {
  6205. lw.Add(string.Format("backNum > 1"));
  6206. }
  6207. lw.Add(string.Format("(AfterSaleState=5)"));
  6208. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6209. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6210. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6211. writeGridDataTableJson(dStruct.TotalCount, dt);
  6212. }
  6213. public void get_erp_handlingaftersalelist()
  6214. {
  6215. DataStruct dStruct = GetPostStruct();
  6216. List<string> lw = new List<string>();
  6217. int st = 2;
  6218. string tid = GetPostString("ctid");
  6219. if (tid.Length > 0)
  6220. {
  6221. string select_tid = getTidByCtid(tid);
  6222. lw.Add(string.Format("tid='{0}'", select_tid));
  6223. }
  6224. string shopname = GetPostString("shopname");
  6225. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6226. string buyernick = GetPostString("buyer_nick");
  6227. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6228. string sellermemo = GetPostString("seller_memo");
  6229. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6230. string orderState = GetPostString("orderState");
  6231. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6232. string afterState = GetPostString("afterstate");
  6233. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6234. string date1 = GetPostString("date1");
  6235. string date2 = GetPostString("date2");
  6236. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6237. if (dw.Length > 0) lw.Add(dw);
  6238. string price1 = GetPostString("price1");
  6239. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6240. string price2 = GetPostString("price2");
  6241. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6242. //lw.Add(string.Format("IsRefund!={0}", 1));
  6243. string reason = GetPostString("reason");
  6244. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6245. string method = GetPostString("method");
  6246. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6247. string handler = GetPostString("handler");
  6248. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6249. string handledate1 = GetPostString("handledate1");
  6250. string handledate2 = GetPostString("handledate2");
  6251. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6252. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6253. string afterdate1 = GetPostString("afterdate1");
  6254. string afterdate2 = GetPostString("afterdate2");
  6255. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6256. if (afterDate.Length > 0) lw.Add(afterDate);
  6257. string supplier = GetPostString("supplier");
  6258. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6259. string responsible = GetPostString("responsibleman");
  6260. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6261. string customer = GetPostString("customer");
  6262. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6263. string design = GetPostString("design");
  6264. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6265. string afterSaleMemo = GetPostString("afterSaleMemo");
  6266. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6267. string afterMemoType = GetPostString("aftermemotype");
  6268. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6269. string afterresult = GetPostString("afterresult");
  6270. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6271. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6272. string poscode = CurrentUser.UserPost.Post.Code;
  6273. if (poscode != "SysAdmin")
  6274. {
  6275. string shopid = CurrentUser.User.pemShop;
  6276. lw.Add(string.Format("shopId in ({0})", shopid));
  6277. }
  6278. string searchType = GetPostString("searchType");
  6279. if (searchType == "wait")
  6280. {
  6281. lw.Add(string.Format("HandleTime is null"));
  6282. }
  6283. if (searchType == "documentary")
  6284. {
  6285. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6286. }
  6287. if (searchType == "handling")
  6288. {
  6289. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6290. }
  6291. if (searchType == "back" || searchType == "puBack")
  6292. {
  6293. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6294. }
  6295. if (searchType == "reBack")
  6296. {
  6297. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6298. }
  6299. if (afterState.Length <= 0)
  6300. {
  6301. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6302. }
  6303. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6304. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6305. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6306. writeGridDataTableJson(dStruct.TotalCount, dt);
  6307. }
  6308. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6309. //public void get_erp_back_handlingaftersalelist()
  6310. //{
  6311. // DataStruct dStruct = GetPostStruct();
  6312. // List<string> lw = new List<string>();
  6313. // string tid = GetPostString("ctid");
  6314. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6315. // string shopname = GetPostString("shopname");
  6316. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6317. // string buyernick = GetPostString("buyer_nick");
  6318. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6319. // string sellermemo = GetPostString("seller_memo");
  6320. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6321. // string orderState = GetPostString("orderState");
  6322. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6323. // string afterState = GetPostString("afterstate");
  6324. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6325. // string date1 = GetPostString("date1");
  6326. // string date2 = GetPostString("date2");
  6327. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6328. // if (dw.Length > 0) lw.Add(dw);
  6329. // string price1 = GetPostString("price1");
  6330. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6331. // string price2 = GetPostString("price2");
  6332. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6333. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6334. // string reason = GetPostString("reason");
  6335. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6336. // string method = GetPostString("method");
  6337. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6338. // string handler = GetPostString("handler");
  6339. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6340. // string handledate1 = GetPostString("handledate1");
  6341. // string handledate2 = GetPostString("handledate2");
  6342. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6343. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6344. // string afterdate1 = GetPostString("afterdate1");
  6345. // string afterdate2 = GetPostString("afterdate2");
  6346. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6347. // if (afterDate.Length > 0) lw.Add(afterDate);
  6348. // string supplier = GetPostString("supplier");
  6349. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6350. // string responsible = GetPostString("responsibleman");
  6351. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6352. // string customer = GetPostString("customer");
  6353. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6354. // string design = GetPostString("design");
  6355. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6356. // string afterMemoType = GetPostString("aftermemotype");
  6357. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6358. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6359. // if (afterState.Length <= 0)
  6360. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6361. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6362. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6363. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6364. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6365. //}
  6366. public void get_erp_aftersaleverifylist()
  6367. {
  6368. DataStruct dStruct = GetPostStruct();
  6369. List<string> lw = new List<string>();
  6370. string tid = GetPostString("ctid");
  6371. if (tid.Length > 0)
  6372. {
  6373. string select_tid = getTidByCtid(tid);
  6374. lw.Add(string.Format("otid='{0}'", select_tid));
  6375. }
  6376. string shopname = GetPostString("shopname");
  6377. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6378. string buyernick = GetPostString("buyer_nick");
  6379. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6380. string sellermemo = GetPostString("seller_memo");
  6381. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6382. string orderState = GetPostString("orderState");
  6383. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6384. //lw.Add(string.Format("IsRefund!={0}", 1));
  6385. string reason = GetPostString("reason");
  6386. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6387. string method = GetPostString("method");
  6388. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6389. string handler = GetPostString("handler");
  6390. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6391. string handledate1 = GetPostString("handledate1");
  6392. string handledate2 = GetPostString("handledate2");
  6393. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6394. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6395. string finish1 = GetPostString("finishdate1");
  6396. string finish2 = GetPostString("finishdate2");
  6397. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6398. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6399. string supplier = GetPostString("supplier");
  6400. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6401. string responsible = GetPostString("responsibleman");
  6402. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6403. string posCode = CurrentUser.UserPost.Post.Code;
  6404. string vstate = GetPostString("vstate");
  6405. if (vstate.Length > 0)
  6406. {
  6407. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6408. }
  6409. if (posCode == "Supplier")
  6410. {
  6411. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6412. lw.Add(string.Format("VerifyState = 0"));
  6413. lw.Add("type = 1");
  6414. lw.Add(string.Format("AfterSaleState={0}", 3));
  6415. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6416. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6417. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6418. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6419. writeGridDataTableJson(dStruct.TotalCount, dt);
  6420. }
  6421. else if (posCode == "logistics")
  6422. {
  6423. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6424. lw.Add(string.Format("VerifyState = 0"));
  6425. lw.Add("type = 2");
  6426. lw.Add(string.Format("AfterSaleState={0}", 3));
  6427. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6428. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6429. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6430. writeGridDataTableJson(dStruct.TotalCount, dt);
  6431. }
  6432. else
  6433. {
  6434. lw.Add(string.Format("(AfterSaleState = 3)"));
  6435. string reasonState = GetPostString("reasonState");
  6436. lw.Add("type = 0");
  6437. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6438. || posCode == "Summarize" || posCode == "Finance")
  6439. {
  6440. if (reasonState == "2")
  6441. {
  6442. lw.Add("VerifyState = 3");
  6443. }
  6444. else if (reasonState == "1")
  6445. {
  6446. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6447. }
  6448. else
  6449. {
  6450. lw.Add("VerifyState in (0,3)");
  6451. }
  6452. //不加条件,可以看全部
  6453. }
  6454. 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")
  6455. {
  6456. int orgid = CurrentUser.UserPost.OrgID;
  6457. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6458. if (string.IsNullOrEmpty(manageOrgId))
  6459. {
  6460. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6461. }
  6462. else
  6463. {
  6464. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6465. }
  6466. if (reasonState == "1")
  6467. {
  6468. lw.Add("VerifyState = 3");
  6469. }
  6470. else if (reasonState == "2")
  6471. {
  6472. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6473. }
  6474. else
  6475. {
  6476. }
  6477. }
  6478. else
  6479. {
  6480. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6481. }
  6482. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6483. //{
  6484. // int org_id = CurrentUser.UserPost.OrgID;
  6485. // lw.Add(string.Format("OrgID={0}", org_id));
  6486. //}
  6487. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6488. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6489. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6490. writeGridDataTableJson(dStruct.TotalCount, dt);
  6491. }
  6492. }
  6493. public void get_erp_finishaftersalelist()
  6494. {
  6495. DataStruct dStruct = GetPostStruct();
  6496. List<string> lw = new List<string>();
  6497. int st = 4;
  6498. string tid = GetPostString("ctid");
  6499. if (tid.Length > 0)
  6500. {
  6501. string select_tid = getTidByCtid(tid);
  6502. lw.Add(string.Format("otid='{0}'", select_tid));
  6503. }
  6504. string shopname = GetPostString("shopname");
  6505. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6506. //lw.Add(string.Format("IsRefund!={0}", 1));
  6507. string reason = GetPostString("reason");
  6508. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6509. string method = GetPostString("method");
  6510. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6511. string buyernick = GetPostString("buyer_nick");
  6512. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6513. string handler = GetPostString("handler");
  6514. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6515. string handledate1 = GetPostString("handledate1");
  6516. string handledate2 = GetPostString("handledate2");
  6517. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6518. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6519. string finish1 = GetPostString("finishdate1");
  6520. string finish2 = GetPostString("finishdate2");
  6521. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6522. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6523. string supplier = GetPostString("supplier");
  6524. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6525. string responsible = GetPostString("responsibleman");
  6526. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6527. string vstate = GetPostString("vstate");
  6528. if (vstate.Length > 0)
  6529. {
  6530. if ("3".Equals(vstate))
  6531. {
  6532. lw.Add(string.Format("IsTem=1"));
  6533. }
  6534. else
  6535. {
  6536. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6537. }
  6538. }
  6539. lw.Add(string.Format("AfterSaleState=4"));
  6540. string code = CurrentUser.UserPost.Post.Code;
  6541. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6542. {
  6543. //不加条件,可以看全部
  6544. }
  6545. else if (code == "Supplier")
  6546. {
  6547. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6548. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6549. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6550. }
  6551. else if (code == "logistics")
  6552. {
  6553. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6554. lw.Add("type = 2");
  6555. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6556. }
  6557. 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")
  6558. {
  6559. int orgid = CurrentUser.UserPost.OrgID;
  6560. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6561. if (string.IsNullOrEmpty(manageOrgIds))
  6562. {
  6563. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6564. }
  6565. else
  6566. {
  6567. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6568. }
  6569. }
  6570. else
  6571. {
  6572. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6573. }
  6574. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6575. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6576. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6577. writeGridDataTableJson(dStruct.TotalCount, dt);
  6578. }
  6579. public void handle_erp_aftersale()
  6580. {
  6581. if (UrlPostParmsCheck("ctid"))
  6582. {
  6583. string eid = GetPostString("ctid");
  6584. string responStr = GetPostString("AfterSaleResponsible");
  6585. if (responStr.Length <= 0)
  6586. {
  6587. returnErrorMsg("售后责任人不能为空");
  6588. return;
  6589. }
  6590. bool isDesign = false;
  6591. double designFree = 0.00;
  6592. int responsibleId = 0;
  6593. CeErpTradeCell entity = null;
  6594. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6595. if (entity != null)
  6596. {
  6597. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6598. string afterMethod = GetPostString("AfterSaleMethod");
  6599. if (isNeedNewOrder == 1)
  6600. {
  6601. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6602. bool ishav = true;
  6603. if (newentity == null)
  6604. {
  6605. newentity = entity.Clone() as CeErpTradeCell;
  6606. ishav = false;
  6607. newentity.ctid = "S_" + entity.ctid;
  6608. newentity.OrderState = 0;
  6609. //唯一标识
  6610. newentity.OrderSn = newentity.ctid;
  6611. string orderSn = dataHelper.getSaleOrderSn();
  6612. if (orderSn != "")
  6613. {
  6614. newentity.OrderSn = orderSn;
  6615. }
  6616. }
  6617. newentity.UpdateTime = DateTime.Now;
  6618. newentity.AfterSaleState = 0;
  6619. newentity.AfterSaleMethod = afterMethod;
  6620. if (!ishav)
  6621. {
  6622. string memo_str = newentity.seller_memo;
  6623. memo_str = memo_str.Replace("(", "(");
  6624. memo_str = memo_str.Replace(")", ")");
  6625. int sIndex = memo_str.IndexOf("(");
  6626. int eIndex = memo_str.IndexOf(")");
  6627. if (sIndex == -1 || eIndex == -1)
  6628. {
  6629. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6630. return;
  6631. }
  6632. string first = memo_str.Substring(0, sIndex + 1);
  6633. string memoCtid = newentity.OrderSn;
  6634. //if (memoCtid.IndexOf("C") != -1)
  6635. //{
  6636. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6637. //if (CIdx.IndexOf("+") != -1)
  6638. //{
  6639. //CIdx = "C" + CIdx.Split('+')[1];
  6640. //}
  6641. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6642. //}
  6643. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6644. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6645. string newMemo = first + memoCtid + last;
  6646. newentity.seller_memo = newMemo;
  6647. newentity.FinishPlaceTime = null;
  6648. newentity.UnusualTag = 0;
  6649. newentity.UnusualCon = "";
  6650. newentity.UnusualTime = null;
  6651. newentity.AfterSaleMemo = "";
  6652. newentity.AfterSaleMethod = afterMethod;
  6653. newentity.AfterSalePreTime = null;
  6654. newentity.AfterSaleReason = "";
  6655. newentity.AfterSaleResponsible = "";
  6656. newentity.AfterSaleState = 0;
  6657. newentity.AfterSaleTime = null;
  6658. newentity.AfterSaleUserId = 0;
  6659. newentity.AfterSaleSupplierState = 0;
  6660. newentity.LastBillWaybillCode = "";
  6661. newentity.LastBillCpCode = "";
  6662. newentity.FinishAfterSaleTime = null;
  6663. newentity.HandleTime = null;
  6664. newentity.IsSF = 0;
  6665. newentity.IsOldCustomer = 0;
  6666. newentity.UrgencyTime = null;
  6667. newentity.ResponsibleUserId = "";
  6668. newentity.IsVerifyToSupplier = false;
  6669. newentity.payment = 0;
  6670. newentity.CheckMemo = "";
  6671. newentity.OutSid = "";
  6672. newentity.CheckOrderTime = null;
  6673. newentity.MemoOpt = 0;
  6674. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6675. }
  6676. newentity.isAfterSaleOrder = 1;
  6677. newentity.IsRefund = 0;
  6678. string receiveMobile = GetPostString("receiver_mobile");
  6679. if (receiveMobile.Length > 0)
  6680. {
  6681. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6682. if (trade != null)
  6683. {
  6684. trade.receiver_name = GetPostString("receiver_name");
  6685. trade.receiver_mobile = receiveMobile;
  6686. trade.receiver_state = GetPostString("receiver_state");
  6687. trade.receiver_city = GetPostString("receiver_city");
  6688. trade.receiver_district = GetPostString("receiver_district");
  6689. trade.receiver_address = GetPostString("receiver_address");
  6690. newentity.IsOffLineOrder = 1;
  6691. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6692. }
  6693. }
  6694. string st = GetPostString("ToState");
  6695. if (st.Length > 0)
  6696. {
  6697. if (newentity.OrderState <= 3)
  6698. {
  6699. newentity.WaitDesignTime = DateTime.Now;
  6700. newentity.StartDesignTime = null;
  6701. newentity.FinishDesignTime = null;
  6702. newentity.OrderState = 3;
  6703. if (st == "下单员")
  6704. {
  6705. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6706. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6707. {
  6708. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6709. }
  6710. }
  6711. else
  6712. {
  6713. newentity.WaitDesignTime = DateTime.Now;
  6714. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6715. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6716. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6717. {
  6718. DataRow user = dt1.Rows[0];
  6719. //找主管
  6720. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6721. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6722. if (dt != null && dt.Rows.Count > 0)
  6723. {
  6724. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6725. newentity.DesignUserId = designMr;
  6726. string key = "aftersale_order_" + designMr;
  6727. if (RedisHelper.HasKey(key))
  6728. {
  6729. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6730. list.Add(newentity.ctid);
  6731. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6732. }
  6733. }
  6734. //账号正常
  6735. if (user["State"].ToString() == "0")
  6736. {
  6737. newentity.DesignUserId = entity.DesignUserId;
  6738. string key = "aftersale_order_" + entity.DesignUserId;
  6739. if (RedisHelper.HasKey(key))
  6740. {
  6741. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6742. list.Add(newentity.ctid);
  6743. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6744. }
  6745. }
  6746. }
  6747. }
  6748. }
  6749. if (entity.IsXianHuo == 1)
  6750. {
  6751. newentity.OrderState = 6;
  6752. entity.FinishPlaceTime = DateTime.Now;
  6753. }
  6754. }
  6755. if (ishav)
  6756. {
  6757. newentity.Update();
  6758. }
  6759. else
  6760. {
  6761. newentity.Create();
  6762. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6763. newCellExtend.ctid = newentity.ctid;
  6764. newCellExtend.orderFrom = 20;
  6765. newCellExtend.orderType = 30;
  6766. if (st == "下单员")
  6767. {
  6768. }
  6769. else
  6770. {
  6771. newCellExtend.ReprintTime = DateTime.Now;
  6772. }
  6773. newCellExtend.Create();
  6774. }
  6775. if (st != "下单员")
  6776. {
  6777. if (entity.DispatchSort == 2)
  6778. {
  6779. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6780. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6781. }
  6782. }
  6783. }
  6784. //处理售后扩展
  6785. string resIdStr = GetPostString("ResponsibleUserId");
  6786. string refundFees = GetPostString("refundFrees");
  6787. int IsComplain = GetPostInt("isComplain");
  6788. int IsBad = GetPostInt("isBad");
  6789. string IsOriginal = GetPostString("isOriginal");
  6790. double diffResultPrice = GetPostDouble("diffResultPrice");
  6791. string textResult = GetPostString("textResult");
  6792. string supplierResponsible = GetPostString("supplierResponsible");
  6793. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6794. if (ceErpTradeAfterSaleExtend == null)
  6795. {
  6796. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6797. ceErpTradeAfterSaleExtend.tid = eid;
  6798. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6799. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6800. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6801. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6802. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6803. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6804. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6805. ceErpTradeAfterSaleExtend.Create();
  6806. }
  6807. else
  6808. {
  6809. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6810. {
  6811. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6812. }
  6813. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6814. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6815. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6816. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6817. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6818. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6819. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6820. ceErpTradeAfterSaleExtend.Update();
  6821. }
  6822. int gysid = GetPostInt("ResponsibleSupId");
  6823. if (entity.AfterSaleUserId == 0)
  6824. {
  6825. entity.AfterSaleUserId = CurrentUser.UserID;
  6826. }
  6827. entity.ResponsibleUserId = resIdStr;
  6828. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6829. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6830. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6831. {
  6832. CeErpTradeResponsible.DelByTid(eid, -1);
  6833. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6834. int backNum = 0;
  6835. if (number != null)
  6836. {
  6837. backNum = number.BackNum;
  6838. }
  6839. char[] separator = { ',' };
  6840. string[] sArray = resIdStr.Split(separator);
  6841. string[] refundFreeList = { };
  6842. if (refundFees.Length > 0)
  6843. {
  6844. refundFreeList = refundFees.Split(separator);
  6845. }
  6846. int index = -1;
  6847. foreach (string i in sArray)
  6848. {
  6849. index++;
  6850. if (i.Length <= 0) continue;
  6851. char[] separator2 = { '_' };
  6852. string idstr = i.Split(separator2)[0];
  6853. string idtype = i.Split(separator2)[1];
  6854. double refudFree = 0;
  6855. if (refundFreeList.Length > 0)
  6856. {
  6857. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6858. }
  6859. if (idtype == "s")
  6860. {
  6861. isDesign = true;
  6862. designFree = refudFree;
  6863. }
  6864. int userId = Convert.ToInt32(idstr);
  6865. int type = 0;
  6866. if (idtype == "g")
  6867. {
  6868. type = 1;
  6869. }
  6870. if (idtype == "w")
  6871. {
  6872. type = 2;
  6873. }
  6874. if (idtype == "t")
  6875. {
  6876. type = 3;
  6877. }
  6878. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6879. if (ceErpTradeResponsible == null)
  6880. {
  6881. ceErpTradeResponsible = new CeErpTradeResponsible();
  6882. ceErpTradeResponsible.tid = eid;
  6883. ceErpTradeResponsible.UserId = userId;
  6884. ceErpTradeResponsible.createdTime = DateTime.Now;
  6885. ceErpTradeResponsible.type = type;
  6886. if (type == 1)
  6887. {
  6888. ceErpTradeResponsible.IsSup = 1;
  6889. }
  6890. if (type == 2)
  6891. {
  6892. ceErpTradeResponsible.IsFlow = 1;
  6893. }
  6894. }
  6895. ceErpTradeResponsible.RefundFee = refudFree;
  6896. ceErpTradeResponsible.VerifyState = 0;
  6897. if (userId == 2125 || idtype == "w")
  6898. {
  6899. ceErpTradeResponsible.VerifyState = 1;
  6900. }
  6901. if (idtype == "w" && userId == 101)
  6902. {
  6903. ceErpTradeResponsible.VerifyState = 0;
  6904. }
  6905. if (ceErpTradeResponsible.ID > 0)
  6906. {
  6907. ceErpTradeResponsible.Update();
  6908. }
  6909. else
  6910. {
  6911. ceErpTradeResponsible.Create();
  6912. }
  6913. if (isDesign)
  6914. {
  6915. responsibleId = ceErpTradeResponsible.ID;
  6916. }
  6917. }
  6918. CeErpTradeResponsible.NumByTid(backNum, eid);
  6919. }
  6920. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6921. if (ceErpTradeCellExtend != null)
  6922. {
  6923. ceErpTradeCellExtend.returnVisit = 0;
  6924. ceErpTradeCellExtend.Update();
  6925. }
  6926. if (entity.HandleTime != null)
  6927. {
  6928. if (entity.AfterSaleState == 1)
  6929. {
  6930. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6931. }
  6932. else
  6933. {
  6934. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6935. }
  6936. }
  6937. else
  6938. {
  6939. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6940. entity.HandleTime = DateTime.Now;
  6941. }
  6942. bool isCompale = false;
  6943. if (entity.AfterSaleState == 5)
  6944. {
  6945. isCompale = true;
  6946. entity.AfterSaleState = 3;
  6947. }
  6948. entity.AfterSaleSupplierState = 0;
  6949. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6950. {
  6951. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6952. }
  6953. string sImgs = GetPostString("img");
  6954. entity.AfterSaleSupplierImg = sImgs;
  6955. entity.supRefundType = GetPostString("supRefundType");
  6956. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6957. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6958. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6959. entity.AfterSaleMemoType = GetPostString("MemoType");
  6960. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6961. {
  6962. //entity.AfterSaleSupplierState = 2;
  6963. }
  6964. string df = GetPostString("DeductFee");
  6965. if (df == "")
  6966. {
  6967. df = "0";
  6968. }
  6969. string rf = GetPostString("RefundFee");
  6970. if (rf == "")
  6971. {
  6972. rf = "0";
  6973. }
  6974. string pm = GetPostString("AfterSalePayment");
  6975. if (pm == "")
  6976. {
  6977. pm = "0";
  6978. }
  6979. entity.AfterSalePayment = Convert.ToDouble(pm);
  6980. entity.DeductFee = Convert.ToDouble(df);
  6981. entity.RefundFee = Convert.ToDouble(rf);
  6982. entity.UpdateTime = DateTime.Now;
  6983. entity.Update();
  6984. string toState = GetPostString("ToState");
  6985. string original = GetPostString("isOriginal");
  6986. ApiVo apiVo = new ApiVo();
  6987. apiVo.orderNumber = entity.ctid;
  6988. apiVo.actionName = "afterDesign";
  6989. apiVo.orderRemarks = entity.AfterSaleMethod;
  6990. apiVo.reasonRemarks = entity.AfterSaleReason;
  6991. apiVo.isDesign = isDesign;
  6992. apiVo.designFree = designFree;
  6993. apiVo.responsibleId = responsibleId;
  6994. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6995. if (toState == "设计师")
  6996. {
  6997. apiVo.isOriginal = Convert.ToBoolean(original);
  6998. }
  6999. designHelper.API_WorkCore(apiVo);//afterDesign
  7000. CeErpMethod methodSql = new CeErpMethod();
  7001. methodSql.con = entity.AfterSaleMethod;
  7002. methodSql.addTime = DateTime.Now;
  7003. methodSql.Create();
  7004. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7005. CeErpMethod.ExecuteNonQuery(delsql);
  7006. if (isCompale)
  7007. {
  7008. aftersale_data_change(entity.ctid);
  7009. }
  7010. returnSuccessMsg("操作成功!");
  7011. return;
  7012. }
  7013. returnErrorMsg("找不到订单记录");
  7014. }
  7015. }
  7016. public void ins_erp_toresponsible()
  7017. {
  7018. if (UrlPostParmsCheck("ctid"))
  7019. {
  7020. string eid = GetPostString("ctid");
  7021. CeErpTradeCell entity = null;
  7022. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7023. if (entity != null)
  7024. {
  7025. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7026. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7027. {
  7028. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7029. return;
  7030. }
  7031. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7032. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7033. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7034. if (entity.AfterSalePreTime == null)
  7035. {
  7036. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7037. {
  7038. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7039. }
  7040. }
  7041. entity.AfterSalePreTime = DateTime.Now;
  7042. //预完成给售后主管审核客户问题直接完成
  7043. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7044. {
  7045. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7046. {
  7047. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7048. }
  7049. }
  7050. ceErpTradeAfterSaleExtend.Update();
  7051. entity.AfterSaleState = 2;
  7052. entity.UpdateTime = DateTime.Now;
  7053. entity.Update();
  7054. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7055. aftersale_data_change(entity.ctid);
  7056. returnSuccessMsg("操作成功!");
  7057. return;
  7058. }
  7059. returnErrorMsg("找不到订单记录");
  7060. }
  7061. }
  7062. public void cancel_erp_aftersaleanddelnew()
  7063. {
  7064. if (UrlPostParmsCheck("ctid"))
  7065. {
  7066. string eid = GetPostString("ctid");
  7067. CeErpTradeCell entity = null;
  7068. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7069. if (entity != null)
  7070. {
  7071. entity.AfterSaleState = 0;
  7072. entity.AfterSaleReason = "";
  7073. entity.AfterSaleMethod = "";
  7074. entity.AfterSaleMemo = "";
  7075. entity.AfterSaleResponsible = "";
  7076. entity.ResponsibleUserId = "";
  7077. entity.DeductFee = 0;
  7078. entity.RefundFee = 0;
  7079. entity.IsArbitrate = 0;
  7080. CeErpTradeResponsible.DelByTid(eid, -1);
  7081. entity.Update();
  7082. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7083. if (after != null)
  7084. {
  7085. if (after.OrderState < 5)
  7086. CeErpTradeCell.DelByCtid("S_" + eid);
  7087. }
  7088. returnSuccessMsg("操作成功!");
  7089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7090. return;
  7091. }
  7092. returnErrorMsg("找不到订单记录");
  7093. }
  7094. }
  7095. public void get_erp_aftersale_pregather()
  7096. {
  7097. List<string> lw = new List<string>();
  7098. int st = GetInt("st");
  7099. string tid = GetPostString("ctid");
  7100. if (tid.Length > 0)
  7101. {
  7102. string select_tid = getTidByCtid(tid);
  7103. lw.Add(string.Format("tid='{0}'", select_tid));
  7104. }
  7105. string shopname = GetPostString("shopname");
  7106. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7107. string buyernick = GetPostString("buyer_nick");
  7108. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7109. string sellermemo = GetPostString("seller_memo");
  7110. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7111. string orderState = GetPostString("orderState");
  7112. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7113. string reason = GetPostString("reason");
  7114. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7115. string method = GetPostString("method");
  7116. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7117. string handler = GetPostString("handler");
  7118. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7119. string handledate1 = GetPostString("handledate1");
  7120. string handledate2 = GetPostString("handledate2");
  7121. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7122. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7123. string supplier = GetPostString("supplier");
  7124. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7125. string responsible = GetPostString("responsibleman");
  7126. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7127. string customer = GetPostString("customer");
  7128. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7129. string design = GetPostString("design");
  7130. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7131. string afterMemoType = GetPostString("aftermemotype");
  7132. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7133. string afterSaleMemo = GetPostString("afterSaleMemo");
  7134. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7135. string afterresult = GetPostString("afterresult");
  7136. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7137. string poscode = CurrentUser.UserPost.Post.Code;
  7138. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7139. {
  7140. string shopid = CurrentUser.User.pemShop;
  7141. lw.Add(string.Format("shopId in ({0})", shopid));
  7142. }
  7143. var mainwhere = string.Join(" and ", lw.ToArray());
  7144. string ro_json = "";
  7145. string type = GetPostString("gather_type");
  7146. int number = 0;
  7147. if (poscode == "AfterSale")
  7148. {
  7149. //处理中
  7150. if (type == "Handling")
  7151. {
  7152. 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) : ""));
  7153. DataTable dt = null;
  7154. try
  7155. {
  7156. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7157. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7158. }
  7159. catch (Exception e)
  7160. {
  7161. dt = new DataTable();
  7162. }
  7163. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7164. return;
  7165. }
  7166. if (type == "Wait")
  7167. {
  7168. //待处理
  7169. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7170. DataTable dt1 = null;
  7171. try
  7172. {
  7173. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7174. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7175. }
  7176. catch (Exception e)
  7177. {
  7178. dt1 = new DataTable();
  7179. }
  7180. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7181. return;
  7182. }
  7183. if (type == "back")
  7184. {
  7185. //打回
  7186. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7187. DataTable dt2 = null;
  7188. try
  7189. {
  7190. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7191. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7192. }
  7193. catch (Exception e)
  7194. {
  7195. dt2 = new DataTable();
  7196. }
  7197. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7198. return;
  7199. }
  7200. if (type == "preCompletion")
  7201. {
  7202. //预完成
  7203. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7204. DataTable dt3 = null;
  7205. try
  7206. {
  7207. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7208. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7209. }
  7210. catch (Exception e)
  7211. {
  7212. dt3 = new DataTable();
  7213. }
  7214. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7215. return;
  7216. }
  7217. if (type == "documentary")
  7218. {
  7219. //跟单中
  7220. 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) : ""));
  7221. DataTable dt4 = null;
  7222. try
  7223. {
  7224. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7225. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7226. }
  7227. catch (Exception e)
  7228. {
  7229. dt4 = new DataTable();
  7230. }
  7231. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7232. return;
  7233. }
  7234. if (type == "reBack")
  7235. {
  7236. //被打回
  7237. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7238. DataTable dt1 = null;
  7239. try
  7240. {
  7241. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7242. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7243. }
  7244. catch (Exception e)
  7245. {
  7246. dt1 = new DataTable();
  7247. }
  7248. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7249. return;
  7250. }
  7251. }
  7252. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7253. {
  7254. if (type == "puBack")
  7255. {
  7256. //退回
  7257. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7258. DataTable dt = null;
  7259. try
  7260. {
  7261. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7262. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7263. }
  7264. catch (Exception e)
  7265. {
  7266. dt = new DataTable();
  7267. }
  7268. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7269. return;
  7270. }
  7271. if (type == "reBack")
  7272. {
  7273. //打回
  7274. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7275. DataTable dt1 = null;
  7276. try
  7277. {
  7278. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7279. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7280. }
  7281. catch (Exception e)
  7282. {
  7283. dt1 = new DataTable();
  7284. }
  7285. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7286. return;
  7287. }
  7288. if (type == "examEd")
  7289. {
  7290. //已审核
  7291. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7292. DataTable dt2 = null;
  7293. try
  7294. {
  7295. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7296. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7297. }
  7298. catch (Exception e)
  7299. {
  7300. dt2 = new DataTable();
  7301. }
  7302. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7303. return;
  7304. }
  7305. if (type == "waitExam")
  7306. {
  7307. //待审核
  7308. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7309. DataTable dt3 = null;
  7310. try
  7311. {
  7312. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7313. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7314. }
  7315. catch (Exception e)
  7316. {
  7317. dt3 = new DataTable();
  7318. }
  7319. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7320. return;
  7321. }
  7322. if (type == "Handling")
  7323. {
  7324. //处理中
  7325. 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) : ""));
  7326. DataTable dt4 = null;
  7327. try
  7328. {
  7329. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7330. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7331. }
  7332. catch (Exception e)
  7333. {
  7334. dt4 = new DataTable();
  7335. }
  7336. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7337. return;
  7338. }
  7339. if (type == "Wait")
  7340. {
  7341. //待处理
  7342. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7343. DataTable dt5 = null;
  7344. try
  7345. {
  7346. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7347. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7348. }
  7349. catch (Exception e)
  7350. {
  7351. dt5 = new DataTable();
  7352. }
  7353. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7354. return;
  7355. }
  7356. if (type == "documentary")
  7357. {
  7358. //跟单中
  7359. 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) : ""));
  7360. DataTable dt6 = null;
  7361. try
  7362. {
  7363. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7364. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7365. }
  7366. catch (Exception e)
  7367. {
  7368. dt6 = new DataTable();
  7369. }
  7370. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7371. return;
  7372. }
  7373. }
  7374. returnSuccess(ro_json);
  7375. }
  7376. public void end_erp_aftersale()
  7377. {
  7378. if (UrlPostParmsCheck("ctid"))
  7379. {
  7380. string eid = GetPostString("ctid");
  7381. CeErpTradeCell entity = null;
  7382. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7383. if (entity != null)
  7384. {
  7385. string stype = GetPostString("stype");
  7386. string typeStr = stype;
  7387. entity.AfterSaleState = 4;
  7388. entity.FinishAfterSaleTime = DateTime.Now;
  7389. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7390. entity.Update();
  7391. ApiVo apiVo = new ApiVo();
  7392. apiVo.orderNumber = entity.ctid;
  7393. apiVo.actionName = "afterOver";
  7394. designHelper.API_WorkCore(apiVo); //afterOver
  7395. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7396. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7397. CeErpSukuraData.createInfo(entity.ctid, 8);
  7398. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7399. returnSuccessMsg("操作成功!");
  7400. return;
  7401. }
  7402. returnErrorMsg("找不到订单记录");
  7403. }
  7404. }
  7405. public void ins_erp_finishaftersale()
  7406. {
  7407. if (UrlPostParmsCheck("id"))
  7408. {
  7409. string eid = GetPostString("id");
  7410. CeErpTradeResponsible entity = null;
  7411. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7412. if (entity != null)
  7413. {
  7414. entity.VerifyState = 1;
  7415. entity.VerifyTime = DateTime.Now;
  7416. entity.Update();
  7417. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7418. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7419. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7420. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7421. if (dt.Rows.Count <= 0)
  7422. {
  7423. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7424. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7425. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7426. CeErpSukuraData.createInfo(entity.tid, 8);
  7427. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7428. {
  7429. CeErpDesignerBill.Del(entity.tid);
  7430. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7431. }
  7432. }
  7433. returnSuccessMsg("操作成功!");
  7434. return;
  7435. }
  7436. returnErrorMsg("找不到订单记录");
  7437. }
  7438. }
  7439. public void upd_erp_arbitrateaftersale()
  7440. {
  7441. if (UrlPostParmsCheck("id"))
  7442. {
  7443. string eid = GetPostString("id");
  7444. CeErpTradeResponsible entity = null;
  7445. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7446. if (entity != null)
  7447. {
  7448. entity.IsArbitrate = 1;
  7449. entity.ArbitradeMemo = GetPostString("reason");
  7450. entity.VerifyState = 2;
  7451. entity.Update();
  7452. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7453. if (tradecell != null)
  7454. {
  7455. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7456. tradecell.IsArbitrate = 1;
  7457. tradecell.Update();
  7458. }
  7459. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7460. returnSuccessMsg("操作成功!");
  7461. return;
  7462. }
  7463. returnErrorMsg("找不到订单记录");
  7464. }
  7465. }
  7466. public void upd_erp_backaftersale()
  7467. {
  7468. if (UrlPostParmsCheck("tid"))
  7469. {
  7470. string eid = GetPostString("tid");
  7471. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7472. int backNum = 0;
  7473. if (number != null)
  7474. {
  7475. backNum = number.BackNum;
  7476. }
  7477. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7478. CeErpTradeCell entity = null;
  7479. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7480. if (entity != null)
  7481. {
  7482. entity.AfterSaleBackReason = GetPostString("backreason");
  7483. entity.AfterSaleState = 1;
  7484. entity.AfterSaleSupplierState = 0;
  7485. entity.UpdateTime = DateTime.Now;
  7486. entity.Update();
  7487. returnSuccessMsg("操作成功!");
  7488. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7489. return;
  7490. }
  7491. returnErrorMsg("找不到订单记录");
  7492. }
  7493. }
  7494. public void get_erp_supplieraftersalelist()
  7495. {
  7496. DataStruct dStruct = GetPostStruct();
  7497. List<string> lw = new List<string>();
  7498. string tid = GetPostString("ctid");
  7499. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7500. string shopname = GetPostString("shopname");
  7501. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7502. string buyernick = GetPostString("buyer_nick");
  7503. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7504. string sellermemo = GetPostString("seller_memo");
  7505. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7506. string orderState = GetPostString("orderState");
  7507. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7508. string afterState = GetPostString("afterstate");
  7509. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7510. string date1 = GetPostString("date1");
  7511. string date2 = GetPostString("date2");
  7512. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7513. if (dw.Length > 0) lw.Add(dw);
  7514. string price1 = GetPostString("price1");
  7515. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7516. string price2 = GetPostString("price2");
  7517. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7518. string reason = GetPostString("reason");
  7519. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7520. string method = GetPostString("method");
  7521. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7522. string handledate1 = GetPostString("handledate1");
  7523. string handledate2 = GetPostString("handledate2");
  7524. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7525. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7526. string handler = GetPostString("handler");
  7527. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7528. string afterdate1 = GetPostString("afterdate1");
  7529. string afterdate2 = GetPostString("afterdate2");
  7530. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7531. if (afterDate.Length > 0) lw.Add(afterDate);
  7532. string customer = GetPostString("customer");
  7533. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7534. string design = GetPostString("design");
  7535. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7536. string afterMemoType = GetPostString("aftermemotype");
  7537. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7538. string vstate = GetPostString("vstate");
  7539. if (vstate.Length > 0)
  7540. {
  7541. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7542. }
  7543. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7544. string supplier = GetPostString("supplier");
  7545. int supid = commonHelper.getSupplierIDByName(supplier);
  7546. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7547. string posCode = CurrentUser.UserPost.Post.Code;
  7548. if (posCode == "Supplier")
  7549. {
  7550. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7551. }
  7552. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7553. {
  7554. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7555. }
  7556. else
  7557. {
  7558. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7559. }
  7560. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7561. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7563. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7564. writeGridDataTableJson(dStruct.TotalCount, dt);
  7565. }
  7566. public void upd_erp_supverifyaftersale()
  7567. {
  7568. if (UrlPostParmsCheck("id"))
  7569. {
  7570. string id = GetPostString("id");
  7571. int st = GetPostInt("afterstate");
  7572. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7573. CeErpTradeCell entity = null;
  7574. if (ceErpTradeResponsible != null)
  7575. {
  7576. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7577. }
  7578. string afmemo = GetPostString("supmemo");
  7579. string image = GetPostString("image");
  7580. if (entity != null)
  7581. {
  7582. entity.AfterSaleSupplierState = st;
  7583. entity.AfterSaleSupplierMemo = afmemo;
  7584. if (st == 1)
  7585. {
  7586. ceErpTradeResponsible.VerifyState = 1;
  7587. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7588. ceErpTradeResponsible.Update();
  7589. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7590. if (isAll)
  7591. {
  7592. entity.AfterSaleState = 4;
  7593. entity.FinishAfterSaleTime = DateTime.Now;
  7594. }
  7595. }
  7596. else
  7597. {
  7598. CeErpTradeResponsible.dateByTid(entity.ctid);
  7599. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7600. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7601. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7602. if (num <= 1)
  7603. {
  7604. entity.AfterSaleState = 1;
  7605. }
  7606. else
  7607. {
  7608. entity.AfterSaleState = 5;
  7609. }
  7610. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7611. if (ceErpTradeAfterSaleExtend != null)
  7612. {
  7613. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7614. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7615. ceErpTradeAfterSaleExtend.Update();
  7616. }
  7617. else
  7618. {
  7619. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7620. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7621. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7622. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7623. ceErpTradeAfterSaleExtend.Create();
  7624. }
  7625. }
  7626. if (entity.AfterSaleState == 4)
  7627. {
  7628. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7629. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7630. {
  7631. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7632. }
  7633. ApiVo apiVo = new ApiVo();
  7634. apiVo.orderNumber = entity.ctid;
  7635. apiVo.actionName = "afterOver";
  7636. designHelper.API_WorkCore(apiVo); //afterOver
  7637. }
  7638. entity.UpdateTime = DateTime.Now;
  7639. entity.Update();
  7640. returnSuccessMsg("操作成功!");
  7641. CeErpSukuraData.createInfo(entity.ctid, 8);
  7642. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7643. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7644. return;
  7645. }
  7646. returnErrorMsg("找不到订单记录");
  7647. }
  7648. }
  7649. public void upd_erp_masteraftersale()
  7650. {
  7651. if (UrlPostParmsCheck("id"))
  7652. {
  7653. string id = GetPostString("id");
  7654. int st = GetPostInt("afterstate");
  7655. string afmemo = GetPostString("supmemo");
  7656. string image = GetPostString("image");
  7657. string textResult = GetPostString("textResult");
  7658. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7659. if (ceErpTradeResponsible != null)
  7660. {
  7661. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7662. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7663. ceErpTradeResponsible.Update();
  7664. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7665. if (entity != null)
  7666. {
  7667. entity.AfterSaleSupplierState = st;
  7668. entity.AfterSaleSupplierMemo = afmemo;
  7669. if (st == 1)
  7670. {
  7671. }
  7672. else
  7673. {
  7674. CeErpTradeResponsible.dateByTid(entity.ctid);
  7675. //退回到售后
  7676. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7677. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7678. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7679. if (num <= 1)
  7680. {
  7681. entity.AfterSaleState = 1;
  7682. }
  7683. else
  7684. {
  7685. entity.AfterSaleState = 5;
  7686. }
  7687. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7688. if (ceErpTradeAfterSaleExtend != null)
  7689. {
  7690. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7691. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7692. ceErpTradeAfterSaleExtend.Update();
  7693. }
  7694. else
  7695. {
  7696. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7697. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7698. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7699. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7700. ceErpTradeAfterSaleExtend.Create();
  7701. }
  7702. }
  7703. entity.UpdateTime = DateTime.Now;
  7704. entity.Update();
  7705. returnSuccessMsg("操作成功!");
  7706. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7707. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7708. return;
  7709. }
  7710. }
  7711. returnErrorMsg("找不到订单记录");
  7712. }
  7713. }
  7714. public void upd_erp_personaftersale()
  7715. {
  7716. if (UrlPostParmsCheck("id"))
  7717. {
  7718. //林小连
  7719. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7720. {
  7721. upd_erp_masteraftersale();
  7722. return;
  7723. }
  7724. string id = GetPostString("id");
  7725. int st = GetPostInt("afterstate");
  7726. string afmemo = GetPostString("supmemo");
  7727. string image = GetPostString("image");
  7728. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7729. if (ceErpTradeResponsible != null)
  7730. {
  7731. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7732. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7733. ceErpTradeResponsible.Update();
  7734. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7735. if (entity != null)
  7736. {
  7737. entity.AfterSaleSupplierMemo = afmemo;
  7738. entity.AfterSaleSupplierState = st;
  7739. if (st == 1)
  7740. {
  7741. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7742. if (isAll)
  7743. {
  7744. entity.AfterSaleState = 4;
  7745. entity.FinishAfterSaleTime = DateTime.Now;
  7746. }
  7747. }
  7748. else
  7749. {
  7750. CeErpTradeResponsible.dateByTid(entity.ctid);
  7751. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7752. if (ceErpTradeAfterSaleExtend != null)
  7753. {
  7754. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7755. ceErpTradeAfterSaleExtend.Update();
  7756. }
  7757. else
  7758. {
  7759. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7760. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7761. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7762. ceErpTradeAfterSaleExtend.Create();
  7763. }
  7764. //退回到主管
  7765. //entity.AfterSaleState = 2;
  7766. }
  7767. if (entity.AfterSaleState == 4)
  7768. {
  7769. ApiVo apiVo = new ApiVo();
  7770. apiVo.orderNumber = entity.ctid;
  7771. apiVo.actionName = "afterOver";
  7772. designHelper.API_WorkCore(apiVo); //afterOver
  7773. }
  7774. entity.UpdateTime = DateTime.Now;
  7775. entity.Update();
  7776. returnSuccessMsg("操作成功!");
  7777. CeErpSukuraData.createInfo(entity.ctid, 8);
  7778. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7779. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7780. return;
  7781. }
  7782. }
  7783. returnErrorMsg("找不到订单记录");
  7784. }
  7785. }
  7786. public void set_erp_supplierrefundtag()
  7787. {
  7788. if (UrlPostParmsCheck("ctid"))
  7789. {
  7790. string eid = GetPostString("ctid");
  7791. CeErpTradeCell entity = null;
  7792. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7793. if (entity != null)
  7794. {
  7795. entity.IsSupplierRefund = GetPostInt("tag");
  7796. entity.Update();
  7797. returnSuccessMsg("操作成功!");
  7798. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7799. return;
  7800. }
  7801. returnErrorMsg("找不到订单记录");
  7802. }
  7803. }
  7804. public void get_erp_refundlist()
  7805. {
  7806. DataStruct dStruct = GetPostStruct();
  7807. List<string> lw = new List<string>();
  7808. string tid = GetPostString("tid");
  7809. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7810. //string rid = GetPostString("refund_id");
  7811. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7812. string shopname = GetPostString("shopname");
  7813. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7814. string buyernick = GetPostString("buyer_nick");
  7815. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7816. string customer = GetPostString("customer");
  7817. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7818. string design = GetPostString("design");
  7819. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7820. string sellermemo = GetPostString("seller_memo");
  7821. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7822. //string date1 = GetPostString("date1");
  7823. //string date2 = GetPostString("date2");
  7824. //string dateType = GetPostString("dateType");
  7825. //if (dateType.Length > 0)
  7826. //{
  7827. // if (dateType == "1001") dateType = "0";
  7828. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7829. // if (searchDT.Count == 2)
  7830. // {
  7831. // date1 = searchDT[0].ToString();
  7832. // date2 = searchDT[1].ToString();
  7833. // }
  7834. //}
  7835. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7836. //if (dw.Length > 0) lw.Add(dw);
  7837. string redate1 = GetPostString("refunddate1");
  7838. string redate2 = GetPostString("refunddate2");
  7839. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7840. if (dwdate.Length > 0) lw.Add(dwdate);
  7841. string price1 = GetPostString("price1");
  7842. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7843. string price2 = GetPostString("price2");
  7844. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7845. string ispartrefund = GetPostString("ispartrefund");
  7846. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7847. string refundState = GetPostString("refundvstate");
  7848. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7849. int st = GetInt("st");
  7850. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7851. {
  7852. string responsible = GetPostString("responsibleman");
  7853. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7854. lw.Add(string.Format("RefundState>={0}", st));
  7855. string code = CurrentUser.UserPost.Post.Code;
  7856. if (code == "CustomerService")
  7857. {
  7858. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7859. }
  7860. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7861. {
  7862. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7863. }
  7864. else if (code == "Place" || code == "PlaceMr")
  7865. {
  7866. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7867. }
  7868. dStruct.Order = "RefundState asc,created desc";
  7869. }
  7870. else if (st == 10)
  7871. {
  7872. string responsible = GetPostString("responsibleman");
  7873. if (responsible == "空白")
  7874. {
  7875. lw.Add(string.Format("ResponsibleUserName = ''"));
  7876. }
  7877. else if (responsible.Length > 0)
  7878. {
  7879. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7880. }
  7881. lw.Add(string.Format("RefundState>=0"));
  7882. dStruct.Order = "created desc";
  7883. }
  7884. else
  7885. {
  7886. string responsible = GetPostString("responsibleman");
  7887. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7888. lw.Add(string.Format("RefundState={0}", st));
  7889. dStruct.Order = "created desc";
  7890. }
  7891. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7892. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7893. dt.Columns.Add("refund_fees");
  7894. foreach (DataRow dr in dt.Rows)
  7895. {
  7896. String status = dr["status"].ToString();
  7897. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7898. {
  7899. dr["refund_fees"] = dr["refund_fee"];
  7900. }
  7901. else
  7902. {
  7903. dr["refund_fees"] = "0.0";
  7904. }
  7905. }
  7906. writeGridDataTableJson(dStruct.TotalCount, dt);
  7907. }
  7908. public void get_erp_refunddesignlist()
  7909. {
  7910. DataStruct dStruct = GetPostStruct();
  7911. List<string> lw = new List<string>();
  7912. string tid = GetPostString("tid");
  7913. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7914. string shopname = GetPostString("shopname");
  7915. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7916. string buyernick = GetPostString("buyer_nick");
  7917. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7918. string customer = GetPostString("customer");
  7919. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7920. string design = GetPostString("design");
  7921. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7922. string sellermemo = GetPostString("seller_memo");
  7923. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7924. string redate1 = GetPostString("refunddate1");
  7925. string redate2 = GetPostString("refunddate2");
  7926. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7927. if (dwdate.Length > 0) lw.Add(dwdate);
  7928. string price1 = GetPostString("price1");
  7929. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7930. string price2 = GetPostString("price2");
  7931. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7932. string ispartrefund = GetPostString("ispartrefund");
  7933. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7934. string designerorg = GetPostString("designerorg");
  7935. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7936. string refundState = GetPostString("refundState");
  7937. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7938. int myOrgid = CurrentUser.UserPost.OrgID;
  7939. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7940. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7941. {
  7942. if (CurrentUser.User.TeamIds.Length > 0)
  7943. {
  7944. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7945. }
  7946. else
  7947. {
  7948. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7949. }
  7950. }
  7951. else if ("SysAdmin".Equals(myOrgCode))
  7952. {
  7953. }
  7954. else
  7955. {
  7956. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7957. {
  7958. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7959. }
  7960. else
  7961. {
  7962. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7963. }
  7964. }
  7965. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7966. dStruct.Order = "created desc";
  7967. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7968. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7969. dt.Columns.Add("refund_fees");
  7970. foreach (DataRow dr in dt.Rows)
  7971. {
  7972. String status = dr["status"].ToString();
  7973. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7974. {
  7975. dr["refund_fees"] = dr["refund_fee"];
  7976. }
  7977. else
  7978. {
  7979. dr["refund_fees"] = "0.0";
  7980. }
  7981. }
  7982. writeGridDataTableJson(dStruct.TotalCount, dt);
  7983. }
  7984. public void handle_erp_refundtag()
  7985. {
  7986. if (UrlPostParmsCheck("refund_id"))
  7987. {
  7988. string eid = GetPostString("refund_id");
  7989. string respMan = GetPostString("ResponsibleName");
  7990. if (respMan.Length <= 0)
  7991. {
  7992. returnErrorMsg("责任人不能为空");
  7993. return;
  7994. }
  7995. CeErpTradeRefund entity = null;
  7996. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7997. if (entity != null)
  7998. {
  7999. entity.ResponsibleUserName = respMan;
  8000. string userid = GetPostString("ResponsibleUserId");
  8001. if (userid.Length > 0)
  8002. {
  8003. entity.ResponsibleUserId = userid;
  8004. }
  8005. entity.Memo = GetPostString("Memo");
  8006. if (respMan.IndexOf("客服") != -1 ||
  8007. respMan.IndexOf("设计师") != -1 ||
  8008. respMan.IndexOf("下单员") != -1)
  8009. {
  8010. entity.RefundState = 2;
  8011. }
  8012. else
  8013. {
  8014. entity.RefundState = 3;
  8015. }
  8016. entity.modified = DateTime.Now;
  8017. entity.Update();
  8018. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8019. returnSuccessMsg("操作成功!");
  8020. return;
  8021. }
  8022. returnErrorMsg("找不到订单记录");
  8023. }
  8024. }
  8025. public void handle_erp_designrefundtag()
  8026. {
  8027. if (UrlPostParmsCheck("refund_id"))
  8028. {
  8029. string eid = GetPostString("refund_id");
  8030. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8031. if (ceErpTradeCellExtend == null)
  8032. {
  8033. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8034. ceErpTradeCellExtend.ctid = eid;
  8035. }
  8036. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8037. if (ceErpTradeCellExtend.ID > 0)
  8038. {
  8039. ceErpTradeCellExtend.Update();
  8040. }
  8041. else
  8042. {
  8043. ceErpTradeCellExtend.Create();
  8044. }
  8045. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8046. returnSuccessMsg("操作成功!");
  8047. return;
  8048. }
  8049. returnErrorMsg("找不到订单记录");
  8050. }
  8051. public void upd_erp_refundverify()
  8052. {
  8053. if (UrlPostParmsCheck("refund_id"))
  8054. {
  8055. string eid = GetPostString("refund_id");
  8056. CeErpTradeRefund entity = null;
  8057. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8058. if (entity != null)
  8059. {
  8060. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8061. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8062. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8063. {
  8064. entity.RefundState = 2;
  8065. }
  8066. else
  8067. {
  8068. entity.RefundState = 3;
  8069. }
  8070. entity.Update();
  8071. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8072. returnSuccessMsg("操作成功!");
  8073. return;
  8074. }
  8075. returnErrorMsg("找不到订单记录");
  8076. }
  8077. }
  8078. public void upd_erp_refundapprove()
  8079. {
  8080. if (UrlPostParmsCheck("refund_id"))
  8081. {
  8082. string eid = GetPostString("refund_id");
  8083. CeErpTradeRefund entity = null;
  8084. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8085. if (entity != null)
  8086. {
  8087. int apr = GetPostInt("approve");
  8088. if (apr == 0)
  8089. {
  8090. entity.RefundState = 1;
  8091. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8092. }
  8093. else if (apr == 1)
  8094. {
  8095. entity.RefundState = 3;
  8096. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8097. }
  8098. entity.modified = DateTime.Now;
  8099. entity.Update();
  8100. returnSuccessMsg("操作成功!");
  8101. return;
  8102. }
  8103. returnErrorMsg("找不到订单记录");
  8104. }
  8105. }
  8106. public void get_erp_billlist()
  8107. {
  8108. DataStruct dStruct = GetPostStruct();
  8109. List<string> lw = new List<string>();
  8110. string title = GetPostString("title");
  8111. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8112. string tid = GetPostString("tid");
  8113. string tids = GetPostString("tids");
  8114. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8115. if (tids.Length > 0)
  8116. {
  8117. tids = "'" + tids + "'";
  8118. tids = tids.Replace(",", "','");
  8119. lw.Add(string.Format("tid in ({0})", tids));
  8120. }
  8121. string shopname = GetPostString("shopname");
  8122. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8123. string buyernick = GetPostString("buyer_nick");
  8124. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8125. string customer = GetPostString("customer");
  8126. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8127. string date1 = GetPostString("date1");
  8128. string date2 = GetPostString("date2");
  8129. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8130. if (dw.Length > 0) lw.Add(dw);
  8131. string price1 = GetPostString("price1");
  8132. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8133. string price2 = GetPostString("price2");
  8134. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8135. string returndate1 = GetPostString("returndate1");
  8136. string returndate2 = GetPostString("returndate2");
  8137. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8138. if (dw1.Length > 0) lw.Add(dw1);
  8139. string billtype = GetPostString("billtype");
  8140. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8141. string billstate = GetPostString("billstate");
  8142. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8143. string usershop = CurrentUser.User.pemShop;
  8144. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8145. dStruct.Order = "createTime desc";
  8146. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8147. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8148. //foreach (DataRow dr in dt.Rows)
  8149. //{
  8150. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8151. //}
  8152. writeGridDataTableJson(dStruct.TotalCount, dt);
  8153. }
  8154. public void modify_erp_billinfo()
  8155. {
  8156. if (UrlPostParmsCheck("ID"))
  8157. {
  8158. string eid = GetPostString("ID");
  8159. CeErpBill bill_entity = null;
  8160. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8161. if (bill_entity != null)
  8162. {
  8163. bill_entity.tid = GetPostString("tid");
  8164. bill_entity.title = GetPostString("title");
  8165. bill_entity.tax = GetPostString("tax");
  8166. bill_entity.bank = GetPostString("bank");
  8167. bill_entity.bankac = GetPostString("bankac");
  8168. bill_entity.address = GetPostString("address");
  8169. bill_entity.phone = GetPostString("phone");
  8170. bill_entity.price = GetPostString("price");
  8171. bill_entity.productId = GetPostInt("ProductName");
  8172. bill_entity.num = GetPostInt("num");
  8173. bill_entity.unit = GetPostString("unit");
  8174. bill_entity.type = GetPostString("type");
  8175. bill_entity.sendType = GetPostString("SendType");
  8176. bill_entity.email = GetPostString("email");
  8177. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8178. bill_entity.shopName = GetPostString("ShopName");
  8179. bill_entity.applymemo = GetPostString("applymemo");
  8180. bill_entity.modifyTime = DateTime.Now;
  8181. bill_entity.createTime = DateTime.Now;
  8182. bill_entity.state = 0;
  8183. bill_entity.Update();
  8184. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8185. returnSuccessMsg("发票修改成功!");
  8186. return;
  8187. }
  8188. returnErrorMsg("找不到对应记录");
  8189. }
  8190. }
  8191. public void set_erp_invoicing()
  8192. {
  8193. if (UrlPostParmsCheck("id"))
  8194. {
  8195. try
  8196. {
  8197. string eid = GetPostString("id");
  8198. CeErpBill bill_entity = null;
  8199. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8200. if (bill_entity != null)
  8201. {
  8202. int ComId = GetPostInt("ComId");
  8203. //string memo = GetPostString("Memo");
  8204. int allInfo = GetPostInt("allinfo");
  8205. string clert = CurrentUser.User.Name;
  8206. //string detailValue = GetPostString("detailvalue");
  8207. string billId = bill_entity.billOrderId;
  8208. string[] billIdList = billId.Split(',');
  8209. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8210. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8211. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8212. {
  8213. billCount += 1;
  8214. }
  8215. if (billId.Length <= 0 || billIdList.Length != billCount)
  8216. {
  8217. bill_entity.billOrderId = "";
  8218. string prebill = "ltb";
  8219. for (int idx = 1; idx <= billCount; idx++)
  8220. {
  8221. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8222. string billoid = prebill + idx + dtstr;
  8223. bill_entity.billOrderId += billoid;
  8224. if (idx < billCount)
  8225. {
  8226. bill_entity.billOrderId += ",";
  8227. }
  8228. }
  8229. }
  8230. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8231. if (bill_entity.state == 5)
  8232. {
  8233. string errMsg = bill_entity.failerror;
  8234. string[] errlist = errMsg.Split('|');
  8235. string[] errTags = new string[errlist.Length];
  8236. for (int itag = 0; itag < errlist.Length; itag++)
  8237. {
  8238. if (errlist[itag].Length <= 0) continue;
  8239. errTags[itag] = errlist[itag].Split('&')[0];
  8240. }
  8241. for (int iii = 0; iii < errTags.Length; iii++)
  8242. {
  8243. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8244. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8245. if (billOrderList.Length >= erroBillOrderTag)
  8246. {
  8247. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8248. if (needModifyBillId.Length <= 19)
  8249. {
  8250. needModifyBillId = needModifyBillId + "1";
  8251. }
  8252. else
  8253. {
  8254. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8255. last = last + 1;
  8256. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8257. }
  8258. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8259. }
  8260. }
  8261. }
  8262. bool isHaveBillSucces = false;
  8263. string totalRes = "";
  8264. bill_entity.failerror = "";
  8265. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8266. {
  8267. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8268. totalRes += res;
  8269. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8270. {
  8271. isHaveBillSucces = true;
  8272. bill_entity.comId = ComId;
  8273. bill_entity.state = 1;
  8274. bill_entity.executeTime = DateTime.Now;
  8275. bill_entity.executeUser = clert;
  8276. }
  8277. else
  8278. {
  8279. bill_entity.state = 5;
  8280. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8281. }
  8282. }
  8283. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8284. bill_entity.Update();
  8285. if (isHaveBillSucces)
  8286. {
  8287. StringBuilder sql = new StringBuilder();
  8288. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8289. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8290. }
  8291. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8292. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8293. {
  8294. returnErrorMsg("开票失败");
  8295. }
  8296. else
  8297. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8298. return;
  8299. }
  8300. returnErrorMsg("找不到对应记录");
  8301. }
  8302. catch (Exception ex)
  8303. {
  8304. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8305. returnErrorMsg("操作失败");
  8306. }
  8307. }
  8308. }
  8309. public void get_erp_invoicing_back()
  8310. {
  8311. if (UrlPostParmsCheck("id"))
  8312. {
  8313. try
  8314. {
  8315. string id = GetPostString("id");
  8316. CeErpBill entiy = CeErpBill.Get(id);
  8317. if (entiy != null)
  8318. {
  8319. if (entiy.state == 0)
  8320. {
  8321. returnErrorMsg("发票还未开具");
  8322. return;
  8323. }
  8324. string[] billOrderList = entiy.billOrderId.Split(',');
  8325. int iTag = 0;
  8326. entiy.fplsh = "";
  8327. entiy.fpdm = "";
  8328. entiy.fphm = "";
  8329. foreach (string billOrderId in billOrderList)
  8330. {
  8331. iTag++;
  8332. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8333. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8334. {
  8335. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8336. try
  8337. {
  8338. Invoicing_get_response_Obj iObj = null;
  8339. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8340. if (iObj != null)
  8341. {
  8342. entiy.state = 2;
  8343. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8344. entiy.fpdm += iObj.list[0].c_fpdm;
  8345. entiy.fphm += iObj.list[0].c_fphm;
  8346. if (iTag < billOrderList.Length)
  8347. {
  8348. entiy.fplsh += ",";
  8349. entiy.fpdm += ",";
  8350. entiy.fphm += ",";
  8351. }
  8352. entiy.Update();
  8353. }
  8354. StringBuilder sql = new StringBuilder();
  8355. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8356. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8357. returnSuccessMsg("开票成功");
  8358. }
  8359. catch (Exception ex)
  8360. {
  8361. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8362. }
  8363. return;
  8364. }
  8365. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8366. {
  8367. var res_obj = new
  8368. {
  8369. data = "开票中"
  8370. };
  8371. string ro_json = JsonConvert.SerializeObject(res_obj);
  8372. returnSuccess(ro_json);
  8373. return;
  8374. }
  8375. else
  8376. {
  8377. int eidx = res.IndexOf("c_resultmsg");
  8378. int lidx = res.IndexOf("c_status");
  8379. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8380. entiy.state = 5;
  8381. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8382. entiy.Update();
  8383. returnErrorMsg("开票失败");
  8384. return;
  8385. }
  8386. }
  8387. }
  8388. }
  8389. catch (Exception ex)
  8390. {
  8391. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8392. }
  8393. return;
  8394. }
  8395. }
  8396. public void get_erp_invoicing()
  8397. {
  8398. if (UrlPostParmsCheck("id"))
  8399. {
  8400. try
  8401. {
  8402. string id = GetPostString("id");
  8403. CeErpBill entiy = CeErpBill.Get(id);
  8404. if (entiy != null)
  8405. {
  8406. if (entiy.state == 0)
  8407. {
  8408. returnErrorMsg("发票还未开具");
  8409. return;
  8410. }
  8411. if (entiy.sendType == "纸质发票")
  8412. {
  8413. if (entiy.img.Length <= 0)
  8414. {
  8415. returnErrorMsg("查无纸质发票");
  8416. return;
  8417. }
  8418. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8419. returnSuccess(returnres);
  8420. return;
  8421. }
  8422. string[] billOrderList = entiy.billOrderId.Split(',');
  8423. int iTag = 0;
  8424. string fpUrl = "";
  8425. entiy.fplsh = "";
  8426. entiy.fpdm = "";
  8427. entiy.fphm = "";
  8428. foreach (string billOrderId in billOrderList)
  8429. {
  8430. iTag++;
  8431. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8432. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8433. {
  8434. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8435. Invoicing_get_response_Obj iObj = null;
  8436. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8437. if (iObj != null)
  8438. {
  8439. //entiy.state = 2;
  8440. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8441. entiy.fpdm += iObj.list[0].c_fpdm;
  8442. entiy.fphm += iObj.list[0].c_fphm;
  8443. if (iTag < billOrderList.Length)
  8444. {
  8445. entiy.fplsh += ",";
  8446. entiy.fpdm += ",";
  8447. entiy.fphm += ",";
  8448. }
  8449. entiy.Update();
  8450. fpUrl += iObj.list[0].c_url + ",";
  8451. }
  8452. //returnSuccess(res);
  8453. StringBuilder sql = new StringBuilder();
  8454. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8455. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8456. }
  8457. else
  8458. {
  8459. int eidx = res.IndexOf("c_resultmsg");
  8460. //int lidx = res.IndexOf("c_status");
  8461. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8462. //开票失败
  8463. entiy.state = 5;
  8464. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8465. entiy.Update();
  8466. returnErrorMsg("开票失败");
  8467. return;
  8468. }
  8469. }
  8470. var returnObj = new
  8471. {
  8472. data = fpUrl
  8473. };
  8474. string ro_json = JsonConvert.SerializeObject(returnObj);
  8475. returnSuccess(ro_json);
  8476. }
  8477. }
  8478. catch (Exception ex)
  8479. {
  8480. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8481. }
  8482. return;
  8483. }
  8484. }
  8485. public void save_erp_billimg()
  8486. {
  8487. if (UrlPostParmsCheck("id"))
  8488. {
  8489. string eid = GetPostString("id");
  8490. CeErpBill bill_entity = null;
  8491. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8492. if (bill_entity != null)
  8493. {
  8494. bill_entity.img = GetPostString("img");
  8495. bill_entity.executeTime = DateTime.Now;
  8496. bill_entity.state = 2;
  8497. bill_entity.Update();
  8498. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8499. returnSuccessMsg("保存成功");
  8500. }
  8501. return;
  8502. }
  8503. }
  8504. public void upd_erp_billreturnback()
  8505. {
  8506. if (UrlPostParmsCheck("id"))
  8507. {
  8508. int eid = GetPostInt("id");
  8509. CeErpBill bill_entity = null;
  8510. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8511. if (bill_entity != null)
  8512. {
  8513. bill_entity.state = 3;
  8514. bill_entity.returnReason = GetPostString("reason");
  8515. bill_entity.Update();
  8516. returnSuccessMsg("驳回成功!");
  8517. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8518. }
  8519. return;
  8520. }
  8521. }
  8522. public void cancel_erp_bill()
  8523. {
  8524. if (UrlPostParmsCheck("id"))
  8525. {
  8526. int eid = GetPostInt("id");
  8527. int detailValue = GetPostInt("detailvalue");
  8528. CeErpBill bill_entity = null;
  8529. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8530. string cres = "";
  8531. string gres = "";
  8532. if (bill_entity != null)
  8533. {
  8534. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8535. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8536. {
  8537. int iTag = 0;
  8538. bill_entity.fplsh = "";
  8539. bill_entity.fpdm = "";
  8540. bill_entity.fphm = "";
  8541. foreach (string billOrderId in billOrderList)
  8542. {
  8543. iTag++;
  8544. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8545. if (gres.IndexOf("success") != -1)
  8546. {
  8547. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8548. Invoicing_get_response_Obj iObj = null;
  8549. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8550. if (iObj != null)
  8551. {
  8552. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8553. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8554. bill_entity.fphm += iObj.list[0].c_fphm;
  8555. if (iTag < billOrderList.Length)
  8556. {
  8557. bill_entity.fplsh += ",";
  8558. bill_entity.fpdm += ",";
  8559. bill_entity.fphm += ",";
  8560. }
  8561. bill_entity.Update();
  8562. }
  8563. }
  8564. else
  8565. {
  8566. returnErrorMsg(gres);
  8567. return;
  8568. }
  8569. }
  8570. }
  8571. if (bill_entity.sendType == "纸质发票")
  8572. {
  8573. //作废
  8574. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8575. //if (DateTime.Now.Month == extime.Month)
  8576. //{
  8577. //cres = taobaoHelper.cancel_invoicing(eid);
  8578. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8579. //{
  8580. bill_entity.state = 4;//已作废
  8581. bill_entity.Update();
  8582. returnSuccessMsg("发票已作废");
  8583. return;
  8584. //}
  8585. //else
  8586. //{
  8587. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8588. // bill_entity.Update();
  8589. // returnErrorMsg(cres);
  8590. // return;
  8591. //}
  8592. //}
  8593. //else
  8594. //{
  8595. // returnErrorMsg("纸质发票只能作废本月的发票");
  8596. // return;
  8597. //}
  8598. }
  8599. //红冲
  8600. int redTag = 0;
  8601. string[] fpdmList = bill_entity.fpdm.Split(',');
  8602. string[] fphmList = bill_entity.fphm.Split(',');
  8603. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8604. {
  8605. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8606. return;
  8607. }
  8608. foreach (string billOrderId in billOrderList)
  8609. {
  8610. redTag++;
  8611. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8612. cres += onecres;
  8613. cres += ",";
  8614. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8615. {
  8616. bill_entity.state = 4;//已作废
  8617. //bill_entity.Update();
  8618. //returnSuccessMsg("发票已红冲");
  8619. }
  8620. else if (onecres.IndexOf("重复冲红") != -1)
  8621. {
  8622. bill_entity.state = 4;//已作废
  8623. //bill_entity.Update();
  8624. //returnSuccessMsg("发票已红冲");
  8625. }
  8626. else
  8627. {
  8628. string errmsg = commonHelper.KeepChinese(onecres);
  8629. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8630. }
  8631. }
  8632. bill_entity.Update();
  8633. if (cres.IndexOf("失败") != -1)
  8634. returnErrorMsg("红冲失败");
  8635. else
  8636. returnSuccessMsg("发票已红冲");
  8637. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8638. return;
  8639. }
  8640. return;
  8641. }
  8642. }
  8643. public void del_erp_billorder()
  8644. {
  8645. if (UrlPostParmsCheck("id"))
  8646. {
  8647. string eid = GetPostString("id");
  8648. CeErpBill.Del(eid);
  8649. CeErpBill bill = CeErpBill.Get(eid);
  8650. if (bill != null)
  8651. {
  8652. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8653. }
  8654. returnSuccessMsg("删除成功");
  8655. }
  8656. }
  8657. public void finish_erp_bill()
  8658. {
  8659. if (UrlPostParmsCheck("ids"))
  8660. {
  8661. string eids = GetPostString("ids");
  8662. string[] list = eids.Split(',');
  8663. foreach (string eid in list)
  8664. {
  8665. CeErpBill bill = CeErpBill.Get(eid);
  8666. if (bill != null)
  8667. {
  8668. bill.state = 2;
  8669. bill.Update();
  8670. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8671. }
  8672. }
  8673. returnSuccessMsg("操作成功");
  8674. }
  8675. }
  8676. public void get_erp_returncash()
  8677. {
  8678. DataStruct dStruct = GetPostStruct();
  8679. List<string> lw = new List<string>();
  8680. string tid = GetPostString("tid");
  8681. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8682. string shopname = GetPostString("shopname");
  8683. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8684. string buyernick = GetPostString("buyer_nick");
  8685. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8686. string customer = GetPostString("customer");
  8687. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8688. string returndate1 = GetPostString("returndate1");
  8689. string returndate2 = GetPostString("returndate2");
  8690. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8691. if (dw.Length > 0) lw.Add(dw);
  8692. string finishDate1 = GetPostString("finishdate1");
  8693. string finishDate2 = GetPostString("finishdate2");
  8694. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8695. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8696. string returntype = GetPostString("returntype");
  8697. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8698. string returnvstate = GetPostString("returnvstate");
  8699. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8700. dStruct.Order = "created desc";
  8701. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8702. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8703. writeGridDataTableJson(dStruct.TotalCount, dt);
  8704. }
  8705. public void get_erp_staygoods()
  8706. {
  8707. DataStruct dStruct = GetPostStruct();
  8708. List<string> lw = new List<string>();
  8709. string tid = GetPostString("tid");
  8710. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8711. string shopname = GetPostString("shopname");
  8712. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8713. string wangwang = GetPostString("wangwang");
  8714. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8715. string customer = GetPostString("customer");
  8716. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8717. string returndate1 = GetPostString("returndate1");
  8718. string returndate2 = GetPostString("returndate2");
  8719. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8720. if (dw.Length > 0) lw.Add(dw);
  8721. string finishDate1 = GetPostString("finishdate1");
  8722. string finishDate2 = GetPostString("finishdate2");
  8723. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8724. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8725. string returnvstate = GetPostString("returnvstate");
  8726. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8727. string persuadetype = GetPostString("persuadetype");
  8728. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8729. string customerOrg = GetPostString("customerOrg");
  8730. if (customerOrg.Length > 0)
  8731. {
  8732. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8733. }
  8734. dStruct.Order = "creata_time desc";
  8735. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8736. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8737. writeGridDataTableJson(dStruct.TotalCount, dt);
  8738. }
  8739. public void upd_erp_staygoods()
  8740. {
  8741. if (UrlPostParmsCheck("id"))
  8742. {
  8743. int eid = GetPostInt("id");
  8744. CeErpStayGoods entity = null;
  8745. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8746. if (entity != null)
  8747. {
  8748. entity.audit_type = 1;
  8749. entity.audit_time = DateTime.Now;
  8750. entity.audit_u_id = CurrentUser.UserID;
  8751. entity.audit_u_name = CurrentUser.UserName;
  8752. entity.Update();
  8753. returnSuccessMsg("审核成功!");
  8754. return;
  8755. }
  8756. returnErrorMsg("找不到订单记录");
  8757. }
  8758. }
  8759. public void upd_erp_stayGoodsback()
  8760. {
  8761. if (UrlPostParmsCheck("id"))
  8762. {
  8763. int eid = GetPostInt("id");
  8764. CeErpStayGoods entity = null;
  8765. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8766. if (entity != null)
  8767. {
  8768. entity.audit_text = GetPostString("reason");
  8769. entity.audit_type = 2;
  8770. entity.audit_time = DateTime.Now;
  8771. entity.audit_u_id = CurrentUser.UserID;
  8772. entity.audit_u_name = CurrentUser.UserName;
  8773. entity.Update();
  8774. returnSuccessMsg("退回成功!");
  8775. return;
  8776. }
  8777. returnErrorMsg("找不到订单记录");
  8778. }
  8779. }
  8780. public void upd_erp_returncashverify()
  8781. {
  8782. if (UrlPostParmsCheck("ID"))
  8783. {
  8784. int eid = GetPostInt("ID");
  8785. CeErpReturnCash entity = null;
  8786. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8787. if (entity != null)
  8788. {
  8789. entity.cashstate = 1;
  8790. entity.verifytime = DateTime.Now;
  8791. entity.verifyuserid = CurrentUser.UserID;
  8792. entity.Update();
  8793. returnSuccessMsg("审核成功!");
  8794. return;
  8795. }
  8796. returnErrorMsg("找不到订单记录");
  8797. }
  8798. }
  8799. public void upd_all_erp_returncashverify()
  8800. {
  8801. if (UrlPostParmsCheck("ID"))
  8802. {
  8803. String[] list = GetPostString("ID").Split(',');
  8804. CeErpReturnCash entity = null;
  8805. for (int i = 0; i < list.Length; i++)
  8806. {
  8807. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8808. if (entity != null)
  8809. {
  8810. if (entity.cashstate == 1)
  8811. {
  8812. returnErrorMsg("已审核过的订单不需要在审核!");
  8813. return;
  8814. }
  8815. entity.cashstate = 1;
  8816. entity.verifytime = DateTime.Now;
  8817. entity.verifyuserid = CurrentUser.UserID;
  8818. entity.Update();
  8819. }
  8820. }
  8821. returnSuccessMsg("审核成功!");
  8822. return;
  8823. }
  8824. }
  8825. public void upd_erp_returncashback()
  8826. {
  8827. if (UrlPostParmsCheck("ID"))
  8828. {
  8829. int eid = GetPostInt("ID");
  8830. CeErpReturnCash entity = null;
  8831. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8832. if (entity != null)
  8833. {
  8834. entity.backreason = GetPostString("reason");
  8835. entity.cashstate = 2;
  8836. entity.verifytime = DateTime.Now;
  8837. entity.verifyuserid = CurrentUser.UserID;
  8838. entity.Update();
  8839. returnSuccessMsg("退回成功!");
  8840. return;
  8841. }
  8842. returnErrorMsg("找不到订单记录");
  8843. }
  8844. }
  8845. public void upd_erp_returnprice()
  8846. {
  8847. if (UrlPostParmsCheck("ID"))
  8848. {
  8849. int eid = GetPostInt("ID");
  8850. CeErpReturnCash entity = null;
  8851. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8852. if (entity != null)
  8853. {
  8854. if (entity.cashstate == 1)
  8855. {
  8856. returnErrorMsg("审核通过了不能改");
  8857. return;
  8858. }
  8859. entity.returnprice = GetPostDouble("returnprice");
  8860. entity.Update();
  8861. returnSuccessMsg("修改成功!");
  8862. return;
  8863. }
  8864. returnErrorMsg("找不到订单记录");
  8865. }
  8866. }
  8867. public void del_erp_returncash()
  8868. {
  8869. if (UrlPostParmsCheck("ID"))
  8870. {
  8871. int eid = GetPostInt("ID");
  8872. CeErpReturnCash.Del(eid);
  8873. returnSuccessMsg("操作成功");
  8874. return;
  8875. }
  8876. }
  8877. public void test_for_do_sql()
  8878. {
  8879. string sql = GetPostString("sqlstr");
  8880. if (sql.Length > 0)
  8881. {
  8882. try
  8883. {
  8884. DbHelper.DbConn.ExecuteNonQuery(sql);
  8885. var res_obj = new
  8886. {
  8887. data = "成功",
  8888. };
  8889. string ro_json = JsonConvert.SerializeObject(res_obj);
  8890. returnSuccess(ro_json);
  8891. }
  8892. catch (Exception ex)
  8893. {
  8894. var res_obj = new
  8895. {
  8896. data = ex.Message,
  8897. };
  8898. string ro_json = JsonConvert.SerializeObject(res_obj);
  8899. returnSuccess(ro_json);
  8900. }
  8901. }
  8902. }
  8903. public void get_user_info()
  8904. {
  8905. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8906. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8907. }
  8908. public void get_total_data()
  8909. {
  8910. int userId = CurrentUser.UserID;
  8911. string sql = "";
  8912. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8913. {
  8914. 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);
  8915. }
  8916. else
  8917. {
  8918. 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 " +
  8919. "(select ID from CE_ErpUser where ID = {0}) d " +
  8920. "left join " +
  8921. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8922. ") a on d.ID = a.id left join " +
  8923. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8924. ") b on a.id = b.id1 left join" +
  8925. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8926. ") c on a.id = c.id2;", userId);
  8927. }
  8928. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8929. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8930. }
  8931. public void get_date_area_total_data2()
  8932. {
  8933. int userId = CurrentUser.UserID;
  8934. string date_type = GetPostString("timetype");
  8935. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8936. string sql = "";
  8937. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8938. {
  8939. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8940. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8941. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8942. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8943. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8944. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8945. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8946. ") a on e.ID = a.id left join " +
  8947. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8948. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8949. ") b on a.id = b.id1 " +
  8950. "left join " +
  8951. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8952. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8953. ") c on a.id = c.id2 " +
  8954. "left join " +
  8955. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8956. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8957. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8958. }
  8959. else
  8960. {
  8961. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8962. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8963. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8964. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8965. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8966. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8967. ") a on e.ID = a.id left join " +
  8968. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8969. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8970. ") c on a.id = c.id2 " +
  8971. "left join " +
  8972. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8973. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8974. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8975. }
  8976. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8977. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8978. }
  8979. public void get_date_area_total_data()
  8980. {
  8981. int userId = CurrentUser.UserID;
  8982. string date_type = GetPostString("timetype");
  8983. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8984. string date1 = searchDT[0].ToString();
  8985. string date2 = searchDT[1].ToString();
  8986. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8987. {
  8988. SqlParameter[] sqlParameter ={
  8989. new SqlParameter("@userId", SqlDbType.Int,4),
  8990. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8991. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8992. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8993. };
  8994. sqlParameter[0].Value = userId;
  8995. sqlParameter[1].Value = date1;
  8996. sqlParameter[2].Value = date2;
  8997. sqlParameter[3].Direction = ParameterDirection.Output;
  8998. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8999. string res = sqlParameter[3].Value.ToString();
  9000. var res_obj = new
  9001. {
  9002. data = res
  9003. };
  9004. string ro_json = JsonConvert.SerializeObject(res_obj);
  9005. returnSuccess(ro_json);
  9006. }
  9007. else
  9008. {
  9009. SqlParameter[] sqlParameter ={
  9010. new SqlParameter("@userId", SqlDbType.Int,4),
  9011. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9012. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9013. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9014. };
  9015. sqlParameter[0].Value = userId;
  9016. sqlParameter[1].Value = date1;
  9017. sqlParameter[2].Value = date2;
  9018. sqlParameter[3].Direction = ParameterDirection.Output;
  9019. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9020. string res = sqlParameter[3].Value.ToString();
  9021. var res_obj = new
  9022. {
  9023. data = res
  9024. };
  9025. string ro_json = JsonConvert.SerializeObject(res_obj);
  9026. returnSuccess(ro_json);
  9027. }
  9028. //writeGridDataViewJson(dt.Rows.Count, dv);
  9029. }
  9030. public void get_order_list()
  9031. {
  9032. string strFields = GetPostString("paraFields");
  9033. string strOrder = GetPostString("paraOrder");
  9034. string strWhere = GetPostString("paraWhere");
  9035. string strPageSize = GetPostString("paraPageSize");
  9036. DataStruct dStruct = GetPostStruct();
  9037. dStruct.PageSize = int.Parse(strPageSize);
  9038. dStruct.Fileds = strFields;
  9039. dStruct.Order = strOrder;
  9040. dStruct.MainWhere = strWhere;
  9041. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9042. writeGridDataTableJson(dStruct.TotalCount, dt);
  9043. }
  9044. ////获取待开始订单列表
  9045. //public void get_wait_design_order_list()
  9046. //{
  9047. // string date_type = GetPostString("date_type");
  9048. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9049. // DataStruct dStruct = GetPostStruct();
  9050. // dStruct.PageSize = 1000;
  9051. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9052. // List<string> lw = new List<string>();
  9053. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9054. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9055. // dStruct.Order = "WaitDesignTime asc";
  9056. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9057. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9058. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9059. //}
  9060. //获取完成单量排名
  9061. public void get_finish_order_count_ranking()
  9062. {
  9063. /* string date_type = GetPostString("date_type");
  9064. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9065. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9066. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9067. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9068. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9069. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9070. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9071. writeGridDataTableJson(0, new DataTable());
  9072. }
  9073. public void get_finish_order_amount_ranking()
  9074. {
  9075. /*string date_type = GetPostString("date_type");
  9076. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9077. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9078. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9079. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9080. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9081. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9082. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9083. writeGridDataTableJson(0, new DataTable());
  9084. }
  9085. public void get_finish_refund_count_ranking()
  9086. {
  9087. string date_type = GetPostString("date_type");
  9088. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9089. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9090. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9091. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9092. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9093. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9094. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9095. writeGridDataTableJson(dt.Rows.Count, dt);
  9096. }
  9097. public void get_finish_refund_amount_ranking()
  9098. {
  9099. string date_type = GetPostString("date_type");
  9100. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9101. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9102. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9103. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9104. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9105. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9106. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9107. writeGridDataTableJson(dt.Rows.Count, dt);
  9108. }
  9109. public void set_erp_finishorder_director()
  9110. {
  9111. if (UrlPostParmsCheck("ctid"))
  9112. {
  9113. string eid = GetPostString("ctid");
  9114. CeErpTradeCell entity = null;
  9115. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9116. if (entity != null)
  9117. {
  9118. entity.OrderState = 8;
  9119. entity.Update();
  9120. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9121. returnSuccessMsg("操作成功!");
  9122. return;
  9123. }
  9124. returnErrorMsg("找不到记录");
  9125. }
  9126. }
  9127. public void get_erp_placeregistlist()
  9128. {
  9129. DataStruct dStruct = GetPostStruct();
  9130. List<string> lw = new List<string>();
  9131. string outsid = GetPostString("outsid");
  9132. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9133. string memo = GetPostString("memo");
  9134. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9135. string filename = GetPostString("filename");
  9136. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9137. string islate = GetPostString("islate");
  9138. if (islate.Length > 0)
  9139. {
  9140. if (islate == "1")
  9141. lw.Add(string.Format("OutLate>0"));
  9142. else
  9143. lw.Add(string.Format("OutLate=0"));
  9144. }
  9145. string placedate1 = GetPostString("placedate1");
  9146. string placedate2 = GetPostString("placedate2");
  9147. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9148. if (dw.Length > 0) lw.Add(dw);
  9149. string deliveryDate1 = GetPostString("deliverydate1");
  9150. string deliveryDate2 = GetPostString("deliverydate2");
  9151. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9152. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9153. dStruct.Order = "ID desc";
  9154. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9155. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9156. writeGridDataTableJson(dStruct.TotalCount, dt);
  9157. }
  9158. public void ins_erp_placeregist()
  9159. {
  9160. if (UrlPostParmsCheck("id"))
  9161. {
  9162. string eid = GetPostString("id");
  9163. CeErpPlaceRegister entity = null;
  9164. if (eid == "0")//新增
  9165. {
  9166. entity = new CeErpPlaceRegister();
  9167. string xdTime = GetPostString("placeTime");
  9168. if (xdTime.Length > 0)
  9169. {
  9170. entity.PlactTime = Convert.ToDateTime(xdTime);
  9171. }
  9172. string fhTime = GetPostString("deliveryTime");
  9173. if (fhTime.Length > 0)
  9174. {
  9175. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9176. }
  9177. string preTime = GetPostString("preOutTime");
  9178. if (preTime.Length > 0)
  9179. {
  9180. entity.PreOutTime = Convert.ToDateTime(preTime);
  9181. }
  9182. entity.DeliveryCount = GetPostInt("deliveryCount");
  9183. entity.ReceiveCount = GetPostInt("receiveCount");
  9184. entity.OutSid = GetPostString("outSid");
  9185. entity.FileName = GetPostString("fileName");
  9186. entity.Memo = GetPostString("memo");
  9187. entity.AddUserId = CurrentUser.UserID;
  9188. entity.CreateTime = DateTime.Now;
  9189. entity.Img = GetPostString("img");
  9190. entity.Supplier = GetPostInt("supplier");
  9191. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9192. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9193. {
  9194. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9195. DateTime dt2 = (DateTime)entity.PreOutTime;
  9196. TimeSpan span = dt1.Subtract(dt2);
  9197. if (span.Days > 0)
  9198. {
  9199. entity.OutLate = span.Days;
  9200. }
  9201. }
  9202. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9203. entity.Create();
  9204. returnSuccessMsg("添加成功!");
  9205. return;
  9206. }
  9207. else //修改
  9208. {
  9209. entity = CeErpPlaceRegister.Get(eid);
  9210. if (entity != null)
  9211. {
  9212. string xdTime = GetPostString("placeTime");
  9213. if (xdTime.Length > 0)
  9214. {
  9215. entity.PlactTime = Convert.ToDateTime(xdTime);
  9216. }
  9217. string fhTime = GetPostString("deliveryTime");
  9218. if (fhTime.Length > 0)
  9219. {
  9220. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9221. }
  9222. string preTime = GetPostString("preOutTime");
  9223. if (preTime.Length > 0)
  9224. {
  9225. entity.PreOutTime = Convert.ToDateTime(preTime);
  9226. }
  9227. entity.DeliveryCount = GetPostInt("deliveryCount");
  9228. entity.ReceiveCount = GetPostInt("receiveCount");
  9229. if (entity.DeliveryCount == entity.ReceiveCount)
  9230. {
  9231. entity.CurState = "已完成";
  9232. }
  9233. else
  9234. {
  9235. entity.CurState = "未完成";
  9236. }
  9237. entity.OutSid = GetPostString("outSid");
  9238. entity.FileName = GetPostString("fileName");
  9239. entity.Memo = GetPostString("memo");
  9240. entity.Img = GetPostString("img");
  9241. entity.Supplier = GetPostInt("supplier");
  9242. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9243. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9244. {
  9245. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9246. DateTime dt2 = (DateTime)entity.PreOutTime;
  9247. TimeSpan span = dt1.Subtract(dt2);
  9248. if (span.Days > 0)
  9249. {
  9250. entity.OutLate = span.Days;
  9251. }
  9252. }
  9253. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9254. entity.Update();
  9255. returnSuccessMsg("修改成功");
  9256. return;
  9257. }
  9258. returnErrorMsg("找不到对应的记录");
  9259. return;
  9260. }
  9261. }
  9262. returnErrorMsg("缺少必要参数");
  9263. }
  9264. public void del_erp_placeregist()
  9265. {
  9266. string eid = GetPostString("id");
  9267. CeErpPlaceRegister.Del(eid);
  9268. returnSuccessMsg("删除成功!");
  9269. return;
  9270. }
  9271. public void ins_erp_placeregistbyorder()
  9272. {
  9273. string ctid = GetPostString("ctid");
  9274. if (ctid.Length > 0)
  9275. {
  9276. StringBuilder sql = new StringBuilder();
  9277. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9278. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9279. if (dt.Rows.Count > 0)
  9280. {
  9281. foreach (DataRow dr in dt.Rows)
  9282. {
  9283. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9284. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9285. entity.AddUserId = CurrentUser.UserID;
  9286. entity.tid = dr["tid"].ToString();
  9287. entity.Did = Convert.ToString(dr["ctid"]);
  9288. entity.splitTag = dr["SplitTag"].ToString();
  9289. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9290. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9291. if (pre_ctid.Length > 0)
  9292. {
  9293. sellmemo = sellmemo.Replace(pre_ctid, "");
  9294. }
  9295. sellmemo = sellmemo.Replace("[", "");
  9296. sellmemo = sellmemo.Replace("]", "");
  9297. entity.FileName = sellmemo;
  9298. string count = dr["ProductCount"].ToString();
  9299. int usecount = commonHelper.getIntCountFromString(count);
  9300. entity.DeliveryCount = usecount;
  9301. entity.CurState = "未完成";
  9302. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9303. {
  9304. entity.Supplier = 24;//dl手提袋定制
  9305. }
  9306. else
  9307. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9308. entity.CreateTime = DateTime.Now;
  9309. entity.Create();
  9310. }
  9311. returnSuccessMsg("操作成功");
  9312. return;
  9313. }
  9314. returnErrorMsg("没有找到对应订单");
  9315. return;
  9316. }
  9317. returnErrorMsg("缺少订单编号");
  9318. return;
  9319. }
  9320. public void get_erp_persuadelist()
  9321. {
  9322. DataStruct dStruct = GetPostStruct();
  9323. List<string> lw = new List<string>();
  9324. string ctid = GetPostString("ctid");
  9325. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9326. string shopname = GetPostString("shopname");
  9327. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9328. string buyernick = GetPostString("buyer_nick");
  9329. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9330. string customer = GetPostString("customer");
  9331. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9332. string returndate1 = GetPostString("returndate1");
  9333. string returndate2 = GetPostString("returndate2");
  9334. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9335. if (dw.Length > 0) lw.Add(dw);
  9336. string finishDate1 = GetPostString("finishdate1");
  9337. string finishDate2 = GetPostString("finishdate2");
  9338. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9339. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9340. string persuadetype = GetPostString("persuadetype");
  9341. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9342. string returnvstate = GetPostString("returnvstate");
  9343. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9344. dStruct.Order = "created desc";
  9345. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9346. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9347. writeGridDataTableJson(dStruct.TotalCount, dt);
  9348. }
  9349. public void upd_erp_returnpersuadeback()
  9350. {
  9351. if (UrlPostParmsCheck("ID"))
  9352. {
  9353. int eid = GetPostInt("ID");
  9354. CeErpPersuade entity = null;
  9355. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9356. if (entity != null)
  9357. {
  9358. entity.backreason = GetPostString("reason");
  9359. entity.pstate = 2;
  9360. entity.verifytime = DateTime.Now;
  9361. entity.verifyuserid = CurrentUser.UserID;
  9362. entity.Update();
  9363. returnSuccessMsg("退回成功!");
  9364. return;
  9365. }
  9366. returnErrorMsg("找不到订单记录");
  9367. }
  9368. }
  9369. public void upd_erp_returnpersuadeverify()
  9370. {
  9371. if (UrlPostParmsCheck("ID"))
  9372. {
  9373. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9374. {
  9375. returnErrorMsg("暂无权限审核");
  9376. return;
  9377. }
  9378. int eid = GetPostInt("ID");
  9379. CeErpPersuade entity = null;
  9380. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9381. if (entity != null)
  9382. {
  9383. entity.pstate = 1;
  9384. entity.verifytime = DateTime.Now;
  9385. entity.verifyuserid = CurrentUser.UserID;
  9386. entity.Update();
  9387. returnSuccessMsg("审核成功!");
  9388. return;
  9389. }
  9390. returnErrorMsg("找不到订单记录");
  9391. }
  9392. }
  9393. public void del_erp_persuade()
  9394. {
  9395. if (UrlPostParmsCheck("ID"))
  9396. {
  9397. int eid = GetPostInt("ID");
  9398. CeErpPersuade.Del(eid);
  9399. returnSuccessMsg("操作成功");
  9400. return;
  9401. }
  9402. }
  9403. public void get_erp_oldcustoupload()
  9404. {
  9405. DataStruct dStruct = GetPostStruct();
  9406. List<string> lw = new List<string>();
  9407. string buyernick = GetPostString("buyer_nick");
  9408. if (buyernick.Length > 0)
  9409. {
  9410. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9411. }
  9412. else
  9413. return;
  9414. dStruct.Order = "pay_time desc";
  9415. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9416. DataTable dt = null;
  9417. dt = WebCache.GetData("view_erptradecell", dStruct);
  9418. writeGridDataTableJson(dStruct.TotalCount, dt);
  9419. }
  9420. public void get_erp_checkorderlist()
  9421. {
  9422. DataStruct dStruct = GetPostStruct();
  9423. List<string> lw = new List<string>();
  9424. string tid = GetPostString("ctid");
  9425. if (tid.Length > 0)
  9426. {
  9427. string select_tid = getTidByCtid(tid);
  9428. lw.Add(string.Format("tid='{0}'", select_tid));
  9429. }
  9430. string shopname = GetPostString("shopname");
  9431. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9432. string buyernick = GetPostString("buyer_nick");
  9433. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9434. string customer = GetPostString("customer");
  9435. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9436. string design = GetPostString("design");
  9437. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9438. string orderState = GetPostString("orderState");
  9439. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9440. string address = GetPostString("address");
  9441. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9442. string sellermemo = GetPostString("seller_memo");
  9443. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9444. string supplier = GetPostString("supplier");
  9445. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9446. {
  9447. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9448. }
  9449. else
  9450. {
  9451. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9452. }
  9453. string date1 = GetPostString("date1");
  9454. string date2 = GetPostString("date2");
  9455. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9456. if (dw.Length > 0) lw.Add(dw);
  9457. string placedate1 = GetPostString("placedate1");
  9458. string placedate2 = GetPostString("placedate2");
  9459. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9460. if (fdw.Length > 0) lw.Add(fdw);
  9461. string price1 = GetPostString("price1");
  9462. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9463. string price2 = GetPostString("price2");
  9464. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9465. string checkst = GetPostString("checkstate");
  9466. if (checkst.Length > 0 && "10".Equals(checkst))
  9467. {
  9468. lw.Add(string.Format("CheckOut>0"));
  9469. }
  9470. else
  9471. {
  9472. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9473. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9474. }
  9475. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9476. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9477. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9478. writeGridDataTableJson(dStruct.TotalCount, dt);
  9479. }
  9480. public void ins_erp_startCheck()
  9481. {
  9482. if (UrlPostParmsCheck("ctid"))
  9483. {
  9484. string eid = GetPostString("ctid");
  9485. CeErpTradeCell entity = null;
  9486. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9487. if (entity != null)
  9488. {
  9489. entity.MemoOpt = 4;
  9490. entity.UpdateTime = DateTime.Now;
  9491. entity.Update();
  9492. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9493. CeErpSukuraData.createInfo(entity.ctid, 6);
  9494. returnSuccessMsg("操作成功!");
  9495. return;
  9496. }
  9497. returnErrorMsg("找不到记录");
  9498. }
  9499. }
  9500. public void upd_erp_sendXlw()
  9501. {
  9502. if (UrlPostParmsCheck("ctid"))
  9503. {
  9504. string eid = GetPostString("ctid");
  9505. CeErpTradeCell entity = null;
  9506. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9507. if (entity != null)
  9508. {
  9509. if (entity.IsSendGift == 1)
  9510. {
  9511. returnErrorMsg("请勿重复标记");
  9512. return;
  9513. }
  9514. entity.IsSendGift = 1;
  9515. entity.Update();
  9516. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9517. returnSuccessMsg("操作成功!");
  9518. return;
  9519. }
  9520. returnErrorMsg("找不到记录");
  9521. }
  9522. }
  9523. public void cancel_sendXlw()
  9524. {
  9525. if (UrlPostParmsCheck("ctid"))
  9526. {
  9527. string eid = GetPostString("ctid");
  9528. CeErpTradeCell entity = null;
  9529. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9530. if (entity != null)
  9531. {
  9532. if (entity.IsSendGift == 0)
  9533. {
  9534. returnErrorMsg("未标记小礼物");
  9535. return;
  9536. }
  9537. entity.IsSendGift = 0;
  9538. entity.Update();
  9539. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9540. returnSuccessMsg("操作成功!");
  9541. return;
  9542. }
  9543. returnErrorMsg("找不到记录");
  9544. }
  9545. }
  9546. public void get_erp_designbill()
  9547. {
  9548. DataStruct dStruct = GetPostStruct();
  9549. List<string> lw = new List<string>();
  9550. int isMy = GetInt("my");
  9551. if (isMy == 1)
  9552. {
  9553. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9554. }
  9555. string tid = GetPostString("tid");
  9556. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9557. string userName = GetPostString("design");
  9558. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9559. string price1 = GetPostString("price1");
  9560. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9561. string price2 = GetPostString("price2");
  9562. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9563. string rePrice1 = GetPostString("rePrice1");
  9564. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9565. string rePrice2 = GetPostString("rePrice2");
  9566. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9567. string designerType = GetPostString("designerType");
  9568. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9569. string orderState = GetPostString("orderState");
  9570. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9571. string endTime1 = GetPostString("endTime1");
  9572. string endTime2 = GetPostString("endTime2");
  9573. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9574. if (dw.Length > 0) lw.Add(dw);
  9575. string isDk = GetPostString("isDk");
  9576. if (isDk == "1")
  9577. {
  9578. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9579. }
  9580. else if (isDk == "0")
  9581. {
  9582. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9583. }
  9584. dStruct.Order = "oid, create_time desc";
  9585. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9586. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9587. writeGridDataTableJson(dStruct.TotalCount, dt);
  9588. }
  9589. public void upd_erp_designerbill()
  9590. {
  9591. if (UrlPostParmsCheck("ID"))
  9592. {
  9593. string eid = GetPostString("ID");
  9594. CeErpDesignerBill entity = null;
  9595. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9596. if (entity != null)
  9597. {
  9598. if (GetPostDouble("designerpirce") > 0)
  9599. {
  9600. entity.realPrice = GetPostDouble("designerpirce");
  9601. entity.update_time = DateTime.Now;
  9602. entity.update_u_id = CurrentUser.UserID;
  9603. entity.update_u_name = CurrentUser.UserName;
  9604. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9605. entity.Update();
  9606. returnSuccessMsg("操作成功!");
  9607. return;
  9608. }
  9609. else
  9610. {
  9611. entity.price = GetPostDouble("price");
  9612. entity.update_time = DateTime.Now;
  9613. entity.update_u_id = CurrentUser.UserID;
  9614. entity.update_u_name = CurrentUser.UserName;
  9615. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9616. entity.Update();
  9617. returnSuccessMsg("操作成功!");
  9618. return;
  9619. }
  9620. }
  9621. returnErrorMsg("找不到记录");
  9622. }
  9623. }
  9624. public void audit_erp_designerbill()
  9625. {
  9626. if (UrlPostParmsCheck("ID"))
  9627. {
  9628. string eid = GetPostString("ID");
  9629. CeErpDesignerBill entity = null;
  9630. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9631. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9632. if (entity != null)
  9633. {
  9634. entity.realPrice = GetPostDouble("designerpirce");
  9635. entity.update_time = DateTime.Now;
  9636. entity.update_u_id = CurrentUser.UserID;
  9637. entity.update_u_name = CurrentUser.UserName;
  9638. entity.isAudit = 1;
  9639. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9640. entity.Update();
  9641. if (orderEntity != null)
  9642. {
  9643. orderEntity.IsReadTag = 3;
  9644. orderEntity.Update();
  9645. }
  9646. returnSuccessMsg("操作成功!");
  9647. return;
  9648. }
  9649. returnErrorMsg("找不到记录");
  9650. }
  9651. }
  9652. public void all_audit_erp_designerbill()
  9653. {
  9654. if (UrlPostParmsCheck("idList"))
  9655. {
  9656. string[] list = GetPostString("idList").Split(',');
  9657. CeErpDesignerBill entity = null;
  9658. for (int i = 0; i < list.Length; i++)
  9659. {
  9660. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9661. if (entity == null) return;
  9662. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9663. if (orderEntity == null) return;
  9664. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9665. entity.update_time = DateTime.Now;
  9666. entity.update_u_id = CurrentUser.UserID;
  9667. entity.update_u_name = CurrentUser.UserName;
  9668. entity.isAudit = 1;
  9669. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9670. entity.Update();
  9671. orderEntity.IsReadTag = 3;
  9672. orderEntity.Update();
  9673. }
  9674. returnSuccessMsg("操作成功!");
  9675. return;
  9676. }
  9677. }
  9678. public void get_erp_sameorders()
  9679. {
  9680. if (UrlPostParmsCheck("ctid"))
  9681. {
  9682. string eid = GetPostString("ctid");
  9683. CeErpTradeCell entity = null;
  9684. entity = CeErpTradeCell.GetByCtid(eid);
  9685. if (entity != null)
  9686. {
  9687. StringBuilder sql = new StringBuilder();
  9688. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9689. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9690. var res = new
  9691. {
  9692. data = dt.Rows.Count
  9693. };
  9694. string ro_jsond = JsonConvert.SerializeObject(res);
  9695. returnSuccess(ro_jsond);
  9696. return;
  9697. }
  9698. returnErrorMsg("未找到订单");
  9699. return;
  9700. }
  9701. returnErrorMsg("缺少必要的参数");
  9702. }
  9703. public void get_erp_islasthavesameorder()
  9704. {
  9705. if (UrlPostParmsCheck("ctid"))
  9706. {
  9707. string eid = GetPostString("ctid");
  9708. string[] ctidList = eid.Split(',');
  9709. StringBuilder sql = new StringBuilder();
  9710. string tisCtid = "";
  9711. foreach (string ctid in ctidList)
  9712. {
  9713. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9714. if (entity != null)
  9715. {
  9716. sql = new StringBuilder();
  9717. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9718. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9719. if (dth.Rows.Count > 0)
  9720. {
  9721. tisCtid += entity.ctid;
  9722. tisCtid += ",";
  9723. }
  9724. }
  9725. }
  9726. if (tisCtid.Length > 0)
  9727. {
  9728. var res = new
  9729. {
  9730. data = tisCtid
  9731. };
  9732. string ro_jsond = JsonConvert.SerializeObject(res);
  9733. returnSuccess(ro_jsond);
  9734. }
  9735. else
  9736. {
  9737. var res = new
  9738. {
  9739. data = ""
  9740. };
  9741. string ro_jsond = JsonConvert.SerializeObject(res);
  9742. returnSuccess(ro_jsond);
  9743. }
  9744. return;
  9745. }
  9746. returnErrorMsg("缺少必要的参数");
  9747. }
  9748. public void file_client_down_url()
  9749. {
  9750. if (!UrlPostParmsCheck("userId"))
  9751. {
  9752. returnErrorMsg("缺少必要的参数");
  9753. }
  9754. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9755. }
  9756. public void checkout_form_data()
  9757. {
  9758. if (!UrlPostParmsCheck("tid"))
  9759. {
  9760. returnErrorMsg("缺少必要的参数");
  9761. }
  9762. string tid = GetPostString("tid");
  9763. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9764. if (ceErpOrderFormData != null)
  9765. {
  9766. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9767. returnSuccess(ro_jsond);
  9768. return;
  9769. }
  9770. returnErrorMsg("尚未有文件!");
  9771. }
  9772. public void back_supplier_audit()
  9773. {
  9774. int userId = CurrentUser.UserID;
  9775. StringBuilder sql = new StringBuilder();
  9776. 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);
  9777. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9778. if (dt.Rows.Count > 0)
  9779. {
  9780. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9781. }
  9782. else
  9783. {
  9784. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9785. }
  9786. }
  9787. public void back_supplier_query()
  9788. {
  9789. string eid = GetPostString("ctid");
  9790. if (eid != "")
  9791. {
  9792. StringBuilder sql = new StringBuilder();
  9793. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9794. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9795. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9796. }
  9797. else
  9798. {
  9799. returnErrorMsg("找不到订单记录");
  9800. return;
  9801. }
  9802. }
  9803. public void verified_to_order()
  9804. {
  9805. int userId = CurrentUser.UserID;
  9806. StringBuilder sql = new StringBuilder();
  9807. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9808. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9809. if (dt.Rows.Count > 0)
  9810. {
  9811. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9812. }
  9813. else
  9814. {
  9815. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9816. }
  9817. }
  9818. public void upd_supplier_audit()
  9819. {
  9820. if (UrlPostParmsCheck("ctid"))
  9821. {
  9822. string eid = GetPostString("ctid");
  9823. string reason = GetPostString("returnreason");
  9824. CeErpTradeCell entity = null;
  9825. CeWithdraw withdraw = null;
  9826. withdraw = CeWithdraw.GetByTid(eid);
  9827. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9828. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9829. {
  9830. if (withdraw != null)
  9831. {
  9832. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9833. {
  9834. returnSuccessMsg("您没有权限操作!");
  9835. return;
  9836. }
  9837. else
  9838. {
  9839. if (reason.Equals("1"))
  9840. {
  9841. if (entity.OrderState == -1)
  9842. {
  9843. if (entity.FinishPlaceTime == null)
  9844. {
  9845. entity.OrderState = 2;
  9846. }
  9847. else
  9848. {
  9849. entity.OrderState = 6;
  9850. }
  9851. }
  9852. entity.Update();
  9853. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9854. if (withdraw != null)
  9855. {
  9856. withdraw.status = int.Parse(reason);
  9857. withdraw.Update();
  9858. }
  9859. returnSuccessMsg("操作成功!");
  9860. return;
  9861. }
  9862. else
  9863. {
  9864. withdraw.status = int.Parse(reason);
  9865. withdraw.acknowledgingtime = DateTime.Now;
  9866. withdraw.Update();
  9867. returnSuccessMsg("查看详细请点击线下订单查询");
  9868. return;
  9869. }
  9870. }
  9871. }
  9872. // 第一个字符是 'N'
  9873. }
  9874. if (eid[0] != 'N')
  9875. {
  9876. }
  9877. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9878. {
  9879. entity.IsVerifyToSupplier = false;
  9880. entity.IsReturn = 1;
  9881. entity.ReturnTime = DateTime.Now;
  9882. entity.ReturnReason = reason;
  9883. if (entity.OrderState == 6)
  9884. {
  9885. entity.OrderState = 5;
  9886. }
  9887. entity.Update();
  9888. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9889. if (withdraw != null)
  9890. {
  9891. withdraw.status = int.Parse(reason);
  9892. withdraw.Update();
  9893. }
  9894. returnSuccessMsg("操作成功!");
  9895. return;
  9896. }
  9897. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9898. {
  9899. ;
  9900. if (withdraw != null)
  9901. {
  9902. withdraw.status = int.Parse(reason);
  9903. withdraw.acknowledgingtime = DateTime.Now;
  9904. withdraw.Update();
  9905. returnSuccessMsg("供应商取消撤回!");
  9906. return;
  9907. }
  9908. }
  9909. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9910. {
  9911. if (entity.OrderState == -1)
  9912. {
  9913. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9914. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9915. {
  9916. returnErrorMsg("订单spu没有确认无法通过审核!");
  9917. return;
  9918. }
  9919. if (entity.FinishPlaceTime == null)
  9920. {
  9921. entity.OrderState = 2;
  9922. }
  9923. else
  9924. {
  9925. entity.OrderState = 3;
  9926. }
  9927. commonHelper.getCytPrice(entity);
  9928. }
  9929. entity.Update();
  9930. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9931. if (withdraw != null)
  9932. {
  9933. withdraw.status = int.Parse(reason);
  9934. withdraw.Update();
  9935. }
  9936. returnSuccessMsg("操作成功!");
  9937. return;
  9938. }
  9939. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9940. {
  9941. if (withdraw == null)
  9942. {
  9943. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9944. return;
  9945. }
  9946. }
  9947. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9948. {
  9949. if (withdraw != null)
  9950. {
  9951. withdraw.status = int.Parse(reason);
  9952. withdraw.acknowledgingtime = DateTime.Now;
  9953. withdraw.Update();
  9954. returnSuccessMsg("查看详细请点击线下订单查询");
  9955. return;
  9956. }
  9957. }
  9958. return;
  9959. }
  9960. }
  9961. //校验报价
  9962. public void refund_order_tip()
  9963. {
  9964. int userid = CurrentUser.UserID;
  9965. int sectionId = CurrentUser.UserPost.OrgID;
  9966. StringBuilder sql = new StringBuilder();
  9967. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9968. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9969. List<string> ids = new List<string>();
  9970. if (dth.Rows.Count > 0)
  9971. {
  9972. foreach (DataRow dr in dth.Rows)
  9973. {
  9974. ids.Add(dr["ID"].ToString());
  9975. }
  9976. try
  9977. {
  9978. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9979. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9980. }
  9981. catch (Exception ex)
  9982. {
  9983. }
  9984. }
  9985. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9986. }
  9987. public void refund_order_Design()
  9988. {
  9989. int userid = CurrentUser.UserID;
  9990. int sectionId = CurrentUser.UserPost.OrgID;
  9991. StringBuilder sql = new StringBuilder();
  9992. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9993. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9994. List<string> ids = new List<string>();
  9995. if (dth.Rows.Count > 0)
  9996. {
  9997. foreach (DataRow dr in dth.Rows)
  9998. {
  9999. ids.Add(dr["ID"].ToString());
  10000. }
  10001. try
  10002. {
  10003. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10004. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10005. }
  10006. catch (Exception ex)
  10007. {
  10008. }
  10009. }
  10010. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10011. }
  10012. public void change_order_info()
  10013. {
  10014. int userid = CurrentUser.UserID;
  10015. StringBuilder sql = new StringBuilder();
  10016. 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);
  10017. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10018. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10019. }
  10020. public void change_win_mome()
  10021. {
  10022. if (UrlPostParmsCheck("id,ctid"))
  10023. {
  10024. string id = GetPostString("id");
  10025. string ctid = GetPostString("ctid");
  10026. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10027. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10028. if (ce == null || ceErpMessageTip == null)
  10029. {
  10030. returnSuccessMsg("未找到对应的订单!");
  10031. return;
  10032. }
  10033. if (ce.OrderState >= 5)
  10034. {
  10035. returnSuccessMsg("已上传文件无法修改!");
  10036. return;
  10037. }
  10038. int type = GetPostInt("type");
  10039. string content = GetPostString("content");
  10040. if (type == 0)
  10041. {
  10042. content = content.Replace("(", "(");
  10043. content = content.Replace(")", ")");
  10044. string check = MidStrEx(content, "(", ")").Trim();
  10045. if (string.IsNullOrEmpty(check))
  10046. {
  10047. returnSuccessMsg("文件名格式不正确");
  10048. return;
  10049. }
  10050. }
  10051. ce.seller_memo = content;
  10052. ce.Update();
  10053. ceErpMessageTip.isVisit = true;
  10054. ceErpMessageTip.Update();
  10055. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10056. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10057. ApiVo apiVo = new ApiVo();
  10058. apiVo.orderNumber = ce.ctid;
  10059. apiVo.actionName = "demandDesign";
  10060. apiVo.orderRemarks = content;
  10061. apiVo.demandExamine = type + 1;
  10062. designHelper.API_WorkCore(apiVo);//demandDesign
  10063. returnSuccessMsg("修改成功!");
  10064. }
  10065. }
  10066. public static string MidStrEx(string sourse, string startstr, string endstr)
  10067. {
  10068. string result = string.Empty;
  10069. int startindex, endindex;
  10070. try
  10071. {
  10072. startindex = sourse.IndexOf(startstr);
  10073. if (startindex == -1)
  10074. return result;
  10075. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10076. endindex = tmpstr.IndexOf(endstr);
  10077. if (endindex == -1)
  10078. return result;
  10079. result = tmpstr.Remove(endindex);
  10080. }
  10081. catch (Exception ex)
  10082. {
  10083. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10084. }
  10085. return result;
  10086. }
  10087. public void refund_order_list()
  10088. {
  10089. int userid = CurrentUser.UserID;
  10090. int sectionId = CurrentUser.UserPost.OrgID;
  10091. StringBuilder sql = new StringBuilder();
  10092. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10093. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10094. DataStruct dStruct = GetPostStruct();
  10095. DataTable dt = null;
  10096. List<string> ids = new List<string>();
  10097. List<string> tids = new List<string>();
  10098. if (dth.Rows.Count > 0)
  10099. {
  10100. foreach (DataRow dr in dth.Rows)
  10101. {
  10102. tids.Add("'" + dr["tid"].ToString() + "'");
  10103. ids.Add(dr["id"].ToString());
  10104. }
  10105. try
  10106. {
  10107. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10108. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10109. List<string> lw = new List<string>();
  10110. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10111. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10112. dt = WebCache.GetData("view_orderlist", dStruct);
  10113. }
  10114. catch (Exception ex)
  10115. {
  10116. }
  10117. }
  10118. writeGridDataTableJson(dStruct.TotalCount, dt);
  10119. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10120. }
  10121. //新增
  10122. public void order_batch_downloads()
  10123. {
  10124. string ceid = GetPostString("tid");
  10125. String[] tid = ceid.Split(',');
  10126. order_batch_caiyingtong(tid);
  10127. /* (string success, string errors) = UploadFiles(tid);
  10128. returnSuccessMsg(success + errors);*/
  10129. return;
  10130. }
  10131. //报价接口
  10132. public void Get_To_Quote()
  10133. {
  10134. string ceid = GetPostString("ctid");
  10135. if (ceid != null)
  10136. {
  10137. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10138. if (entity != null)
  10139. {
  10140. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10141. {
  10142. return;
  10143. }
  10144. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10145. double price = 0;
  10146. if (cp == null)
  10147. {
  10148. JObject jsonObject12 = new JObject
  10149. {
  10150. { "UserId", "77886" },
  10151. { "Pwd", "lt666888" },
  10152. { "Filename", entity.seller_memo }
  10153. };
  10154. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10155. JObject jsonObjects1 = JObject.Parse(response1);
  10156. string ms1g = (string)jsonObjects1["msg"];
  10157. if (ms1g == "报价成功")
  10158. {
  10159. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10160. string data = (string)jsonObject1["price"];
  10161. 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 + "');";
  10162. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10163. returnSuccessMsg("获取报价成功:" + data);
  10164. price = Convert.ToDouble(data);
  10165. }
  10166. else
  10167. {
  10168. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10169. return;
  10170. }
  10171. }
  10172. String[] beizhu = entity.seller_memo.Split('-');
  10173. String chanp = "";
  10174. if (beizhu.Length > 0)
  10175. {
  10176. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10177. }
  10178. else
  10179. {
  10180. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10181. }
  10182. JObject jsonObject = new JObject
  10183. {
  10184. { "UserId", "77886" },
  10185. { "Pwd", "lt666888" },
  10186. { "Filename", chanp }
  10187. };
  10188. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10189. JObject jsonObjects = JObject.Parse(response);
  10190. string msg = (string)jsonObjects["msg"];
  10191. if (msg == "报价成功")
  10192. {
  10193. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10194. string data = (string)jsonObject1["price"];
  10195. 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 + "');";
  10196. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10197. returnSuccessMsg("获取报价成功:" + data);
  10198. price = Convert.ToDouble(data);
  10199. }
  10200. else
  10201. {
  10202. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10203. return;
  10204. }
  10205. if (price > 0)
  10206. {
  10207. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10208. if (ceErpTradeCellExtend == null)
  10209. {
  10210. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10211. ceErpTradeCellExtend.ctid = entity.ctid;
  10212. ceErpTradeCellExtend.payment_cyt = price;
  10213. ceErpTradeCellExtend.Create();
  10214. }
  10215. else
  10216. {
  10217. ceErpTradeCellExtend.payment_cyt = price;
  10218. ceErpTradeCellExtend.Update();
  10219. }
  10220. }
  10221. return;
  10222. }
  10223. }
  10224. else
  10225. {
  10226. returnErrorMsg("请至少选择一条数据");
  10227. return;
  10228. }
  10229. }
  10230. //新增
  10231. public void order_To_Supplier()
  10232. {
  10233. string ceid = GetPostString("tid");
  10234. String[] tid = ceid.Split(',');
  10235. if (tid.Length > 0)
  10236. {
  10237. try
  10238. {
  10239. for (int i = 0; i < tid.Length; i++)
  10240. {
  10241. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10242. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10243. entity.SupplierId = suid;
  10244. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10245. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10246. entity.Update();
  10247. }
  10248. }
  10249. catch (Exception ex)
  10250. {
  10251. returnErrorMsg("自动匹配供应商失败");
  10252. return;
  10253. }
  10254. }
  10255. else
  10256. {
  10257. returnErrorMsg("请至少选择一条数据");
  10258. return;
  10259. }
  10260. returnSuccessMsg("自动匹配供应商成功");
  10261. return;
  10262. }
  10263. public (string, string) UploadFiles(string[] urls)
  10264. {
  10265. string success = "";
  10266. string errors = "";
  10267. int userid = CurrentUser.UserID;
  10268. foreach (string url in urls)
  10269. {
  10270. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10271. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10272. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10273. {
  10274. JObject jsonObject = new JObject
  10275. {
  10276. { "Userid", "77886" },
  10277. { "pwd", "cyt86435015" },
  10278. { "content", base64FileContent },
  10279. { "ext", Path.GetExtension(fileName) }
  10280. };
  10281. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10282. JObject jsonObjects = JObject.Parse(response);
  10283. string msg = (string)jsonObjects["msg"];
  10284. if (msg.Equals("上传成功"))
  10285. {
  10286. success += url + " 上传成功";
  10287. }
  10288. else
  10289. {
  10290. errors += url + " 上传失败";
  10291. }
  10292. }
  10293. else
  10294. {
  10295. errors += url + " 格式出现问题";
  10296. }
  10297. }
  10298. if (urls.Length == 0)
  10299. {
  10300. return (success, errors);
  10301. }
  10302. return (success, errors);
  10303. }
  10304. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10305. {
  10306. return true; //总是接受
  10307. }
  10308. public static string HttpPost(string url, string param = null)
  10309. {
  10310. HttpWebRequest request;
  10311. //如果是发送HTTPS请求
  10312. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10313. {
  10314. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10315. request = WebRequest.Create(url) as HttpWebRequest;
  10316. request.ProtocolVersion = HttpVersion.Version10;
  10317. }
  10318. else
  10319. {
  10320. request = WebRequest.Create(url) as HttpWebRequest;
  10321. }
  10322. request.Method = "POST";
  10323. request.ContentType = "application/json";
  10324. request.Accept = "*/*";
  10325. request.Timeout = 120000;
  10326. request.AllowAutoRedirect = false;
  10327. StreamWriter requestStream = null;
  10328. WebResponse response = null;
  10329. string responseStr = null;
  10330. try
  10331. {
  10332. requestStream = new StreamWriter(request.GetRequestStream());
  10333. requestStream.Write(param);
  10334. requestStream.Close();
  10335. response = request.GetResponse();
  10336. if (response != null)
  10337. {
  10338. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10339. responseStr = reader.ReadToEnd();
  10340. reader.Close();
  10341. }
  10342. }
  10343. catch (Exception ex)
  10344. {
  10345. return ex.Message;
  10346. }
  10347. finally
  10348. {
  10349. request = null;
  10350. requestStream = null;
  10351. response = null;
  10352. }
  10353. return responseStr;
  10354. }
  10355. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10356. {
  10357. string base64FileContent;
  10358. string fileName;
  10359. using (WebClient webClient = new WebClient())
  10360. {
  10361. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10362. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10363. {
  10364. using (Stream stream = response.GetResponseStream())
  10365. {
  10366. using (MemoryStream memoryStream = new MemoryStream())
  10367. {
  10368. stream.CopyTo(memoryStream);
  10369. byte[] fileBytes = memoryStream.ToArray();
  10370. base64FileContent = Convert.ToBase64String(fileBytes);
  10371. fileName = response.Headers["Content-Disposition"];
  10372. if (!string.IsNullOrEmpty(fileName))
  10373. {
  10374. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10375. if (index >= 0)
  10376. {
  10377. fileName = fileName.Substring(index + 9).Trim('\"');
  10378. }
  10379. }
  10380. else
  10381. {
  10382. fileName = Path.GetFileName(downloadUrl);
  10383. }
  10384. }
  10385. }
  10386. }
  10387. }
  10388. return (fileName, base64FileContent);
  10389. }
  10390. //新增
  10391. public void order_batch_caiyingtong(string[] downloadUrls)
  10392. {
  10393. try
  10394. {
  10395. //遍历文件
  10396. DataStruct dStruct = GetPostStruct();
  10397. DataTable dt = null;
  10398. int userid = CurrentUser.UserID;
  10399. List<string> ids = new List<string>();//失败组
  10400. List<string> tids = new List<string>();
  10401. using (WebClient webClient = new WebClient())
  10402. {
  10403. foreach (var url in downloadUrls)
  10404. {
  10405. try
  10406. {
  10407. tids.Add("'" + url + "'");
  10408. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10409. if (entity != null)
  10410. {
  10411. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10412. if (cp == null)
  10413. {
  10414. JObject jsonObject = new JObject
  10415. {
  10416. { "Userid", "77886" },
  10417. { "pwd", "lt666888" },
  10418. { "Filename",entity.seller_memo }
  10419. };
  10420. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10421. JObject jsonObjects = JObject.Parse(response);
  10422. string msg = (string)jsonObjects["msg"];
  10423. if (msg == "报价成功")
  10424. {
  10425. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10426. DownloadAndConvertToBase64(url1);
  10427. }
  10428. else
  10429. {
  10430. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10431. }
  10432. }
  10433. else
  10434. {
  10435. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10436. JObject jsonObject = new JObject
  10437. {
  10438. { "Userid", "77886" },
  10439. { "pwd", "lt666888" },
  10440. { "Filename",chanp }
  10441. };
  10442. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10443. JObject jsonObjects = JObject.Parse(response);
  10444. string msg = (string)jsonObjects["msg"];
  10445. if (msg == "报价成功")
  10446. {
  10447. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10448. DownloadAndConvertToBase64(url1);
  10449. }
  10450. else
  10451. {
  10452. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10453. }
  10454. }
  10455. }
  10456. // 上传文件到FTP
  10457. }
  10458. catch (Exception ex)
  10459. {
  10460. Console.WriteLine($"An error occurred: {ex.Message}");
  10461. }
  10462. }
  10463. List<string> lw = new List<string>();
  10464. lw.Add(string.Format("( OrderState < 6 )"));
  10465. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10466. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10467. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10468. if (dt.Rows.Count > 0)
  10469. {
  10470. foreach (DataRow dr in dt.Rows)
  10471. {
  10472. ids.Add(dr["ctid"].ToString());
  10473. }
  10474. }
  10475. String ErrorMsgs = "";
  10476. foreach (String id in ids)
  10477. {
  10478. ErrorMsgs += id + ",";
  10479. }
  10480. if (ErrorMsgs.Length > 1)
  10481. {
  10482. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10483. }
  10484. if (ErrorMsgs.Length < 1)
  10485. {
  10486. ErrorMsgs = "上传成功";
  10487. returnSuccessMsg(ErrorMsgs);
  10488. }
  10489. else
  10490. {
  10491. returnErrorMsg("以下订单" + ErrorMsgs);
  10492. }
  10493. }
  10494. // 删除文件夹及其内容
  10495. /* Directory.Delete(localDirectory, true);*/
  10496. }
  10497. catch { }
  10498. }
  10499. public void get_center_data()
  10500. {
  10501. int userId = CurrentUser.UserID;
  10502. string postCode = CurrentUser.UserPost.Post.Code;
  10503. List<string> lw = new List<string>();
  10504. List<string> ww = new List<string>();
  10505. DateTime currentTime = DateTime.Now;
  10506. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10507. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10508. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10509. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10510. string sql = " SELECT ";
  10511. string startTime = "2023-10-01 11:22:31";
  10512. //设计
  10513. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10514. {
  10515. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10516. 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));
  10517. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10518. 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));
  10519. }
  10520. //客服
  10521. else if (postCode == "CustomerService" || postCode == "Director")
  10522. {
  10523. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10524. 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));
  10525. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10526. 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));
  10527. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10528. 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));
  10529. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10530. 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));
  10531. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10532. 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));
  10533. }
  10534. //售后
  10535. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10536. {
  10537. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10538. 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));
  10539. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10540. 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));
  10541. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10542. 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));
  10543. }
  10544. //下单部
  10545. else if (postCode == "Place" || postCode == "PlaceMr")
  10546. {
  10547. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10548. 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));
  10549. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10550. 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));
  10551. }
  10552. //车间
  10553. else if (postCode == "Supplier")
  10554. {
  10555. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10556. 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));
  10557. }
  10558. DataTable dt = new DataTable();
  10559. if (lw.Count > 0)
  10560. {
  10561. sql += string.Join(" , ", lw);
  10562. sql += " FROM ";
  10563. sql += string.Join(" , ", ww);
  10564. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10565. }
  10566. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10567. }
  10568. public void get_center_data_list()
  10569. {
  10570. int userId = CurrentUser.UserID;
  10571. string postCode = CurrentUser.UserPost.Post.Code;
  10572. string shopIds = CurrentUser.User.pemShop;
  10573. DataStruct dStruct = GetPostStruct();
  10574. List<string> lw = new List<string>();
  10575. DateTime currentTime = DateTime.Now;
  10576. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10577. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10578. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10579. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10580. string startTime = "2023-10-01 11:22:31";
  10581. int order_type = GetPostInt("order_type");
  10582. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10583. {
  10584. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10585. if (order_type == 0)
  10586. {
  10587. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10588. }
  10589. else if (order_type == 3)
  10590. {
  10591. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10592. }
  10593. else
  10594. {
  10595. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10596. }
  10597. }
  10598. //客服
  10599. if (postCode == "CustomerService" || postCode == "Director")
  10600. {
  10601. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10602. if (order_type == 0)
  10603. {
  10604. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10605. }
  10606. else if (order_type == 1)
  10607. {
  10608. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10609. }
  10610. else if (order_type == 2)
  10611. {
  10612. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10613. }
  10614. else if (order_type == 3)
  10615. {
  10616. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10617. }
  10618. else if (order_type == 4)
  10619. {
  10620. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10621. }
  10622. else
  10623. {
  10624. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10625. }
  10626. }
  10627. //售后
  10628. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10629. {
  10630. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10631. if (shopIds != "")
  10632. {
  10633. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10634. }
  10635. if (order_type == 2)
  10636. {
  10637. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10638. }
  10639. else if (order_type == 4)
  10640. {
  10641. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10642. }
  10643. else if (order_type == 5)
  10644. {
  10645. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10646. }
  10647. else
  10648. {
  10649. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10650. }
  10651. }
  10652. //下单部
  10653. if (postCode == "Place" || postCode == "PlaceMr")
  10654. {
  10655. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10656. if (shopIds != "")
  10657. {
  10658. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10659. }
  10660. else if (order_type == 1)
  10661. {
  10662. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10663. }
  10664. else if (order_type == 2)
  10665. {
  10666. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10667. }
  10668. else
  10669. {
  10670. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10671. }
  10672. }
  10673. //车间
  10674. if (postCode == "Supplier")
  10675. {
  10676. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10677. if (order_type == 5)
  10678. {
  10679. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10680. }
  10681. else
  10682. {
  10683. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10684. }
  10685. }
  10686. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10687. dStruct.Fileds = "tid,ctid";
  10688. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10689. writeGridDataTableJson(dStruct.TotalCount, dt);
  10690. }
  10691. public void aftersale_audit_master()
  10692. {
  10693. if (UrlPostParmsCheck("ctid"))
  10694. {
  10695. string ctid = GetPostString("ctid");
  10696. if (ctid.Length > 0)
  10697. {
  10698. bool result = aftersale_data_change(ctid);
  10699. if (result)
  10700. {
  10701. returnSuccessMsg("修改成功!");
  10702. return;
  10703. }
  10704. }
  10705. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10706. }
  10707. }
  10708. public void aftersale_batch_audit_master()
  10709. {
  10710. if (UrlPostParmsCheck("ctids"))
  10711. {
  10712. string ctids = GetPostString("ctids");
  10713. if (ctids.Length > 0)
  10714. {
  10715. List<string> list = new List<string>();
  10716. string[] ctid_list = ctids.Split(',');
  10717. foreach (var item in ctid_list)
  10718. {
  10719. bool result = aftersale_data_change(item);
  10720. if (!result)
  10721. {
  10722. list.Add(item);
  10723. }
  10724. }
  10725. if (list.Count > 0)
  10726. {
  10727. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10728. return;
  10729. }
  10730. returnSuccessMsg("修改成功!");
  10731. return;
  10732. }
  10733. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10734. }
  10735. }
  10736. public bool aftersale_data_change(string ctid)
  10737. {
  10738. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10739. if (ceErpTradeCell != null)
  10740. {
  10741. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10742. ceErpTradeCell.AfterSaleSupplierState = 0;
  10743. StringBuilder sql = new StringBuilder();
  10744. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10745. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10746. CeErpTradeResponsible.DelByTid(ctid, 0);
  10747. 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 == "不理赔")
  10748. {
  10749. CeErpTradeResponsible.DelByTid(ctid, 1);
  10750. ceErpTradeCell.AfterSaleSupplierState = 1;
  10751. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10752. ceErpTradeCell.AfterSaleState = 4;
  10753. }
  10754. else
  10755. {
  10756. ceErpTradeCell.AfterSaleState = 3;
  10757. }
  10758. bool needCyt = false;
  10759. if (dt != null)
  10760. {
  10761. if (dt.Rows.Count == 1)
  10762. {
  10763. bool isEnd = false;
  10764. foreach (DataRow dr in dt.Rows)
  10765. {
  10766. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10767. {
  10768. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10769. isEnd = true;
  10770. }
  10771. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10772. {
  10773. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10774. isEnd = true;
  10775. }
  10776. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10777. {
  10778. needCyt = true;
  10779. }
  10780. }
  10781. if (isEnd)
  10782. {
  10783. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10784. ceErpTradeCell.AfterSaleState = 4;
  10785. ceErpTradeCell.AfterSaleSupplierState = 1;
  10786. }
  10787. }
  10788. else
  10789. {
  10790. bool isAll = true;
  10791. foreach (DataRow dr in dt.Rows)
  10792. {
  10793. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10794. {
  10795. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10796. continue;
  10797. }
  10798. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10799. {
  10800. string path = "";
  10801. int OrgID = 0;
  10802. if (!Convert.IsDBNull(dr["OrgPath"]))
  10803. {
  10804. path = dr["OrgPath"].ToString();
  10805. }
  10806. if (!Convert.IsDBNull(dr["OrgID"]))
  10807. {
  10808. OrgID = Convert.ToInt32(dr["OrgID"]);
  10809. }
  10810. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10811. {
  10812. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10813. continue;
  10814. }
  10815. }
  10816. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10817. {
  10818. needCyt = true;
  10819. }
  10820. isAll = false;
  10821. }
  10822. if (isAll)
  10823. {
  10824. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10825. ceErpTradeCell.AfterSaleState = 4;
  10826. ceErpTradeCell.AfterSaleSupplierState = 1;
  10827. }
  10828. }
  10829. }
  10830. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10831. {
  10832. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10833. }
  10834. if (ceErpTradeCell.AfterSaleState == 4)
  10835. {
  10836. ApiVo apiVo = new ApiVo();
  10837. apiVo.orderNumber = ceErpTradeCell.ctid;
  10838. apiVo.actionName = "afterOver";
  10839. designHelper.API_WorkCore(apiVo); //afterOver
  10840. }
  10841. ceErpTradeCell.Update();
  10842. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10843. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10844. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10845. return true;
  10846. }
  10847. return false;
  10848. }
  10849. public void get_erp_wechatorder()
  10850. {
  10851. DataStruct dStruct = GetPostStruct();
  10852. List<string> lw = new List<string>();
  10853. string tid = GetPostString("tid");
  10854. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10855. string shopname = GetPostString("shopname");
  10856. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10857. string buyernick = GetPostString("buyer_nick");
  10858. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10859. string customer = GetPostString("customer");
  10860. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10861. string returndate1 = GetPostString("returndate1");
  10862. string returndate2 = GetPostString("returndate2");
  10863. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10864. if (dw.Length > 0) lw.Add(dw);
  10865. string finishDate1 = GetPostString("finishdate1");
  10866. string finishDate2 = GetPostString("finishdate2");
  10867. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10868. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10869. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10870. dStruct.Order = "created desc";
  10871. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10872. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10873. writeGridDataTableJson(dStruct.TotalCount, dt);
  10874. }
  10875. public void get_erp_wechatlist_sumprice()
  10876. {
  10877. DataStruct dStruct = GetPostStruct();
  10878. List<string> lw = new List<string>();
  10879. string tid = GetPostString("tid");
  10880. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10881. string shopname = GetPostString("shopname");
  10882. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10883. string buyernick = GetPostString("buyer_nick");
  10884. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10885. string customer = GetPostString("customer");
  10886. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10887. string returndate1 = GetPostString("returndate1");
  10888. string returndate2 = GetPostString("returndate2");
  10889. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10890. if (dw.Length > 0) lw.Add(dw);
  10891. string finishDate1 = GetPostString("finishdate1");
  10892. string finishDate2 = GetPostString("finishdate2");
  10893. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10894. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10895. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10896. string mainWhere = string.Join(" and ", lw.ToArray());
  10897. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10898. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10899. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10900. decimal total = 0;
  10901. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10902. {
  10903. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10904. }
  10905. var res = new
  10906. {
  10907. data = total
  10908. };
  10909. string ro_jsond = JsonConvert.SerializeObject(res);
  10910. returnSuccess(ro_jsond);
  10911. return;
  10912. }
  10913. public void get_erp_qr_waitdeliverylist()
  10914. {
  10915. DataStruct dStruct = GetPostStruct();
  10916. List<string> lw = new List<string>();
  10917. string tid = GetPostString("ctid");
  10918. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10919. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10920. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10921. var res_objz = new
  10922. {
  10923. restype = 1,
  10924. data = dt
  10925. };
  10926. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10927. returnSuccess(ro_jsonz);
  10928. }
  10929. public void get_erp_yield_list()
  10930. {
  10931. DataStruct dStruct = GetPostStruct();
  10932. List<string> lw = new List<string>();
  10933. string tid = GetPostString("ctid");
  10934. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10935. string shopname = GetPostString("shopname");
  10936. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10937. string buyernick = GetPostString("buyer_nick");
  10938. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10939. //if (tid.Length == 0 && buyernick.Length == 0)
  10940. //{
  10941. // lw.Add(string.Format("IsRefund<={0}", 1));
  10942. //}
  10943. string customer = GetPostString("customer");
  10944. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10945. string design = GetPostString("design");
  10946. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10947. string orderState = GetPostString("orderState");
  10948. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10949. string address = GetPostString("address");
  10950. 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));
  10951. string sellermemo = GetPostString("seller_memo");
  10952. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10953. string supplier = GetPostString("supplier");
  10954. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10955. string OrderArea = GetPostString("order_area");
  10956. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10957. string placedate1 = GetPostString("placedate1");
  10958. string placedate2 = GetPostString("placedate2");
  10959. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10960. if (fdw.Length > 0) lw.Add(fdw);
  10961. string price1 = GetPostString("price1");
  10962. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10963. string price2 = GetPostString("price2");
  10964. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10965. string unusualCon = GetPostString("unusualcon");
  10966. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10967. string posTag = CurrentUser.UserPost.Post.Code;
  10968. if (posTag == "Supplier")
  10969. {
  10970. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10971. }
  10972. lw.Add(string.Format("OrderState = 6 "));
  10973. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10974. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10975. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10976. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10977. writeGridDataTableJson(dStruct.TotalCount, dt);
  10978. }
  10979. public void change_erp_sup_state()
  10980. {
  10981. if (UrlPostParmsCheck("ctid"))
  10982. {
  10983. string ctid = GetPostString("ctid");
  10984. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10985. if (ceErpTradeCell != null)
  10986. {
  10987. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10988. if (ceErpTradeCellExtend == null)
  10989. {
  10990. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10991. ceErpTradeCellExtend.ctid = ctid;
  10992. ceErpTradeCellExtend.SupState = 1;
  10993. ceErpTradeCellExtend.Create();
  10994. }
  10995. else
  10996. {
  10997. ceErpTradeCellExtend.SupState = 1;
  10998. ceErpTradeCellExtend.Update();
  10999. }
  11000. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11001. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11002. return;
  11003. }
  11004. returnErrorMsg("找不到订单");
  11005. }
  11006. }
  11007. public void supplier_all_downs()
  11008. {
  11009. if (UrlPostParmsCheck("tids"))
  11010. {
  11011. string tids = GetPostString("tids");
  11012. if (tids != null && tids.Length > 0)
  11013. {
  11014. StringBuilder sql = new StringBuilder();
  11015. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11016. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11017. sql = new StringBuilder();
  11018. 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, "下载设计文件");
  11019. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11020. string[] list = tids.Split(',');
  11021. foreach (string ctid in list)
  11022. {
  11023. CeErpSukuraData.createInfo(ctid, 3);
  11024. }
  11025. designHelper.api_approveDesign(tids); //approveDesign
  11026. returnSuccessMsg("下载成功!");
  11027. return;
  11028. }
  11029. returnErrorMsg("下载订单更新失败");
  11030. }
  11031. }
  11032. public void uploaderFileSuccess()
  11033. {
  11034. if (UrlPostParmsCheck("fileName"))
  11035. {
  11036. string fileName = GetPostString("fileName");
  11037. ApiVo apiVo = new ApiVo();
  11038. apiVo.orderNumber = fileName;
  11039. apiVo.actionName = "finishDesign";
  11040. designHelper.API_WorkCore(apiVo);//finishDesign
  11041. returnSuccessMsg("");
  11042. }
  11043. }
  11044. public void get_sample2_order()
  11045. {
  11046. if (UrlPostParmsCheck("ctid"))
  11047. {
  11048. string ctid = GetPostString("ctid");
  11049. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11050. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11051. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11052. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11053. double total = 0.0;
  11054. double order_price = 0.0;
  11055. if (dt_bu.Rows.Count > 0)
  11056. {
  11057. foreach (DataRow dr in dt_bu.Rows)
  11058. {
  11059. total += Convert.ToDouble(dr["payment"]);
  11060. }
  11061. }
  11062. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11063. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11064. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11065. string tid = ctid.Replace("S_", "");
  11066. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11067. double paymant = 0.0;
  11068. if (entity != null)
  11069. {
  11070. paymant = entity.payment;
  11071. }
  11072. string return_reason = "";
  11073. if (dt_after != null && dt_after.Rows.Count > 0)
  11074. {
  11075. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11076. }
  11077. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11078. }
  11079. }
  11080. public void get_erp_design_status()
  11081. {
  11082. string designName = GetPostString("designName");
  11083. DataStruct dStruct = GetPostStruct();
  11084. if (designName.Length > 0)
  11085. {
  11086. 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";
  11087. sql_user += " and Name like '%" + designName + "%'";
  11088. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11089. List<string> ids_list = new List<string>();
  11090. if (user_table.Rows.Count > 0)
  11091. {
  11092. foreach (DataRow item in user_table.Rows)
  11093. {
  11094. ids_list.Add(item["id"].ToString());
  11095. string ids_s = item["TeamIds"].ToString();
  11096. if (ids_s.Length > 0)
  11097. {
  11098. ids_list.AddRange(ids_s.Split(','));
  11099. }
  11100. }
  11101. }
  11102. HashSet<string> set = new HashSet<string>(ids_list);
  11103. ids_list = set.ToList();
  11104. if (ids_list.Count > 0)
  11105. {
  11106. 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));
  11107. dStruct.MainWhere = sql;
  11108. DataTable dt = null;
  11109. dt = WebCache.GetData("view_ErpUser", dStruct);
  11110. writeGridDataTableJson(dStruct.TotalCount, dt);
  11111. }
  11112. }
  11113. }
  11114. public void change_erp_order_price()
  11115. {
  11116. string ctid = GetPostString("ctid");
  11117. double price = GetPostDouble("price");
  11118. if (ctid.Length > 0)
  11119. {
  11120. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11121. if (ceErpTradeCellExtend == null)
  11122. {
  11123. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11124. ceErpTradeCellExtend.ctid = ctid;
  11125. ceErpTradeCellExtend.payment_cyt = price;
  11126. ceErpTradeCellExtend.Create();
  11127. }
  11128. else
  11129. {
  11130. ceErpTradeCellExtend.payment_cyt = price;
  11131. ceErpTradeCellExtend.Update();
  11132. }
  11133. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11134. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11135. {
  11136. ceErpDataSendOrderInfo.isSync = false;
  11137. ceErpDataSendOrderInfo.Update();
  11138. }
  11139. if (ceErpDataSendOrderInfo == null)
  11140. {
  11141. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11142. ceErpDataSendOrderInfo.isSync = false;
  11143. ceErpDataSendOrderInfo.ctid = ctid;
  11144. ceErpDataSendOrderInfo.Create();
  11145. }
  11146. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11147. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11148. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11149. if (dth != null && dth.Rows.Count > 0)
  11150. {
  11151. dataSendOrderBean dataSendOrderBean = null;
  11152. foreach (DataRow item in dth.Rows)
  11153. {
  11154. try
  11155. {
  11156. dataSendOrderBean = new dataSendOrderBean();
  11157. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11158. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11159. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11160. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11161. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11162. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11163. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11164. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11165. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11166. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11167. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11168. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11169. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11170. if (result != null)
  11171. {
  11172. if ("0".Equals(result.errcode))
  11173. {
  11174. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11175. }
  11176. else
  11177. {
  11178. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11179. }
  11180. }
  11181. }
  11182. catch (Exception ex)
  11183. {
  11184. }
  11185. }
  11186. }
  11187. returnSuccessMsg("修改成功!");
  11188. return;
  11189. }
  11190. returnErrorMsg("找不到订单");
  11191. }
  11192. public void find_he_together()
  11193. {
  11194. string ctid = GetPostString("ctid");
  11195. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11196. List<string> list = new List<string>();
  11197. if (ceErpTradeCell != null)
  11198. {
  11199. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11200. {
  11201. 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);
  11202. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11203. if (table != null && table.Rows.Count > 0)
  11204. {
  11205. foreach (TableRow row in table.Rows)
  11206. {
  11207. }
  11208. }
  11209. }
  11210. }
  11211. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11212. }
  11213. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11214. {
  11215. //chy----19
  11216. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11217. //GD-CYT-----64
  11218. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11219. //ZHX----3
  11220. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11221. //JK----97
  11222. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11223. //ZT----70
  11224. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11225. //LHCY-----98
  11226. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11227. //XD-----90
  11228. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11229. //CYCY-----14
  11230. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11231. };
  11232. //其他改名
  11233. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11234. {
  11235. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11236. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11237. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11238. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11239. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11240. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11241. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11242. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11243. };
  11244. //不统计
  11245. List<int> no_suppliers = new List<int>()
  11246. {
  11247. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11248. };
  11249. //配件单
  11250. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11251. {
  11252. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11253. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11254. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11255. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11256. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11257. {"旗杆",new List<string>(){ "班旗" } },
  11258. {"牙签",new List<string>(){ "不干胶" } }
  11259. };
  11260. public void get_place_order_data()
  11261. {
  11262. string date1 = GetPostString("date1");
  11263. string date2 = GetPostString("date2");
  11264. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11265. DateTime start = DateTime.Parse(starttime);
  11266. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11267. DateTime end = DateTime.Parse(endtime);
  11268. if (date1 != null && date1.Length > 0)
  11269. {
  11270. DateTime dateTime = DateTime.Parse(date1);
  11271. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11272. start = DateTime.Parse(starttime);
  11273. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11274. end = DateTime.Parse(endtime);
  11275. }
  11276. if (date2 != null && date2.Length > 0)
  11277. {
  11278. DateTime dateTime = DateTime.Parse(date2);
  11279. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11280. end = DateTime.Parse(endtime);
  11281. }
  11282. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierName is not null ", starttime, endtime);
  11283. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11284. //不干胶-----1,卡片-----29
  11285. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11286. foreach (DataRow row in data.Rows)
  11287. {
  11288. int productId = Convert.ToInt32(row["ProductId"]);
  11289. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11290. if (no_suppliers.Contains(supplierId))
  11291. {
  11292. continue;
  11293. }
  11294. string seller_memo = row["seller_memo"].ToString();
  11295. bool ispj = false;//是否配件单
  11296. bool isfirst = true;//第一个配
  11297. maps.Keys.ForEach(key =>
  11298. {
  11299. //备注包含配件
  11300. if (seller_memo.Contains(key) && isfirst)
  11301. {
  11302. List<string> list = maps[key];
  11303. ispj = true;
  11304. isfirst = false;
  11305. for (int i = 0; i < list.Count; i++)
  11306. {
  11307. if (seller_memo.Contains(list[i]))
  11308. {
  11309. ispj = false;
  11310. break;
  11311. }
  11312. }
  11313. }
  11314. });
  11315. if (ispj)
  11316. {
  11317. continue;
  11318. }
  11319. seller_memo = seller_memo.Replace("UV", "uv");
  11320. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11321. //吊牌归到卡片
  11322. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11323. seller_memo = seller_memo.Replace("卡套", "卡片");
  11324. seller_memo = seller_memo.Replace("封套", "卡片");
  11325. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11326. seller_memo = seller_memo.Replace("腰封", "卡片");
  11327. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11328. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11329. seller_memo = seller_memo.Replace("横幅", "条幅");
  11330. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11331. string map_key = "";
  11332. string type = "";
  11333. if (supplierMap.ContainsKey(supplierId))
  11334. {
  11335. foreach (var kvp in supplierMap[supplierId])
  11336. {
  11337. if (seller_memo.Contains(kvp.Key))
  11338. {
  11339. map_key = kvp.Value;
  11340. type = kvp.Value;
  11341. break;
  11342. }
  11343. }
  11344. }
  11345. if (map_key == "")
  11346. {
  11347. type = "其他";
  11348. map_key = "其他";
  11349. }
  11350. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11351. {
  11352. map_key = suppliers[supplierId];
  11353. }
  11354. if (supplierId == 70)
  11355. {
  11356. supplierId = 70;
  11357. }
  11358. map_key += "_" + row["SupplierName"].ToString();
  11359. Dictionary<string, int> map = null;
  11360. if (other_map.ContainsKey(map_key))
  11361. {
  11362. other_map.TryGetValue(map_key, out map);
  11363. }
  11364. else
  11365. {
  11366. map = new Dictionary<string, int>();
  11367. map.Add("dayDev", 0);//当天出货
  11368. map.Add("dayTotal", 0);//下单总数
  11369. map.Add("payTotal", 0);//500以上
  11370. map.Add("today", 0);//当天出货数量
  11371. map.Add("unusua", 0);//异常数
  11372. other_map.Add(map_key, map);
  11373. other_map.TryGetValue(map_key, out map);
  11374. }
  11375. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11376. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11377. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11378. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11379. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11380. {
  11381. map["dayTotal"]++;
  11382. if (supplierId == 97)
  11383. {
  11384. supplierId = 97;
  11385. }
  11386. }
  11387. if (Convert.ToDecimal(row["payment"]) >= 500)
  11388. {
  11389. map["payTotal"]++;
  11390. }
  11391. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11392. {
  11393. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11394. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11395. {
  11396. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11397. {
  11398. map["today"]++;
  11399. }
  11400. }
  11401. else
  11402. {
  11403. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11404. {
  11405. map["today"]++;
  11406. }
  11407. else
  11408. {
  11409. if (supplierId == 119)
  11410. {
  11411. Debug.WriteLine(row["seller_memo"].ToString());
  11412. }
  11413. }
  11414. }
  11415. }
  11416. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11417. {
  11418. map["unusua"]++;
  11419. }
  11420. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11421. //GD-CYT-----64
  11422. DateTime two = palceTimeStart.AddHours(14);
  11423. DateTime three = palceTimeStart.AddHours(15);
  11424. DateTime four = palceTimeStart.AddHours(16);
  11425. DateTime six = palceTimeStart.AddHours(18);
  11426. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11427. {
  11428. //下午四点前 500-1000
  11429. string count = row["ProductCount"].ToString();
  11430. if (count != null && count.Length > 0)
  11431. {
  11432. int productCount = commonHelper.getPlaceProductCount(count);
  11433. if (productCount >= 500 && productCount <= 1000)
  11434. {
  11435. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11436. {
  11437. map["dayDev"]++;
  11438. }
  11439. }
  11440. }
  11441. }
  11442. //UV
  11443. else if ("uv".Equals(type))
  11444. {
  11445. //ZT----70
  11446. //ZHX----3
  11447. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11448. {
  11449. map["dayDev"]++;
  11450. }
  11451. //JK----97
  11452. //HZX----105
  11453. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11454. {
  11455. map["dayDev"]++;
  11456. }
  11457. }
  11458. //帆布---52|条幅---27
  11459. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11460. {
  11461. //LHCY-----98
  11462. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11463. {
  11464. map["dayDev"]++;
  11465. }
  11466. }
  11467. //条幅
  11468. else if ("条幅".Equals(type))
  11469. {
  11470. //XD-----90
  11471. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11472. {
  11473. map["dayDev"]++;
  11474. }
  11475. }
  11476. //桌布
  11477. else if ("桌布".Equals(type))
  11478. {
  11479. //XD-----90
  11480. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11481. {
  11482. map["dayDev"]++;
  11483. }
  11484. }
  11485. //DL---10
  11486. //AYTW---119
  11487. //FS-CYT-DY ----80
  11488. //JK----97
  11489. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11490. {
  11491. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11492. {
  11493. map["dayDev"]++;
  11494. }
  11495. }
  11496. // QC---121
  11497. else if (supplierId == 121)
  11498. {
  11499. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11500. {
  11501. map["dayDev"]++;
  11502. }
  11503. }
  11504. }
  11505. DataTable dt = new DataTable();
  11506. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11507. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11508. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11509. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11510. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11511. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11512. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11513. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11514. other_map.Keys.ForEach(key =>
  11515. {
  11516. DataRow dr = dt.NewRow();
  11517. Dictionary<string, int> map = other_map[key];
  11518. string[] key_list = key.Split('_');
  11519. dr[0] = key_list[0];
  11520. dr[1] = key_list[1];
  11521. if (key_list.Length > 2)
  11522. {
  11523. dr[1] += "(" + key_list[2] + ")";
  11524. }
  11525. dr[2] = map["dayTotal"];
  11526. dr[3] = map["payTotal"];
  11527. dr[4] = map["today"];
  11528. dr[5] = map["unusua"];
  11529. dr[6] = map["dayDev"];
  11530. double rate = 0.00;
  11531. if (map["dayDev"] > 0)
  11532. {
  11533. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11534. }
  11535. dr[7] = rate.ToString();
  11536. dt.Rows.Add(dr);
  11537. });
  11538. DataView dv = new DataView(dt);
  11539. dv.Sort = "SupplierName";
  11540. //dv.Sort = "AllOrder desc";
  11541. DataTable dtNew = dv.ToTable();
  11542. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11543. }
  11544. public void check_order_desing_info()
  11545. {
  11546. string ctid = GetPostString("ctid");
  11547. if (!string.IsNullOrEmpty(ctid))
  11548. {
  11549. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11550. if (ceErpTradeCell != null)
  11551. {
  11552. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11553. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11554. return;
  11555. }
  11556. returnErrorMsg("找不到订单");
  11557. return;
  11558. }
  11559. returnErrorMsg("找不到订单");
  11560. }
  11561. public void get_timeout_detail()
  11562. {
  11563. string poscode = CurrentUser.UserPost.Post.Code;
  11564. DataStruct dStruct = GetPostStruct();
  11565. List<string> lw = new List<string>();
  11566. string id = GetPostString("id");
  11567. string pay_date1 = GetPostString("pay_date1");
  11568. string pay_date2 = GetPostString("pay_date2");
  11569. int type = GetPostInt("type");
  11570. if (type == 0)
  11571. {
  11572. if (pay_date1.Length > 0)
  11573. {
  11574. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11575. }
  11576. if (pay_date2.Length > 0)
  11577. {
  11578. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11579. }
  11580. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11581. }
  11582. if (type == 1)
  11583. {
  11584. if (pay_date1.Length > 0)
  11585. {
  11586. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11587. }
  11588. if (pay_date2.Length > 0)
  11589. {
  11590. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11591. }
  11592. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11593. }
  11594. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11595. DataTable dt = null;
  11596. dt = WebCache.GetData("view_orderlist", dStruct);
  11597. writeGridDataTableJson(dStruct.TotalCount, dt);
  11598. }
  11599. public void saveUrgentChargePrice()
  11600. {
  11601. string ctid = GetPostString("ctid");
  11602. if (!string.IsNullOrEmpty(ctid))
  11603. {
  11604. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11605. if (ceErpTradeCell != null)
  11606. {
  11607. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11608. if (prices <= 100)
  11609. {
  11610. returnErrorMsg("此订单金额不足100元,无法加急。");
  11611. return;
  11612. }
  11613. double price = GetPostDouble("price");
  11614. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11615. if (ceErpTradeCellExtend == null)
  11616. {
  11617. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11618. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11619. }
  11620. ceErpTradeCellExtend.urgentCharge = price;
  11621. if (ceErpTradeCellExtend.ID > 0)
  11622. {
  11623. ceErpTradeCellExtend.Update();
  11624. }
  11625. else
  11626. {
  11627. ceErpTradeCellExtend.Save();
  11628. }
  11629. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11630. returnSuccessMsg("修改成功!");
  11631. return;
  11632. }
  11633. returnErrorMsg("找不到订单");
  11634. return;
  11635. }
  11636. returnErrorMsg("找不到订单");
  11637. }
  11638. public void finish_erp_order()
  11639. {
  11640. string ctid = GetPostString("ctid");
  11641. if (!string.IsNullOrEmpty(ctid))
  11642. {
  11643. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11644. {
  11645. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11646. if (ceErpTradeCell != null)
  11647. {
  11648. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11649. ceErpTradeCell.Update();
  11650. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11651. returnSuccessMsg("修改成功!");
  11652. return;
  11653. }
  11654. }
  11655. }
  11656. returnErrorMsg("找不到订单");
  11657. }
  11658. public void get_trade_order_list()
  11659. {
  11660. string tid = GetPostString("tid");
  11661. if (!string.IsNullOrEmpty(tid))
  11662. {
  11663. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11664. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11665. writeGridDataTableJson(data.Rows.Count, data);
  11666. return;
  11667. }
  11668. returnErrorMsg("找不到订单");
  11669. }
  11670. public void save_cell_spu()
  11671. {
  11672. string ctid = GetPostString("ctid");
  11673. string spu_id = GetPostString("spu_id");
  11674. if (!string.IsNullOrEmpty(ctid))
  11675. {
  11676. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11677. if (ceErpTradeCellExtend == null)
  11678. {
  11679. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11680. ceErpTradeCellExtend.ctid = ctid;
  11681. }
  11682. ceErpTradeCellExtend.spu_id = spu_id;
  11683. if (!string.IsNullOrEmpty(spu_id))
  11684. {
  11685. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11686. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11687. }
  11688. if (ceErpTradeCellExtend.ID == 0)
  11689. {
  11690. ceErpTradeCellExtend.Create();
  11691. }
  11692. else
  11693. {
  11694. ceErpTradeCellExtend.Update();
  11695. }
  11696. returnSuccessMsg("修改成功!");
  11697. return;
  11698. }
  11699. returnErrorMsg("找不到订单");
  11700. }
  11701. public void change_express_info()
  11702. {
  11703. string ctid = GetPostString("ctid");
  11704. string transNo = GetPostString("transNo");
  11705. string transCom = GetPostString("transCom");
  11706. if (!string.IsNullOrEmpty(ctid))
  11707. {
  11708. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11709. if (ceErpTradeCellExtend == null)
  11710. {
  11711. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11712. ceErpTradeCellExtend.ctid = ctid;
  11713. }
  11714. ceErpTradeCellExtend.modExpressNo = transNo;
  11715. ceErpTradeCellExtend.modExpressCom = transCom;
  11716. ceErpTradeCellExtend.readMod = 2;
  11717. if (ceErpTradeCellExtend.ID == 0)
  11718. {
  11719. ceErpTradeCellExtend.Create();
  11720. }
  11721. else
  11722. {
  11723. ceErpTradeCellExtend.Update();
  11724. }
  11725. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11726. returnSuccessMsg("修改成功!");
  11727. return;
  11728. }
  11729. returnErrorMsg("找不到订单");
  11730. }
  11731. public void get_change_express_list()
  11732. {
  11733. DataStruct dStruct = GetPostStruct();
  11734. List<string> lw = new List<string>();
  11735. int st = 2;
  11736. string tid = GetPostString("ctid");
  11737. if (tid.Length > 0)
  11738. {
  11739. string select_tid = getTidByCtid(tid);
  11740. lw.Add(string.Format("tid='{0}'", select_tid));
  11741. }
  11742. string shopname = GetPostString("shopname");
  11743. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11744. string buyernick = GetPostString("buyer_nick");
  11745. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11746. string sellermemo = GetPostString("seller_memo");
  11747. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11748. string supplier = GetPostString("supplier");
  11749. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11750. string customer = GetPostString("customer");
  11751. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11752. string design = GetPostString("design");
  11753. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11754. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11755. string poscode = CurrentUser.UserPost.Post.Code;
  11756. if (poscode != "SysAdmin")
  11757. {
  11758. string shopid = CurrentUser.User.pemShop;
  11759. lw.Add(string.Format("shopId in ({0})", shopid));
  11760. }
  11761. lw.Add("readMod = 2");
  11762. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11763. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11764. writeGridDataTableJson(dStruct.TotalCount, dt);
  11765. }
  11766. public void deal_express_complete()
  11767. {
  11768. string ctid = GetPostString("ctid");
  11769. if (!string.IsNullOrEmpty(ctid))
  11770. {
  11771. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11772. if (ceErpTradeCellExtend == null)
  11773. {
  11774. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11775. ceErpTradeCellExtend.ctid = ctid;
  11776. }
  11777. ceErpTradeCellExtend.readMod = 1;
  11778. if (ceErpTradeCellExtend.ID == 0)
  11779. {
  11780. ceErpTradeCellExtend.Create();
  11781. }
  11782. else
  11783. {
  11784. ceErpTradeCellExtend.Update();
  11785. }
  11786. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11787. returnSuccessMsg("修改成功!");
  11788. return;
  11789. }
  11790. returnErrorMsg("找不到订单");
  11791. }
  11792. public void aftersale_return_visit()
  11793. {
  11794. string ctid = GetPostString("ctid");
  11795. if (!string.IsNullOrEmpty(ctid))
  11796. {
  11797. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11798. if (ceErpTradeCellExtend == null)
  11799. {
  11800. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11801. ceErpTradeCellExtend.ctid = ctid;
  11802. }
  11803. ceErpTradeCellExtend.returnVisit = 1;
  11804. if (ceErpTradeCellExtend.ID == 0)
  11805. {
  11806. ceErpTradeCellExtend.Create();
  11807. }
  11808. else
  11809. {
  11810. ceErpTradeCellExtend.Update();
  11811. }
  11812. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11813. if (ceErpTradeAfterSaleExtend != null)
  11814. {
  11815. ceErpTradeAfterSaleExtend.TextResult = "";
  11816. ceErpTradeAfterSaleExtend.Update();
  11817. }
  11818. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11819. returnSuccessMsg("修改成功!");
  11820. return;
  11821. }
  11822. returnErrorMsg("找不到订单");
  11823. }
  11824. public void orderPlaceInfo()
  11825. {
  11826. string ctids = GetPostString("ctids");
  11827. string[] list = ctids.Split(',');
  11828. foreach (string ctid in list)
  11829. {
  11830. CeErpSukuraData.createInfo(ctid, 3);
  11831. }
  11832. StringBuilder sql = new StringBuilder();
  11833. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11834. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11835. designHelper.api_approveDesign(ctids); //approveDesign
  11836. returnSuccessMsg("");
  11837. }
  11838. public void get_issue_list()
  11839. {
  11840. DataStruct dStruct = GetPostStruct();
  11841. List<string> lw = new List<string>();
  11842. int st = 2;
  11843. string tid = GetPostString("ctid");
  11844. if (tid.Length > 0)
  11845. {
  11846. string select_tid = getTidByCtid(tid);
  11847. lw.Add(string.Format("tid='{0}'", select_tid));
  11848. }
  11849. string shopname = GetPostString("shopname");
  11850. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11851. string buyernick = GetPostString("buyer_nick");
  11852. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11853. string sellermemo = GetPostString("seller_memo");
  11854. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11855. string supplier = GetPostString("supplier");
  11856. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11857. string customer = GetPostString("customer");
  11858. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11859. string design = GetPostString("design");
  11860. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11861. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11862. string poscode = CurrentUser.UserPost.Post.Code;
  11863. if (poscode != "SysAdmin")
  11864. {
  11865. string shopid = CurrentUser.User.pemShop;
  11866. lw.Add(string.Format("shopId in ({0})", shopid));
  11867. }
  11868. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11869. {
  11870. lw.Add("IssueState = 1");
  11871. }
  11872. lw.Add("IssueState > 0");
  11873. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11874. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11875. writeGridDataTableJson(dStruct.TotalCount, dt);
  11876. }
  11877. public void saveIssueContent()
  11878. {
  11879. string ctid = GetPostString("ctid");
  11880. if (!string.IsNullOrEmpty(ctid))
  11881. {
  11882. string content = GetPostString("content");
  11883. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11884. if (ceErpTradeAfterSaleExtend == null)
  11885. {
  11886. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11887. ceErpTradeAfterSaleExtend.tid = ctid;
  11888. }
  11889. ceErpTradeAfterSaleExtend.IssueContent = content;
  11890. ceErpTradeAfterSaleExtend.IssueState = 1;
  11891. if (ceErpTradeAfterSaleExtend.ID > 0)
  11892. {
  11893. ceErpTradeAfterSaleExtend.Update();
  11894. }
  11895. else
  11896. {
  11897. ceErpTradeAfterSaleExtend.Create();
  11898. }
  11899. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11900. returnSuccessMsg("添加成功!");
  11901. return;
  11902. }
  11903. returnErrorMsg("找不到订单");
  11904. }
  11905. public void dealIssueContent()
  11906. {
  11907. string ctid = GetPostString("ctid");
  11908. if (!string.IsNullOrEmpty(ctid))
  11909. {
  11910. string content = GetPostString("content");
  11911. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11912. if (ceErpTradeAfterSaleExtend != null)
  11913. {
  11914. ceErpTradeAfterSaleExtend.IssueState = 2;
  11915. ceErpTradeAfterSaleExtend.Update();
  11916. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11917. returnSuccessMsg("修改完成!");
  11918. return;
  11919. }
  11920. }
  11921. returnErrorMsg("找不到订单");
  11922. }
  11923. public void set_tid_attachments()
  11924. {
  11925. string tid = GetPostString("tid");
  11926. string atta = GetPostString("atta");
  11927. if (!string.IsNullOrEmpty(tid))
  11928. {
  11929. if (string.IsNullOrEmpty(atta))
  11930. {
  11931. returnErrorMsg("文件地址为空");
  11932. return;
  11933. }
  11934. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11935. if (ceErpTradeCell != null)
  11936. {
  11937. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11938. if (ceErpTrade == null)
  11939. {
  11940. returnErrorMsg("找不到订单");
  11941. return;
  11942. }
  11943. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11944. bool isSend = false;
  11945. if (dt != null && dt.Rows.Count > 0)
  11946. {
  11947. foreach (DataRow row in dt.Rows)
  11948. {
  11949. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11950. {
  11951. isSend = true;
  11952. }
  11953. }
  11954. if (isSend)
  11955. {
  11956. returnErrorMsg("已发货无法修改");
  11957. return;
  11958. }
  11959. ceErpTrade.Attachments = atta;
  11960. ceErpTrade.Update();
  11961. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  11962. returnSuccessMsg("上传成功!");
  11963. return;
  11964. }
  11965. }
  11966. }
  11967. returnErrorMsg("找不到订单");
  11968. }
  11969. public void get_tid_attachments()
  11970. {
  11971. string tid = GetPostString("tid");
  11972. if (!string.IsNullOrEmpty(tid))
  11973. {
  11974. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11975. if (ceErpTradeCell != null)
  11976. {
  11977. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11978. if (ceErpTrade == null)
  11979. {
  11980. returnErrorMsg("找不到订单");
  11981. return;
  11982. }
  11983. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11984. return;
  11985. }
  11986. }
  11987. returnErrorMsg("找不到订单");
  11988. }
  11989. public void check_erp_sameorders()
  11990. {
  11991. if (UrlPostParmsCheck("ctid"))
  11992. {
  11993. string eid = GetPostString("ctid");
  11994. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11995. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11996. if (entity != null && ceErpTrade != null)
  11997. {
  11998. if (entity.OrderState > 6)
  11999. {
  12000. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12001. return;
  12002. }
  12003. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12004. List<string> ids = new List<string>();
  12005. if (dt != null && dt.Rows.Count > 1)
  12006. {
  12007. bool needhe = true;
  12008. foreach (DataRow dr in dt.Rows)
  12009. {
  12010. ids.Add("'" + dr["ctid"] + "'");
  12011. /* //备注有合包
  12012. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12013. {
  12014. needhe = true;
  12015. }
  12016. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12017. {
  12018. needhe = true;
  12019. }
  12020. //顺丰快递
  12021. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12022. {
  12023. needhe = true;
  12024. }*/
  12025. }
  12026. if (!needhe)
  12027. {
  12028. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12029. return;
  12030. }
  12031. StringBuilder sql = new StringBuilder();
  12032. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12033. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12034. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12035. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12036. foreach (DataRow dr in dt.Rows)
  12037. {
  12038. dr["dstate"] = 0;
  12039. dr["dnumber"] = 0;
  12040. foreach (DataRow row in dt1.Rows)
  12041. {
  12042. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12043. {
  12044. dr["dstate"] = 2;
  12045. dr["default"] = 1;
  12046. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12047. }
  12048. }
  12049. if (eid.Equals(dr["ctid"].ToString()))
  12050. {
  12051. dr["dstate"] = 1;
  12052. dr["default"] = 1;
  12053. }
  12054. }
  12055. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12056. return;
  12057. }
  12058. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12059. return;
  12060. }
  12061. returnErrorMsg("未找到订单");
  12062. return;
  12063. }
  12064. returnErrorMsg("缺少必要的参数");
  12065. }
  12066. public void get_mark_number()
  12067. {
  12068. string eid = GetPostString("ctid");
  12069. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12070. if (entity != null)
  12071. {
  12072. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12073. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12074. int current = 1;
  12075. if (ceErpDeliverMark == null)
  12076. {
  12077. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12078. List<string> ids = new List<string>();
  12079. if (dt != null && dt.Rows.Count > 1)
  12080. {
  12081. foreach (DataRow dr in dt.Rows)
  12082. {
  12083. ids.Add("'" + dr["ctid"] + "'");
  12084. }
  12085. //查询已有的编号
  12086. StringBuilder sql = new StringBuilder();
  12087. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12088. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12089. if (dt1 == null || dt1.Rows.Count == 0)
  12090. {
  12091. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12092. List<int> list_number = new List<int>();
  12093. foreach (DataRow row in numbers.Rows)
  12094. {
  12095. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12096. }
  12097. //查询空余编号
  12098. for (int i = 0; i < list_number.Count + 2; i++)
  12099. {
  12100. if (!list_number.Contains(current))
  12101. {
  12102. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12103. //防止查询过程中有新数据生成
  12104. if (ceErpDeliverMark1 == null)
  12105. {
  12106. break;
  12107. }
  12108. }
  12109. current++;
  12110. }
  12111. }
  12112. else
  12113. {
  12114. foreach (DataRow row in dt1.Rows)
  12115. {
  12116. current = Convert.ToInt32(row["markNumber"]);
  12117. }
  12118. }
  12119. ceErpDeliverMark = new CeErpDeliverMark();
  12120. ceErpDeliverMark.ctid = eid;
  12121. ceErpDeliverMark.createtime = DateTime.Now;
  12122. if (ceErpTrade != null)
  12123. {
  12124. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12125. }
  12126. ceErpDeliverMark.markNumber = current;
  12127. ceErpDeliverMark.Create();
  12128. }
  12129. }
  12130. else
  12131. {
  12132. current = ceErpDeliverMark.markNumber;
  12133. }
  12134. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12135. return;
  12136. }
  12137. }
  12138. public void aftersaleCytSend()
  12139. {
  12140. string ctid = GetPostString("ctid");
  12141. if (!string.IsNullOrEmpty(ctid))
  12142. {
  12143. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12144. if (ceErpTradeCell != null)
  12145. {
  12146. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12147. }
  12148. returnSuccessMsg("推送成功");
  12149. return;
  12150. }
  12151. returnErrorMsg("缺少必要的参数");
  12152. }
  12153. public void packOrderInfo()
  12154. {
  12155. string ctids = GetPostString("ctids");
  12156. if (!string.IsNullOrEmpty(ctids))
  12157. {
  12158. string[] ctid_list = ctids.Split(',');
  12159. if (ctid_list.Length > 20)
  12160. {
  12161. returnErrorMsg("单次下载次数不能超过20个");
  12162. return;
  12163. }
  12164. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12165. StringBuilder sql = new StringBuilder();
  12166. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12167. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12168. int supplierId = 0;
  12169. StringBuilder insterSql = new StringBuilder();
  12170. for (int i = 0; i < dt.Rows.Count; i++)
  12171. {
  12172. DataRow row = dt.Rows[i];
  12173. if (i == 0)
  12174. {
  12175. supplierId = Convert.ToInt32(row["SupplierId"]);
  12176. }
  12177. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12178. {
  12179. returnErrorMsg("同车间的订单才能一起打包");
  12180. return;
  12181. }
  12182. int orderState = Convert.ToInt32(row["OrderState"]);
  12183. if (orderState != 5)
  12184. {
  12185. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12186. return;
  12187. }
  12188. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12189. }
  12190. CeErpPackData ceErpPackData = new CeErpPackData();
  12191. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12192. ceErpPackData.supplierId = supplierId;
  12193. ceErpPackData.createtime = DateTime.Now;
  12194. ceErpPackData.createBy = CurrentUser.UserID;
  12195. ceErpPackData.createName = CurrentUser.UserName;
  12196. ceErpPackData.Create();
  12197. if (ceErpPackData.ID > 0)
  12198. {
  12199. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12200. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12201. }
  12202. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12203. returnSuccessMsg("打包成功");
  12204. return;
  12205. }
  12206. returnErrorMsg("缺少必要的参数");
  12207. }
  12208. public void rePackOrderInfo()
  12209. {
  12210. string id = GetPostString("id");
  12211. if (!string.IsNullOrEmpty(id))
  12212. {
  12213. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12214. if (ceErpPackData == null)
  12215. {
  12216. returnSuccessMsg("查无数据");
  12217. return;
  12218. }
  12219. ceErpPackData.upStatus = 0;
  12220. ceErpPackData.message = "";
  12221. ceErpPackData.Update();
  12222. returnSuccessMsg("打包成功");
  12223. return;
  12224. }
  12225. returnErrorMsg("缺少必要的参数");
  12226. }
  12227. public void addPackDownNum()
  12228. {
  12229. string id = GetPostString("id");
  12230. if (!string.IsNullOrEmpty(id))
  12231. {
  12232. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12233. returnSuccessMsg("下载成功");
  12234. return;
  12235. }
  12236. returnErrorMsg("缺少必要的参数");
  12237. }
  12238. public void get_pack_list()
  12239. {
  12240. DataStruct dStruct = GetPostStruct();
  12241. List<string> lw = new List<string>();
  12242. string supplier = GetPostString("supplier");
  12243. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12244. string posTag = CurrentUser.UserPost.Post.Code;
  12245. if (posTag == "Supplier")
  12246. {
  12247. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12248. }
  12249. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12250. dStruct.Order = "createtime desc";
  12251. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12252. writeGridDataTableJson(dStruct.TotalCount, dt);
  12253. }
  12254. public void get_pack_order_list()
  12255. {
  12256. string packId = GetPostString("packId");
  12257. if (string.IsNullOrEmpty(packId))
  12258. {
  12259. returnErrorMsg("缺少必要的参数");
  12260. return;
  12261. }
  12262. StringBuilder sql = new StringBuilder();
  12263. 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);
  12264. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12265. if (dt == null || dt.Rows.Count == 0)
  12266. {
  12267. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12268. return;
  12269. }
  12270. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12271. return;
  12272. }
  12273. public void get_supplier_product_time_list()
  12274. {
  12275. DataStruct dStruct = GetPostStruct();
  12276. List<string> lw = new List<string>();
  12277. string supplier = GetPostString("supplier");
  12278. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12279. string posTag = CurrentUser.UserPost.Post.Code;
  12280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12281. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12282. writeGridDataTableJson(dStruct.TotalCount, dt);
  12283. }
  12284. public void saveSupplierProductTime()
  12285. {
  12286. string productId = GetPostString("productId");
  12287. if (string.IsNullOrEmpty(productId))
  12288. {
  12289. returnErrorMsg("缺少必要的参数");
  12290. return;
  12291. }
  12292. string productName = GetPostString("productName");
  12293. int supplierId = GetPostInt("supplierId");
  12294. if (supplierId == 0)
  12295. {
  12296. returnErrorMsg("缺少必要的参数");
  12297. return;
  12298. }
  12299. int quantity = GetPostInt("quantity");
  12300. int sendDay = GetPostInt("sendTime");
  12301. string supplierName = GetPostString("supplierName");
  12302. string craft = GetPostString("craft");
  12303. string deadLine = GetPostString("deadLine");
  12304. string dayDeadLine = GetPostString("dayDeadLine");
  12305. try
  12306. {
  12307. int eid = GetPostInt("eid");
  12308. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12309. if (ceErpSupplierProductTime == null)
  12310. {
  12311. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12312. }
  12313. ceErpSupplierProductTime.productId = productId;
  12314. ceErpSupplierProductTime.productName = productName;
  12315. ceErpSupplierProductTime.supplierId = supplierId;
  12316. ceErpSupplierProductTime.supplierName = supplierName;
  12317. ceErpSupplierProductTime.craft = craft;
  12318. ceErpSupplierProductTime.sendDay = sendDay;
  12319. ceErpSupplierProductTime.quantity = quantity;
  12320. if (!string.IsNullOrEmpty(deadLine))
  12321. {
  12322. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12323. }
  12324. if (!string.IsNullOrEmpty(dayDeadLine))
  12325. {
  12326. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12327. }
  12328. if (ceErpSupplierProductTime.ID == 0)
  12329. {
  12330. ceErpSupplierProductTime.Save();
  12331. }
  12332. else
  12333. {
  12334. ceErpSupplierProductTime.Update();
  12335. }
  12336. }
  12337. catch (Exception e)
  12338. {
  12339. }
  12340. returnSuccessMsg("保存成功");
  12341. return;
  12342. }
  12343. public void delSupplierProductTime()
  12344. {
  12345. int eid = GetPostInt("eid");
  12346. if (eid > 0)
  12347. {
  12348. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12349. if (ceErpSupplierProductTime == null)
  12350. {
  12351. returnErrorMsg("查无数据");
  12352. return;
  12353. }
  12354. ceErpSupplierProductTime.Delete();
  12355. returnSuccessMsg("保存成功");
  12356. return;
  12357. }
  12358. returnErrorMsg("缺少必要的参数");
  12359. }
  12360. public void getExpressInfo()
  12361. {
  12362. string ctid = GetPostString("ctid");
  12363. if (!string.IsNullOrEmpty(ctid))
  12364. {
  12365. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12366. if (ceErpTradeCell != null)
  12367. {
  12368. string outSid = ceErpTradeCell.OutSid;
  12369. if (outSid.Length > 0)
  12370. {
  12371. 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);
  12372. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12373. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12374. return;
  12375. }
  12376. }
  12377. returnErrorMsg("查无记录");
  12378. return;
  12379. }
  12380. returnErrorMsg("缺少必要的参数");
  12381. }
  12382. public void getExpressPostData()
  12383. {
  12384. string express = GetPostString("express");
  12385. if (!string.IsNullOrEmpty(express))
  12386. {
  12387. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12388. if (ceErpExpressInfo != null)
  12389. {
  12390. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12391. return;
  12392. }
  12393. }
  12394. returnErrorMsg("缺少必要的参数");
  12395. }
  12396. }
  12397. }