sync.order.cs 638 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. namespace SiteCore.Handler
  49. {
  50. public partial class sync
  51. {
  52. public void get_erp_orderlist()
  53. {
  54. string poscode = CurrentUser.UserPost.Post.Code;
  55. DataStruct dStruct = GetPostStruct();
  56. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\uv特殊工艺价格(1).xls");
  57. //apiHelper.Api_SyncOrderByTime("598825");
  58. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  59. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  60. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  61. //banniuApiHelper.sendLogisticsInfo(null);
  62. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  63. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  64. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  65. //int sid = commonHelper.autoDistributeToSupplier(entity);
  66. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  67. //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\"}}");
  68. //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}}");
  69. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  70. //commonHelper.loginGetOrder(2152);
  71. List<string> lw = new List<string>();
  72. string tid = GetPostString("ctid");
  73. string date1 = GetPostString("date1");
  74. //12-1 修改
  75. string urgent = GetPostString("urgent");
  76. string back = GetPostString("back");
  77. string offlineSearch = GetPostString("offlineSearch");
  78. int paramsCount = 0;
  79. if (!string.IsNullOrWhiteSpace(urgent))
  80. {
  81. if (urgent.Equals("true"))
  82. {
  83. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  84. }
  85. }
  86. if (!string.IsNullOrWhiteSpace(back))
  87. {
  88. if (back.Equals("true"))
  89. {
  90. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  91. }
  92. }
  93. if (!string.IsNullOrWhiteSpace(offlineSearch))
  94. {
  95. if (offlineSearch.Equals("true"))
  96. {
  97. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  98. }
  99. }
  100. //end
  101. string date2 = GetPostString("date2");
  102. string buyernick = GetPostString("buyer_nick");
  103. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  104. {
  105. if (tid.Length <= 0 && buyernick.Length <= 0)
  106. {
  107. return;
  108. }
  109. }
  110. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  111. {
  112. if (tid.Length > 0)
  113. {
  114. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  115. if (ceErpTradeCell != null)
  116. {
  117. tid = ceErpTradeCell.tid;
  118. }
  119. List<string> select_tid = getTidByCtidMore(tid);
  120. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  121. }
  122. if (buyernick.Length > 0)
  123. {
  124. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  125. }
  126. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  127. if (dw.Length > 0)
  128. {
  129. lw.Add(dw);
  130. }
  131. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  132. {
  133. string usershop = CurrentUser.User.pemShop;
  134. lw.Add(string.Format("ShopId in ({0})", usershop));
  135. }
  136. }
  137. else
  138. {
  139. if (ex_psize == 0)
  140. {
  141. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  142. }
  143. if (PKey != "admin")
  144. {
  145. string usershop = CurrentUser.User.pemShop;
  146. lw.Add(string.Format("ShopId in ({0})", usershop));
  147. paramsCount++;
  148. }
  149. }
  150. string uploaddate1 = GetPostString("uploaddate1");
  151. string uploaddate2 = GetPostString("uploaddate2");
  152. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  153. if (update.Length > 0) lw.Add(update);
  154. string deliverydate1 = GetPostString("deliverydate1");
  155. string deliverydate2 = GetPostString("deliverydate2");
  156. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  157. if (deliverydate.Length > 0)
  158. {
  159. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  160. };
  161. string shopname = GetPostString("shopname");
  162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  163. string addwechat = GetPostString("addwechat");
  164. if (addwechat.Length > 0)
  165. {
  166. int addWt = Convert.ToInt32(addwechat);
  167. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  168. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  169. }
  170. string customer = GetPostString("customer");
  171. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  172. string design = GetPostString("design");
  173. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  174. string orderState = GetPostString("orderState");
  175. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  176. string address = GetPostString("address");
  177. 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));
  178. string sellermemo = GetPostString("seller_memo");
  179. if (sellermemo.Length > 0)
  180. {
  181. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  182. }
  183. string backReason = GetPostString("backReason");
  184. if (backReason.Length > 0)
  185. {
  186. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  187. }
  188. string apdate1 = GetPostString("apdate1");
  189. string apdate2 = GetPostString("apdate2");
  190. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  191. if (dwap.Length > 0) lw.Add(dwap);
  192. string price1 = GetPostString("price1");
  193. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  194. string price2 = GetPostString("price2");
  195. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  196. string isoldcustomer = GetPostString("isoldcus");
  197. string spudata = GetPostString("spudata");
  198. if ("0".Equals(spudata))
  199. {
  200. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  201. }
  202. if ("1".Equals(spudata))
  203. {
  204. lw.Add(string.Format("spu_id <> ''"));
  205. }
  206. string finishdate1 = GetPostString("finishdate1");
  207. string finishdate2 = GetPostString("finishdate2");
  208. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  209. bool isFinish = false;
  210. if (finishdate.Length > 0)
  211. {
  212. lw.Add(finishdate);
  213. isFinish = true;
  214. paramsCount++;
  215. }
  216. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  217. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  218. if (ex_psize > 0)
  219. {
  220. int UserID = CurrentUser.UserID;
  221. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  222. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  223. {
  224. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  225. }
  226. dStruct.Order = "pay_time desc";
  227. }
  228. string isNew = GetPostString("isNew");
  229. if (isNew == "true")
  230. {
  231. lw.Add(string.Format("IsNew = {0}", 1));
  232. }
  233. string overtime = GetPostString("overtime");
  234. if (overtime == "1")
  235. {
  236. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  237. }
  238. String usePost = CurrentUser.UserPost.Post.Code;
  239. if (usePost.Equals("Operation") == true)
  240. {
  241. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  242. }
  243. else
  244. {
  245. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  246. }
  247. //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";
  248. if (dStruct.PageSize == 100000)
  249. {
  250. dStruct.Order = "";
  251. }
  252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  253. DataTable dt = null;
  254. string tablename = "view_orderlist";
  255. if (isFinish)
  256. {
  257. tablename = "view_orderlist_end";
  258. }
  259. dt = WebCache.GetData(tablename, dStruct);
  260. if (dt != null && dt.Rows.Count > 0)
  261. {
  262. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  263. foreach (DataRow dr in dt.Rows)
  264. {
  265. try
  266. {
  267. if (dr["refund_fees"] != null)
  268. {
  269. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  270. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  271. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  272. if (payment == refund_fees)
  273. {
  274. dr["refund_fees"] = Math.Round(refund_fees, 2);
  275. }
  276. else if (refund_fees == total_fee)
  277. {
  278. dr["refund_fees"] = payment;
  279. }
  280. else
  281. {
  282. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  283. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  284. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  285. }
  286. }
  287. // 对象操作
  288. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  289. ceErpTradeCell.ctid = dr["ctid"].ToString();
  290. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  291. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  292. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  293. if (dStruct.PageSize != 100000)
  294. {
  295. if (dr["DispatchSort"].ToString() == "2")
  296. {
  297. dr["gongchuang"] = 200;
  298. }
  299. else if ("外协".Equals(dr["ToType"].ToString()))
  300. {
  301. dr["gongchuang"] = 200;
  302. }
  303. else if ("内部".Equals(dr["ToType"].ToString()))
  304. {
  305. dr["gongchuang"] = -1;
  306. }
  307. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  308. {
  309. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  310. dr["gongchuang"] = response.code;
  311. }
  312. }
  313. }
  314. catch (NullReferenceException ex)
  315. {
  316. // 处理空引用异常
  317. dr["refund_fees"] = "0.00";
  318. }
  319. }
  320. }
  321. writeGridDataTableJson(dStruct.TotalCount, dt);
  322. }
  323. public void get_erp_orderlist_sumprice()
  324. {
  325. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  326. return;
  327. List<string> lw = new List<string>();
  328. string tid = GetPostString("ctid");
  329. string date1 = GetPostString("date1");
  330. string date2 = GetPostString("date2");
  331. if (tid.Length > 0 || date1.Length > 0)
  332. {
  333. lw.Add(string.Format("ctid like '%{0}%'", tid));
  334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  335. if (dw.Length > 0) lw.Add(dw);
  336. }
  337. else
  338. {
  339. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  340. }
  341. string shopname = GetPostString("shopname");
  342. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  343. string buyernick = GetPostString("buyer_nick");
  344. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  345. string customer = GetPostString("customer");
  346. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  347. string design = GetPostString("design");
  348. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  349. string orderState = GetPostString("orderState");
  350. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  351. string address = GetPostString("address");
  352. 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));
  353. string sellermemo = GetPostString("seller_memo");
  354. if (sellermemo.Length > 0)
  355. {
  356. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  357. }
  358. string apdate1 = GetPostString("apdate1");
  359. string apdate2 = GetPostString("apdate2");
  360. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  361. if (dwap.Length > 0) lw.Add(dwap);
  362. string price1 = GetPostString("price1");
  363. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  364. string price2 = GetPostString("price2");
  365. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  366. string isoldcustomer = GetPostString("isoldcus");
  367. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  368. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  369. if (PKey != "admin")
  370. {
  371. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  372. lw.Add(string.Format("shopId in ({0})", usershop));
  373. }
  374. //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";
  375. string mainWhere = string.Join(" and ", lw.ToArray());
  376. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  377. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  378. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  379. decimal total = 0;
  380. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  381. {
  382. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  383. }
  384. var res = new
  385. {
  386. data = total
  387. };
  388. string ro_jsond = JsonConvert.SerializeObject(res);
  389. returnSuccess(ro_jsond);
  390. return;
  391. }
  392. public void get_erp_CustomerServiceGather()
  393. {
  394. string userWhere = "", orderWhere = "";
  395. List<string> lw = new List<string>();
  396. string customer = GetPostString("customer");
  397. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  398. string shopname = GetPostString("shopname");
  399. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  400. string date1 = GetPostString("date1");
  401. string date2 = GetPostString("date2");
  402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  403. if (dw.Length > 0) lw.Add(dw);
  404. orderWhere = string.Join(" and ", lw.ToArray());
  405. 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 " +
  406. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  407. "left join " +
  408. "( " +
  409. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  410. ") as b on a.ID = b.CustomerUserId " +
  411. "left join " +
  412. "( " +
  413. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  414. ") as d on a.ID = d.CustomerUserId " +
  415. "left join " +
  416. "( " +
  417. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  418. ") as e on a.ID = e.CustomerUserId " +
  419. "left join " +
  420. "( " +
  421. " select CustomerUserId, RefundCount, RefundSum from " +
  422. " ( " +
  423. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  424. " from CE_ErpTradeRefund a " +
  425. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  426. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  427. " group by CustomerUserId " +
  428. " ) as a " +
  429. ") as f on a.ID = f.CustomerUserId " +
  430. "where a.PostCode = 'CustomerService'",
  431. userWhere, orderWhere);
  432. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  433. writeGridDataTableJson(dt.Rows.Count, dt);
  434. //writeGridDataTableJson(dt.Rows.Count, dt);
  435. }
  436. //设计汇总
  437. public void get_erp_DesignerGather()
  438. {
  439. string userWhere = "", orderWhere = "";
  440. List<string> lw = new List<string>();
  441. string Designer = GetPostString("designer");
  442. int org = GetPostInt("org");
  443. if (Designer.Length > 0)
  444. {
  445. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  446. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  447. }
  448. else if (org > 0)
  449. {
  450. userWhere = string.Format(" where OrgID ={0}", org);
  451. }
  452. string shopname = GetPostString("shopname");
  453. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  454. string state = GetPostString("state");
  455. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  456. string OrderArea = GetPostString("order_area");
  457. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  458. string date1 = GetPostString("date1");
  459. string date2 = GetPostString("date2");
  460. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  461. if (dw.Length > 0) lw.Add(dw);
  462. string UpDate1 = GetPostString("UpDate1");
  463. string UpDate2 = GetPostString("UpDate2");
  464. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  465. if (dw.Length > 0) lw.Add(dw);
  466. orderWhere = string.Join(" and ", lw.ToArray());
  467. 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 (" +
  468. "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 " +
  469. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  470. "left join " +
  471. "( " +
  472. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  473. ") as b on a.ID = b.DesignUserId " +
  474. "left join " +
  475. "( " +
  476. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  477. ") as d on a.ID = d.DesignUserId " +
  478. "left join " +
  479. "( " +
  480. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  481. ") as e on a.ID = e.DesignUserId " +
  482. "left join " +
  483. "( " +
  484. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  485. ") as g on a.ID = g.DesignUserId " +
  486. "left join " +
  487. "( " +
  488. " select CustomerUserId, RefundCount, RefundSum from " +
  489. " ( " +
  490. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  491. " from CE_ErpTradeRefund a " +
  492. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  493. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  494. " group by CustomerUserId " +
  495. " ) as a " +
  496. ") as f on a.ID = f.CustomerUserId " +
  497. "where a.PostCode = 'Designer') as z",
  498. userWhere, orderWhere);
  499. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  500. writeGridDataTableJson(dt.Rows.Count, dt);
  501. }
  502. //删除tradecell的订单
  503. public void del_erp_cellorder()
  504. {
  505. if (UrlPostParmsCheck("ctid"))
  506. {
  507. string eid = GetPostString("ctid");
  508. CeErpTradeCell.DelByCtid(eid);
  509. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  510. returnSuccessMsg("删除成功");
  511. }
  512. }
  513. public void clear_erp_refundstate()
  514. {
  515. if (UrlPostParmsCheck("ids"))
  516. {
  517. string eids = GetPostString("ids");
  518. string[] ctidList = eids.Split(',');
  519. foreach (string ctid in ctidList)
  520. {
  521. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  522. if (entity != null)
  523. {
  524. entity.IsRefund = 0;
  525. entity.Update();
  526. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  527. }
  528. else
  529. continue;
  530. }
  531. returnSuccessMsg("操作成功");
  532. return;
  533. }
  534. returnErrorMsg("缺少必要参数");
  535. }
  536. public void set_erp_urgency()
  537. {
  538. if (UrlPostParmsCheck("ctid"))
  539. {
  540. string eid = GetPostString("ctid");
  541. CeErpTradeCell entity = null;
  542. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  543. if (entity != null)
  544. {
  545. double prices = commonHelper.calculationPrice(entity);
  546. if (prices <= 100)
  547. {
  548. returnErrorMsg("此订单金额不足100元,无法加急。");
  549. return;
  550. }
  551. string utime = GetPostString("urgencytime");
  552. if (utime.Length > 0)
  553. {
  554. entity.UrgencyTime = Convert.ToDateTime(utime);
  555. }
  556. else
  557. {
  558. returnErrorMsg("请选择加急时间");
  559. return;
  560. }
  561. if (entity.OrderState <= 4)
  562. {
  563. //entity.seller_memo = entity.seller_memo + "-加急";
  564. string smemo = entity.seller_memo;
  565. int kindex = smemo.IndexOf(")");
  566. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  567. if (lastoneStr != "-")
  568. {
  569. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  570. }
  571. string prememo = smemo.Substring(0, kindex + 2);
  572. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  573. int lastkindex = lastmemo.IndexOf("(");
  574. DateTime urgtime = Convert.ToDateTime(utime);
  575. string newlastmemo = "";
  576. if (lastkindex == 0)
  577. {
  578. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  579. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  580. }
  581. else
  582. {
  583. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  584. }
  585. entity.seller_memo = prememo + newlastmemo;
  586. }
  587. entity.IsUrgency = true;
  588. entity.UpdateTime = DateTime.Now;
  589. entity.Update();
  590. ApiVo apiVo = new ApiVo();
  591. apiVo.orderNumber = entity.ctid;
  592. apiVo.actionName = "changeDesign";
  593. apiVo.orderRemarks = entity.seller_memo;
  594. apiVo.remarkSign = 3;
  595. designHelper.API_WorkCore(apiVo); //changeDesign
  596. CeErpSukuraData.createInfo(entity.ctid, 7);
  597. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  598. returnSuccessMsg("设置成功!");
  599. return;
  600. }
  601. returnErrorMsg("找不到记录");
  602. }
  603. }
  604. public void set_erp_reset()
  605. {
  606. if (UrlPostParmsCheck("ctid"))
  607. {
  608. string eid = GetPostString("ctid");
  609. CeErpTradeCell entity = null;
  610. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  611. if (entity != null)
  612. {
  613. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  614. {
  615. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  616. {
  617. returnErrorMsg("财务要求已下单已发货无法重置");
  618. return;
  619. }
  620. }
  621. entity.IsUrgency = false;
  622. entity.seller_memo = "";
  623. entity.OtherMemo = "";
  624. entity.OrderState = 0;
  625. entity.IsReturn = 0;
  626. //entity.IsRefund = 0;
  627. entity.MemoOpt = 0;
  628. entity.AfterSaleState = 0;
  629. entity.AfterSaleResponsible = "";
  630. entity.AfterSaleUserId = 0;
  631. entity.IsNeedBill = 0;
  632. entity.CustomerUserId = 0;
  633. entity.DesignUserId = 0;
  634. entity.SupplierId = 0;
  635. entity.PlaceUserId = 0;
  636. entity.ptid = "";
  637. entity.IsSample = 0;
  638. entity.IsXianHuo = 0;
  639. entity.isDianziOrder = 0;
  640. entity.DispatchSort = 0;
  641. entity.FinishPlaceTime = null;
  642. entity.Update();
  643. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  644. if (trade != null)
  645. {
  646. trade.seller_memo = "";
  647. trade.Update();
  648. }
  649. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  650. returnSuccessMsg("重置成功!");
  651. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  652. if (desginBill != null)
  653. {
  654. desginBill.isDel = 1;
  655. desginBill.Update();
  656. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  657. }
  658. ApiVo apiVo = new ApiVo();
  659. apiVo.orderNumber = entity.ctid;
  660. apiVo.actionName = "resetDesign";
  661. designHelper.API_WorkCore(apiVo);//resetDesign
  662. return;
  663. }
  664. returnErrorMsg("找不到记录");
  665. }
  666. }
  667. public void save_erp_sellermemo()
  668. {
  669. if (UrlPostParmsCheck("ctid"))
  670. {
  671. string ctid = GetPostString("ctid");
  672. CeErpTradeCell entity = null;
  673. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  674. if (entity != null)
  675. {
  676. string memo = GetPostString("seller_memo");
  677. memo = memo.Replace(" ", "");
  678. if (memo.Contains("补差"))
  679. {
  680. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  681. return;
  682. }
  683. List<string> bitList = new List<string>
  684. {
  685. "\\","/",":","*","?", "\"","<" ,">","|"
  686. };
  687. bool isIn = false;
  688. foreach (string bit in bitList)
  689. {
  690. if (memo.Contains(bit))
  691. {
  692. isIn = true;
  693. }
  694. }
  695. if (isIn)
  696. {
  697. returnErrorMsg("不能使用 一些符合作为文件名");
  698. return;
  699. }
  700. if (entity.seller_memo != memo)
  701. {
  702. if (entity.IsSample == 2)
  703. {
  704. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  705. return;
  706. }
  707. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  708. {
  709. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  710. {
  711. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  712. return;
  713. }
  714. /*if (CurrentUser.UserPost.Post.Code != "Place")
  715. {
  716. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  717. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  718. {
  719. returnErrorMsg("售前系统订单无法再此修改!");
  720. return;
  721. }
  722. }*/
  723. }
  724. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  725. }
  726. commonHelper.getCytPrice(entity);
  727. int memoopt = GetPostInt("MemoOpt");
  728. Boolean ismemoopt = false;
  729. if (memoopt > 0)
  730. {
  731. string stropt = "";
  732. if (memoopt == 1)
  733. {
  734. stropt = "“改稿”";
  735. ismemoopt = true;
  736. }
  737. else if (memoopt == 2)
  738. {
  739. stropt = "“定稿”";
  740. }
  741. else if (memoopt == 3)
  742. {
  743. stropt = "“查货”";
  744. CeErpSukuraData.createInfo(entity.ctid, 6);
  745. }
  746. entity.MemoOpt = Convert.ToInt32(memoopt);
  747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  748. }
  749. if (entity.OrderState < 5)
  750. {
  751. memo = memo.Replace("(", "(");
  752. memo = memo.Replace(")", ")");
  753. }
  754. if (entity.OrderState < 3)
  755. {
  756. entity.DispatchSort = 0;
  757. }
  758. entity.seller_memo = memo;
  759. entity.UpdateTime = DateTime.Now;
  760. entity.Update();
  761. ApiVo apiVo = new ApiVo();
  762. apiVo.orderNumber = entity.ctid;
  763. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  764. apiVo.orderRemarks = memo;
  765. apiVo.remarkSign = memoopt;
  766. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  767. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  768. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  769. {
  770. dataHelper.api_orderBack(entity.ctid, "0", "");
  771. }
  772. if (entity.seller_memo.Contains("改稿"))
  773. {
  774. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  775. }
  776. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  777. returnSuccessMsg("保存成功!");
  778. return;
  779. }
  780. returnErrorMsg("找不到记录");
  781. }
  782. }
  783. public void ins_erp_checkorder()
  784. {
  785. if (UrlPostParmsCheck("ctid"))
  786. {
  787. string ctid = GetPostString("ctid");
  788. CeErpTradeCell entity = null;
  789. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  790. if (entity != null)
  791. {
  792. if (entity.OrderState < 6)
  793. {
  794. returnErrorMsg("下单完成后才可查货");
  795. return;
  796. }
  797. /*if (entity.OrderState > 6)
  798. {
  799. returnErrorMsg("订单已发货");
  800. return;
  801. }*/
  802. if (entity.FinishPlaceTime != null)
  803. {
  804. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  805. {
  806. returnErrorMsg("下单时间不足,无法查货");
  807. return;
  808. }
  809. }
  810. entity.MemoOpt = 3;
  811. entity.CheckOrderTime = DateTime.Now;
  812. entity.UpdateTime = DateTime.Now;
  813. entity.Update();
  814. CeErpSukuraData.createInfo(entity.ctid, 6);
  815. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  816. returnSuccessMsg("操作成功!");
  817. return;
  818. }
  819. returnErrorMsg("找不到记录");
  820. }
  821. }
  822. public void save_erp_othermemo()
  823. {
  824. if (UrlPostParmsCheck("ctid"))
  825. {
  826. string ctid = GetPostString("ctid");
  827. CeErpTradeCell entity = null;
  828. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  829. if (entity != null)
  830. {
  831. entity.OtherMemo = GetPostString("otherMemo");
  832. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  833. {
  834. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  835. StringBuilder sql = new StringBuilder();
  836. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  837. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  838. if (dt != null && dt.Rows.Count > 0)
  839. {
  840. foreach (DataRow dr in dt.Rows)
  841. {
  842. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  843. {
  844. //品类一直
  845. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  846. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  847. if (ceErpSampleCustomer == null)
  848. {
  849. ceErpSampleCustomer = new CeErpSampleCustomer();
  850. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  851. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  852. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  853. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  854. ceErpSampleCustomer.shopId = entity.ShopId;
  855. }
  856. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  857. ceErpSampleCustomer.lastTid = entity.tid;
  858. if (ceErpSampleCustomer.ID > 0)
  859. {
  860. ceErpSampleCustomer.Update();
  861. }
  862. else
  863. {
  864. ceErpSampleCustomer.Create();
  865. }
  866. }
  867. }
  868. }
  869. }
  870. //if (entity.IsOldCustomer == 1)
  871. //{
  872. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  873. //{
  874. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  875. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  876. //}
  877. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  878. //{
  879. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  880. // {
  881. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  882. // {
  883. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  884. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  885. // }
  886. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  887. // {
  888. // entity.OrderState = 2;
  889. // entity.DesignUserId = 0;
  890. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  891. // }
  892. // else
  893. // {
  894. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  895. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  896. // }
  897. // }
  898. //}
  899. //}
  900. entity.UpdateTime = DateTime.Now;
  901. entity.Update();
  902. returnSuccessMsg("保存成功!");
  903. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  904. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  905. if (entity.OtherMemo.Contains("改稿"))
  906. {
  907. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  908. }
  909. return;
  910. }
  911. returnErrorMsg("找不到记录");
  912. }
  913. }
  914. public void save_erp_customermemo()
  915. {
  916. if (UrlPostParmsCheck("ctid"))
  917. {
  918. string ctid = GetPostString("ctid");
  919. CeErpTradeCell entity = null;
  920. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  921. if (entity != null)
  922. {
  923. entity.UpdateTime = DateTime.Now;
  924. entity.CustomerMemo = GetPostString("CustomerMemo");
  925. entity.Update();
  926. ApiVo apiVo = new ApiVo();
  927. apiVo.orderNumber = entity.ctid;
  928. apiVo.actionName = "followRemarks";
  929. apiVo.orderRemarks = entity.CustomerMemo;
  930. designHelper.API_WorkCore(apiVo);//followRemarks
  931. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  932. returnSuccessMsg("保存成功!");
  933. return;
  934. }
  935. returnErrorMsg("找不到记录");
  936. }
  937. }
  938. public void upd_erp_addmemotag()
  939. {
  940. if (UrlPostParmsCheck("ctid"))
  941. {
  942. ;
  943. string eid = GetPostString("ctid");
  944. string sfTagstr = GetPostString("memotag");
  945. CeErpTradeCell entity = null;
  946. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  947. if (entity != null)
  948. {
  949. ApiVo apiVo = new ApiVo();
  950. if (entity.OrderState == 0)
  951. {
  952. returnErrorMsg("请先领单");
  953. return;
  954. }
  955. //撤销顺丰
  956. if (sfTagstr == "撤销顺丰")
  957. {
  958. entity.IsSF = 0;
  959. string reMsg = "";
  960. string oldmemo = entity.seller_memo;
  961. if (entity.OrderState < 5)
  962. {
  963. oldmemo = oldmemo.Replace("顺丰到付", "");
  964. oldmemo = oldmemo.Replace("顺丰寄付", "");
  965. entity.seller_memo = oldmemo;
  966. }
  967. else
  968. {
  969. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  970. {
  971. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  972. }
  973. }
  974. entity.Update();
  975. apiVo.orderNumber = entity.ctid;
  976. apiVo.actionName = "orderRemarks";
  977. apiVo.orderRemarks = entity.seller_memo;
  978. apiVo.isSf = entity.IsSF.ToString();
  979. designHelper.API_WorkCore(apiVo);//orderRemarks
  980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  981. returnSuccessMsg("撤销成功!" + reMsg);
  982. return;
  983. }
  984. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  985. {
  986. //string oldmemo = entity.seller_memo;
  987. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  988. string sfStr = GetPostString("memotag");
  989. string smemo = entity.seller_memo;
  990. int kindex = smemo.IndexOf(")");
  991. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  992. if (lastoneStr != "-")
  993. {
  994. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  995. }
  996. string prememo = smemo.Substring(0, kindex + 2);
  997. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  998. int lastkindex = lastmemo.IndexOf("(");
  999. string newlastmemo = "";
  1000. if (lastkindex == 0)
  1001. {
  1002. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1003. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1004. }
  1005. else
  1006. {
  1007. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1008. }
  1009. entity.seller_memo = prememo + newlastmemo;
  1010. }
  1011. string sfTagMSg = "";
  1012. if (sfTagstr == "顺丰寄付")
  1013. {
  1014. entity.IsSF = 1;
  1015. sfTagMSg = "顺丰寄付";
  1016. }
  1017. else if (sfTagstr == "顺丰到付")
  1018. {
  1019. entity.IsSF = 2;
  1020. sfTagMSg = "顺丰到付";
  1021. }
  1022. entity.Update();
  1023. apiVo = new ApiVo();
  1024. apiVo.orderNumber = entity.ctid;
  1025. apiVo.actionName = "orderRemarks";
  1026. apiVo.orderRemarks = entity.seller_memo;
  1027. apiVo.isSf = entity.IsSF.ToString();
  1028. designHelper.API_WorkCore(apiVo);//orderRemarks
  1029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1030. returnSuccessMsg("标记成功!");
  1031. return;
  1032. }
  1033. returnErrorMsg("找不到记录");
  1034. }
  1035. }
  1036. public void upd_erp_ordertag()
  1037. {
  1038. if (UrlPostParmsCheck("ctid"))
  1039. {
  1040. string eid = GetPostString("ctid");
  1041. CeErpTradeCell entity = null;
  1042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1043. if (entity != null)
  1044. {
  1045. int tag = GetPostInt("wechattag");
  1046. //if(tag==4 && entity.IsSample == 2)
  1047. //{
  1048. // returnErrorMsg("补差价单不能标记微信单");
  1049. // return;
  1050. //}
  1051. entity.wechatTag = tag;
  1052. entity.Update();
  1053. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1054. if (tag == 1)
  1055. {
  1056. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1057. if (cash == null)
  1058. {
  1059. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1060. cash = new CeErpReturnCash();
  1061. cash.tid = entity.tid;
  1062. cash.seller_nick = main.seller_nick;
  1063. cash.payment = trade.payment;
  1064. cash.buyer_nick = main.buyer_nick;
  1065. cash.cashstate = 0;
  1066. cash.rtype = "微信返现";
  1067. cash.returnprice = 0;
  1068. cash.created = DateTime.Now;
  1069. cash.con = "订单标记微信单";
  1070. cash.img = "";
  1071. cash.applyuserid = CurrentUser.UserID;
  1072. cash.Create();
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1074. }
  1075. else
  1076. {
  1077. cash.cashstate = 0;
  1078. cash.Update();
  1079. }
  1080. CeErpSukuraData.createInfo(entity.ctid, 9);
  1081. }
  1082. else if (tag == 2)
  1083. {
  1084. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1085. if (cash == null)
  1086. {
  1087. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1088. cash = new CeErpReturnCash();
  1089. cash.tid = entity.tid;
  1090. cash.seller_nick = main.seller_nick;
  1091. cash.payment = trade.payment;
  1092. cash.buyer_nick = main.buyer_nick;
  1093. cash.cashstate = 0;
  1094. cash.rtype = "推购返现";
  1095. cash.returnprice = 5;
  1096. cash.created = DateTime.Now;
  1097. cash.con = "订单标记推购单";
  1098. cash.img = "";
  1099. cash.applyuserid = CurrentUser.UserID;
  1100. cash.Create();
  1101. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1102. }
  1103. else
  1104. {
  1105. cash.cashstate = 0;
  1106. cash.Update();
  1107. }
  1108. CeErpSukuraData.createInfo(entity.ctid, 9);
  1109. }
  1110. else if (tag == 3)
  1111. {
  1112. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1113. if (pers == null)
  1114. {
  1115. pers = new CeErpPersuade();
  1116. pers.ctid = entity.ctid;
  1117. pers.pstate = 0;
  1118. pers.created = DateTime.Now;
  1119. pers.applyuserid = CurrentUser.UserID;
  1120. pers.Create();
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1122. }
  1123. else
  1124. {
  1125. pers.pstate = 0;
  1126. pers.Update();
  1127. }
  1128. }
  1129. else if (tag == 4 || tag == 5)
  1130. {
  1131. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1132. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1133. if (pers == null)
  1134. {
  1135. pers = new CeErpStayGoods();
  1136. pers.t_id = entity.tid;
  1137. pers.status = "待审核";
  1138. pers.audit_type = 0;
  1139. if (tag == 4)
  1140. {
  1141. pers.stay_type = "微信推购";
  1142. }
  1143. else
  1144. {
  1145. pers.stay_type = "旺旺推购";
  1146. }
  1147. if (entity.IsXianHuo == 0)
  1148. {
  1149. pers.product_id = entity.ProductId;
  1150. }
  1151. pers.wangwang = main.buyer_nick;
  1152. pers.shop_name = main.seller_nick;
  1153. pers.creata_time = DateTime.Now;
  1154. pers.create_u_id = CurrentUser.UserID;
  1155. pers.create_u_name = CurrentUser.UserName;
  1156. pers.Create();
  1157. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1158. }
  1159. else
  1160. {
  1161. pers.audit_type = 0;
  1162. pers.Update();
  1163. }
  1164. CeErpSukuraData.createInfo(entity.ctid, 10);
  1165. }
  1166. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1167. returnSuccessMsg("标记成功!");
  1168. return;
  1169. }
  1170. returnErrorMsg("找不到记录");
  1171. }
  1172. }
  1173. public void upd_erp_ordertag_cancel()
  1174. {
  1175. if (UrlPostParmsCheck("ctid"))
  1176. {
  1177. string eid = GetPostString("ctid");
  1178. CeErpTradeCell entity = null;
  1179. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1180. if (entity != null)
  1181. {
  1182. entity.wechatTag = 0;
  1183. entity.Update();
  1184. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1185. if (pers != null)
  1186. {
  1187. pers.status = "取消推购";
  1188. pers.audit_type = 3;
  1189. pers.Update();
  1190. }
  1191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1192. returnSuccessMsg("标记成功!");
  1193. return;
  1194. }
  1195. returnErrorMsg("找不到记录");
  1196. }
  1197. }
  1198. public void upd_erp_addweichattag()
  1199. {
  1200. if (UrlPostParmsCheck("ctid"))
  1201. {
  1202. ;
  1203. string eid = GetPostString("ctid");
  1204. CeErpTradeCell entity = null;
  1205. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1206. if (entity != null)
  1207. {
  1208. if (entity.IsAddWechat > 0)
  1209. {
  1210. returnErrorMsg("此单已经标记过了");
  1211. return;
  1212. }
  1213. 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);
  1214. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1215. if (dt.Rows.Count > 0)
  1216. {
  1217. entity.IsAddWechat = 2;
  1218. }
  1219. else
  1220. {
  1221. entity.IsAddWechat = 1;
  1222. }
  1223. entity.Update();
  1224. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1225. returnSuccessMsg("标记成功!");
  1226. return;
  1227. }
  1228. returnErrorMsg("找不到记录");
  1229. }
  1230. }
  1231. public void upd_erp_getmyorder()
  1232. {
  1233. if (UrlPostParmsCheck("ctid"))
  1234. {
  1235. ;
  1236. string eid = GetPostString("ctid");
  1237. CeErpTradeCell entity = null;
  1238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1239. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1240. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1241. {
  1242. returnErrorMsg("台湾客户需填写身份证号!");
  1243. return;
  1244. }
  1245. if (entity != null)
  1246. {
  1247. if (entity.ctid.IndexOf("C") != -1)
  1248. {
  1249. StringBuilder sql = new StringBuilder();
  1250. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1251. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1252. if (dt.Rows.Count > 0)
  1253. {
  1254. decimal total = 0;
  1255. foreach (DataRow dr in dt.Rows)
  1256. {
  1257. total += Convert.ToDecimal(dr["payment"]);
  1258. }
  1259. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1260. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1261. {
  1262. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1263. return;
  1264. }
  1265. }
  1266. }
  1267. if (entity.OrderState == -1)
  1268. {
  1269. returnErrorMsg("待审核订单无法领取!");
  1270. return;
  1271. }
  1272. entity.CustomerUserId = CurrentUser.UserID;
  1273. if (entity.OrderState < 2)
  1274. {
  1275. entity.OrderState = 2;
  1276. if (entity.ShopId != 0)
  1277. {
  1278. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1279. }
  1280. }
  1281. entity.UpdateTime = DateTime.Now;
  1282. entity.Update();
  1283. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1284. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1285. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1286. {
  1287. dataHelper.api_orderBack(entity.ctid, "0", "");
  1288. }
  1289. returnSuccessMsg("领单成功!");
  1290. return;
  1291. }
  1292. returnErrorMsg("找不到记录");
  1293. }
  1294. }
  1295. public void getmyorder_from_init()
  1296. {
  1297. if (UrlPostParmsCheck("ctid"))
  1298. {
  1299. string eid = GetPostString("ctid");
  1300. CeErpTradeCell entity = null;
  1301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1302. if (entity != null)
  1303. {
  1304. string sellerMemo = GetPostString("sellerMemo");
  1305. if (sellerMemo.Length > 0)
  1306. {
  1307. entity.seller_memo = sellerMemo;
  1308. }
  1309. string oterhMemo = GetPostString("otherMemo");
  1310. if (oterhMemo.Length > 0)
  1311. {
  1312. entity.OtherMemo = oterhMemo;
  1313. }
  1314. int urg = GetPostInt("urgency");
  1315. entity.IsUrgency = (urg == 1 ? true : false);
  1316. int wechat = GetPostInt("wechat");
  1317. int command = GetPostInt("command");
  1318. if (wechat == 1)
  1319. {
  1320. entity.wechatTag = 1;
  1321. }
  1322. if (command == 1)
  1323. {
  1324. entity.wechatTag = 2;
  1325. }
  1326. string pPro = GetPostString("pprofession");
  1327. if (pPro.Length > 0)
  1328. {
  1329. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1330. string spro = GetPostString("profession");
  1331. if (spro.Length > 0)
  1332. {
  1333. entity.ProfessionId = Convert.ToInt32(spro);
  1334. }
  1335. }
  1336. string proId = GetPostString("productId");
  1337. if (proId.Length > 0)
  1338. {
  1339. entity.ProductId = Convert.ToInt32(proId);
  1340. }
  1341. entity.Material = GetPostString("material");
  1342. entity.Craft = GetPostString("craft");
  1343. entity.CustomerUserId = CurrentUser.UserID;
  1344. if (entity.OrderState < 2)
  1345. {
  1346. entity.OrderState = 2;
  1347. if (entity.ShopId != 0)
  1348. {
  1349. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1350. }
  1351. }
  1352. entity.Update();
  1353. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1354. returnSuccessMsg("领单成功!");
  1355. return;
  1356. }
  1357. returnErrorMsg("找不到记录");
  1358. }
  1359. }
  1360. public void upd_erp_setrelationorder()
  1361. {
  1362. if (UrlPostParmsCheck("ctid"))
  1363. {
  1364. ;
  1365. string eid = GetPostString("ctid");
  1366. string ftid = GetPostString("ftid");
  1367. CeErpTradeCell entity = null;
  1368. CeErpTradeCell fentity = null;
  1369. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1370. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1371. if (fentity == null)
  1372. {
  1373. returnErrorMsg("找不到关联的主订单");
  1374. return;
  1375. }
  1376. if (entity != null)
  1377. {
  1378. if (entity.OrderState >= 5)
  1379. {
  1380. returnErrorMsg("本单已经设计完成无法关联");
  1381. return;
  1382. }
  1383. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1384. {
  1385. returnErrorMsg("线下单续审核后才能关联!");
  1386. return;
  1387. }
  1388. entity.ptid = ftid;
  1389. entity.OrderState = fentity.OrderState;
  1390. //entity.status = fentity.status;
  1391. entity.CustomerUserId = fentity.CustomerUserId;
  1392. entity.DesignUserId = fentity.DesignUserId;
  1393. entity.seller_memo = "补差价单:" + ftid;
  1394. entity.IsSample = 2;
  1395. entity.Update();
  1396. ApiVo apiVo = new ApiVo();
  1397. apiVo.orderNumber = ftid;
  1398. apiVo.payment = entity.payment;
  1399. apiVo.actionName = "repairDesign";
  1400. designHelper.API_WorkCore(apiVo);//repairDesign
  1401. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1402. returnSuccessMsg("关联成功!");
  1403. return;
  1404. }
  1405. else
  1406. returnErrorMsg("找不到记录");
  1407. }
  1408. }
  1409. public void download_erp_neworder()
  1410. {
  1411. string seller = GetPostString("seller_nick");
  1412. string tid = GetPostString("tid");
  1413. if (seller.Length <= 0 || tid.Length <= 0)
  1414. {
  1415. returnErrorMsg("数据错误");
  1416. }
  1417. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1418. //{
  1419. // returnErrorMsg("找不到店铺Sessionkey");
  1420. //}
  1421. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1422. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1423. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1424. if (res.IndexOf("refOid") == -1)
  1425. {
  1426. returnErrorMsg("下载订单数据失败");
  1427. return;
  1428. }
  1429. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1430. returnSuccessMsg("下载完成");
  1431. //tmcHelper.createNewOrder(res);
  1432. //CeErpTrade entr = null;
  1433. //entr = CeErpTrade.Get(tid);
  1434. //if (entr != null)
  1435. //{
  1436. // returnSuccess("下载成功");
  1437. // //下载成功之后,Cell表生成对应的订单;
  1438. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1439. //}
  1440. //else
  1441. //{
  1442. // returnErrorMsg("下载失败或者创建订单失败");
  1443. //}
  1444. }
  1445. public void set_erp_atersale()
  1446. {
  1447. if (UrlPostParmsCheck("ctid"))
  1448. {
  1449. string eid = GetPostString("ctid");
  1450. string reason = GetPostString("AfterSaleReason");
  1451. CeErpTradeCell entity = null;
  1452. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1453. if (entity != null)
  1454. {
  1455. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1456. {
  1457. returnErrorMsg("此订单已经在售后");
  1458. return;
  1459. }
  1460. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1461. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1462. entity.AfterSaleTime = DateTime.Now;
  1463. entity.Update();
  1464. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1465. returnSuccessMsg("转售后成功!");
  1466. return;
  1467. }
  1468. returnErrorMsg("找不到记录");
  1469. }
  1470. }
  1471. public void set_erp_withdraw()
  1472. {
  1473. if (UrlPostParmsCheck("ctid"))
  1474. {
  1475. try
  1476. {
  1477. string eid = GetPostString("ctid");//商品id
  1478. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1479. CeWithdraw ceWithdrawSelect = null;
  1480. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1481. if (ceWithdrawSelect != null)
  1482. {
  1483. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1484. {
  1485. ceWithdrawSelect.status = -1;
  1486. ceWithdrawSelect.Update();
  1487. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1488. returnSuccessMsg("重新发起审核成功");
  1489. return;
  1490. }
  1491. else
  1492. {
  1493. returnSuccessMsg("请勿重复申请!");
  1494. return;
  1495. }
  1496. }
  1497. else
  1498. {
  1499. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1500. if (string.IsNullOrEmpty(CustomerUserId))
  1501. {
  1502. CustomerUserId = "-1";
  1503. }
  1504. int Userid = CurrentUser.UserID;//用户id
  1505. CeWithdraw ceWithdraw = new CeWithdraw();
  1506. ceWithdraw.tid = eid;
  1507. ceWithdraw.userid = Userid;
  1508. ceWithdraw.providerid = CustomerUserId;
  1509. ceWithdraw.status = 3;
  1510. ceWithdraw.creationtime = DateTime.Now;
  1511. ceWithdraw.Create();
  1512. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1513. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1514. return;
  1515. }
  1516. }
  1517. catch
  1518. {
  1519. returnErrorMsg("申请撤回订单失败");
  1520. return;
  1521. }
  1522. }
  1523. }
  1524. public void ins_erp_billinfo()
  1525. {
  1526. if (UrlPostParmsCheck("ctid"))
  1527. {
  1528. string eid = GetPostString("ctid");
  1529. CeErpTradeCell entity = null;
  1530. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1531. if (entity != null)
  1532. {
  1533. CeErpBill bill = CeErpBill.GetByTid(eid);
  1534. bool isHave = false;
  1535. if (bill != null)
  1536. {
  1537. isHave = true;
  1538. if (bill.state != 4)
  1539. {
  1540. returnErrorMsg("此单已经申请过发票了");
  1541. return;
  1542. }
  1543. }
  1544. if (entity.IsNeedBill == 0)
  1545. {
  1546. entity.IsNeedBill = 1;
  1547. }
  1548. entity.Update();
  1549. string errjson = "";
  1550. try
  1551. {
  1552. CeErpBill bill_entity = new CeErpBill();
  1553. bill_entity.tid = entity.tid;
  1554. bill_entity.title = GetPostString("title");
  1555. string taxstr = GetPostString("tax");
  1556. taxstr = taxstr.Replace(" ", "");
  1557. bill_entity.tax = taxstr;
  1558. bill_entity.bank = GetPostString("bank");
  1559. string bankacstr = GetPostString("bankac");
  1560. bankacstr = bankacstr.Replace(" ", "");
  1561. bill_entity.bankac = bankacstr;
  1562. bill_entity.address = GetPostString("address");
  1563. bill_entity.phone = GetPostString("phone");
  1564. bill_entity.price = GetPostString("price");
  1565. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1566. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1567. {
  1568. billCount += 1;
  1569. }
  1570. string prebill = "ltb";
  1571. for (int idx = 1; idx <= billCount; idx++)
  1572. {
  1573. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1574. string billoid = prebill + idx + dtstr;
  1575. bill_entity.billOrderId += billoid;
  1576. if (idx < billCount)
  1577. {
  1578. bill_entity.billOrderId += ",";
  1579. }
  1580. }
  1581. bill_entity.productId = GetPostInt("ProductName");
  1582. bill_entity.num = GetPostInt("num");
  1583. bill_entity.unit = GetPostString("unit");
  1584. bill_entity.type = GetPostString("type");
  1585. bill_entity.sendType = GetPostString("SendType");
  1586. bill_entity.email = GetPostString("email");
  1587. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1588. bill_entity.shopName = GetPostString("ShopName");
  1589. bill_entity.applymemo = GetPostString("applyMemo");
  1590. bill_entity.createTime = DateTime.Now;
  1591. bill_entity.state = 0;
  1592. bill_entity.userId = CurrentUser.UserID;
  1593. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1594. bill_entity.Create();
  1595. }
  1596. catch (Exception ex)
  1597. {
  1598. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1599. returnErrorMsg("创建发票出错!");
  1600. return;
  1601. }
  1602. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1603. returnSuccessMsg("发票申请成功!");
  1604. return;
  1605. }
  1606. returnErrorMsg("找不到记录");
  1607. }
  1608. }
  1609. public void ins_erp_neworder()
  1610. {
  1611. if (UrlPostParmsCheck("receiver_name"))
  1612. {
  1613. CeErpTrade entity = new CeErpTrade();
  1614. string plat_form = GetPostString("platform");
  1615. string preStr = "N_";
  1616. if (plat_form == "拼多多")
  1617. {
  1618. preStr = "P_";
  1619. }
  1620. else if (plat_form == "阿里巴巴")
  1621. {
  1622. preStr = "A_";
  1623. }
  1624. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1625. entity.seller_nick = GetPostString("seller_nick");
  1626. entity.buyer_nick = GetPostString("buyer_nick");
  1627. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1628. entity.total_fee = entity.payment;
  1629. entity.pay_time = DateTime.Now;
  1630. entity.status = "NOT_SHIPPED";
  1631. entity.receiver_name = GetPostString("receiver_name");
  1632. entity.receiver_mobile = GetPostString("receiver_mobile");
  1633. entity.receiver_state = GetPostString("receiver_state");
  1634. entity.receiver_city = GetPostString("receiver_city");
  1635. entity.receiver_district = GetPostString("receiver_district");
  1636. entity.receiver_address = GetPostString("receiver_address");
  1637. if (entity.receiver_state == "" || entity.receiver_city == "")
  1638. {
  1639. returnErrorMsg("收件地址不能为空");
  1640. return;
  1641. }
  1642. int shopId = 0;
  1643. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1644. if (nShop != null)
  1645. {
  1646. shopId = nShop.ID;
  1647. }
  1648. if (shopId != 34 && entity.payment == 0)
  1649. {
  1650. returnErrorMsg("公司自用的单金额才能为0");
  1651. return;
  1652. }
  1653. entity.Create();
  1654. CeErpTradeCell entitycell = new CeErpTradeCell();
  1655. entitycell.ctid = entity.tid;
  1656. entitycell.tid = entity.tid;
  1657. entitycell.ShopId = shopId;
  1658. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1659. entitycell.OrderState = 0;
  1660. entitycell.pay_time = entity.pay_time;
  1661. entitycell.IsOffLineOrder = 1;
  1662. entitycell.Create();
  1663. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1664. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1665. return;
  1666. }
  1667. }
  1668. public void ins_erp_neworder2()
  1669. {
  1670. if (UrlPostParmsCheck("receiver_name"))
  1671. {
  1672. //string plat_form = GetPostString("platform");
  1673. string preStr = "X_";
  1674. string memo = GetPostString("memo");
  1675. string productId = GetPostString("productId");
  1676. string primg = GetPostString("proofimg");
  1677. string sellerNick = GetPostString("seller_nick");
  1678. string addFrom = GetPostString("addfrom");
  1679. if (addFrom == "1")
  1680. {
  1681. preStr = "N_";
  1682. }
  1683. int shopId = 0;
  1684. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1685. if (nShop != null)
  1686. {
  1687. shopId = nShop.ID;
  1688. }
  1689. else
  1690. {
  1691. returnErrorMsg("找不到对应店铺");
  1692. return;
  1693. }
  1694. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1695. {
  1696. returnErrorMsg("必须上传付款凭证");
  1697. return;
  1698. }
  1699. CeErpTrade entity = new CeErpTrade();
  1700. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1701. entity.seller_nick = sellerNick;
  1702. entity.buyer_nick = GetPostString("buyer_nick");
  1703. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1704. entity.total_fee = entity.payment;
  1705. entity.pay_time = DateTime.Now;
  1706. entity.status = "NOT_SHIPPED";
  1707. entity.receiver_name = GetPostString("receiver_name");
  1708. entity.receiver_mobile = GetPostString("receiver_mobile");
  1709. entity.receiver_state = GetPostString("receiver_state");
  1710. entity.receiver_city = GetPostString("receiver_city");
  1711. entity.receiver_district = GetPostString("receiver_district");
  1712. entity.receiver_address = GetPostString("receiver_address");
  1713. entity.seller_memo = memo;
  1714. entity.orderFrom = 20;
  1715. entity.orderType = 15;
  1716. if (entity.receiver_state == "" || entity.receiver_city == "")
  1717. {
  1718. returnErrorMsg("收件地址不能为空");
  1719. return;
  1720. }
  1721. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1722. {
  1723. returnErrorMsg("公司自用的单金额才能为0");
  1724. return;
  1725. }
  1726. entity.Create();
  1727. string toWhere = GetPostString("towhere");
  1728. CeErpTradeCell entitycell = new CeErpTradeCell();
  1729. entitycell.ctid = entity.tid;
  1730. //唯一标识
  1731. entitycell.OrderSn = entity.tid;
  1732. string orderSn = dataHelper.getSaleOrderSn();
  1733. if (orderSn != "")
  1734. {
  1735. entitycell.OrderSn = orderSn;
  1736. }
  1737. entitycell.tid = entity.tid;
  1738. //if (preStr == "X_")
  1739. //{
  1740. entitycell.IsOffLineOrder = 1;
  1741. //}
  1742. entitycell.CustomerUserId = CurrentUser.UserID;
  1743. entitycell.PayProofImg = primg;
  1744. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1745. entitycell.ProductId = Convert.ToInt32(productId);
  1746. entitycell.ShopId = shopId;
  1747. entitycell.UpdateTime = DateTime.Now;
  1748. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1749. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1750. {
  1751. entitycell.IsXianHuo = 1;
  1752. }
  1753. entitycell.pay_time = entity.pay_time;
  1754. if (toWhere == "1")
  1755. {
  1756. entitycell.OrderState = 2;
  1757. }
  1758. else
  1759. {
  1760. entitycell.OrderState = 6;
  1761. entitycell.FinishPlaceTime = entitycell.pay_time;
  1762. }
  1763. if (shopId == 94)
  1764. {
  1765. entitycell.OrderState = 4;
  1766. entitycell.WaitDesignTime = entitycell.pay_time;
  1767. entitycell.StartDesignTime = entitycell.pay_time;
  1768. entitycell.DesignUserId = 218;
  1769. }
  1770. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1771. {
  1772. entitycell.OrderState = -1;//修改12-5
  1773. CeWithdraw ceWithdraw = new CeWithdraw();
  1774. ceWithdraw.tid = entity.tid;
  1775. ceWithdraw.providerid = "-1";
  1776. ceWithdraw.status = -1;
  1777. ceWithdraw.creationtime = DateTime.Now;
  1778. ceWithdraw.userid = 1337;
  1779. ceWithdraw.Create();
  1780. }
  1781. entitycell.Create();
  1782. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1783. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1784. {
  1785. addPlaceRegist(entitycell, CurrentUser.UserID);
  1786. }
  1787. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1788. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1789. return;
  1790. }
  1791. }
  1792. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1793. {
  1794. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1795. entity.PlactTime = tradecell.pay_time;
  1796. entity.AddUserId = userid;
  1797. entity.FileName = tradecell.seller_memo;
  1798. entity.Supplier = 24;
  1799. entity.CreateTime = DateTime.Now;
  1800. entity.Did = tradecell.ctid;
  1801. entity.tid = tradecell.tid;
  1802. entity.splitTag = tradecell.SplitTag;
  1803. entity.CurState = "未完成";
  1804. entity.Create();
  1805. }
  1806. public void get_erp_offlinelist()
  1807. {
  1808. DataStruct dStruct = GetPostStruct();
  1809. List<string> lw = new List<string>();
  1810. string tid = GetPostString("ctid");
  1811. string date1 = GetPostString("date1");
  1812. string date2 = GetPostString("date2");
  1813. if (tid.Length > 0 || date1.Length > 0)
  1814. {
  1815. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1816. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1817. if (dw.Length > 0) lw.Add(dw);
  1818. }
  1819. else
  1820. {
  1821. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1822. }
  1823. string shopname = GetPostString("shopname");
  1824. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1825. string buyernick = GetPostString("buyer_nick");
  1826. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1827. string customer = GetPostString("customer");
  1828. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1829. string design = GetPostString("design");
  1830. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1831. string orderState = GetPostString("orderState");
  1832. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1833. string address = GetPostString("address");
  1834. 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));
  1835. string sellermemo = GetPostString("seller_memo");
  1836. if (sellermemo.Length > 0)
  1837. {
  1838. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1839. }
  1840. string price1 = GetPostString("price1");
  1841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1842. string price2 = GetPostString("price2");
  1843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1844. //if (PKey != "admin")
  1845. //{
  1846. // string usershop = CurrentUser.User.pemShop;
  1847. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1848. //}
  1849. //if (ex_psize > 0)
  1850. //{
  1851. dStruct.Order = "pay_time desc";
  1852. //}
  1853. //else
  1854. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1855. lw.Add(string.Format("IsOffLineOrder=1"));
  1856. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1857. DataTable dt = null;
  1858. dt = WebCache.GetData("view_erptradecell", dStruct);
  1859. writeGridDataTableJson(dStruct.TotalCount, dt);
  1860. }
  1861. public void get_erp_returncashrecord()
  1862. {
  1863. DataStruct dStruct = GetPostStruct();
  1864. List<string> lw = new List<string>();
  1865. string tid = GetPostString("ctid");
  1866. if (tid.Length > 0)
  1867. {
  1868. lw.Add(string.Format("tid like '%{0}%'", tid));
  1869. dStruct.Order = "id desc";
  1870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1871. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1872. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1873. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1874. return;
  1875. }
  1876. returnErrorMsg("id数据错误!");
  1877. }
  1878. public void ins_erp_returncashrecord()
  1879. {
  1880. if (UrlPostParmsCheck("tid"))
  1881. {
  1882. string tid = GetPostString("tid");
  1883. string retype = GetPostString("type");
  1884. StringBuilder sql = new StringBuilder();
  1885. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1886. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1887. if (dt.Rows.Count > 0)
  1888. {
  1889. returnErrorMsg("相同返现类型记录已存在");
  1890. return;
  1891. }
  1892. CeErpReturnCash entity = new CeErpReturnCash();
  1893. entity.tid = tid;
  1894. entity.seller_nick = GetPostString("seller_nick");
  1895. string pment = GetPostString("payment");
  1896. if (pment.Length > 0)
  1897. {
  1898. entity.payment = Convert.ToDouble(pment);
  1899. }
  1900. entity.buyer_nick = GetPostString("buyer_nick");
  1901. entity.cashstate = 0;
  1902. entity.rtype = retype;
  1903. string rPrice = GetPostString("returnprice");
  1904. if (rPrice.Length > 0)
  1905. {
  1906. entity.returnprice = Convert.ToDouble(rPrice);
  1907. }
  1908. entity.created = DateTime.Now;
  1909. entity.con = GetPostString("con");
  1910. entity.img = GetPostString("img");
  1911. entity.applyuserid = CurrentUser.UserID;
  1912. entity.Create();
  1913. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1914. returnSuccessMsg("操作成功!");
  1915. return;
  1916. }
  1917. }
  1918. public void set_erp_predelivery()
  1919. {
  1920. if (UrlPostParmsCheck("ctid"))
  1921. {
  1922. string eid = GetPostString("ctid");
  1923. CeErpTradeCell entity = null;
  1924. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1925. if (entity != null)
  1926. {
  1927. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1928. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1929. //{
  1930. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1931. // return;
  1932. //}
  1933. entity.IsPreDelivery = 1;
  1934. entity.Update();
  1935. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1936. returnSuccessMsg("预发货成功!");
  1937. return;
  1938. //string shop = GetPostString("seller_nick");
  1939. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1940. //string comName = GetPostString("comName");
  1941. //string comCode = GetPostString("comCode");
  1942. //string outSid = GetPostString("outSid");//运单号
  1943. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1944. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1945. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1946. //string apires = "";
  1947. //if (deliveryType == "虚拟发货")
  1948. //{
  1949. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1950. //}
  1951. //else
  1952. //{
  1953. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1954. //}
  1955. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1956. ////{
  1957. //if (apires.IndexOf("发货成功") != -1)
  1958. //{
  1959. // if (deliveryType != "虚拟发货")
  1960. // {
  1961. // //还要插入快递信息到 快递信息表
  1962. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1963. // exinfo.tid = eid;
  1964. // exinfo.out_sid = outSid;
  1965. // exinfo.company_code = comCode;
  1966. // exinfo.company_name = comName;
  1967. // exinfo.delivery_memo = deliveryMemo;
  1968. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1969. // exinfo.deliveryType = deliveryType;
  1970. // exinfo.Create();
  1971. // }
  1972. // returnSuccessMsg("发货成功!");
  1973. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1974. //}
  1975. //else
  1976. //{
  1977. // returnErrorMsg("淘宝发货失败!!");
  1978. //}
  1979. //return;
  1980. }
  1981. returnErrorMsg("找不到订单记录");
  1982. }
  1983. }
  1984. public void get_erp_unusuallist()
  1985. {
  1986. DataStruct dStruct = GetPostStruct();
  1987. List<string> lw = new List<string>();
  1988. string tid = GetPostString("ctid");
  1989. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1990. string shopname = GetPostString("shopname");
  1991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1992. string buyernick = GetPostString("buyer_nick");
  1993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1994. string ResponsibleMan = GetPostString("responsible");
  1995. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1996. string date1 = GetPostString("date1");
  1997. string date2 = GetPostString("date2");
  1998. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1999. if (dw.Length > 0) lw.Add(dw);
  2000. string price1 = GetPostString("price1");
  2001. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2002. string price2 = GetPostString("price2");
  2003. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2004. string orderState = GetPostString("orderState");
  2005. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2006. string sellermemo = GetPostString("seller_memo");
  2007. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2008. lw.Add(string.Format("UnusualTag > 0"));
  2009. lw.Add(string.Format("IsRefund<={0}", 1));
  2010. dStruct.Order = "pay_time desc";
  2011. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2012. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2013. writeGridDataTableJson(dStruct.TotalCount, dt);
  2014. }
  2015. public void set_erp_unusualtonomal()
  2016. {
  2017. if (UrlPostParmsCheck("ctid"))
  2018. {
  2019. string eid = GetPostString("ctid");
  2020. CeErpTradeCell entity = null;
  2021. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2022. if (entity != null)
  2023. {
  2024. entity.UnusualTag = -1;
  2025. entity.Update();
  2026. returnSuccessMsg("忽略成功!");
  2027. return;
  2028. }
  2029. returnErrorMsg("找不到记录");
  2030. }
  2031. }
  2032. public void ins_erp_unusualreason()
  2033. {
  2034. if (UrlPostParmsCheck("ctid"))
  2035. {
  2036. string eid = GetPostString("ctid");
  2037. CeErpTradeCell entity = null;
  2038. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2039. if (entity != null)
  2040. {
  2041. entity.MemoOpt = 4;
  2042. entity.UnusualCon = GetPostString("con");
  2043. entity.Update();
  2044. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2045. if (trade != null)
  2046. {
  2047. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2048. }
  2049. //查货是否超时
  2050. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2051. if (ceErpTradeCellExtend == null)
  2052. {
  2053. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2054. ceErpTradeCellExtend.ctid = entity.ctid;
  2055. }
  2056. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2057. {
  2058. ceErpTradeCellExtend.CheckOut += 1;
  2059. }
  2060. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2061. if (ceErpTradeCellExtend.ID > 0)
  2062. {
  2063. ceErpTradeCellExtend.Update();
  2064. }
  2065. else
  2066. {
  2067. ceErpTradeCellExtend.Create();
  2068. }
  2069. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2070. returnSuccessMsg("操作成功!");
  2071. return;
  2072. }
  2073. returnErrorMsg("找不到记录");
  2074. }
  2075. }
  2076. public void upd_erp_sampleorder()
  2077. {
  2078. if (UrlPostParmsCheck("ctid"))
  2079. {
  2080. string eid = GetPostString("ctid");
  2081. string[] eArr = eid.Split(',');
  2082. if (eArr.Length > 1)
  2083. {
  2084. List<string> eLst = new List<string>();
  2085. for (int i = 0; i < eArr.Length; i++)
  2086. {
  2087. eLst.Add("'" + eArr[i] + "'");
  2088. }
  2089. eid = string.Join(",", eLst.ToArray());
  2090. }
  2091. else
  2092. {
  2093. eid = "'" + eid + "'";
  2094. }
  2095. StringBuilder sql = new StringBuilder();
  2096. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2097. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2098. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2099. if (dt.Rows.Count > 0)
  2100. {
  2101. string errmsg = "";
  2102. foreach (DataRow dr in dt.Rows)
  2103. {
  2104. StringBuilder sqlsb = new StringBuilder();
  2105. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2106. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2107. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2108. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2109. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2110. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2111. {
  2112. continue;
  2113. }
  2114. else
  2115. {
  2116. string emsg = commonHelper.KeepChinese(apires);
  2117. errmsg += emsg;
  2118. }
  2119. }
  2120. if (errmsg.Length > 0)
  2121. {
  2122. returnErrorMsg(errmsg);
  2123. return;
  2124. }
  2125. returnSuccessMsg("操作成功");
  2126. return;
  2127. }
  2128. returnErrorMsg("找不到记录");
  2129. }
  2130. }
  2131. public void upd_erp_transcustomer()
  2132. {
  2133. if (UrlPostParmsCheck("ctid"))
  2134. {
  2135. string eid = GetPostString("ctid");
  2136. int userid = GetPostInt("CustomerUserId");
  2137. CeErpTradeCell entity = null;
  2138. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2139. if (entity != null)
  2140. {
  2141. //string[] mlist = entity.seller_memo.Split('-');
  2142. //string sql = "select * from view_erpuser where id=" + userid;
  2143. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2144. //if (dt != null && dt.Rows.Count > 0)
  2145. //{
  2146. // string nmemo = "";
  2147. // for(int i = 0; i < mlist.Length - 1; i++)
  2148. // {
  2149. // nmemo += mlist[i];
  2150. // nmemo += "-";
  2151. // }
  2152. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2153. // entity.seller_memo = nmemo;
  2154. //}
  2155. entity.CustomerUserId = userid;
  2156. entity.Update();
  2157. returnSuccessMsg("操作成功!");
  2158. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2159. return;
  2160. }
  2161. returnErrorMsg("找不到记录");
  2162. }
  2163. }
  2164. public void upd_erp_transdesigner()
  2165. {
  2166. if (UrlPostParmsCheck("ctid"))
  2167. {
  2168. string eids = GetPostString("ctid");
  2169. string[] ctidList = eids.Split(',');
  2170. int userid = GetPostInt("DesignUserId");
  2171. foreach (string ctid in ctidList)
  2172. {
  2173. CeErpTradeCell entity = null;
  2174. CeErpDesignerBill entitys = null;
  2175. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2176. entitys = CeErpDesignerBill.GetByTid(ctid);
  2177. if (entity != null)
  2178. {
  2179. if (entity.OrderState > 4)
  2180. {
  2181. continue;
  2182. }
  2183. //存在退款不能流转
  2184. if (entity.IsRefund > 0)
  2185. {
  2186. continue;
  2187. }
  2188. entity.DesignUserId = userid;
  2189. entity.WaitDesignTime = DateTime.Now;
  2190. entity.Update();
  2191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2192. }
  2193. }
  2194. returnSuccessMsg("操作成功!");
  2195. }
  2196. }
  2197. public void upd_erp_distributedesigner()
  2198. {
  2199. if (UrlPostParmsCheck("ctid"))
  2200. {
  2201. string eid = GetPostString("ctid");
  2202. int userid = GetPostInt("DesignUserId");
  2203. string[] idlist = eid.Split(',');
  2204. if (idlist.Length <= 0)
  2205. {
  2206. returnErrorMsg("订单不能为空");
  2207. return;
  2208. }
  2209. foreach (string ctid in idlist)
  2210. {
  2211. CeErpTradeCell entity = null;
  2212. CeErpDesignerBill entitys = null;
  2213. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2214. else continue;
  2215. if (entity != null)
  2216. {
  2217. if (userid == 2125 || userid == 3542)
  2218. { }
  2219. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2220. {
  2221. returnErrorMsg("金额错误的订单无法指派");
  2222. return;
  2223. }
  2224. if (entity.OrderState >= 5)
  2225. {
  2226. returnErrorMsg("已经设计完成无法指派");
  2227. return;
  2228. }
  2229. if (entity.OrderState == -1)
  2230. {
  2231. returnErrorMsg("审核中的订单无法指派");
  2232. return;
  2233. }
  2234. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2235. {
  2236. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2237. return;
  2238. }
  2239. //157赖橙帆 159林晨 73 静之颖
  2240. 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)
  2241. {
  2242. returnErrorMsg("指派设计共创无法再次指派!");
  2243. return;
  2244. }
  2245. entity.OrderState = 3;
  2246. if (entity.SupplierId == 0)
  2247. {
  2248. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2249. entity.SupplierId = suid;
  2250. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2251. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2252. }
  2253. if (userid == 2125 && entity.seller_memo != "")
  2254. {
  2255. apiDesign.API_GetPrintData_CreateOrder(entity);
  2256. }
  2257. if (userid == 3542 && entity.seller_memo != "")
  2258. {
  2259. string userPost = CurrentUser.UserPost.Post.Code;
  2260. if (CurrentUser.UserID == 73)
  2261. {
  2262. userPost = "SysAdmin";
  2263. }
  2264. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2265. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2266. if (response.msg != "设计共创:成功")
  2267. {
  2268. returnErrorMsg(response.msg);
  2269. return;
  2270. }
  2271. entity.DispatchSort = 2;
  2272. }
  2273. else
  2274. {
  2275. if (entity.DispatchSort == 2)
  2276. {
  2277. ApiVo apiVo = new ApiVo();
  2278. apiVo.actionName = "closeDesign";
  2279. apiVo.orderNumber = entity.ctid;
  2280. designHelper.API_WorkCore(apiVo);//closeDesign
  2281. }
  2282. entity.DispatchSort = 0;
  2283. }
  2284. entity.DesignUserId = userid;
  2285. entity.WaitDesignTime = DateTime.Now;
  2286. entity.UpdateTime = DateTime.Now;
  2287. entity.Update();
  2288. string name = commonHelper.getUserNameById(userid);
  2289. commonHelper.UpdateRelationOrder(entity.ctid);
  2290. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2291. }
  2292. }
  2293. returnSuccessMsg("操作成功!");
  2294. return;
  2295. }
  2296. }
  2297. public string getTidByCtid(string ctid)
  2298. {
  2299. string tid = "";
  2300. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2301. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2302. if (dataTable != null && dataTable.Rows.Count > 0)
  2303. {
  2304. tid = dataTable.Rows[0]["tid"].ToString();
  2305. }
  2306. return tid;
  2307. }
  2308. public List<string> getTidByCtidMore(string ctid)
  2309. {
  2310. 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);
  2311. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2312. List<string> list = new List<string>();
  2313. if (dataTable != null && dataTable.Rows.Count > 0)
  2314. {
  2315. foreach (DataRow item in dataTable.Rows)
  2316. {
  2317. list.Add("'" + item["tid"].ToString() + "'");
  2318. }
  2319. }
  2320. return list;
  2321. }
  2322. public List<string> getTidByCtidLike(string ctid)
  2323. {
  2324. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2325. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2326. List<string> list = new List<string>();
  2327. if (dataTable != null && dataTable.Rows.Count > 0)
  2328. {
  2329. foreach (DataRow item in dataTable.Rows)
  2330. {
  2331. list.Add("'" + item["tid"].ToString() + "'");
  2332. }
  2333. }
  2334. return list;
  2335. }
  2336. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2337. {
  2338. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2339. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2340. List<string> list = new List<string>();
  2341. if (dataTable != null && dataTable.Rows.Count > 0)
  2342. {
  2343. foreach (DataRow item in dataTable.Rows)
  2344. {
  2345. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2346. {
  2347. continue;
  2348. }
  2349. list.Add("'" + item["receiverId"].ToString() + "'");
  2350. }
  2351. }
  2352. return list;
  2353. }
  2354. public void get_erp_myorderlist()
  2355. {
  2356. DataStruct dStruct = GetPostStruct();
  2357. List<string> lw = new List<string>();
  2358. string tid = GetPostString("ctid");
  2359. if (tid.Length > 0)
  2360. {
  2361. string select_tid = getTidByCtid(tid);
  2362. lw.Add(string.Format("tid='{0}'", select_tid));
  2363. }
  2364. else
  2365. {
  2366. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2367. }
  2368. //12-1 修改
  2369. string urgent = GetPostString("urgent");
  2370. string back = GetPostString("back");
  2371. string offlineSearch = GetPostString("offlineSearch");
  2372. if (!string.IsNullOrWhiteSpace(urgent))
  2373. {
  2374. if (urgent.Equals("true"))
  2375. {
  2376. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2377. }
  2378. }
  2379. if (!string.IsNullOrWhiteSpace(back))
  2380. {
  2381. if (back.Equals("true"))
  2382. {
  2383. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2384. }
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2387. {
  2388. if (offlineSearch.Equals("true"))
  2389. {
  2390. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2391. }
  2392. }
  2393. //end
  2394. string shopname = GetPostString("shopname");
  2395. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2396. string buyernick = GetPostString("buyer_nick");
  2397. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2398. string design = GetPostString("design");
  2399. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2400. string orderState = GetPostString("orderState");
  2401. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2402. string sellermemo = GetPostString("seller_memo");
  2403. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2404. string date1 = GetPostString("date1");
  2405. string date2 = GetPostString("date2");
  2406. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2407. if (dw.Length > 0) lw.Add(dw);
  2408. string price1 = GetPostString("price1");
  2409. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2410. string price2 = GetPostString("price2");
  2411. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2412. string urgency = GetPostString("urgency");
  2413. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2414. string after = GetPostString("after");
  2415. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2416. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2417. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2418. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2420. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2421. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2422. if (dt != null && dt.Rows.Count > 0)
  2423. {
  2424. foreach (DataRow dr in dt.Rows)
  2425. {
  2426. try
  2427. {
  2428. // 对象操作
  2429. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2430. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2431. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2432. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2433. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2434. if (dStruct.PageSize != 100000)
  2435. {
  2436. if (dr["DispatchSort"].ToString() == "2")
  2437. {
  2438. dr["gongchuang"] = 200;
  2439. }
  2440. else if ("外协".Equals(dr["ToType"].ToString()))
  2441. {
  2442. dr["gongchuang"] = 200;
  2443. }
  2444. else if ("内部".Equals(dr["ToType"].ToString()))
  2445. {
  2446. dr["gongchuang"] = -1;
  2447. }
  2448. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2449. {
  2450. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2451. dr["gongchuang"] = response.code;
  2452. }
  2453. }
  2454. }
  2455. catch (NullReferenceException ex)
  2456. {
  2457. }
  2458. }
  2459. }
  2460. writeGridDataTableJson(dStruct.TotalCount, dt);
  2461. }
  2462. public void get_erp_myreturnorderlist()
  2463. {
  2464. DataStruct dStruct = GetPostStruct();
  2465. List<string> lw = new List<string>();
  2466. string tid = GetPostString("ctid");
  2467. if (tid.Length > 0)
  2468. {
  2469. string select_tid = getTidByCtid(tid);
  2470. lw.Add(string.Format("tid='{0}'", select_tid));
  2471. }
  2472. else
  2473. {
  2474. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2475. }
  2476. string shopname = GetPostString("shopname");
  2477. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2478. string buyernick = GetPostString("buyer_nick");
  2479. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2480. string design = GetPostString("design");
  2481. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2482. string orderState = GetPostString("orderState");
  2483. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2484. string sellermemo = GetPostString("seller_memo");
  2485. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2486. string date1 = GetPostString("date1");
  2487. string date2 = GetPostString("date2");
  2488. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2489. if (dw.Length > 0) lw.Add(dw);
  2490. string price1 = GetPostString("price1");
  2491. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2492. string price2 = GetPostString("price2");
  2493. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2494. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2495. {
  2496. lw.Add(string.Format("CusOrgID = 94"));
  2497. }
  2498. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2499. {
  2500. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2501. }
  2502. else
  2503. {
  2504. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2505. }
  2506. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2507. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2508. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2509. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2510. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2511. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2512. if (dt != null && dt.Rows.Count > 0)
  2513. {
  2514. foreach (DataRow dr in dt.Rows)
  2515. {
  2516. try
  2517. {
  2518. // 对象操作
  2519. if (dStruct.PageSize != 100000)
  2520. {
  2521. if (dr["DispatchSort"].ToString() == "2")
  2522. {
  2523. dr["gongchuang"] = 200;
  2524. }
  2525. else if ("外协".Equals(dr["ToType"].ToString()))
  2526. {
  2527. dr["gongchuang"] = 200;
  2528. }
  2529. else if ("内部".Equals(dr["ToType"].ToString()))
  2530. {
  2531. dr["gongchuang"] = -1;
  2532. }
  2533. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2534. {
  2535. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2536. dr["gongchuang"] = response.code;
  2537. }
  2538. }
  2539. }
  2540. catch (NullReferenceException ex)
  2541. {
  2542. // 处理空引用异常
  2543. }
  2544. }
  2545. }
  2546. writeGridDataTableJson(dStruct.TotalCount, dt);
  2547. }
  2548. public void get_erp_myorderlist_pregather()
  2549. {
  2550. string date1 = GetPostString("date1");
  2551. string date2 = GetPostString("date2");
  2552. int userId = CurrentUser.UserID; //客服id
  2553. string orderWhere = "";
  2554. List<string> lw = new List<string>();
  2555. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2556. if (dw.Length > 0) lw.Add(dw);
  2557. lw.Add(string.Format("CustomerUserId={0}", userId));
  2558. lw.Add(string.Format("OrderState<9"));
  2559. orderWhere = string.Join(" and ", lw.ToArray());
  2560. string orderWhere2 = "";
  2561. List<string> lw2 = new List<string>();
  2562. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2563. if (dw2.Length > 0) lw2.Add(dw2);
  2564. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2565. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2566. string sql = string.Format("select *" +
  2567. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2568. "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 " +
  2569. "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 " +
  2570. "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");
  2571. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2572. //writeGridDataTableJson(dt.Rows.Count, dt);
  2573. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2574. }
  2575. public void upd_erp_publishorder()
  2576. {
  2577. if (UrlPostParmsCheck("ctid"))
  2578. {
  2579. string eid = GetPostString("ctid");
  2580. CeErpTradeCell entity = null;
  2581. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2582. if (entity != null)
  2583. {
  2584. entity.OrderState = 0; //发布后,变为待抢单
  2585. entity.Update();
  2586. commonHelper.UpdateRelationOrder(entity.ctid);
  2587. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2588. returnSuccessMsg("发布成功!");
  2589. return;
  2590. }
  2591. returnErrorMsg("找不到记录");
  2592. }
  2593. }
  2594. public void get_erp_my_tiporder()
  2595. {
  2596. StringBuilder sql = new StringBuilder();
  2597. int userId = 0;
  2598. if (CurrentUser != null) userId = CurrentUser.UserID;
  2599. string posCode = CurrentUser.UserPost.Post.Code;
  2600. string isTipedAfterSaleVerify = GetPostString("af");
  2601. DataTable dt = new DataTable();
  2602. if (posCode != "Supplier")
  2603. {
  2604. if (posCode == "CustomerService" || posCode == "Director")
  2605. {
  2606. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2607. }
  2608. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2609. {
  2610. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2611. }
  2612. else
  2613. {
  2614. string teamIds = CurrentUser.User.TeamIds;
  2615. if (teamIds == "")
  2616. {
  2617. teamIds = "0";
  2618. }
  2619. 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);
  2620. }
  2621. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2622. }
  2623. if (dt.Rows.Count <= 0)
  2624. {
  2625. string key = "aftersale_order_" + userId;
  2626. if (RedisHelper.HasKey(key))
  2627. {
  2628. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2629. dt.Columns.Add("ctid", typeof(string));
  2630. dt.Columns.Add("IsReadTag", typeof(int));
  2631. foreach (var i in list)
  2632. {
  2633. DataRow data = dt.NewRow();
  2634. data["ctid"] = i;
  2635. data["IsReadTag"] = 4;
  2636. dt.Rows.Add(data);
  2637. }
  2638. RedisHelper.StringDelete(key);
  2639. }
  2640. }
  2641. if (dt.Rows.Count <= 0)
  2642. {
  2643. sql = new StringBuilder();
  2644. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2645. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2646. }
  2647. if (posCode == "Supplier")
  2648. {
  2649. string ids = CurrentUser.User.pemVend;
  2650. if (ids != null && ids.Length > 0)
  2651. {
  2652. string[] ids_list = ids.Split(',');
  2653. foreach (var item in ids_list)
  2654. {
  2655. string key = "return_order_" + item;
  2656. if (RedisHelper.HasKey(key))
  2657. {
  2658. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2659. dt.Columns.Add("ctid", typeof(string));
  2660. dt.Columns.Add("IsReadTag", typeof(int));
  2661. foreach (var i in list)
  2662. {
  2663. DataRow data = dt.NewRow();
  2664. data["ctid"] = i;
  2665. data["IsReadTag"] = 1;
  2666. dt.Rows.Add(data);
  2667. }
  2668. RedisHelper.StringDelete(key);
  2669. }
  2670. }
  2671. }
  2672. if (dt.Rows.Count <= 0)
  2673. {
  2674. sql = new StringBuilder();
  2675. 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);
  2676. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2677. }
  2678. }
  2679. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2680. }
  2681. public void reset_erp_tiporder()
  2682. {
  2683. string ids = GetPostString("ids");
  2684. string[] ctidList = ids.Split(',');
  2685. foreach (string ctid in ctidList)
  2686. {
  2687. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2688. if (enty != null)
  2689. {
  2690. enty.IsReadTag = 0;
  2691. enty.Update();
  2692. }
  2693. }
  2694. returnSuccessMsg("成功!");
  2695. return;
  2696. }
  2697. public void get_erp_designlist()
  2698. {
  2699. DataStruct dStruct = GetPostStruct();
  2700. List<string> lw = new List<string>();
  2701. string tid = GetPostString("ctid");
  2702. if (tid.Length > 0)
  2703. {
  2704. string select_tid = getTidByCtid(tid);
  2705. lw.Add(string.Format("tid='{0}'", select_tid));
  2706. }
  2707. string shopname = GetPostString("shopname");
  2708. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2709. string buyernick = GetPostString("buyer_nick");
  2710. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2711. string customer = GetPostString("customer");
  2712. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2713. string design = GetPostString("design");
  2714. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2715. string orderState = GetPostString("orderState");
  2716. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2717. lw.Add(string.Format("OrderState<6"));
  2718. string address = GetPostString("address");
  2719. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2720. string sellermemo = GetPostString("seller_memo");
  2721. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2722. string date1 = GetPostString("date1");
  2723. string date2 = GetPostString("date2");
  2724. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2725. if (dw.Length > 0) lw.Add(dw);
  2726. string apdate1 = GetPostString("apdate1");
  2727. string apdate2 = GetPostString("apdate2");
  2728. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2729. if (dwap.Length > 0) lw.Add(dwap);
  2730. string price1 = GetPostString("price1");
  2731. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2732. string price2 = GetPostString("price2");
  2733. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2734. string designTime = GetPostString("designtime");
  2735. if (designTime.Length > 0)
  2736. {
  2737. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2738. }
  2739. string usershop = CurrentUser.User.pemShop;
  2740. if (usershop.Length > 0)
  2741. {
  2742. lw.Add(string.Format("shopId in ({0})", usershop));
  2743. }
  2744. int myOrgid = CurrentUser.UserPost.OrgID;
  2745. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2746. if (myOrgCode.IndexOf("Designer") != -1)
  2747. {
  2748. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2749. {
  2750. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2751. }
  2752. else
  2753. {
  2754. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2755. }
  2756. }
  2757. else
  2758. {
  2759. string orgId = GetPostString("designerhd");
  2760. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2761. }
  2762. if (tid.Length > 0 || buyernick.Length > 0)
  2763. {
  2764. lw.Add(string.Format("OrderState >= 3"));
  2765. }
  2766. else
  2767. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2768. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2769. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2771. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2772. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2773. if (dt != null && dt.Rows.Count > 0)
  2774. {
  2775. foreach (DataRow dr in dt.Rows)
  2776. {
  2777. try
  2778. {
  2779. // 对象操作
  2780. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2781. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2782. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2783. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2784. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2785. if (dStruct.PageSize != 100000)
  2786. {
  2787. if (dr["DispatchSort"].ToString() == "2")
  2788. {
  2789. dr["gongchuang"] = 200;
  2790. }
  2791. else if ("外协".Equals(dr["ToType"].ToString()))
  2792. {
  2793. dr["gongchuang"] = 200;
  2794. }
  2795. else if ("内部".Equals(dr["ToType"].ToString()))
  2796. {
  2797. dr["gongchuang"] = -1;
  2798. }
  2799. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2800. {
  2801. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2802. dr["gongchuang"] = response.code;
  2803. }
  2804. }
  2805. }
  2806. catch (NullReferenceException ex)
  2807. {
  2808. }
  2809. }
  2810. }
  2811. writeGridDataTableJson(dStruct.TotalCount, dt);
  2812. }
  2813. public void get_erp_mydesignlist()
  2814. {
  2815. DataStruct dStruct = GetPostStruct();
  2816. List<string> lw = new List<string>();
  2817. string tid = GetPostString("ctid");
  2818. if (tid.Length > 0)
  2819. {
  2820. string select_tid = getTidByCtid(tid);
  2821. lw.Add(string.Format("tid='{0}'", select_tid));
  2822. }
  2823. string shopname = GetPostString("shopname");
  2824. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2825. string buyernick = GetPostString("buyer_nick");
  2826. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2827. string customer = GetPostString("customer");
  2828. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2829. string orderState = GetPostString("orderState");
  2830. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2831. //lw.Add(string.Format("OrderState<6"));
  2832. string date1 = GetPostString("date1");
  2833. string date2 = GetPostString("date2");
  2834. string dw = GetDateWhere("pay_time", date1, date2);
  2835. if (dw.Length > 0) lw.Add(dw);
  2836. string apdate1 = GetPostString("apdate1");
  2837. string apdate2 = GetPostString("apdate2");
  2838. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2839. if (dwap.Length > 0) lw.Add(dwap);
  2840. string price1 = GetPostString("price1");
  2841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2842. string price2 = GetPostString("price2");
  2843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2844. string olddownload = GetPostString("olddown");
  2845. if (olddownload == "1")
  2846. {
  2847. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2848. }
  2849. else if (olddownload == "2")
  2850. {
  2851. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2852. }
  2853. string sellermemo = GetPostString("seller_memo");
  2854. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2855. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2856. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2857. {
  2858. if (CurrentUser.User.TeamIds.Length > 0)
  2859. {
  2860. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2861. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2862. else
  2863. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2864. }
  2865. else
  2866. {
  2867. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2868. }
  2869. }
  2870. if (tid.Length <= 0)
  2871. {
  2872. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2873. }
  2874. lw.Add(string.Format("IsReturn!=3"));
  2875. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2876. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2877. string teamids = CurrentUser.User.TeamIds.ToString();
  2878. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2879. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2880. if (dt != null && dt.Rows.Count > 0)
  2881. {
  2882. foreach (DataRow dr in dt.Rows)
  2883. {
  2884. try
  2885. {
  2886. // 对象操作
  2887. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2888. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2889. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2890. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2891. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2892. if (dStruct.PageSize != 100000)
  2893. {
  2894. if (dr["DispatchSort"].ToString() == "2")
  2895. {
  2896. dr["gongchuang"] = 200;
  2897. }
  2898. else if ("外协".Equals(dr["ToType"].ToString()))
  2899. {
  2900. dr["gongchuang"] = 200;
  2901. }
  2902. else if ("内部".Equals(dr["ToType"].ToString()))
  2903. {
  2904. dr["gongchuang"] = -1;
  2905. }
  2906. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2907. {
  2908. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2909. dr["gongchuang"] = response.code;
  2910. }
  2911. }
  2912. }
  2913. catch (NullReferenceException ex)
  2914. {
  2915. }
  2916. }
  2917. }
  2918. writeGridDataTableJson(dStruct.TotalCount, dt);
  2919. }
  2920. public void set_erp_startdesign()
  2921. {
  2922. if (UrlPostParmsCheck("ctid"))
  2923. {
  2924. string eid = GetPostString("ctid");
  2925. CeErpTradeCell entity = null;
  2926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2927. if (entity != null)
  2928. {
  2929. if (entity.OrderState != 3)
  2930. {
  2931. returnErrorMsg("请刷新,订单已经设计了");
  2932. return;
  2933. }
  2934. entity.StartDesignTime = DateTime.Now;
  2935. entity.OrderState = 4;
  2936. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2937. {
  2938. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2939. entity.SupplierId = suid;
  2940. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2941. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2942. }
  2943. entity.UpdateTime = DateTime.Now;
  2944. //entity.MakeSupplier = suname;
  2945. entity.Update();
  2946. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2948. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2949. commonHelper.getCytPrice(entity);
  2950. returnSuccessMsg("操作成功!");
  2951. return;
  2952. }
  2953. returnErrorMsg("找不到记录");
  2954. }
  2955. }
  2956. public void ins_erp_designselfmemo()
  2957. {
  2958. if (UrlPostParmsCheck("ctid"))
  2959. {
  2960. string eid = GetPostString("ctid");
  2961. string con = GetPostString("con");
  2962. CeErpTradeCell entity = null;
  2963. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2964. if (entity != null)
  2965. {
  2966. entity.DesignSelfMemo = con;
  2967. entity.Update();
  2968. returnSuccessMsg("操作成功!");
  2969. return;
  2970. }
  2971. returnErrorMsg("找不到记录");
  2972. }
  2973. }
  2974. public void ins_erp_designprice()
  2975. {
  2976. if (UrlPostParmsCheck("ctid"))
  2977. {
  2978. string eid = GetPostString("ctid");
  2979. int uid = CurrentUser.UserID;
  2980. string userName = CurrentUser.UserName;
  2981. CeErpTradeCell entity = null;
  2982. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2983. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2984. if (entitys == null)
  2985. {
  2986. entitys = new CeErpDesignerBill();
  2987. }
  2988. if (entity != null)
  2989. {
  2990. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2991. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2992. entity.StartDesignTime = DateTime.Now;
  2993. entity.OrderState = 4;
  2994. string suname = "";
  2995. if (entity.SupplierId == 0)
  2996. {
  2997. int sid = commonHelper.autoDistributeToSupplier(entity);
  2998. entity.SupplierId = sid;
  2999. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3000. }
  3001. entity.Update();
  3002. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3003. if (ceErpUserPost != null)
  3004. {
  3005. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3006. if (ceErpPost != null)
  3007. {
  3008. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3009. {
  3010. entitys.tid = entity.ctid;
  3011. entitys.oid = entity.tid;
  3012. entitys.uid = uid;
  3013. entitys.userName = userName;
  3014. entitys.designerType = 1;
  3015. entitys.designerTypeText = "内部设计师";
  3016. entitys.price = Convert.ToDouble(GetPostString("price"));
  3017. entitys.designNum = GetPostInt("designNum");
  3018. entitys.modifyNum = GetPostInt("modifyNum");
  3019. entitys.designSize = GetPostString("designSize");
  3020. entitys.modifySize = GetPostString("modifySize");
  3021. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3022. {
  3023. entitys.create_time = DateTime.Now;
  3024. entitys.create_u_id = uid;
  3025. entitys.create_u_name = userName;
  3026. entitys.Save();
  3027. }
  3028. else
  3029. {
  3030. entitys.update_time = DateTime.Now;
  3031. entitys.update_u_id = uid;
  3032. entitys.update_u_name = userName;
  3033. entitys.Update();
  3034. }
  3035. }
  3036. }
  3037. }
  3038. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3040. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3041. if (suname != "")
  3042. {
  3043. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3044. }
  3045. commonHelper.getCytPrice(entity);
  3046. returnSuccessMsg("操作成功!");
  3047. return;
  3048. }
  3049. returnErrorMsg("找不到记录");
  3050. }
  3051. }
  3052. public void upload_erp_filecomplete()
  3053. {
  3054. if (UrlPostParmsCheck("ctid"))
  3055. {
  3056. string eid = GetPostString("ctid");
  3057. CeErpTradeCell entity = null;
  3058. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3059. if (entity != null)
  3060. {
  3061. entity.OrderState = 5; //设计完成
  3062. entity.Update();
  3063. returnSuccessMsg(eid + "上传成功,设计完成!");
  3064. return;
  3065. }
  3066. returnErrorMsg("找不到订单记录");
  3067. }
  3068. }
  3069. public void get_erp_designovertimelist()
  3070. {
  3071. DataStruct dStruct = GetPostStruct();
  3072. List<string> lw = new List<string>();
  3073. string tid = GetPostString("ctid");
  3074. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3075. string shopname = GetPostString("shopname");
  3076. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3077. string buyernick = GetPostString("buyer_nick");
  3078. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3079. string ResponsibleMan = GetPostString("responsible");
  3080. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3081. string date1 = GetPostString("date1");
  3082. string date2 = GetPostString("date2");
  3083. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3084. if (dw.Length > 0) lw.Add(dw);
  3085. string price1 = GetPostString("price1");
  3086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3087. string price2 = GetPostString("price2");
  3088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3089. string orderState = GetPostString("orderState");
  3090. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3091. string sellermemo = GetPostString("seller_memo");
  3092. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3093. lw.Add(string.Format("UnusualTag=3"));
  3094. lw.Add(string.Format("IsRefund<={0}", 1));
  3095. dStruct.Order = "WaitDesignTime desc";
  3096. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3097. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3098. writeGridDataTableJson(dStruct.TotalCount, dt);
  3099. }
  3100. //设计管理 获取抢单大厅列表
  3101. public void get_erp_grabinglist()
  3102. {
  3103. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3104. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3105. bool oldOrder = false;
  3106. if (org != null)
  3107. {
  3108. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3109. }
  3110. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3111. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3112. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3113. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3114. //先处理订单数据
  3115. if (dt.Rows.Count > 0)
  3116. {
  3117. Dictionary<string, int> design = null;
  3118. int count = 0;
  3119. foreach (DataRow row in dt.Rows)
  3120. {
  3121. if (map.ContainsKey(row["ShopId"].ToString()))
  3122. {
  3123. map.TryGetValue(row["ShopId"].ToString(), out design);
  3124. }
  3125. else
  3126. {
  3127. design = new Dictionary<string, int>();
  3128. }
  3129. if (design.ContainsKey(row["ProductId"].ToString()))
  3130. {
  3131. design.TryGetValue(row["ProductId"].ToString(), out count);
  3132. }
  3133. count++;
  3134. design[row["ProductId"].ToString()] = count;
  3135. map[row["ShopId"].ToString()] = design;
  3136. }
  3137. }
  3138. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3139. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3140. //把店铺排序和技能排序分类
  3141. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3142. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3143. if (design_dt.Rows.Count > 0)
  3144. {
  3145. Dictionary<string, string> design = null;
  3146. List<string> shopIds = null;
  3147. foreach (DataRow row in design_dt.Rows)
  3148. {
  3149. if ("0".Equals(row["designId"].ToString()))
  3150. {
  3151. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3152. {
  3153. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3154. }
  3155. else
  3156. {
  3157. shopIds = new List<string>();
  3158. }
  3159. shopIds.Add(row["shopId"].ToString());
  3160. shop_orders[row["orders"].ToString()] = shopIds;
  3161. }
  3162. else
  3163. {
  3164. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3165. {
  3166. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3167. }
  3168. else
  3169. {
  3170. design = new Dictionary<string, string>();
  3171. }
  3172. design[row["orders"].ToString()] = row["designId"].ToString();
  3173. design_orders[row["shopId"].ToString()] = design;
  3174. }
  3175. }
  3176. //处理成key value后根据key排序
  3177. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3178. foreach (List<string> val in shop_orders.Values)
  3179. {
  3180. if (val != null)
  3181. {
  3182. foreach (string key in val)
  3183. {
  3184. if (design_orders.ContainsKey(key.ToString()))
  3185. {
  3186. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3187. }
  3188. }
  3189. }
  3190. }
  3191. }
  3192. //校验哪个优先级有订单
  3193. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3194. foreach (string key in shop_orders.Keys)
  3195. {
  3196. List<string> ids = null;
  3197. shop_orders.TryGetValue(key, out ids);
  3198. //id为shopid
  3199. foreach (string id in ids)
  3200. {
  3201. Dictionary<string, int> list = null;
  3202. Dictionary<string, string> desing = null;
  3203. map.TryGetValue(id, out list);
  3204. design_orders.TryGetValue(id, out desing);
  3205. if (list != null && desing != null)
  3206. {
  3207. foreach (var item in desing)
  3208. {
  3209. int count = 0;
  3210. if (list.ContainsKey(item.Value))
  3211. {
  3212. list.TryGetValue(item.Value, out count);
  3213. if (count > 0)
  3214. {
  3215. designIds[id] = item.Value;
  3216. break;
  3217. }
  3218. }
  3219. }
  3220. }
  3221. }
  3222. if (designIds.Count > 0)
  3223. {
  3224. break;
  3225. }
  3226. }
  3227. DataTable table = new DataTable();
  3228. table.Columns.Add("tid", typeof(string));
  3229. table.Columns.Add("ctid", typeof(string));
  3230. table.Columns.Add("seller_nick", typeof(string));
  3231. table.Columns.Add("productName", typeof(string));
  3232. table.Columns.Add("pay_time", typeof(string));
  3233. table.Columns.Add("seller_memo", typeof(string));
  3234. if (designIds.Count > 0)
  3235. {
  3236. string shopId = "";
  3237. string productId = "";
  3238. foreach (var designInfo in designIds)
  3239. {
  3240. shopId = designInfo.Key;
  3241. productId = designInfo.Value;
  3242. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3243. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3244. if (dt.Rows.Count > 0)
  3245. {
  3246. foreach (DataRow row in dt.Rows)
  3247. {
  3248. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3249. {
  3250. DataRow data = table.NewRow();
  3251. data["ctid"] = row["ctid"].ToString();
  3252. data["tid"] = row["tid"].ToString();
  3253. data["seller_nick"] = ceErpShop.ShopName;
  3254. data["pay_time"] = row["pay_time"].ToString();
  3255. data["seller_memo"] = row["seller_memo"].ToString();
  3256. data["productName"] = ceErpProduct.PType;
  3257. table.Rows.Add(data);
  3258. }
  3259. }
  3260. }
  3261. }
  3262. }
  3263. writeGridDataTableJson(table.Rows.Count, table);
  3264. }
  3265. private object rushLockObject = new object();
  3266. public void set_erp_grabingorder()
  3267. {
  3268. if (UrlPostParmsCheck("ctid"))
  3269. {
  3270. int total = CurrentUser.User.Person.Total;
  3271. int userId = CurrentUser.User.ID;
  3272. int noFinish = CurrentUser.User.Person.NoFinish;
  3273. int finalization = CurrentUser.User.Person.Finalization;
  3274. string eids = GetPostString("ctid");
  3275. string key = "RushKey_" + userId;
  3276. int count = 0;
  3277. if (erpRedis.RedisHelper.KeyExists(key))
  3278. {
  3279. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3280. if (redisCount != null)
  3281. {
  3282. count = Convert.ToInt32(redisCount);
  3283. }
  3284. }
  3285. if (count >= total)
  3286. {
  3287. returnErrorMsg("半小时内已经抢" + total + "单");
  3288. return;
  3289. }
  3290. string[] ctidlist = eids.Split(',');
  3291. if (count + ctidlist.Length > total)
  3292. {
  3293. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3294. return;
  3295. }
  3296. int itag = 0;
  3297. lock (rushLockObject)
  3298. {
  3299. if (ctidlist.Length > 0)
  3300. {
  3301. string[] dtList = new string[ctidlist.Length];
  3302. for (int i = 0; i < ctidlist.Length; i++)
  3303. {
  3304. dtList[i] = "'" + ctidlist[i] + "'";
  3305. }
  3306. 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"));
  3307. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3308. if (dt_user.Rows.Count > 0)
  3309. {
  3310. int doing = 0;//未定稿
  3311. int finish = 0;//已完成
  3312. foreach (DataRow dr in dt_user.Rows)
  3313. {
  3314. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3315. {
  3316. doing++;
  3317. }
  3318. else
  3319. {
  3320. finish++;
  3321. }
  3322. }
  3323. if (doing >= noFinish)
  3324. {
  3325. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3326. return;
  3327. }
  3328. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3329. {
  3330. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3331. return;
  3332. }
  3333. }
  3334. //校验选择单子状态
  3335. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3337. if (dt.Rows.Count > 0)
  3338. {
  3339. List<string> list = new List<string>();
  3340. foreach (DataRow dr in dt.Rows)
  3341. {
  3342. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3343. {
  3344. list.Add(dr["ctid"].ToString());
  3345. }
  3346. }
  3347. if (list.Count > 0)
  3348. {
  3349. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3350. return;
  3351. }
  3352. }
  3353. foreach (string ctid in ctidlist)
  3354. {
  3355. CeErpTradeCell entity = null;
  3356. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3357. if (entity != null)
  3358. {
  3359. entity.OrderState = 3;
  3360. entity.DesignUserId = CurrentUser.UserID;
  3361. entity.WaitDesignTime = DateTime.Now;
  3362. entity.StartDesignTime = DateTime.Now;
  3363. entity.Update();
  3364. commonHelper.UpdateRelationOrder(entity.ctid);
  3365. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3366. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3367. itag++;
  3368. }
  3369. }
  3370. }
  3371. }
  3372. count += ctidlist.Length;
  3373. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3374. if (itag == 0)
  3375. returnErrorMsg("没有找到相关订单");
  3376. else
  3377. returnSuccessMsg("抢单成功!");
  3378. return;
  3379. }
  3380. }
  3381. public void get_erp_waitorderlist()
  3382. {
  3383. DataStruct dStruct = GetPostStruct();
  3384. List<string> lw = new List<string>();
  3385. string tid = GetPostString("ctid");
  3386. if (tid.Length > 0)
  3387. {
  3388. string select_tid = getTidByCtid(tid);
  3389. lw.Add(string.Format("tid='{0}'", select_tid));
  3390. }
  3391. string shopname = GetPostString("shopname");
  3392. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3393. string buyernick = GetPostString("buyer_nick");
  3394. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3395. string customer = GetPostString("customer");
  3396. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3397. string design = GetPostString("design");
  3398. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3399. string orderState = GetPostString("orderState");
  3400. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3401. string supplier = GetPostString("supplier");
  3402. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3403. string sellermemo = GetPostString("seller_memo");
  3404. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3405. string otherMemo = GetPostString("otherMemo");
  3406. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3407. string address = GetPostString("address");
  3408. 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));
  3409. string date1 = GetPostString("date1");
  3410. string date2 = GetPostString("date2");
  3411. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3412. if (dw.Length > 0) lw.Add(dw);
  3413. string price1 = GetPostString("price1");
  3414. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3415. string price2 = GetPostString("price2");
  3416. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3417. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3418. lw.Add(string.Format("IsSample != 2 "));
  3419. lw.Add(string.Format("OrderState = 5 "));
  3420. lw.Add(string.Format("IsRefund<={0}", 1));
  3421. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3422. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3423. string pagesize = GetPostString("pagesize");
  3424. if (pagesize != null)
  3425. {
  3426. dStruct.PageSize = 200;
  3427. }
  3428. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3429. List<string> tids = new List<string>();
  3430. if (dt != null)
  3431. {
  3432. dt.Columns.Add("compenPrice", typeof(double));
  3433. foreach (DataRow dr in dt.Rows)
  3434. {
  3435. if (Convert.IsDBNull(dr["compenPrice"]))
  3436. {
  3437. dr["compenPrice"] = 0;
  3438. }
  3439. tids.Add("'" + dr["tid"].ToString() + "'");
  3440. 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();
  3441. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3442. {
  3443. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3444. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3445. entity.SupplierId = suid;
  3446. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3447. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3448. entity.Update();
  3449. }
  3450. }
  3451. }
  3452. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3453. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3454. if (dt_price != null && dt_price.Rows.Count > 0)
  3455. {
  3456. foreach (DataRow dr in dt_price.Rows)
  3457. {
  3458. foreach (DataRow row in dt.Rows)
  3459. {
  3460. if (row["tid"].Equals(dr["ptid"]))
  3461. {
  3462. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3463. break;
  3464. }
  3465. }
  3466. }
  3467. }
  3468. writeGridDataTableJson(dStruct.TotalCount, dt);
  3469. }
  3470. public void get_erp_supplierwaitorderlist()
  3471. {
  3472. DataStruct dStruct = GetPostStruct();
  3473. List<string> lw = new List<string>();
  3474. string tid = GetPostString("ctid");
  3475. if (tid.Length > 0)
  3476. {
  3477. string select_tid = getTidByCtid(tid);
  3478. lw.Add(string.Format("tid='{0}'", select_tid));
  3479. }
  3480. string shopname = GetPostString("shopname");
  3481. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3482. string sellermemo = GetPostString("seller_memo");
  3483. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3484. string date1 = GetPostString("date1");
  3485. string date2 = GetPostString("date2");
  3486. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3487. if (dw.Length > 0) lw.Add(dw);
  3488. lw.Add(string.Format("OrderState = 5 "));
  3489. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3490. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3491. {
  3492. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3493. }
  3494. string supplier = GetPostString("supplier");
  3495. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3496. {
  3497. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3498. }
  3499. lw.Add(string.Format("IsRefund<={0}", 1));
  3500. dStruct.Order = "FinishDesignTime desc";
  3501. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3502. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3503. if (dt != null)
  3504. {
  3505. foreach (DataRow dr in dt.Rows)
  3506. {
  3507. 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();
  3508. }
  3509. }
  3510. writeGridDataTableJson(dStruct.TotalCount, dt);
  3511. }
  3512. public void upd_erp_verifytosupplier()
  3513. {
  3514. if (UrlPostParmsCheck("ctid"))
  3515. {
  3516. string eids = GetPostString("ctid");
  3517. CeErpTradeCell entity = null;
  3518. string[] eidsList = eids.Split(',');
  3519. if (eidsList.Length <= 0)
  3520. {
  3521. returnErrorMsg("订单号不能空");
  3522. return;
  3523. }
  3524. List<string> tLst = new List<string>();
  3525. foreach (string ctidstr in eidsList)
  3526. {
  3527. tLst.Add("'" + ctidstr + "'");
  3528. CeErpDataSendOrderInfo.createObject(ctidstr);
  3529. }
  3530. string needtids = string.Join(",", tLst.ToArray());
  3531. StringBuilder sql = new StringBuilder();
  3532. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3533. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3534. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3535. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3536. returnSuccessMsg("操作成功!");
  3537. return;
  3538. /**foreach (string ctidstr in eidsList)
  3539. {
  3540. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3541. if (entity != null)
  3542. {
  3543. if (entity.SupplierId == 0)
  3544. {
  3545. continue;
  3546. }
  3547. entity.IsVerifyToSupplier = true;
  3548. if (entity.IsReturn == 1) //1是供应商打回
  3549. {
  3550. entity.IsReturn = 0;
  3551. }
  3552. entity.FinishPlaceTime = DateTime.Now;
  3553. entity.PlaceUserId = CurrentUser.UserID;
  3554. entity.Update();
  3555. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3556. }
  3557. }
  3558. returnSuccessMsg("操作成功!");
  3559. return;**/
  3560. }
  3561. }
  3562. public void upd_erp_supplierback()
  3563. {
  3564. if (UrlPostParmsCheck("ctid"))
  3565. {
  3566. string eid = GetPostString("ctid");
  3567. string reason = GetPostString("returnreason");
  3568. CeErpTradeCell entity = null;
  3569. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3570. if (entity != null)
  3571. {
  3572. string message = "操作成功!";
  3573. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3574. {
  3575. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3576. }
  3577. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3578. {
  3579. string key = "return_order_" + entity.SupplierId;
  3580. List<string> list = new List<string>();
  3581. if (RedisHelper.HasKey(key))
  3582. {
  3583. object data = RedisHelper.StringGet(key);
  3584. list = Convert.ToString(data).Split(',').ToList();
  3585. }
  3586. list.Add(eid);
  3587. RedisHelper.StringSet(key, string.Join(",", list));
  3588. }
  3589. entity.IsVerifyToSupplier = false;
  3590. entity.IsReturn = 1;
  3591. entity.IsHaveNewOrder = 0;
  3592. entity.ReturnTime = DateTime.Now;
  3593. entity.ReturnReason = reason;
  3594. if (entity.OrderState == 6)
  3595. {
  3596. entity.OrderState = 5;
  3597. }
  3598. entity.Update();
  3599. CeErpSukuraData.createInfo(entity.ctid, 5);
  3600. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3601. returnSuccessMsg(message);
  3602. return;
  3603. }
  3604. returnErrorMsg("找不到订单记录");
  3605. }
  3606. }
  3607. public void upd_erp_toaftersaleorder()
  3608. {
  3609. if (UrlPostParmsCheck("ctid"))
  3610. {
  3611. string eid = GetPostString("ctid");
  3612. string reason = GetPostString("returnreason");
  3613. CeErpTradeCell entity = null;
  3614. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3615. if (entity != null)
  3616. {
  3617. if (entity.isAfterSaleOrder != 1)
  3618. {
  3619. returnErrorMsg("带S的售后单才能打回给售后");
  3620. return;
  3621. }
  3622. if (entity.OrderState >= 5)
  3623. {
  3624. returnErrorMsg("已经设计完成了不能打回给售后");
  3625. return;
  3626. }
  3627. entity.OrderState = 0;
  3628. entity.IsReturn = 3;
  3629. entity.ReturnTime = DateTime.Now;
  3630. entity.UpdateTime = DateTime.Now;
  3631. entity.ReturnReason = reason;
  3632. entity.Update();
  3633. CeErpSukuraData.createInfo(entity.ctid, 5);
  3634. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3635. returnSuccessMsg("操作成功!");
  3636. return;
  3637. }
  3638. returnErrorMsg("找不到订单记录");
  3639. }
  3640. }
  3641. public void upd_erp_aftersaletodesign()
  3642. {
  3643. if (UrlPostParmsCheck("ctid"))
  3644. {
  3645. string eid = GetPostString("ctid");
  3646. CeErpTradeCell entity = null;
  3647. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3648. if (entity != null)
  3649. {
  3650. entity.OrderState = 3;
  3651. entity.IsReturn = 0;
  3652. entity.UpdateTime = DateTime.Now;
  3653. entity.Update();
  3654. CeErpSukuraData.createInfo(entity.ctid, 5);
  3655. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3656. returnSuccessMsg("操作成功!");
  3657. return;
  3658. }
  3659. returnErrorMsg("找不到订单记录");
  3660. }
  3661. }
  3662. public void assign_erp_supplier()
  3663. {
  3664. if (UrlPostParmsCheck("ctid"))
  3665. {
  3666. string eids = GetPostString("ctid");
  3667. int sid = GetPostInt("SupplierName");
  3668. string fromTag = GetPostString("tag");
  3669. string[] eidList = eids.Split(',');
  3670. if (eidList.Length <= 0)
  3671. {
  3672. returnErrorMsg("指派不能为空");
  3673. return;
  3674. }
  3675. string errMsg = "";
  3676. string suname = commonHelper.getSupplierNameById(sid);
  3677. foreach (string ctid in eidList)
  3678. {
  3679. CeErpTradeCell entity = null;
  3680. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3681. if (entity != null)
  3682. {
  3683. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3684. {
  3685. errMsg += (ctid + "指派失败!!!");
  3686. continue;
  3687. }
  3688. entity.SupplierId = sid;
  3689. entity.Update();
  3690. commonHelper.UpdateRelationOrder(entity.ctid);
  3691. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3692. if (entity.OrderState >= 6)
  3693. {
  3694. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3695. //{
  3696. // string msl = entity.MakeSupplier;
  3697. // string[] mslist = msl.Split(',');
  3698. // 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);
  3699. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3700. //}
  3701. //else
  3702. //{
  3703. StringBuilder sql = new StringBuilder();
  3704. 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);
  3705. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3706. //}
  3707. }
  3708. }
  3709. else
  3710. {
  3711. continue;
  3712. }
  3713. }
  3714. if (errMsg.Length > 0)
  3715. {
  3716. returnErrorMsg(errMsg);
  3717. return;
  3718. }
  3719. returnSuccessMsg("操作成功!");
  3720. return;
  3721. }
  3722. }
  3723. public void assign_erp_makesupplier()
  3724. {
  3725. if (UrlPostParmsCheck("ctid"))
  3726. {
  3727. string eids = GetPostString("ctid");
  3728. string sname = GetPostString("SupplierName");
  3729. string[] eidList = eids.Split(',');
  3730. if (eidList.Length <= 0)
  3731. {
  3732. returnErrorMsg("指派不能为空");
  3733. return;
  3734. }
  3735. List<string> tLst = new List<string>();
  3736. foreach (string ctid in eidList)
  3737. {
  3738. CeErpTradeCell entity = null;
  3739. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3740. if (entity != null)
  3741. {
  3742. entity.MakeSupplier = sname;
  3743. entity.Update();
  3744. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3745. tLst.Add("'" + ctid + "'");
  3746. }
  3747. else
  3748. {
  3749. continue;
  3750. }
  3751. }
  3752. string ctids = string.Join(",", tLst.ToArray());
  3753. StringBuilder sql2 = new StringBuilder();
  3754. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3755. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3756. returnSuccessMsg("操作成功!");
  3757. return;
  3758. }
  3759. }
  3760. public void ins_erp_returnreason()
  3761. {
  3762. if (UrlPostParmsCheck("ctid"))
  3763. {
  3764. string eid = GetPostString("ctid");
  3765. CeErpTradeCell entity = null;
  3766. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3767. string userpost = CurrentUser.UserPost.Post.Code;
  3768. if (entity != null)
  3769. {
  3770. bool isPlace = false;
  3771. if (entity.OrderState > 6)
  3772. {
  3773. returnErrorMsg("已发货无法打回!");
  3774. return;
  3775. }
  3776. if (entity.OrderState == 6)
  3777. {
  3778. isPlace = true;
  3779. }
  3780. bool isNeedUpdateCell2 = false;
  3781. if (entity.OrderState >= 6)
  3782. {
  3783. isNeedUpdateCell2 = true;
  3784. }
  3785. int returnTag = 2;
  3786. if (userpost == "Supplier")
  3787. {
  3788. returnTag = 1;
  3789. }
  3790. int toType = GetPostInt("totype");
  3791. string fromType = "3";
  3792. if (entity.OrderState < 5)
  3793. {
  3794. fromType = "3";
  3795. }
  3796. else
  3797. {
  3798. fromType = "4";
  3799. }
  3800. if (entity.IsXianHuo == 0)
  3801. {
  3802. if (returnTag == 2)
  3803. {
  3804. if (toType == 1)
  3805. {
  3806. entity.OrderState = 0;
  3807. entity.ReturnUserType = 1;
  3808. string clearman = GetPostString("clearman");
  3809. if (!string.IsNullOrEmpty(clearman))
  3810. {
  3811. entity.DesignUserId = 0;
  3812. }
  3813. }
  3814. else
  3815. {
  3816. entity.OrderState = 3;
  3817. entity.ReturnUserType = 2;
  3818. }
  3819. entity.IsReadTag = 1;
  3820. }
  3821. else if (returnTag == 1)
  3822. {
  3823. entity.OrderState = 5;
  3824. }
  3825. entity.IsVerifyToSupplier = false;
  3826. }
  3827. if (entity.IsXianHuo == 1)
  3828. {
  3829. entity.OrderState = 5;
  3830. }
  3831. entity.UnusualTag = 0;
  3832. entity.UnusualTime = null;
  3833. entity.UnusualCon = "";
  3834. entity.IsReturn = returnTag;
  3835. entity.ReturnTime = DateTime.Now;
  3836. entity.UpdateTime = DateTime.Now;
  3837. entity.ReturnReason = GetPostString("returnreason");
  3838. entity.Update();
  3839. if (entity.OrderState == 3)
  3840. {
  3841. ApiVo apiVo = new ApiVo();
  3842. apiVo.orderNumber = entity.ctid;
  3843. apiVo.actionName = "rebutDesign";
  3844. apiVo.orderRemarks = entity.ReturnReason;
  3845. designHelper.API_WorkCore(apiVo);//rebutDesign
  3846. }
  3847. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3848. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3849. {
  3850. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3851. }
  3852. CeErpSukuraData.createInfo(entity.ctid, 5);
  3853. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3854. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3855. if (isPlace)
  3856. {
  3857. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3858. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3859. if (dth != null && dth.Rows.Count > 0)
  3860. {
  3861. dataSendOrderBean dataSendOrderBean = null;
  3862. foreach (DataRow item in dth.Rows)
  3863. {
  3864. try
  3865. {
  3866. dataSendOrderBean = new dataSendOrderBean();
  3867. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3868. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3869. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3870. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3871. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3872. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3873. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3874. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3875. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3876. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3877. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3878. dataSendOrderBean.Radio1723534706288 = "打回";
  3879. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3880. if (result != null)
  3881. {
  3882. if ("0".Equals(result.errcode))
  3883. {
  3884. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3885. }
  3886. else
  3887. {
  3888. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3889. }
  3890. }
  3891. }
  3892. catch (Exception ex)
  3893. {
  3894. }
  3895. }
  3896. }
  3897. }
  3898. if (isNeedUpdateCell2)
  3899. {
  3900. if (entity.MakeSupplier.IndexOf(",") != -1)
  3901. {
  3902. StringBuilder sql2 = new StringBuilder();
  3903. 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);
  3904. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3905. }
  3906. else
  3907. {
  3908. StringBuilder sql2 = new StringBuilder();
  3909. 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);
  3910. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3911. }
  3912. }
  3913. returnSuccessMsg("操作成功!");
  3914. return;
  3915. }
  3916. returnErrorMsg("找不到订单记录");
  3917. }
  3918. }
  3919. public void cyt_erp_returnreason()
  3920. {
  3921. if (UrlPostParmsCheck("ctid"))
  3922. {
  3923. string eid = GetPostString("ctid");
  3924. CeErpTradeCell entity = null;
  3925. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3926. string userpost = CurrentUser.UserPost.Post.Code;
  3927. if (entity != null)
  3928. {
  3929. if (entity.OrderState > 6)
  3930. {
  3931. returnErrorMsg("已发货无法打回!");
  3932. return;
  3933. }
  3934. JObject jsonObject = new JObject
  3935. {
  3936. { "Userid", "77886" },
  3937. { "Pwd", "lt666888" },
  3938. { "LTOrderId",eid }
  3939. };
  3940. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3941. JObject jsonObjects = JObject.Parse(response);
  3942. string msg = (string)jsonObjects["msg"];
  3943. if (msg != "取消成功")
  3944. {
  3945. returnErrorMsg(msg);
  3946. return;
  3947. }
  3948. bool isNeedUpdateCell2 = false;
  3949. if (entity.OrderState >= 6)
  3950. {
  3951. isNeedUpdateCell2 = true;
  3952. }
  3953. int returnTag = 2;
  3954. if (userpost == "Supplier")
  3955. {
  3956. returnTag = 1;
  3957. }
  3958. if (entity.IsXianHuo == 0)
  3959. {
  3960. if (returnTag == 2)
  3961. {
  3962. int toType = GetPostInt("totype");
  3963. if (toType == 1)
  3964. {
  3965. entity.OrderState = 0;
  3966. entity.ReturnUserType = 1;
  3967. }
  3968. else
  3969. {
  3970. entity.OrderState = 4;
  3971. entity.ReturnUserType = 2;
  3972. }
  3973. entity.IsReadTag = 1;
  3974. }
  3975. else if (returnTag == 1)
  3976. {
  3977. entity.OrderState = 5;
  3978. }
  3979. entity.IsVerifyToSupplier = false;
  3980. }
  3981. entity.UnusualTag = 0;
  3982. entity.UnusualTime = null;
  3983. entity.UnusualCon = "";
  3984. entity.IsReturn = returnTag;
  3985. entity.ReturnTime = DateTime.Now;
  3986. entity.ReturnReason = GetPostString("returnreason");
  3987. entity.Update();
  3988. if (entity.OrderState == 4)
  3989. {
  3990. ApiVo apiVo = new ApiVo();
  3991. apiVo.orderNumber = entity.ctid;
  3992. apiVo.actionName = "rebutDesign";
  3993. apiVo.orderRemarks = entity.ReturnReason;
  3994. designHelper.API_WorkCore(apiVo);//rebutDesign
  3995. }
  3996. CeErpSukuraData.createInfo(entity.ctid, 5);
  3997. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3998. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3999. if (isNeedUpdateCell2)
  4000. {
  4001. if (entity.MakeSupplier.IndexOf(",") != -1)
  4002. {
  4003. StringBuilder sql2 = new StringBuilder();
  4004. 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);
  4005. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4006. }
  4007. else
  4008. {
  4009. StringBuilder sql2 = new StringBuilder();
  4010. 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);
  4011. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4012. }
  4013. }
  4014. returnSuccessMsg("操作成功!");
  4015. return;
  4016. }
  4017. returnErrorMsg("找不到订单记录");
  4018. }
  4019. }
  4020. public void upd_erp_xianhuoreturntag()
  4021. {
  4022. if (UrlPostParmsCheck("ctid"))
  4023. {
  4024. string eids = GetPostString("ctid");
  4025. string[] ctids = eids.Split(',');
  4026. foreach (string ctid in ctids)
  4027. {
  4028. CeErpTradeCell entity = null;
  4029. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4030. if (entity != null)
  4031. {
  4032. entity.IsReturn = 0;
  4033. entity.Update();
  4034. CeErpSukuraData.createInfo(entity.ctid, 5);
  4035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4036. }
  4037. }
  4038. returnSuccessMsg("操作成功!");
  4039. return;
  4040. }
  4041. }
  4042. public void get_erp_waitdeliverylist()
  4043. {
  4044. DataStruct dStruct = GetPostStruct();
  4045. List<string> lw = new List<string>();
  4046. string tid = GetPostString("ctid");
  4047. if (tid.Length > 0)
  4048. {
  4049. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4050. if (tid.Length > 5)
  4051. {
  4052. List<string> tids = getTidByCtidLike(tid);
  4053. if (tids.Count > 0 && tids.Count < 10)
  4054. {
  4055. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4056. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4057. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4058. {
  4059. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4060. }*/
  4061. }
  4062. }
  4063. lw.Add(tid_sql);
  4064. }
  4065. string shopname = GetPostString("shopname");
  4066. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4067. string buyernick = GetPostString("buyer_nick");
  4068. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4069. //if (tid.Length == 0 && buyernick.Length == 0)
  4070. //{
  4071. // lw.Add(string.Format("IsRefund<={0}", 1));
  4072. //}
  4073. string customer = GetPostString("customer");
  4074. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4075. string design = GetPostString("design");
  4076. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4077. string orderState = GetPostString("orderState");
  4078. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4079. string address = GetPostString("address");
  4080. 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));
  4081. string sellermemo = GetPostString("seller_memo");
  4082. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4083. string supplier = GetPostString("supplier");
  4084. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4085. string OrderArea = GetPostString("order_area");
  4086. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4087. string placedate1 = GetPostString("placedate1");
  4088. string placedate2 = GetPostString("placedate2");
  4089. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4090. if (fdw.Length > 0) lw.Add(fdw);
  4091. string price1 = GetPostString("price1");
  4092. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4093. string price2 = GetPostString("price2");
  4094. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4095. string unusualCon = GetPostString("unusualcon");
  4096. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4097. string otherMemo = GetPostString("otherMemo");
  4098. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4099. string posTag = CurrentUser.UserPost.Post.Code;
  4100. if (posTag == "Supplier")
  4101. {
  4102. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4103. }
  4104. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4105. lw.Add(string.Format("type != 'PDD' "));
  4106. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4107. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4108. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4109. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4110. writeGridDataTableJson(dStruct.TotalCount, dt);
  4111. }
  4112. public void get_erp_changedeliverylist()
  4113. {
  4114. DataStruct dStruct = GetPostStruct();
  4115. List<string> lw = new List<string>();
  4116. string tid = GetPostString("ctid");
  4117. if (tid.Length > 0)
  4118. {
  4119. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4120. if (tid.Length > 5)
  4121. {
  4122. List<string> tids = getTidByCtidLike(tid);
  4123. if (tids.Count > 0 && tids.Count < 10)
  4124. {
  4125. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4126. }
  4127. }
  4128. lw.Add(tid_sql);
  4129. }
  4130. string shopname = GetPostString("shopname");
  4131. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4132. string buyernick = GetPostString("buyer_nick");
  4133. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4134. //if (tid.Length == 0 && buyernick.Length == 0)
  4135. //{
  4136. // lw.Add(string.Format("IsRefund<={0}", 1));
  4137. //}
  4138. string customer = GetPostString("customer");
  4139. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4140. string design = GetPostString("design");
  4141. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4142. string orderState = GetPostString("orderState");
  4143. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4144. string address = GetPostString("address");
  4145. 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));
  4146. string sellermemo = GetPostString("seller_memo");
  4147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4148. string supplier = GetPostString("supplier");
  4149. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4150. string OrderArea = GetPostString("order_area");
  4151. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4152. string placedate1 = GetPostString("placedate1");
  4153. string placedate2 = GetPostString("placedate2");
  4154. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4155. if (fdw.Length > 0) lw.Add(fdw);
  4156. string price1 = GetPostString("price1");
  4157. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4158. string price2 = GetPostString("price2");
  4159. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4160. string unusualCon = GetPostString("unusualcon");
  4161. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4162. string otherMemo = GetPostString("otherMemo");
  4163. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4164. string posTag = CurrentUser.UserPost.Post.Code;
  4165. if (posTag == "Supplier")
  4166. {
  4167. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4168. }
  4169. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4170. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4171. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4172. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4173. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4174. /*if (tid.Length > 0)
  4175. {
  4176. List<string> tids = new List<string>();
  4177. if (dt != null && dt.Rows.Count > 0)
  4178. {
  4179. foreach (DataRow item in dt.Rows)
  4180. {
  4181. tids.Add("'" + item["tid"] + "'");
  4182. }
  4183. }
  4184. if (tids.Count > 0)
  4185. {
  4186. lw.RemoveAt(0);
  4187. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4188. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4189. dt = WebCache.GetData("view_erptradecell", dStruct);
  4190. }
  4191. }*/
  4192. writeGridDataTableJson(dStruct.TotalCount, dt);
  4193. }
  4194. public void get_erp_pddderiving()
  4195. {
  4196. DataStruct dStruct = GetPostStruct();
  4197. List<string> lw = new List<string>();
  4198. string tid = GetPostString("ctid");
  4199. if (tid.Length > 0)
  4200. {
  4201. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4202. if (tid.Length > 5)
  4203. {
  4204. List<string> tids = getTidByCtidLike(tid);
  4205. if (tids.Count > 0 && tids.Count < 10)
  4206. {
  4207. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4208. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4209. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4210. {
  4211. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4212. }*/
  4213. }
  4214. }
  4215. lw.Add(tid_sql);
  4216. }
  4217. string shopname = GetPostString("shopname");
  4218. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4219. string buyernick = GetPostString("buyer_nick");
  4220. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4221. //if (tid.Length == 0 && buyernick.Length == 0)
  4222. //{
  4223. // lw.Add(string.Format("IsRefund<={0}", 1));
  4224. //}
  4225. string customer = GetPostString("customer");
  4226. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4227. string design = GetPostString("design");
  4228. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4229. string orderState = GetPostString("orderState");
  4230. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4231. string address = GetPostString("address");
  4232. 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));
  4233. string sellermemo = GetPostString("seller_memo");
  4234. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4235. string supplier = GetPostString("supplier");
  4236. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4237. string OrderArea = GetPostString("order_area");
  4238. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4239. string placedate1 = GetPostString("placedate1");
  4240. string placedate2 = GetPostString("placedate2");
  4241. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4242. if (fdw.Length > 0) lw.Add(fdw);
  4243. string price1 = GetPostString("price1");
  4244. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4245. string price2 = GetPostString("price2");
  4246. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4247. string unusualCon = GetPostString("unusualcon");
  4248. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4249. string posTag = CurrentUser.UserPost.Post.Code;
  4250. if (posTag == "Supplier")
  4251. {
  4252. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4253. }
  4254. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4255. lw.Add(string.Format("type = 'PDD' "));
  4256. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4257. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4258. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4259. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4260. /*if (tid.Length > 0)
  4261. {
  4262. List<string> tids = new List<string>();
  4263. if (dt != null && dt.Rows.Count > 0)
  4264. {
  4265. foreach (DataRow item in dt.Rows)
  4266. {
  4267. tids.Add("'" + item["tid"] + "'");
  4268. }
  4269. }
  4270. if (tids.Count > 0)
  4271. {
  4272. lw.RemoveAt(0);
  4273. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4274. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4275. dt = WebCache.GetData("view_erptradecell", dStruct);
  4276. }
  4277. }*/
  4278. writeGridDataTableJson(dStruct.TotalCount, dt);
  4279. }
  4280. public void get_erp_jdderiving()
  4281. {
  4282. DataStruct dStruct = GetPostStruct();
  4283. List<string> lw = new List<string>();
  4284. string tid = GetPostString("ctid");
  4285. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4286. string shopname = GetPostString("shopname");
  4287. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4288. string buyernick = GetPostString("buyer_nick");
  4289. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4290. //if (tid.Length == 0 && buyernick.Length == 0)
  4291. //{
  4292. // lw.Add(string.Format("IsRefund<={0}", 1));
  4293. //}
  4294. string customer = GetPostString("customer");
  4295. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4296. string design = GetPostString("design");
  4297. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4298. string orderState = GetPostString("orderState");
  4299. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4300. string address = GetPostString("address");
  4301. 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));
  4302. string sellermemo = GetPostString("seller_memo");
  4303. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4304. string supplier = GetPostString("supplier");
  4305. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4306. string OrderArea = GetPostString("order_area");
  4307. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4308. string placedate1 = GetPostString("placedate1");
  4309. string placedate2 = GetPostString("placedate2");
  4310. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4311. if (fdw.Length > 0) lw.Add(fdw);
  4312. string price1 = GetPostString("price1");
  4313. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4314. string price2 = GetPostString("price2");
  4315. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4316. string unusualCon = GetPostString("unusualcon");
  4317. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4318. string posTag = CurrentUser.UserPost.Post.Code;
  4319. if (posTag == "Supplier")
  4320. {
  4321. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4322. }
  4323. lw.Add(string.Format("OrderState = 6 "));
  4324. lw.Add(string.Format("type = 'JD' "));
  4325. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4326. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4327. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4328. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4329. writeGridDataTableJson(dStruct.TotalCount, dt);
  4330. }
  4331. public void get_erp_demoorderlist()
  4332. {
  4333. DataStruct dStruct = GetPostStruct();
  4334. List<string> lw = new List<string>();
  4335. string tid = GetPostString("ctid");
  4336. if (tid.Length > 0)
  4337. {
  4338. string select_tid = getTidByCtid(tid);
  4339. lw.Add(string.Format("tid='{0}'", select_tid));
  4340. }
  4341. string shopname = GetPostString("shopname");
  4342. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4343. string buyernick = GetPostString("buyer_nick");
  4344. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4345. string customer = GetPostString("customer");
  4346. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4347. string design = GetPostString("design");
  4348. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4349. string orderState = GetPostString("orderState");
  4350. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4351. string address = GetPostString("address");
  4352. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4353. string sellermemo = GetPostString("seller_memo");
  4354. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4355. string supplier = GetPostString("supplier");
  4356. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4357. string OrderArea = GetPostString("order_area");
  4358. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4359. string date1 = GetPostString("date1");
  4360. string date2 = GetPostString("date2");
  4361. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4362. if (dw.Length > 0) lw.Add(dw);
  4363. string price1 = GetPostString("price1");
  4364. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4365. string price2 = GetPostString("price2");
  4366. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4367. string posTag = CurrentUser.UserPost.Post.Code;
  4368. if (posTag == "Supplier")
  4369. {
  4370. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4371. }
  4372. //lw.Add(string.Format("OrderState = 6 "));
  4373. lw.Add(string.Format("IsSample={0}", 3));
  4374. lw.Add(string.Format("IsRefund<={0}", 1));
  4375. dStruct.Order = "pay_time desc";
  4376. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4377. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4378. writeGridDataTableJson(dStruct.TotalCount, dt);
  4379. }
  4380. public void save_erp_checkmemo()
  4381. {
  4382. if (UrlPostParmsCheck("ctid"))
  4383. {
  4384. string ctid = GetPostString("ctid");
  4385. CeErpTradeCell entity = null;
  4386. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4387. if (entity != null)
  4388. {
  4389. entity.CheckMemo = GetPostString("CheckMemo");
  4390. entity.Update();
  4391. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4392. if (trade != null)
  4393. {
  4394. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4395. }
  4396. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4397. returnSuccessMsg("保存成功!");
  4398. return;
  4399. }
  4400. returnErrorMsg("找不到记录");
  4401. }
  4402. }
  4403. public void get_erp_returnlist()
  4404. {
  4405. DataStruct dStruct = GetPostStruct();
  4406. List<string> lw = new List<string>();
  4407. string tid = GetPostString("ctid");
  4408. if (tid.Length > 0)
  4409. {
  4410. string select_tid = getTidByCtid(tid);
  4411. lw.Add(string.Format("tid='{0}'", select_tid));
  4412. }
  4413. string shopname = GetPostString("shopname");
  4414. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4415. string buyernick = GetPostString("buyer_nick");
  4416. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4417. string customer = GetPostString("customer");
  4418. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4419. string design = GetPostString("design");
  4420. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4421. string orderState = GetPostString("orderState");
  4422. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4423. string address = GetPostString("address");
  4424. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4425. string sellermemo = GetPostString("seller_memo");
  4426. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4427. string supplier = GetPostString("supplier");
  4428. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4429. string date1 = GetPostString("date1");
  4430. string date2 = GetPostString("date2");
  4431. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4432. if (dw.Length > 0) lw.Add(dw);
  4433. string bdate1 = GetPostString("backdate1");
  4434. string bdate2 = GetPostString("backdate2");
  4435. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4436. if (dw_back.Length > 0) lw.Add(dw_back);
  4437. string price1 = GetPostString("price1");
  4438. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4439. string price2 = GetPostString("price2");
  4440. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4441. lw.Add(string.Format("IsReturn>0"));
  4442. lw.Add(string.Format("IsXianHuo=0"));
  4443. lw.Add(string.Format("IsReturn!=3"));
  4444. string backtype = GetPostString("backtype");
  4445. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4446. dStruct.Order = "FinishDesignTime desc";
  4447. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4448. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4449. writeGridDataTableJson(dStruct.TotalCount, dt);
  4450. }
  4451. public void get_erp_today_sumreturn()
  4452. {
  4453. DataStruct dStruct = GetPostStruct();
  4454. List<string> lw = new List<string>();
  4455. string bdate1 = GetPostString("returnTimeS");
  4456. string bdate2 = GetPostString("returnTimeE");
  4457. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4458. if (dw_back.Length > 0) lw.Add(dw_back);
  4459. lw.Add(string.Format("IsReturn=0"));
  4460. lw.Add(string.Format("IsXianHuo=0"));
  4461. string mainWhere = string.Join(" and ", lw.ToArray());
  4462. string sql = "";
  4463. if (dw_back.Length > 0)
  4464. {
  4465. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4466. }
  4467. else
  4468. {
  4469. 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 + "'";
  4470. }
  4471. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4472. decimal total = 0, today_finish = 0;
  4473. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4474. {
  4475. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4476. }
  4477. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4478. {
  4479. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4480. }
  4481. var res = new
  4482. {
  4483. data = total,
  4484. data1 = today_finish,
  4485. };
  4486. string ro_jsond = JsonConvert.SerializeObject(res);
  4487. returnSuccess(ro_jsond);
  4488. return;
  4489. }
  4490. public void get_erp_allreturnlist()
  4491. {
  4492. DataStruct dStruct = GetPostStruct();
  4493. List<string> lw = new List<string>();
  4494. string tid = GetPostString("ctid");
  4495. if (tid.Length > 0)
  4496. {
  4497. string select_tid = getTidByCtid(tid);
  4498. lw.Add(string.Format("tid='{0}'", select_tid));
  4499. }
  4500. string shopname = GetPostString("shopname");
  4501. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4502. string buyernick = GetPostString("buyer_nick");
  4503. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4504. string customer = GetPostString("customer");
  4505. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4506. string design = GetPostString("design");
  4507. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4508. string orderState = GetPostString("orderState");
  4509. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4510. string address = GetPostString("address");
  4511. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4512. string sellermemo = GetPostString("seller_memo");
  4513. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4514. string supplier = GetPostString("supplier");
  4515. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4516. string date1 = GetPostString("date1");
  4517. string date2 = GetPostString("date2");
  4518. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4519. if (dw.Length > 0) lw.Add(dw);
  4520. string bdate1 = GetPostString("backdate1");
  4521. string bdate2 = GetPostString("backdate2");
  4522. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4523. if (dw_back.Length > 0) lw.Add(dw_back);
  4524. string price1 = GetPostString("price1");
  4525. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4526. string price2 = GetPostString("price2");
  4527. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4528. string backreason = GetPostString("backreason");
  4529. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4530. lw.Add(string.Format("IsXianHuo=0"));
  4531. lw.Add(string.Format("ReturnTime != ''"));
  4532. string backtype = GetPostString("backtype");
  4533. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4534. dStruct.Order = "FinishDesignTime desc";
  4535. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4536. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4537. writeGridDataTableJson(dStruct.TotalCount, dt);
  4538. }
  4539. public void get_erp_aftersalereturnlist()
  4540. {
  4541. DataStruct dStruct = GetPostStruct();
  4542. List<string> lw = new List<string>();
  4543. string tid = GetPostString("ctid");
  4544. if (tid.Length > 0)
  4545. {
  4546. string select_tid = getTidByCtid(tid);
  4547. lw.Add(string.Format("tid='{0}'", select_tid));
  4548. }
  4549. string shopname = GetPostString("shopname");
  4550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4551. string buyernick = GetPostString("buyer_nick");
  4552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4553. string customer = GetPostString("customer");
  4554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4555. string design = GetPostString("design");
  4556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4557. string orderState = GetPostString("orderState");
  4558. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4559. string address = GetPostString("address");
  4560. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4561. string sellermemo = GetPostString("seller_memo");
  4562. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4563. string supplier = GetPostString("supplier");
  4564. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4565. string date1 = GetPostString("date1");
  4566. string date2 = GetPostString("date2");
  4567. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4568. if (dw.Length > 0) lw.Add(dw);
  4569. string bdate1 = GetPostString("backdate1");
  4570. string bdate2 = GetPostString("backdate2");
  4571. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4572. if (dw_back.Length > 0) lw.Add(dw_back);
  4573. string price1 = GetPostString("price1");
  4574. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4575. string price2 = GetPostString("price2");
  4576. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4577. lw.Add(string.Format("IsReturn=3"));
  4578. string backtype = GetPostString("backtype");
  4579. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4580. string backreason = GetPostString("backreason");
  4581. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4582. dStruct.Order = "ReturnTime desc";
  4583. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4584. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4585. writeGridDataTableJson(dStruct.TotalCount, dt);
  4586. }
  4587. public void get_erp_xianhuoreturnlist()
  4588. {
  4589. DataStruct dStruct = GetPostStruct();
  4590. List<string> lw = new List<string>();
  4591. string tid = GetPostString("ctid");
  4592. if (tid.Length > 0)
  4593. {
  4594. string select_tid = getTidByCtid(tid);
  4595. lw.Add(string.Format("tid='{0}'", select_tid));
  4596. }
  4597. string shopname = GetPostString("shopname");
  4598. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4599. string buyernick = GetPostString("buyer_nick");
  4600. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4601. string customer = GetPostString("customer");
  4602. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4603. string design = GetPostString("design");
  4604. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4605. string orderState = GetPostString("orderState");
  4606. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4607. string address = GetPostString("address");
  4608. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4609. string sellermemo = GetPostString("seller_memo");
  4610. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4611. string supplier = GetPostString("supplier");
  4612. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4613. string OrderArea = GetPostString("order_area");
  4614. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4615. string date1 = GetPostString("date1");
  4616. string date2 = GetPostString("date2");
  4617. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4618. if (dw.Length > 0) lw.Add(dw);
  4619. string price1 = GetPostString("price1");
  4620. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4621. string price2 = GetPostString("price2");
  4622. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4623. string posTag = CurrentUser.UserPost.Post.Code;
  4624. if (posTag == "Supplier")
  4625. {
  4626. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4627. }
  4628. lw.Add(string.Format("OrderState=6 "));
  4629. lw.Add(string.Format("IsXianHuo=1 "));
  4630. lw.Add(string.Format("IsReturn>0 "));
  4631. lw.Add(string.Format("IsReturn!=3"));
  4632. lw.Add(string.Format("IsRefund<={0}", 1));
  4633. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4634. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4635. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4636. writeGridDataTableJson(dStruct.TotalCount, dt);
  4637. }
  4638. public void set_erp_orderdelivery()
  4639. {
  4640. if (UrlPostParmsCheck("ctid"))
  4641. {
  4642. string eid = GetPostString("ctid");
  4643. CeErpTradeCell entity = null;
  4644. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4645. if (entity != null)
  4646. {
  4647. if (entity.OrderState >= 7)
  4648. {
  4649. returnErrorMsg("此单已发货,无需重复发货");
  4650. return;
  4651. }
  4652. if (entity.OrderState != 6)
  4653. {
  4654. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4655. return;
  4656. }
  4657. string shop = GetPostString("seller_nick");
  4658. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4659. string comName = GetPostString("comName");
  4660. string comCode = GetPostString("comCode");
  4661. string outSid = GetPostString("outSid");
  4662. string deliveryType = GetPostString("deliveryType");
  4663. string deliveryMemo = GetPostString("deliveryMemo");
  4664. outSid = outSid.Trim();
  4665. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4666. if (mainEn == null)
  4667. {
  4668. returnErrorMsg("找不到原始订单记录");
  4669. return;
  4670. }
  4671. bool isInitOrderDeliv = false;
  4672. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4673. {
  4674. isInitOrderDeliv = true;
  4675. }
  4676. string apires = "";
  4677. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4678. 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)
  4679. {
  4680. apires = "发货成功true";
  4681. }
  4682. else
  4683. {
  4684. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4685. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4686. }
  4687. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4688. {
  4689. entity.OrderState = 7;//发货后订单已发货
  4690. entity.OutSid = outSid;
  4691. entity.MemoOpt = 0;
  4692. entity.UpdateTime = DateTime.Now;
  4693. entity.FinishDeliveryTime = DateTime.Now;
  4694. entity.Update();
  4695. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4696. commonHelper.UpdateRelationOrder(entity.ctid);
  4697. //还要插入快递信息到 快递信息表
  4698. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4699. exinfo.tid = eid;
  4700. exinfo.out_sid = outSid;
  4701. exinfo.company_code = comCode;
  4702. exinfo.company_name = comName;
  4703. exinfo.delivery_memo = deliveryMemo;
  4704. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4705. exinfo.deliveryType = deliveryType;
  4706. exinfo.Create();
  4707. returnSuccessMsg("发货操作成功!");
  4708. commonHelper.UpdateRelationOrder(entity.ctid);
  4709. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4710. CeErpSukuraData.createInfo(entity.ctid, 4);
  4711. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4712. {
  4713. commonHelper.sendCytExpress(exinfo);
  4714. }
  4715. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4716. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4717. }
  4718. else
  4719. {
  4720. string errmsg = commonHelper.KeepChinese(apires);
  4721. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4722. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4723. }
  4724. return;
  4725. }
  4726. returnErrorMsg("找不到订单记录");
  4727. }
  4728. }
  4729. public void set_erp_multidelivery()
  4730. {
  4731. string eids = GetPostString("tids");
  4732. string[] eidList = eids.Split(',');
  4733. if (eidList.Length <= 0)
  4734. {
  4735. returnErrorMsg("发货不能为空");
  4736. return;
  4737. }
  4738. foreach (string ctid in eidList)
  4739. {
  4740. if (ctid.Length <= 0) continue;
  4741. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4742. if (expInfo != null)
  4743. {
  4744. StringBuilder sql = new StringBuilder();
  4745. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4746. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4747. if (dt.Rows.Count > 0)
  4748. {
  4749. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4750. {
  4751. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4752. expInfo.state = "异常";
  4753. expInfo.isMultiDelivery = 1;
  4754. expInfo.Update();
  4755. continue;
  4756. }
  4757. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4758. {
  4759. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4760. expInfo.state = "异常";
  4761. expInfo.Update();
  4762. continue;
  4763. }
  4764. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4765. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4766. bool isInitOrderDeliv = false;
  4767. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4768. {
  4769. isInitOrderDeliv = true;
  4770. expInfo.isMultiDelivery = 1;
  4771. }
  4772. if (ctid.IndexOf("N") != -1)
  4773. {
  4774. StringBuilder sqlbucha = new StringBuilder();
  4775. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4776. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4777. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4778. commonHelper.UpdateRelationOrder(ctid);
  4779. expInfo.delivery_memo = "发货成功";
  4780. expInfo.state = "发货成功";
  4781. expInfo.isMultiDelivery = 1;
  4782. expInfo.Update();
  4783. }
  4784. else
  4785. {
  4786. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4787. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4788. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4789. {
  4790. expInfo.delivery_memo = "发货成功";
  4791. expInfo.state = "发货成功";
  4792. expInfo.isMultiDelivery = 1;
  4793. expInfo.Update();
  4794. commonHelper.UpdateRelationOrder(ctid);
  4795. CeErpSukuraData.createInfo(ctid, 4);
  4796. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4797. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4798. }
  4799. else
  4800. {
  4801. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4802. expInfo.state = "异常";
  4803. expInfo.Update();
  4804. }
  4805. }
  4806. }
  4807. }
  4808. }
  4809. returnSuccessMsg("操作完成");
  4810. }
  4811. public void reset_erp_memoopt()
  4812. {
  4813. if (UrlPostParmsCheck("ctid"))
  4814. {
  4815. string eid = GetPostString("ctid");
  4816. CeErpTradeCell entity = null;
  4817. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4818. if (entity != null)
  4819. {
  4820. string stropt = "";
  4821. if (entity.MemoOpt == 1)
  4822. {
  4823. stropt = "“改稿”";
  4824. }
  4825. else if (entity.MemoOpt == 2)
  4826. {
  4827. stropt = "“定稿”";
  4828. }
  4829. else if (entity.MemoOpt == 3)
  4830. {
  4831. stropt = "“完成查货”";
  4832. CeErpSukuraData.createInfo(entity.ctid, 6);
  4833. }
  4834. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4835. entity.UpdateTime = DateTime.Now;
  4836. entity.MemoOpt = 0;
  4837. entity.Update();
  4838. returnSuccessMsg("操作成功!");
  4839. return;
  4840. }
  4841. returnErrorMsg("找不到记录");
  4842. }
  4843. }
  4844. public void get_erp_deliveryunusual()
  4845. {
  4846. DataStruct dStruct = GetPostStruct();
  4847. List<string> lw = new List<string>();
  4848. string tid = GetPostString("ctid");
  4849. if (tid.Length > 0)
  4850. {
  4851. string select_tid = getTidByCtid(tid);
  4852. lw.Add(string.Format("tid='{0}'", select_tid));
  4853. }
  4854. string shopname = GetPostString("shopname");
  4855. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4856. string buyernick = GetPostString("buyer_nick");
  4857. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4858. string customer = GetPostString("customer");
  4859. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4860. string design = GetPostString("design");
  4861. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4862. string sellermemo = GetPostString("seller_memo");
  4863. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4864. string supplier = GetPostString("supplier");
  4865. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4866. string date1 = GetPostString("date1");
  4867. string date2 = GetPostString("date2");
  4868. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4869. if (dw.Length > 0) lw.Add(dw);
  4870. string placedate1 = GetPostString("placedate1");
  4871. string placedate2 = GetPostString("placedate2");
  4872. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4873. if (dw_place.Length > 0) lw.Add(dw_place);
  4874. string price1 = GetPostString("price1");
  4875. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4876. string price2 = GetPostString("price2");
  4877. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4878. string unusualCon = GetPostString("unusualcon");
  4879. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4880. string posTag = CurrentUser.UserPost.Post.Code;
  4881. if (posTag == "Supplier")
  4882. {
  4883. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4884. }
  4885. lw.Add(string.Format("OrderState = 6"));
  4886. lw.Add(string.Format("UnusualTag = 5"));
  4887. lw.Add(string.Format("IsRefund<={0}", 1));
  4888. dStruct.Order = "FinishPlaceTime desc";
  4889. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4890. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4891. writeGridDataTableJson(dStruct.TotalCount, dt);
  4892. }
  4893. public void get_erp_deliveryedlist()
  4894. {
  4895. DataStruct dStruct = GetPostStruct();
  4896. List<string> lw = new List<string>();
  4897. string tid = GetPostString("ctid");
  4898. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4899. string shopname = GetPostString("shopname");
  4900. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4901. string buyernick = GetPostString("buyer_nick");
  4902. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4903. string customer = GetPostString("customer");
  4904. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4905. string design = GetPostString("design");
  4906. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4907. string sellermemo = GetPostString("seller_memo");
  4908. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4909. string logistics = GetPostString("logistics");
  4910. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4911. string date1 = GetPostString("date1");
  4912. string date2 = GetPostString("date2");
  4913. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4914. //if (dw.Length > 0) lw.Add(dw);
  4915. string placedate1 = GetPostString("placedate1");
  4916. string placedate2 = GetPostString("placedate2");
  4917. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4918. if (fdw.Length > 0) lw.Add(fdw);
  4919. string devdate1 = GetPostString("deliverydate1");
  4920. string devdate2 = GetPostString("deliverydate2");
  4921. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4922. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4923. string price1 = GetPostString("price1");
  4924. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4925. string price2 = GetPostString("price2");
  4926. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4927. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4928. {
  4929. if (tid.Length > 0)
  4930. {
  4931. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4932. if (tid.Length > 5)
  4933. {
  4934. List<string> tids = getTidByCtidLike(tid);
  4935. if (tids.Count > 0 && tids.Count < 10)
  4936. {
  4937. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4938. }
  4939. }
  4940. lw.Add(tid_sql);
  4941. }
  4942. if (buyernick.Length > 0)
  4943. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4944. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4945. if (dw.Length > 0) lw.Add(dw);
  4946. }
  4947. else
  4948. {
  4949. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4950. }
  4951. string posTag = CurrentUser.UserPost.Post.Code;
  4952. if (posTag == "Supplier")
  4953. {
  4954. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4955. }
  4956. else
  4957. {
  4958. string supplier = GetPostString("supplier");
  4959. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4960. }
  4961. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4962. lw.Add(string.Format("type != 'PDD' "));
  4963. lw.Add(string.Format("IsRefund!={0}", 2));
  4964. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4965. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4966. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4967. /*if (tid.Length > 0)
  4968. {
  4969. List<string> tids = new List<string>();
  4970. if (dt != null && dt.Rows.Count > 0)
  4971. {
  4972. foreach (DataRow item in dt.Rows)
  4973. {
  4974. tids.Add("'" + item["tid"] + "'");
  4975. }
  4976. }
  4977. if (tids.Count > 0)
  4978. {
  4979. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4980. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4981. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4982. dt = WebCache.GetData("view_erptradecell", dStruct);
  4983. }
  4984. }*/
  4985. if (dt != null)
  4986. {
  4987. foreach (DataRow dr in dt.Rows)
  4988. {
  4989. 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();
  4990. }
  4991. }
  4992. writeGridDataTableJson(dStruct.TotalCount, dt);
  4993. }
  4994. public void get_erp_pdddeliveryed()
  4995. {
  4996. DataStruct dStruct = GetPostStruct();
  4997. List<string> lw = new List<string>();
  4998. string tid = GetPostString("ctid");
  4999. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5000. string shopname = GetPostString("shopname");
  5001. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5002. string buyernick = GetPostString("buyer_nick");
  5003. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5004. string customer = GetPostString("customer");
  5005. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5006. string design = GetPostString("design");
  5007. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5008. string sellermemo = GetPostString("seller_memo");
  5009. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5010. string logistics = GetPostString("logistics");
  5011. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5012. string date1 = GetPostString("date1");
  5013. string date2 = GetPostString("date2");
  5014. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5015. //if (dw.Length > 0) lw.Add(dw);
  5016. string placedate1 = GetPostString("placedate1");
  5017. string placedate2 = GetPostString("placedate2");
  5018. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5019. if (fdw.Length > 0) lw.Add(fdw);
  5020. string devdate1 = GetPostString("deliverydate1");
  5021. string devdate2 = GetPostString("deliverydate2");
  5022. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5023. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5024. string price1 = GetPostString("price1");
  5025. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5026. string price2 = GetPostString("price2");
  5027. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5028. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5029. {
  5030. if (tid.Length > 0)
  5031. {
  5032. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5033. if (tid.Length > 5)
  5034. {
  5035. List<string> tids = getTidByCtidLike(tid);
  5036. if (tids.Count > 0 && tids.Count < 10)
  5037. {
  5038. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5039. }
  5040. }
  5041. lw.Add(tid_sql);
  5042. }
  5043. if (buyernick.Length > 0)
  5044. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5045. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5046. if (dw.Length > 0) lw.Add(dw);
  5047. }
  5048. else
  5049. {
  5050. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5051. }
  5052. string posTag = CurrentUser.UserPost.Post.Code;
  5053. if (posTag == "Supplier")
  5054. {
  5055. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5056. }
  5057. else
  5058. {
  5059. string supplier = GetPostString("supplier");
  5060. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5061. }
  5062. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5063. lw.Add(string.Format("type = 'PDD' "));
  5064. lw.Add(string.Format("IsRefund!={0}", 2));
  5065. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5066. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5067. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5068. /* if (tid.Length > 0)
  5069. {
  5070. List<string> tids = new List<string>();
  5071. if (dt != null && dt.Rows.Count > 0)
  5072. {
  5073. foreach (DataRow item in dt.Rows)
  5074. {
  5075. tids.Add("'" + item["tid"] + "'");
  5076. }
  5077. }
  5078. if (tids.Count > 0)
  5079. {
  5080. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5081. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5082. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5083. dt = WebCache.GetData("view_erptradecell", dStruct);
  5084. }
  5085. }*/
  5086. foreach (DataRow dr in dt.Rows)
  5087. {
  5088. 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();
  5089. }
  5090. writeGridDataTableJson(dStruct.TotalCount, dt);
  5091. }
  5092. public void get_erp_jddeliveryed()
  5093. {
  5094. DataStruct dStruct = GetPostStruct();
  5095. List<string> lw = new List<string>();
  5096. string tid = GetPostString("ctid");
  5097. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5098. string shopname = GetPostString("shopname");
  5099. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5100. string buyernick = GetPostString("buyer_nick");
  5101. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5102. string customer = GetPostString("customer");
  5103. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5104. string design = GetPostString("design");
  5105. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5106. string sellermemo = GetPostString("seller_memo");
  5107. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5108. string date1 = GetPostString("date1");
  5109. string date2 = GetPostString("date2");
  5110. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5111. //if (dw.Length > 0) lw.Add(dw);
  5112. string placedate1 = GetPostString("placedate1");
  5113. string placedate2 = GetPostString("placedate2");
  5114. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5115. if (fdw.Length > 0) lw.Add(fdw);
  5116. string devdate1 = GetPostString("deliverydate1");
  5117. string devdate2 = GetPostString("deliverydate2");
  5118. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5119. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5120. string price1 = GetPostString("price1");
  5121. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5122. string price2 = GetPostString("price2");
  5123. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5124. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5125. {
  5126. if (tid.Length > 0)
  5127. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5128. if (buyernick.Length > 0)
  5129. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5130. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5131. if (dw.Length > 0) lw.Add(dw);
  5132. }
  5133. else
  5134. {
  5135. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5136. }
  5137. string posTag = CurrentUser.UserPost.Post.Code;
  5138. if (posTag == "Supplier")
  5139. {
  5140. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5141. }
  5142. else
  5143. {
  5144. string supplier = GetPostString("supplier");
  5145. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5146. }
  5147. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5148. lw.Add(string.Format("type = 'JD' "));
  5149. lw.Add(string.Format("IsRefund!={0}", 2));
  5150. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5152. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5153. foreach (DataRow dr in dt.Rows)
  5154. {
  5155. 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();
  5156. }
  5157. writeGridDataTableJson(dStruct.TotalCount, dt);
  5158. }
  5159. public void get_erp_allplacelist()
  5160. {
  5161. DataStruct dStruct = GetPostStruct();
  5162. List<string> lw = new List<string>();
  5163. string tid = GetPostString("ctid");
  5164. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5165. string shopname = GetPostString("shopname");
  5166. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5167. string buyernick = GetPostString("buyer_nick");
  5168. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5169. string customer = GetPostString("customer");
  5170. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5171. string design = GetPostString("design");
  5172. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5173. string sellermemo = GetPostString("seller_memo");
  5174. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5175. string supplier = GetPostString("supplier");
  5176. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5177. string date1 = GetPostString("date1");
  5178. string date2 = GetPostString("date2");
  5179. string pldate1 = GetPostString("placedate1");
  5180. string pldate2 = GetPostString("placedate2");
  5181. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5182. //if (dw.Length > 0) lw.Add(dw);
  5183. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5184. {
  5185. if (tid.Length > 0)
  5186. {
  5187. string select_tid = getTidByCtid(tid);
  5188. lw.Add(string.Format("tid='{0}'", select_tid));
  5189. }
  5190. if (buyernick.Length > 0)
  5191. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5192. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5193. if (dw.Length > 0) lw.Add(dw);
  5194. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5195. if (dw_place.Length > 0) lw.Add(dw_place);
  5196. }
  5197. else
  5198. {
  5199. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5200. {
  5201. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5202. }
  5203. }
  5204. string price1 = GetPostString("price1");
  5205. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5206. string price2 = GetPostString("price2");
  5207. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5208. string posTag = CurrentUser.UserPost.Post.Code;
  5209. if (posTag == "Supplier")
  5210. {
  5211. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5212. }
  5213. lw.Add(string.Format("OrderState >= 6"));
  5214. lw.Add(string.Format("IsSample != 2 "));
  5215. //lw.Add(string.Format("isDianziOrder = 0 "));
  5216. lw.Add(string.Format("SupplierId > 0 "));
  5217. //lw.Add(string.Format("IsRefund<={0}", 1));
  5218. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5219. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5220. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5221. foreach (DataRow dr in dt.Rows)
  5222. {
  5223. 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();
  5224. }
  5225. writeGridDataTableJson(dStruct.TotalCount, dt);
  5226. }
  5227. public void get_erp_financeallplacelist()
  5228. {
  5229. DataStruct dStruct = GetPostStruct();
  5230. List<string> lw = new List<string>();
  5231. string tid = GetPostString("ctid");
  5232. string shopname = GetPostString("shopname");
  5233. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5234. string buyernick = GetPostString("buyer_nick");
  5235. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5236. string customer = GetPostString("customer");
  5237. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5238. string design = GetPostString("design");
  5239. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5240. string sellermemo = GetPostString("seller_memo");
  5241. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5242. string supplier = GetPostString("supplier");
  5243. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5244. string date1 = GetPostString("date1");
  5245. string date2 = GetPostString("date2");
  5246. string pldate1 = GetPostString("placedate1");
  5247. string pldate2 = GetPostString("placedate2");
  5248. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5249. {
  5250. if (tid.Length > 0)
  5251. {
  5252. string select_tid = getTidByCtid(tid);
  5253. lw.Add(string.Format("tid='{0}'", select_tid));
  5254. }
  5255. if (buyernick.Length > 0)
  5256. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5257. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5258. if (dw.Length > 0) lw.Add(dw);
  5259. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5260. if (dw_place.Length > 0) lw.Add(dw_place);
  5261. }
  5262. else
  5263. {
  5264. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5265. {
  5266. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5267. }
  5268. }
  5269. string price1 = GetPostString("price1");
  5270. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5271. string price2 = GetPostString("price2");
  5272. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5273. string posTag = CurrentUser.UserPost.Post.Code;
  5274. if (posTag == "Supplier")
  5275. {
  5276. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5277. }
  5278. //lw.Add(string.Format("OrderState >= 6"));
  5279. lw.Add(string.Format("IsSample != 2 "));
  5280. lw.Add(string.Format("isDianziOrder = 0 "));
  5281. //lw.Add(string.Format("IsRefund<={0}", 1));
  5282. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5283. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5284. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5285. foreach (DataRow dr in dt.Rows)
  5286. {
  5287. 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();
  5288. }
  5289. writeGridDataTableJson(dStruct.TotalCount, dt);
  5290. }
  5291. public void get_erp_expresslist()
  5292. {
  5293. int listtype = GetInt("ltype");
  5294. DataStruct dStruct = GetPostStruct();
  5295. List<string> lw = new List<string>();
  5296. string tid = GetPostString("tid");
  5297. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5298. string outsid = GetPostString("out_sid");
  5299. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5300. string importer = GetPostString("ImportUserName");
  5301. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5302. string file = GetPostString("import_file");
  5303. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5304. string printman = GetPostString("printman");
  5305. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5306. string date1 = GetPostString("date1");
  5307. string date2 = GetPostString("date2");
  5308. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5309. if (dw.Length > 0) lw.Add(dw);
  5310. string fdate1 = GetPostString("finishdate1");
  5311. string fdate2 = GetPostString("finishdate2");
  5312. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5313. if (fdw.Length > 0) lw.Add(fdw);
  5314. string supplierId = GetPostString("supplierId");
  5315. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5316. if (listtype == 1)
  5317. {
  5318. lw.Add(string.Format("importUserId !=0"));
  5319. }
  5320. string posTag = CurrentUser.UserPost.Post.Code;
  5321. if (posTag == "Supplier")
  5322. {
  5323. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5324. }
  5325. if (dStruct.PageSize != 100000)
  5326. {
  5327. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5328. }
  5329. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5330. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5331. writeGridDataTableJson(dStruct.TotalCount, dt);
  5332. }
  5333. public void set_erp_buchaorderdelivery()
  5334. {
  5335. if (UrlPostParmsCheck("ctid"))
  5336. {
  5337. string eid = GetPostString("ctid");
  5338. CeErpTradeCell entity = null;
  5339. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5340. if (entity != null)
  5341. {
  5342. if (entity.IsSample != 2)
  5343. {
  5344. returnErrorMsg("补差价单才能标记为已发货");
  5345. return;
  5346. }
  5347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5348. entity.OrderState = 7;
  5349. entity.Update();
  5350. returnSuccessMsg("操作成功!");
  5351. return;
  5352. }
  5353. returnErrorMsg("找不到记录");
  5354. }
  5355. }
  5356. public void get_stdtemplates()
  5357. {
  5358. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5359. //string res = taobaoHelper.test();
  5360. string res = apiHelper.API_PrintTemplate();
  5361. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5362. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5363. {
  5364. int sidx = res.IndexOf("error_code");
  5365. int eidx = res.IndexOf("success");
  5366. string msg = res.Substring(sidx, eidx - sidx);
  5367. returnErrorMsg(msg);
  5368. return;
  5369. }
  5370. if (res.Length <= 0)
  5371. {
  5372. returnErrorMsg("模板数据为空!");
  5373. return;
  5374. }
  5375. ReturnSuccess(res);
  5376. }
  5377. public void cancel_print_order()
  5378. {
  5379. if (UrlPostParmsCheck("ctid"))
  5380. {
  5381. string ctid = GetPostString("ctid");
  5382. CeErpTradeCell entity = null;
  5383. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5384. if (entity != null)
  5385. {
  5386. string res = "";
  5387. string code = entity.LastBillWaybillCode;
  5388. if (code == "")
  5389. {
  5390. code = entity.OutSid;
  5391. }
  5392. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5393. XLog.SaveLog(0, "取消面单" + res);
  5394. }
  5395. }
  5396. }
  5397. public void set_erp_printwaybill()
  5398. {
  5399. if (UrlPostParmsCheck("ctid"))
  5400. {
  5401. string ctid = GetPostString("ctid");
  5402. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5403. string cpName = GetPostString("cpname");
  5404. string isTogether = GetPostString("together");
  5405. string printType = GetPostString("printType");
  5406. //var res_obj = new
  5407. //{
  5408. // restype = 1,
  5409. // 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\"}"
  5410. //};
  5411. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5412. //ReturnSuccess(ro_json);
  5413. //return;
  5414. bool isUseLastWayBillCode = false;
  5415. CeErpTradeCell entity = null;
  5416. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5417. if (entity != null)
  5418. {
  5419. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5420. {
  5421. isUseLastWayBillCode = true;
  5422. }
  5423. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5424. {
  5425. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5426. return;
  5427. }
  5428. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5429. {
  5430. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5431. return;
  5432. }
  5433. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5434. {
  5435. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5436. return;
  5437. }
  5438. }
  5439. string res = "";
  5440. Api_waybill_code_response_Obj fullObj = null;
  5441. string pData_str = "";
  5442. string curUseWayBillCode = "";
  5443. if (isUseLastWayBillCode == false)
  5444. {
  5445. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5446. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5447. if (res.IndexOf("failure") != -1)
  5448. {
  5449. //int idx = res.IndexOf("sub_message");
  5450. //int idx2 = res.IndexOf("flag");
  5451. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5452. string errMsgNeed = commonHelper.KeepChinese(res);
  5453. var res_objd = new
  5454. {
  5455. restype = 0,
  5456. data = "获取面单失败" + errMsgNeed
  5457. };
  5458. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5459. returnSuccess(ro_jsond);
  5460. if (res.IndexOf("停发") != -1)
  5461. {
  5462. entity.UnusualCon = "物流停发";
  5463. entity.Update();
  5464. }
  5465. //returnErrorMsg("获取面单失败,"+emsg);
  5466. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5467. return;
  5468. }
  5469. else if (res.IndexOf("errorMsg") != -1)
  5470. {
  5471. //int idx = res.IndexOf("errorMsg");
  5472. //int idx2 = res.IndexOf("}]}");
  5473. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5474. string errMsgNeed = commonHelper.KeepChinese(res);
  5475. var res_objf = new
  5476. {
  5477. restype = 0,
  5478. data = "获取面单失败2" + errMsgNeed
  5479. };
  5480. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5481. if (res.IndexOf("停发") != -1)
  5482. {
  5483. entity.UnusualCon = "物流停发";
  5484. entity.Update();
  5485. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5486. if (trade != null)
  5487. {
  5488. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5489. }
  5490. }
  5491. returnSuccess(ro_jsonf);
  5492. //returnErrorMsg("获取面单失败," + emsg);
  5493. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5494. return;
  5495. }
  5496. try
  5497. {
  5498. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5499. //res = res.Replace(" ", "");
  5500. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5501. }
  5502. catch (Exception ex)
  5503. {
  5504. XLog.SaveLog(0, "生成fullObj" + res);
  5505. var res_objf = new
  5506. {
  5507. restype = 0,
  5508. data = "生成fullObj发生错误" + ex.Message
  5509. };
  5510. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5511. returnSuccess(ro_jsonf);
  5512. return;
  5513. }
  5514. if (fullObj.response.data.content.Count > 0)
  5515. {
  5516. ContentItem codeObj = fullObj.response.data.content[0];
  5517. if (cpCode.IndexOf("SFFQ-") != -1)
  5518. {
  5519. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5520. }
  5521. else
  5522. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5523. curUseWayBillCode = codeObj.waybillCode;
  5524. }
  5525. else
  5526. {
  5527. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5528. var res_objf = new
  5529. {
  5530. restype = 0,
  5531. data = "生成fullObj找不到快递单号waybillCode"
  5532. };
  5533. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5534. returnSuccess(ro_jsonf);
  5535. return;
  5536. }
  5537. }
  5538. else
  5539. {
  5540. //使用上次打印的快递单号
  5541. if (cpCode == "SFFQ-LY")
  5542. {
  5543. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5544. }
  5545. else
  5546. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5547. curUseWayBillCode = entity.LastBillWaybillCode;
  5548. }
  5549. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5550. {
  5551. var res_obje = new
  5552. {
  5553. restype = 0,
  5554. data = "获取加密打印数据失败"
  5555. };
  5556. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5557. returnSuccess(ro_jsone);
  5558. entity.LastBillCpCode = cpCode;
  5559. entity.LastBillWaybillCode = curUseWayBillCode;
  5560. entity.Update();
  5561. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5562. //returnErrorMsg("获取加密打印数据失败");
  5563. return;
  5564. }
  5565. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5566. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5567. string btnType = "";
  5568. string errorMsg = "";
  5569. if (entity != null)
  5570. {
  5571. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5572. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5573. //cpcode是 YTO-CAINIAO
  5574. //string comCode = cpCode.Split('-')[0].ToString();
  5575. string apires = "";
  5576. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5577. //isTogether=2是新的合包弹窗
  5578. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5579. {
  5580. if (ctid.IndexOf("N") != -1)
  5581. {
  5582. apires = "发货成功";
  5583. }
  5584. else
  5585. {
  5586. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5587. }
  5588. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5589. //打单后发货
  5590. StringBuilder sql = new StringBuilder();
  5591. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5592. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5593. {
  5594. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5595. }
  5596. else
  5597. {
  5598. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5599. }
  5600. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5601. foreach (DataRow row in dt.Rows)
  5602. {
  5603. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5604. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5605. {
  5606. try
  5607. {
  5608. btnType = "待发货";
  5609. entity.OutSid = curUseWayBillCode;
  5610. entity.OrderState = 7;
  5611. entity.IsUrgency = false;
  5612. entity.LastBillCpCode = "";
  5613. entity.LastBillWaybillCode = "";
  5614. entity.FinishDeliveryTime = DateTime.Now;
  5615. entity.IsReturn = 0;
  5616. entity.MemoOpt = 0;
  5617. entity.UpdateTime = DateTime.Now;
  5618. entity.Update();
  5619. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5620. //还要插入快递信息到 快递信息表
  5621. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5622. exinfo.tid = entity.ctid;
  5623. exinfo.out_sid = curUseWayBillCode;
  5624. exinfo.company_code = cpCode;
  5625. exinfo.company_name = cpName;
  5626. exinfo.supplierUserName = supplierName;
  5627. exinfo.deliveryType = "发货成功";
  5628. exinfo.print_time = DateTime.Now;
  5629. exinfo.printUser = CurrentUser.UserName;
  5630. exinfo.postData = pData_str;
  5631. exinfo.Create();
  5632. commonHelper.UpdateRelationOrder(entity.ctid);
  5633. CeErpSukuraData.createInfo(ctid, 4);
  5634. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5635. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5636. {
  5637. commonHelper.sendCytExpress(exinfo);
  5638. }
  5639. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5640. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5641. }
  5642. catch (Exception ex)
  5643. {
  5644. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5645. }
  5646. }
  5647. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5648. {
  5649. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5650. if (entity.OrderState == 6)
  5651. {
  5652. entity.OrderState = 7;
  5653. }
  5654. entity.UpdateTime = DateTime.Now;
  5655. entity.FinishDeliveryTime = DateTime.Now;
  5656. btnType = "已发货";
  5657. entity.Update();
  5658. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5659. exinfo.tid = entity.ctid;
  5660. exinfo.out_sid = curUseWayBillCode;
  5661. exinfo.company_code = cpCode;
  5662. exinfo.company_name = cpName;
  5663. exinfo.supplierUserName = supplierName;
  5664. exinfo.deliveryType = "发货成功";
  5665. exinfo.print_time = DateTime.Now;
  5666. exinfo.printUser = CurrentUser.UserName;
  5667. exinfo.postData = pData_str;
  5668. exinfo.Create();
  5669. commonHelper.UpdateRelationOrder(entity.ctid);
  5670. CeErpSukuraData.createInfo(entity.ctid, 4);
  5671. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5672. {
  5673. commonHelper.sendCytExpress(exinfo);
  5674. }
  5675. //不处理
  5676. }
  5677. else
  5678. {
  5679. entity.UpdateTime = DateTime.Now;
  5680. entity.LastBillCpCode = cpCode;
  5681. entity.LastBillWaybillCode = curUseWayBillCode;
  5682. entity.Update();
  5683. string errmsg = commonHelper.KeepChinese(apires);
  5684. var res_objz = new
  5685. {
  5686. restype = 0,
  5687. data = "打单后发货失败"
  5688. };
  5689. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5690. returnSuccess(ro_jsonz);
  5691. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5692. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5693. return;
  5694. }
  5695. }
  5696. }
  5697. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5698. {
  5699. string ctids = GetPostString("ctids");
  5700. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5701. List<string> list = new List<string>();
  5702. List<string> send_list = new List<string>();
  5703. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5704. CeErpTrade ceErpTrade = new CeErpTrade();
  5705. //可合包的合并一起发货
  5706. if (dt == null && string.IsNullOrEmpty(ctids))
  5707. {
  5708. var res_objz = new
  5709. {
  5710. restype = 0,
  5711. data = "打单后发货失败"
  5712. };
  5713. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5714. returnSuccess(ro_jsonz);
  5715. return;
  5716. }
  5717. if (!string.IsNullOrEmpty(ctids))
  5718. {
  5719. StringBuilder sql = new StringBuilder();
  5720. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5721. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5722. }
  5723. foreach (DataRow row in dt.Rows)
  5724. {
  5725. list.Add("'" + row["ctid"] + "'");
  5726. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5727. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5728. if (ctid.IndexOf("N") != -1)
  5729. {
  5730. apires = "发货成功";
  5731. }
  5732. else
  5733. {
  5734. if (!send_list.Contains(ceErpTrade.tid))
  5735. {
  5736. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5737. }
  5738. else
  5739. {
  5740. apires = "发货成功";
  5741. }
  5742. }
  5743. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5744. {
  5745. send_list.Add(ceErpTrade.tid);
  5746. try
  5747. {
  5748. btnType = "待发货";
  5749. ceErpTradeCell.OutSid = curUseWayBillCode;
  5750. ceErpTradeCell.OrderState = 7;
  5751. ceErpTradeCell.IsUrgency = false;
  5752. ceErpTradeCell.LastBillCpCode = "";
  5753. ceErpTradeCell.LastBillWaybillCode = "";
  5754. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5755. ceErpTradeCell.IsReturn = 0;
  5756. ceErpTradeCell.MemoOpt = 0;
  5757. ceErpTradeCell.UpdateTime = DateTime.Now;
  5758. ceErpTradeCell.Update();
  5759. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5760. //还要插入快递信息到 快递信息表
  5761. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5762. exinfo.tid = ceErpTradeCell.ctid;
  5763. exinfo.out_sid = curUseWayBillCode;
  5764. exinfo.company_code = cpCode;
  5765. exinfo.company_name = cpName;
  5766. exinfo.supplierUserName = supplierName;
  5767. exinfo.deliveryType = "发货成功";
  5768. exinfo.print_time = DateTime.Now;
  5769. exinfo.printUser = CurrentUser.UserName;
  5770. exinfo.postData = pData_str;
  5771. exinfo.Create();
  5772. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5773. CeErpSukuraData.createInfo(ctid, 4);
  5774. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5775. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5776. {
  5777. commonHelper.sendCytExpress(exinfo);
  5778. }
  5779. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5780. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5781. }
  5782. catch (Exception ex)
  5783. {
  5784. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5785. }
  5786. }
  5787. else
  5788. {
  5789. ceErpTradeCell.UpdateTime = DateTime.Now;
  5790. ceErpTradeCell.LastBillCpCode = cpCode;
  5791. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5792. ceErpTradeCell.Update();
  5793. string errmsg = commonHelper.KeepChinese(apires);
  5794. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5795. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5796. }
  5797. }
  5798. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5799. }
  5800. }
  5801. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5802. var res_obj = new
  5803. {
  5804. restype = 1,
  5805. data = pData_str,
  5806. errorMsg
  5807. };
  5808. string ro_json = JsonConvert.SerializeObject(res_obj);
  5809. ReturnSuccess(ro_json);
  5810. return;
  5811. }
  5812. }
  5813. private string GetUTF8String(byte[] vs)
  5814. {
  5815. throw new NotImplementedException();
  5816. }
  5817. public void set_erp_printwaybill_cn()
  5818. {
  5819. if (UrlPostParmsCheck("ctid"))
  5820. {
  5821. string ctid = GetPostString("ctid");
  5822. string cpCode = GetPostString("cpcode");
  5823. string cpName = GetPostString("cpname");
  5824. string tempUrl = GetPostString("tempurl");
  5825. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5826. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5827. //string res = taobaoHelper.test();
  5828. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5829. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5830. {
  5831. int sidx = res.IndexOf("errorMsg");
  5832. int eidx = res.IndexOf("}");
  5833. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5834. var res_objzxx = new
  5835. {
  5836. restype = 0,
  5837. data = msg
  5838. };
  5839. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5840. returnSuccess(ro_jsonzxx);
  5841. //returnErrorMsg(msg);
  5842. return;
  5843. }
  5844. int idx = res.IndexOf("waybillCode");
  5845. int idx2 = res.IndexOf("printData");
  5846. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5847. string eid = GetPostString("ctid");
  5848. CeErpTradeCell entity = null;
  5849. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5850. if (entity != null)
  5851. {
  5852. string osid = entity.OutSid;
  5853. entity.OutSid = osid + "," + outsid;
  5854. entity.FinishDeliveryTime = DateTime.Now;
  5855. entity.OrderState = 7;
  5856. entity.UpdateTime = DateTime.Now;
  5857. entity.IsReturn = 0;
  5858. entity.Update();
  5859. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5860. exinfo.tid = entity.ctid;
  5861. exinfo.out_sid = outsid;
  5862. exinfo.company_code = cpCode;
  5863. exinfo.company_name = cpName;
  5864. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5865. exinfo.deliveryType = "发货成功";
  5866. exinfo.print_time = DateTime.Now;
  5867. exinfo.printUser = CurrentUser.UserName;
  5868. exinfo.Create();
  5869. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5870. {
  5871. commonHelper.sendCytExpress(exinfo);
  5872. }
  5873. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5874. }
  5875. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5876. var res_objz = new
  5877. {
  5878. restype = 1,
  5879. data = res
  5880. };
  5881. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5882. returnSuccess(ro_jsonz);
  5883. //ReturnSuccess(res);
  5884. }
  5885. }
  5886. ////打单,打印面单 获取面单号
  5887. //public void set_erp_printwaybill()
  5888. //{
  5889. // if (UrlPostParmsCheck("ctid"))
  5890. // {
  5891. // string ctid = GetPostString("ctid");
  5892. // string cpCode = GetPostString("cpcode");
  5893. // string tempUrl = GetPostString("tempurl");
  5894. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5895. // //string res = taobaoHelper.test();
  5896. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5897. // if (res.IndexOf("error_response") != -1)
  5898. // {
  5899. // int sidx = res.IndexOf("sub_msg");
  5900. // int eidx = res.IndexOf("request_id");
  5901. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5902. // returnErrorMsg(msg);
  5903. // return;
  5904. // }
  5905. // int idx = res.IndexOf("waybill_code");
  5906. // int idx2 = res.IndexOf("}]}");
  5907. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5908. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5909. // ReturnSuccess(res);
  5910. // }
  5911. //}
  5912. public void cancel_erp_aftersale()
  5913. {
  5914. if (UrlPostParmsCheck("ctid"))
  5915. {
  5916. string eid = GetPostString("ctid");
  5917. CeErpTradeCell entity = null;
  5918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5919. if (entity != null)
  5920. {
  5921. //有过处理的售后,取消也不能删除 售 字,保留
  5922. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5923. {
  5924. entity.AfterSaleState = 4;
  5925. }
  5926. else
  5927. entity.AfterSaleState = 0;
  5928. entity.UpdateTime = DateTime.Now;
  5929. entity.Update();
  5930. returnSuccessMsg("操作成功!");
  5931. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5932. return;
  5933. }
  5934. returnErrorMsg("找不到订单记录");
  5935. }
  5936. }
  5937. public void get_erp_aftersalelist()
  5938. {
  5939. DataStruct dStruct = GetPostStruct();
  5940. List<string> lw = new List<string>();
  5941. int st = GetInt("st");
  5942. string tid = GetPostString("ctid");
  5943. if (st == 3)
  5944. {
  5945. if (tid.Length > 0)
  5946. {
  5947. string select_tid = getTidByCtid(tid);
  5948. lw.Add(string.Format("tid='{0}'", select_tid));
  5949. }
  5950. }
  5951. else
  5952. {
  5953. if (tid.Length > 0)
  5954. {
  5955. string select_tid = getTidByCtid(tid);
  5956. lw.Add(string.Format("tid='{0}'", select_tid));
  5957. }
  5958. }
  5959. string shopname = GetPostString("shopname");
  5960. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5961. string buyernick = GetPostString("buyer_nick");
  5962. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5963. string sellermemo = GetPostString("seller_memo");
  5964. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5965. string orderState = GetPostString("orderState");
  5966. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5967. string afterState = GetPostString("afterstate");
  5968. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5969. string date1 = GetPostString("date1");
  5970. string date2 = GetPostString("date2");
  5971. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5972. if (dw.Length > 0) lw.Add(dw);
  5973. string price1 = GetPostString("price1");
  5974. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5975. string price2 = GetPostString("price2");
  5976. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5977. //lw.Add(string.Format("IsRefund!={0}", 1));
  5978. string reason = GetPostString("reason");
  5979. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5980. string method = GetPostString("method");
  5981. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5982. string handler = GetPostString("handler");
  5983. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5984. string handledate1 = GetPostString("handledate1");
  5985. string handledate2 = GetPostString("handledate2");
  5986. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5987. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5988. string finish1 = GetPostString("finishdate1");
  5989. string finish2 = GetPostString("finishdate2");
  5990. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5991. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5992. string afterdate1 = GetPostString("afterdate1");
  5993. string afterdate2 = GetPostString("afterdate2");
  5994. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5995. if (afterDate.Length > 0) lw.Add(afterDate);
  5996. string supplier = GetPostString("supplier");
  5997. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5998. string responsible = GetPostString("responsibleman");
  5999. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6000. string customer = GetPostString("customer");
  6001. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6002. string design = GetPostString("design");
  6003. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6004. string afterMemoType = GetPostString("aftermemotype");
  6005. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6006. string posCode = CurrentUser.UserPost.Post.Code;
  6007. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6008. //{
  6009. // string vstate = GetPostString("vstate");
  6010. // if (vstate.Length > 0)
  6011. // {
  6012. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6013. // }
  6014. // if (posCode == "Supplier")
  6015. // {
  6016. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6017. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6018. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6019. // }
  6020. // else
  6021. // {
  6022. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6023. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6024. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6025. // {
  6026. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6027. // }
  6028. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6029. // {
  6030. // int orgid = CurrentUser.UserPost.OrgID;
  6031. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6032. // }
  6033. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6034. // {
  6035. // string shopid = CurrentUser.User.pemShop;
  6036. // lw.Add(string.Format("shopId in ({0})", shopid));
  6037. // }
  6038. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6039. // //{
  6040. // // int org_id = CurrentUser.UserPost.OrgID;
  6041. // // lw.Add(string.Format("OrgID={0}", org_id));
  6042. // //}
  6043. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6044. // }
  6045. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6046. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6047. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6048. //}
  6049. if (st == 5)
  6050. {
  6051. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6052. {
  6053. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6054. {
  6055. string shopid = CurrentUser.User.pemShop;
  6056. lw.Add(string.Format("shopId in ({0})", shopid));
  6057. }
  6058. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6059. {
  6060. int mrOrgid = CurrentUser.UserPost.OrgID;
  6061. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6062. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6063. }
  6064. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6065. //{
  6066. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6067. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6068. //}
  6069. else
  6070. {
  6071. string userIdStr = "";
  6072. if (posCode == "CustomerService")
  6073. {
  6074. userIdStr = CurrentUser.UserID + "_k";
  6075. }
  6076. else if (posCode == "Designer" || posCode == "wxDesigner")
  6077. {
  6078. userIdStr = CurrentUser.UserID + "_s";
  6079. }
  6080. else if (posCode == "Place")
  6081. {
  6082. userIdStr = CurrentUser.UserID + "_x";
  6083. }
  6084. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6085. }
  6086. }
  6087. string placedate1 = GetPostString("placedate1");
  6088. string placedate2 = GetPostString("placedate2");
  6089. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6090. if (dwplace.Length > 0) lw.Add(dwplace);
  6091. string supState = GetPostString("supState");
  6092. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6093. string searchType = GetPostString("searchType");
  6094. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6095. {
  6096. lw.Add(string.Format("BackNum>1"));
  6097. }
  6098. lw.Add(string.Format("AfterSaleState>0"));
  6099. if (ex_psize > 0)
  6100. {
  6101. if (CurrentUser.UserPost.Post.Code == "Finance")
  6102. dStruct.Order = "pay_time desc";
  6103. else
  6104. dStruct.Order = "HandleTime desc";
  6105. }
  6106. else
  6107. dStruct.Order = "HandleTime desc";
  6108. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6109. DataTable dt = WebCache.GetData("view_test", dStruct);
  6110. writeGridDataTableJson(dStruct.TotalCount, dt);
  6111. }
  6112. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6113. //{
  6114. // lw.Add(string.Format("AfterSaleState=4"));
  6115. // string code = CurrentUser.UserPost.Post.Code;
  6116. // if (code == "CustomerService")
  6117. // {
  6118. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6119. // }
  6120. // else if (code == "Designer" || code == "DesignerMr")
  6121. // {
  6122. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6123. // }
  6124. // else if (code == "Place" || code == "PlaceMr")
  6125. // {
  6126. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6127. // }
  6128. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6129. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6130. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6131. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6132. //}
  6133. //else //处理中的售后,待处理和处理中合并
  6134. //{
  6135. // if (afterState.Length <= 0)
  6136. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6137. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6138. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6139. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6140. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6141. //}
  6142. }
  6143. public void get_erp_disagreeftersalelist()
  6144. {
  6145. DataStruct dStruct = GetPostStruct();
  6146. List<string> lw = new List<string>();
  6147. int st = 2;
  6148. string tid = GetPostString("ctid");
  6149. if (tid.Length > 0)
  6150. {
  6151. string select_tid = getTidByCtid(tid);
  6152. lw.Add(string.Format("tid='{0}'", select_tid));
  6153. }
  6154. string shopname = GetPostString("shopname");
  6155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6156. string buyernick = GetPostString("buyer_nick");
  6157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6158. string sellermemo = GetPostString("seller_memo");
  6159. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6160. string orderState = GetPostString("orderState");
  6161. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6162. string afterState = GetPostString("afterstate");
  6163. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6164. string date1 = GetPostString("date1");
  6165. string date2 = GetPostString("date2");
  6166. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6167. if (dw.Length > 0) lw.Add(dw);
  6168. string price1 = GetPostString("price1");
  6169. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6170. string price2 = GetPostString("price2");
  6171. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6172. //lw.Add(string.Format("IsRefund!={0}", 1));
  6173. string reason = GetPostString("reason");
  6174. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6175. string method = GetPostString("method");
  6176. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6177. string handler = GetPostString("handler");
  6178. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6179. string handledate1 = GetPostString("handledate1");
  6180. string handledate2 = GetPostString("handledate2");
  6181. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6182. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6183. string afterdate1 = GetPostString("afterdate1");
  6184. string afterdate2 = GetPostString("afterdate2");
  6185. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6186. if (afterDate.Length > 0) lw.Add(afterDate);
  6187. string backdate1 = GetPostString("backdate1");
  6188. string backdate2 = GetPostString("backdate2");
  6189. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6190. if (backDate.Length > 0) lw.Add(backDate);
  6191. string supplier = GetPostString("supplier");
  6192. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6193. string responsible = GetPostString("responsibleman");
  6194. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6195. string customer = GetPostString("customer");
  6196. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6197. string design = GetPostString("design");
  6198. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6199. string afterSaleMemo = GetPostString("afterSaleMemo");
  6200. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6201. string afterMemoType = GetPostString("aftermemotype");
  6202. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6203. string aftersakereason = GetPostString("aftersakereason");
  6204. if (aftersakereason.Length > 0)
  6205. {
  6206. if (aftersakereason == "1")
  6207. {
  6208. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6209. }
  6210. if (aftersakereason == "2")
  6211. {
  6212. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6213. }
  6214. }
  6215. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6216. string poscode = CurrentUser.UserPost.Post.Code;
  6217. if (poscode != "SysAdmin")
  6218. {
  6219. string shopid = CurrentUser.User.pemShop;
  6220. lw.Add(string.Format("shopId in ({0})", shopid));
  6221. }
  6222. string searchType = GetPostString("searchType");
  6223. if (searchType == "wait")
  6224. {
  6225. lw.Add(string.Format("HandleTime is null"));
  6226. }
  6227. if (searchType == "handling")
  6228. {
  6229. lw.Add(string.Format("HandleTime is not null "));
  6230. }
  6231. if (searchType == "back" || searchType == "puBack")
  6232. {
  6233. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6234. }
  6235. if (searchType == "reBack")
  6236. {
  6237. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6238. }
  6239. if (searchType == "moreBack")
  6240. {
  6241. lw.Add(string.Format("backNum > 1"));
  6242. }
  6243. lw.Add(string.Format("(AfterSaleState=5)"));
  6244. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6246. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6247. writeGridDataTableJson(dStruct.TotalCount, dt);
  6248. }
  6249. public void get_erp_handlingaftersalelist()
  6250. {
  6251. DataStruct dStruct = GetPostStruct();
  6252. List<string> lw = new List<string>();
  6253. int st = 2;
  6254. string tid = GetPostString("ctid");
  6255. if (tid.Length > 0)
  6256. {
  6257. string select_tid = getTidByCtid(tid);
  6258. lw.Add(string.Format("tid='{0}'", select_tid));
  6259. }
  6260. string shopname = GetPostString("shopname");
  6261. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6262. string buyernick = GetPostString("buyer_nick");
  6263. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6264. string sellermemo = GetPostString("seller_memo");
  6265. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6266. string orderState = GetPostString("orderState");
  6267. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6268. string afterState = GetPostString("afterstate");
  6269. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6270. string date1 = GetPostString("date1");
  6271. string date2 = GetPostString("date2");
  6272. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6273. if (dw.Length > 0) lw.Add(dw);
  6274. string price1 = GetPostString("price1");
  6275. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6276. string price2 = GetPostString("price2");
  6277. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6278. //lw.Add(string.Format("IsRefund!={0}", 1));
  6279. string reason = GetPostString("reason");
  6280. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6281. string method = GetPostString("method");
  6282. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6283. string handler = GetPostString("handler");
  6284. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6285. string handledate1 = GetPostString("handledate1");
  6286. string handledate2 = GetPostString("handledate2");
  6287. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6288. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6289. string afterdate1 = GetPostString("afterdate1");
  6290. string afterdate2 = GetPostString("afterdate2");
  6291. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6292. if (afterDate.Length > 0) lw.Add(afterDate);
  6293. string supplier = GetPostString("supplier");
  6294. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6295. string responsible = GetPostString("responsibleman");
  6296. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6297. string customer = GetPostString("customer");
  6298. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6299. string design = GetPostString("design");
  6300. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6301. string afterSaleMemo = GetPostString("afterSaleMemo");
  6302. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6303. string afterMemoType = GetPostString("aftermemotype");
  6304. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6305. string afterresult = GetPostString("afterresult");
  6306. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6307. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6308. string poscode = CurrentUser.UserPost.Post.Code;
  6309. if (poscode != "SysAdmin")
  6310. {
  6311. string shopid = CurrentUser.User.pemShop;
  6312. lw.Add(string.Format("shopId in ({0})", shopid));
  6313. }
  6314. string searchType = GetPostString("searchType");
  6315. if (searchType == "wait")
  6316. {
  6317. lw.Add(string.Format("HandleTime is null"));
  6318. }
  6319. if (searchType == "documentary")
  6320. {
  6321. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6322. }
  6323. if (searchType == "handling")
  6324. {
  6325. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6326. }
  6327. if (searchType == "back" || searchType == "puBack")
  6328. {
  6329. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6330. }
  6331. if (searchType == "reBack")
  6332. {
  6333. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6334. }
  6335. if (afterState.Length <= 0)
  6336. {
  6337. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6338. }
  6339. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6340. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6341. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6342. writeGridDataTableJson(dStruct.TotalCount, dt);
  6343. }
  6344. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6345. //public void get_erp_back_handlingaftersalelist()
  6346. //{
  6347. // DataStruct dStruct = GetPostStruct();
  6348. // List<string> lw = new List<string>();
  6349. // string tid = GetPostString("ctid");
  6350. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6351. // string shopname = GetPostString("shopname");
  6352. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6353. // string buyernick = GetPostString("buyer_nick");
  6354. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6355. // string sellermemo = GetPostString("seller_memo");
  6356. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6357. // string orderState = GetPostString("orderState");
  6358. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6359. // string afterState = GetPostString("afterstate");
  6360. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6361. // string date1 = GetPostString("date1");
  6362. // string date2 = GetPostString("date2");
  6363. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6364. // if (dw.Length > 0) lw.Add(dw);
  6365. // string price1 = GetPostString("price1");
  6366. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6367. // string price2 = GetPostString("price2");
  6368. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6369. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6370. // string reason = GetPostString("reason");
  6371. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6372. // string method = GetPostString("method");
  6373. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6374. // string handler = GetPostString("handler");
  6375. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6376. // string handledate1 = GetPostString("handledate1");
  6377. // string handledate2 = GetPostString("handledate2");
  6378. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6379. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6380. // string afterdate1 = GetPostString("afterdate1");
  6381. // string afterdate2 = GetPostString("afterdate2");
  6382. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6383. // if (afterDate.Length > 0) lw.Add(afterDate);
  6384. // string supplier = GetPostString("supplier");
  6385. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6386. // string responsible = GetPostString("responsibleman");
  6387. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6388. // string customer = GetPostString("customer");
  6389. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6390. // string design = GetPostString("design");
  6391. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6392. // string afterMemoType = GetPostString("aftermemotype");
  6393. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6394. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6395. // if (afterState.Length <= 0)
  6396. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6397. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6398. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6399. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6400. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6401. //}
  6402. public void get_erp_aftersaleverifylist()
  6403. {
  6404. DataStruct dStruct = GetPostStruct();
  6405. List<string> lw = new List<string>();
  6406. string tid = GetPostString("ctid");
  6407. if (tid.Length > 0)
  6408. {
  6409. string select_tid = getTidByCtid(tid);
  6410. lw.Add(string.Format("otid='{0}'", select_tid));
  6411. }
  6412. string shopname = GetPostString("shopname");
  6413. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6414. string buyernick = GetPostString("buyer_nick");
  6415. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6416. string sellermemo = GetPostString("seller_memo");
  6417. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6418. string orderState = GetPostString("orderState");
  6419. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6420. //lw.Add(string.Format("IsRefund!={0}", 1));
  6421. string reason = GetPostString("reason");
  6422. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6423. string method = GetPostString("method");
  6424. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6425. string handler = GetPostString("handler");
  6426. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6427. string handledate1 = GetPostString("handledate1");
  6428. string handledate2 = GetPostString("handledate2");
  6429. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6430. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6431. string finish1 = GetPostString("finishdate1");
  6432. string finish2 = GetPostString("finishdate2");
  6433. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6434. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6435. string supplier = GetPostString("supplier");
  6436. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6437. string responsible = GetPostString("responsibleman");
  6438. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6439. string posCode = CurrentUser.UserPost.Post.Code;
  6440. string vstate = GetPostString("vstate");
  6441. if (vstate.Length > 0)
  6442. {
  6443. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6444. }
  6445. if (posCode == "Supplier")
  6446. {
  6447. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6448. lw.Add(string.Format("VerifyState = 0"));
  6449. lw.Add("type = 1");
  6450. lw.Add(string.Format("AfterSaleState={0}", 3));
  6451. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6452. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6453. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6454. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6455. writeGridDataTableJson(dStruct.TotalCount, dt);
  6456. }
  6457. else if (posCode == "logistics")
  6458. {
  6459. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6460. lw.Add(string.Format("VerifyState = 0"));
  6461. lw.Add("type = 2");
  6462. lw.Add(string.Format("AfterSaleState={0}", 3));
  6463. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6464. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6465. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6466. writeGridDataTableJson(dStruct.TotalCount, dt);
  6467. }
  6468. else
  6469. {
  6470. lw.Add(string.Format("(AfterSaleState = 3)"));
  6471. string reasonState = GetPostString("reasonState");
  6472. lw.Add("type = 0");
  6473. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6474. || posCode == "Summarize" || posCode == "Finance")
  6475. {
  6476. if (reasonState == "2")
  6477. {
  6478. lw.Add("VerifyState = 3");
  6479. }
  6480. else if (reasonState == "1")
  6481. {
  6482. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6483. }
  6484. else
  6485. {
  6486. lw.Add("VerifyState in (0,3)");
  6487. }
  6488. //不加条件,可以看全部
  6489. }
  6490. 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")
  6491. {
  6492. int orgid = CurrentUser.UserPost.OrgID;
  6493. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6494. if (string.IsNullOrEmpty(manageOrgId))
  6495. {
  6496. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6497. }
  6498. else
  6499. {
  6500. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6501. }
  6502. if (reasonState == "1")
  6503. {
  6504. lw.Add("VerifyState = 3");
  6505. }
  6506. else if (reasonState == "2")
  6507. {
  6508. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6509. }
  6510. else
  6511. {
  6512. }
  6513. }
  6514. else
  6515. {
  6516. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6517. }
  6518. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6519. //{
  6520. // int org_id = CurrentUser.UserPost.OrgID;
  6521. // lw.Add(string.Format("OrgID={0}", org_id));
  6522. //}
  6523. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6524. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6525. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6526. writeGridDataTableJson(dStruct.TotalCount, dt);
  6527. }
  6528. }
  6529. public void get_erp_finishaftersalelist()
  6530. {
  6531. DataStruct dStruct = GetPostStruct();
  6532. List<string> lw = new List<string>();
  6533. int st = 4;
  6534. string tid = GetPostString("ctid");
  6535. if (tid.Length > 0)
  6536. {
  6537. string select_tid = getTidByCtid(tid);
  6538. lw.Add(string.Format("otid='{0}'", select_tid));
  6539. }
  6540. string shopname = GetPostString("shopname");
  6541. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6542. //lw.Add(string.Format("IsRefund!={0}", 1));
  6543. string reason = GetPostString("reason");
  6544. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6545. string method = GetPostString("method");
  6546. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6547. string buyernick = GetPostString("buyer_nick");
  6548. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6549. string handler = GetPostString("handler");
  6550. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6551. string handledate1 = GetPostString("handledate1");
  6552. string handledate2 = GetPostString("handledate2");
  6553. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6554. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6555. string finish1 = GetPostString("finishdate1");
  6556. string finish2 = GetPostString("finishdate2");
  6557. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6558. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6559. string supplier = GetPostString("supplier");
  6560. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6561. string responsible = GetPostString("responsibleman");
  6562. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6563. string vstate = GetPostString("vstate");
  6564. if (vstate.Length > 0)
  6565. {
  6566. if ("3".Equals(vstate))
  6567. {
  6568. lw.Add(string.Format("IsTem=1"));
  6569. }
  6570. else
  6571. {
  6572. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6573. }
  6574. }
  6575. lw.Add(string.Format("AfterSaleState=4"));
  6576. string code = CurrentUser.UserPost.Post.Code;
  6577. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6578. {
  6579. //不加条件,可以看全部
  6580. }
  6581. else if (code == "Supplier")
  6582. {
  6583. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6584. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6585. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6586. }
  6587. else if (code == "logistics")
  6588. {
  6589. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6590. lw.Add("type = 2");
  6591. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6592. }
  6593. 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")
  6594. {
  6595. int orgid = CurrentUser.UserPost.OrgID;
  6596. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6597. if (string.IsNullOrEmpty(manageOrgIds))
  6598. {
  6599. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6600. }
  6601. else
  6602. {
  6603. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6604. }
  6605. }
  6606. else
  6607. {
  6608. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6609. }
  6610. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6611. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6612. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6613. writeGridDataTableJson(dStruct.TotalCount, dt);
  6614. }
  6615. public void handle_erp_aftersale()
  6616. {
  6617. if (UrlPostParmsCheck("ctid"))
  6618. {
  6619. string eid = GetPostString("ctid");
  6620. string responStr = GetPostString("AfterSaleResponsible");
  6621. if (responStr.Length <= 0)
  6622. {
  6623. returnErrorMsg("售后责任人不能为空");
  6624. return;
  6625. }
  6626. bool isDesign = false;
  6627. double designFree = 0.00;
  6628. int responsibleId = 0;
  6629. CeErpTradeCell entity = null;
  6630. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6631. if (entity != null)
  6632. {
  6633. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6634. string afterMethod = GetPostString("AfterSaleMethod");
  6635. if (isNeedNewOrder == 1)
  6636. {
  6637. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6638. bool ishav = true;
  6639. if (newentity == null)
  6640. {
  6641. newentity = entity.Clone() as CeErpTradeCell;
  6642. ishav = false;
  6643. newentity.ctid = "S_" + entity.ctid;
  6644. newentity.OrderState = 0;
  6645. //唯一标识
  6646. newentity.OrderSn = newentity.ctid;
  6647. string orderSn = dataHelper.getSaleOrderSn();
  6648. if (orderSn != "")
  6649. {
  6650. newentity.OrderSn = orderSn;
  6651. }
  6652. }
  6653. newentity.UpdateTime = DateTime.Now;
  6654. newentity.AfterSaleState = 0;
  6655. newentity.AfterSaleMethod = afterMethod;
  6656. if (!ishav)
  6657. {
  6658. string memo_str = newentity.seller_memo;
  6659. memo_str = memo_str.Replace("(", "(");
  6660. memo_str = memo_str.Replace(")", ")");
  6661. int sIndex = memo_str.IndexOf("(");
  6662. int eIndex = memo_str.IndexOf(")");
  6663. if (sIndex == -1 || eIndex == -1)
  6664. {
  6665. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6666. return;
  6667. }
  6668. string first = memo_str.Substring(0, sIndex + 1);
  6669. string memoCtid = newentity.OrderSn;
  6670. //if (memoCtid.IndexOf("C") != -1)
  6671. //{
  6672. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6673. //if (CIdx.IndexOf("+") != -1)
  6674. //{
  6675. //CIdx = "C" + CIdx.Split('+')[1];
  6676. //}
  6677. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6678. //}
  6679. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6680. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6681. string newMemo = first + memoCtid + last;
  6682. newentity.seller_memo = newMemo;
  6683. newentity.FinishPlaceTime = null;
  6684. newentity.UnusualTag = 0;
  6685. newentity.UnusualCon = "";
  6686. newentity.UnusualTime = null;
  6687. newentity.AfterSaleMemo = "";
  6688. newentity.AfterSaleMethod = afterMethod;
  6689. newentity.AfterSalePreTime = null;
  6690. newentity.AfterSaleReason = "";
  6691. newentity.AfterSaleResponsible = "";
  6692. newentity.AfterSaleState = 0;
  6693. newentity.AfterSaleTime = null;
  6694. newentity.AfterSaleUserId = 0;
  6695. newentity.AfterSaleSupplierState = 0;
  6696. newentity.LastBillWaybillCode = "";
  6697. newentity.LastBillCpCode = "";
  6698. newentity.FinishAfterSaleTime = null;
  6699. newentity.HandleTime = null;
  6700. newentity.IsSF = 0;
  6701. newentity.IsOldCustomer = 0;
  6702. newentity.UrgencyTime = null;
  6703. newentity.ResponsibleUserId = "";
  6704. newentity.IsVerifyToSupplier = false;
  6705. newentity.payment = 0;
  6706. newentity.CheckMemo = "";
  6707. newentity.OutSid = "";
  6708. newentity.CheckOrderTime = null;
  6709. newentity.MemoOpt = 0;
  6710. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6711. }
  6712. newentity.isAfterSaleOrder = 1;
  6713. newentity.IsRefund = 0;
  6714. string receiveMobile = GetPostString("receiver_mobile");
  6715. if (receiveMobile.Length > 0)
  6716. {
  6717. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6718. if (trade != null)
  6719. {
  6720. trade.receiver_name = GetPostString("receiver_name");
  6721. trade.receiver_mobile = receiveMobile;
  6722. trade.receiver_state = GetPostString("receiver_state");
  6723. trade.receiver_city = GetPostString("receiver_city");
  6724. trade.receiver_district = GetPostString("receiver_district");
  6725. trade.receiver_address = GetPostString("receiver_address");
  6726. newentity.IsOffLineOrder = 1;
  6727. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6728. }
  6729. }
  6730. string st = GetPostString("ToState");
  6731. if (st.Length > 0)
  6732. {
  6733. if (newentity.OrderState <= 3)
  6734. {
  6735. newentity.WaitDesignTime = DateTime.Now;
  6736. newentity.StartDesignTime = null;
  6737. newentity.FinishDesignTime = null;
  6738. newentity.OrderState = 3;
  6739. if (st == "下单员")
  6740. {
  6741. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6742. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6743. {
  6744. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6745. }
  6746. }
  6747. else
  6748. {
  6749. newentity.WaitDesignTime = DateTime.Now;
  6750. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6751. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6752. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6753. {
  6754. DataRow user = dt1.Rows[0];
  6755. //找主管
  6756. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6757. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6758. if (dt != null && dt.Rows.Count > 0)
  6759. {
  6760. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6761. newentity.DesignUserId = designMr;
  6762. string key = "aftersale_order_" + designMr;
  6763. if (RedisHelper.HasKey(key))
  6764. {
  6765. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6766. list.Add(newentity.ctid);
  6767. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6768. }
  6769. }
  6770. //账号正常
  6771. if (user["State"].ToString() == "0")
  6772. {
  6773. newentity.DesignUserId = entity.DesignUserId;
  6774. string key = "aftersale_order_" + entity.DesignUserId;
  6775. if (RedisHelper.HasKey(key))
  6776. {
  6777. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6778. list.Add(newentity.ctid);
  6779. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6780. }
  6781. }
  6782. }
  6783. }
  6784. }
  6785. if (entity.IsXianHuo == 1)
  6786. {
  6787. newentity.OrderState = 6;
  6788. entity.FinishPlaceTime = DateTime.Now;
  6789. }
  6790. }
  6791. if (ishav)
  6792. {
  6793. newentity.Update();
  6794. }
  6795. else
  6796. {
  6797. newentity.Create();
  6798. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6799. newCellExtend.ctid = newentity.ctid;
  6800. newCellExtend.orderFrom = 20;
  6801. newCellExtend.orderType = 30;
  6802. if (st == "下单员")
  6803. {
  6804. }
  6805. else
  6806. {
  6807. newCellExtend.ReprintTime = DateTime.Now;
  6808. }
  6809. newCellExtend.Create();
  6810. }
  6811. if (st != "下单员")
  6812. {
  6813. if (entity.DispatchSort == 2)
  6814. {
  6815. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6816. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6817. }
  6818. }
  6819. }
  6820. //处理售后扩展
  6821. string resIdStr = GetPostString("ResponsibleUserId");
  6822. string refundFees = GetPostString("refundFrees");
  6823. int IsComplain = GetPostInt("isComplain");
  6824. int IsBad = GetPostInt("isBad");
  6825. string IsOriginal = GetPostString("isOriginal");
  6826. double diffResultPrice = GetPostDouble("diffResultPrice");
  6827. string textResult = GetPostString("textResult");
  6828. string supplierResponsible = GetPostString("supplierResponsible");
  6829. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6830. if (ceErpTradeAfterSaleExtend == null)
  6831. {
  6832. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6833. ceErpTradeAfterSaleExtend.tid = eid;
  6834. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6835. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6836. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6837. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6838. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6839. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6840. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6841. ceErpTradeAfterSaleExtend.Create();
  6842. }
  6843. else
  6844. {
  6845. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6846. {
  6847. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6848. }
  6849. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6850. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6851. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6852. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6853. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6854. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6855. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6856. ceErpTradeAfterSaleExtend.Update();
  6857. }
  6858. int gysid = GetPostInt("ResponsibleSupId");
  6859. if (entity.AfterSaleUserId == 0)
  6860. {
  6861. entity.AfterSaleUserId = CurrentUser.UserID;
  6862. }
  6863. entity.ResponsibleUserId = resIdStr;
  6864. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6865. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6866. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6867. {
  6868. CeErpTradeResponsible.DelByTid(eid, -1);
  6869. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6870. int backNum = 0;
  6871. if (number != null)
  6872. {
  6873. backNum = number.BackNum;
  6874. }
  6875. char[] separator = { ',' };
  6876. string[] sArray = resIdStr.Split(separator);
  6877. string[] refundFreeList = { };
  6878. if (refundFees.Length > 0)
  6879. {
  6880. refundFreeList = refundFees.Split(separator);
  6881. }
  6882. int index = -1;
  6883. foreach (string i in sArray)
  6884. {
  6885. index++;
  6886. if (i.Length <= 0) continue;
  6887. char[] separator2 = { '_' };
  6888. string idstr = i.Split(separator2)[0];
  6889. string idtype = i.Split(separator2)[1];
  6890. double refudFree = 0;
  6891. if (refundFreeList.Length > 0)
  6892. {
  6893. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6894. }
  6895. if (idtype == "s")
  6896. {
  6897. isDesign = true;
  6898. designFree = refudFree;
  6899. }
  6900. int userId = Convert.ToInt32(idstr);
  6901. int type = 0;
  6902. if (idtype == "g")
  6903. {
  6904. type = 1;
  6905. }
  6906. if (idtype == "w")
  6907. {
  6908. type = 2;
  6909. }
  6910. if (idtype == "t")
  6911. {
  6912. type = 3;
  6913. }
  6914. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6915. if (ceErpTradeResponsible == null)
  6916. {
  6917. ceErpTradeResponsible = new CeErpTradeResponsible();
  6918. ceErpTradeResponsible.tid = eid;
  6919. ceErpTradeResponsible.UserId = userId;
  6920. ceErpTradeResponsible.createdTime = DateTime.Now;
  6921. ceErpTradeResponsible.type = type;
  6922. if (type == 1)
  6923. {
  6924. ceErpTradeResponsible.IsSup = 1;
  6925. }
  6926. if (type == 2)
  6927. {
  6928. ceErpTradeResponsible.IsFlow = 1;
  6929. }
  6930. }
  6931. ceErpTradeResponsible.RefundFee = refudFree;
  6932. ceErpTradeResponsible.VerifyState = 0;
  6933. if (userId == 2125 || idtype == "w")
  6934. {
  6935. ceErpTradeResponsible.VerifyState = 1;
  6936. }
  6937. if (idtype == "w" && userId == 101)
  6938. {
  6939. ceErpTradeResponsible.VerifyState = 0;
  6940. }
  6941. if (ceErpTradeResponsible.ID > 0)
  6942. {
  6943. ceErpTradeResponsible.Update();
  6944. }
  6945. else
  6946. {
  6947. ceErpTradeResponsible.Create();
  6948. }
  6949. if (isDesign)
  6950. {
  6951. responsibleId = ceErpTradeResponsible.ID;
  6952. }
  6953. }
  6954. CeErpTradeResponsible.NumByTid(backNum, eid);
  6955. }
  6956. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6957. if (ceErpTradeCellExtend != null)
  6958. {
  6959. ceErpTradeCellExtend.returnVisit = 0;
  6960. ceErpTradeCellExtend.Update();
  6961. }
  6962. if (entity.HandleTime != null)
  6963. {
  6964. if (entity.AfterSaleState == 1)
  6965. {
  6966. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6967. }
  6968. else
  6969. {
  6970. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6971. }
  6972. }
  6973. else
  6974. {
  6975. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6976. entity.HandleTime = DateTime.Now;
  6977. }
  6978. bool isCompale = false;
  6979. if (entity.AfterSaleState == 5)
  6980. {
  6981. isCompale = true;
  6982. entity.AfterSaleState = 3;
  6983. }
  6984. entity.AfterSaleSupplierState = 0;
  6985. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6986. {
  6987. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6988. }
  6989. string sImgs = GetPostString("img");
  6990. entity.AfterSaleSupplierImg = sImgs;
  6991. entity.supRefundType = GetPostString("supRefundType");
  6992. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6993. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6994. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6995. entity.AfterSaleMemoType = GetPostString("MemoType");
  6996. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6997. {
  6998. //entity.AfterSaleSupplierState = 2;
  6999. }
  7000. string df = GetPostString("DeductFee");
  7001. if (df == "")
  7002. {
  7003. df = "0";
  7004. }
  7005. string rf = GetPostString("RefundFee");
  7006. if (rf == "")
  7007. {
  7008. rf = "0";
  7009. }
  7010. string pm = GetPostString("AfterSalePayment");
  7011. if (pm == "")
  7012. {
  7013. pm = "0";
  7014. }
  7015. entity.AfterSalePayment = Convert.ToDouble(pm);
  7016. entity.DeductFee = Convert.ToDouble(df);
  7017. entity.RefundFee = Convert.ToDouble(rf);
  7018. entity.UpdateTime = DateTime.Now;
  7019. entity.Update();
  7020. string toState = GetPostString("ToState");
  7021. string original = GetPostString("isOriginal");
  7022. ApiVo apiVo = new ApiVo();
  7023. apiVo.orderNumber = entity.ctid;
  7024. apiVo.actionName = "afterDesign";
  7025. apiVo.orderRemarks = entity.AfterSaleMethod;
  7026. apiVo.reasonRemarks = entity.AfterSaleReason;
  7027. apiVo.isDesign = isDesign;
  7028. apiVo.designFree = designFree;
  7029. apiVo.responsibleId = responsibleId;
  7030. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7031. if (toState == "设计师")
  7032. {
  7033. apiVo.isOriginal = Convert.ToBoolean(original);
  7034. }
  7035. designHelper.API_WorkCore(apiVo);//afterDesign
  7036. CeErpMethod methodSql = new CeErpMethod();
  7037. methodSql.con = entity.AfterSaleMethod;
  7038. methodSql.addTime = DateTime.Now;
  7039. methodSql.Create();
  7040. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7041. CeErpMethod.ExecuteNonQuery(delsql);
  7042. if (isCompale)
  7043. {
  7044. aftersale_data_change(entity.ctid);
  7045. }
  7046. returnSuccessMsg("操作成功!");
  7047. return;
  7048. }
  7049. returnErrorMsg("找不到订单记录");
  7050. }
  7051. }
  7052. public void ins_erp_toresponsible()
  7053. {
  7054. if (UrlPostParmsCheck("ctid"))
  7055. {
  7056. string eid = GetPostString("ctid");
  7057. CeErpTradeCell entity = null;
  7058. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7059. if (entity != null)
  7060. {
  7061. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7062. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7063. {
  7064. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7065. return;
  7066. }
  7067. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7068. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7069. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7070. if (entity.AfterSalePreTime == null)
  7071. {
  7072. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7073. {
  7074. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7075. }
  7076. }
  7077. entity.AfterSalePreTime = DateTime.Now;
  7078. //预完成给售后主管审核客户问题直接完成
  7079. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7080. {
  7081. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7082. {
  7083. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7084. }
  7085. }
  7086. ceErpTradeAfterSaleExtend.Update();
  7087. entity.AfterSaleState = 2;
  7088. entity.UpdateTime = DateTime.Now;
  7089. entity.Update();
  7090. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7091. aftersale_data_change(entity.ctid);
  7092. returnSuccessMsg("操作成功!");
  7093. return;
  7094. }
  7095. returnErrorMsg("找不到订单记录");
  7096. }
  7097. }
  7098. public void cancel_erp_aftersaleanddelnew()
  7099. {
  7100. if (UrlPostParmsCheck("ctid"))
  7101. {
  7102. string eid = GetPostString("ctid");
  7103. CeErpTradeCell entity = null;
  7104. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7105. if (entity != null)
  7106. {
  7107. entity.AfterSaleState = 0;
  7108. entity.AfterSaleReason = "";
  7109. entity.AfterSaleMethod = "";
  7110. entity.AfterSaleMemo = "";
  7111. entity.AfterSaleResponsible = "";
  7112. entity.ResponsibleUserId = "";
  7113. entity.DeductFee = 0;
  7114. entity.RefundFee = 0;
  7115. entity.IsArbitrate = 0;
  7116. CeErpTradeResponsible.DelByTid(eid, -1);
  7117. entity.Update();
  7118. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7119. if (after != null)
  7120. {
  7121. if (after.OrderState < 5)
  7122. CeErpTradeCell.DelByCtid("S_" + eid);
  7123. }
  7124. returnSuccessMsg("操作成功!");
  7125. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7126. return;
  7127. }
  7128. returnErrorMsg("找不到订单记录");
  7129. }
  7130. }
  7131. public void get_erp_aftersale_pregather()
  7132. {
  7133. List<string> lw = new List<string>();
  7134. int st = GetInt("st");
  7135. string tid = GetPostString("ctid");
  7136. if (tid.Length > 0)
  7137. {
  7138. string select_tid = getTidByCtid(tid);
  7139. lw.Add(string.Format("tid='{0}'", select_tid));
  7140. }
  7141. string shopname = GetPostString("shopname");
  7142. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7143. string buyernick = GetPostString("buyer_nick");
  7144. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7145. string sellermemo = GetPostString("seller_memo");
  7146. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7147. string orderState = GetPostString("orderState");
  7148. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7149. string reason = GetPostString("reason");
  7150. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7151. string method = GetPostString("method");
  7152. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7153. string handler = GetPostString("handler");
  7154. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7155. string handledate1 = GetPostString("handledate1");
  7156. string handledate2 = GetPostString("handledate2");
  7157. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7158. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7159. string supplier = GetPostString("supplier");
  7160. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7161. string responsible = GetPostString("responsibleman");
  7162. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7163. string customer = GetPostString("customer");
  7164. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7165. string design = GetPostString("design");
  7166. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7167. string afterMemoType = GetPostString("aftermemotype");
  7168. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7169. string afterSaleMemo = GetPostString("afterSaleMemo");
  7170. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7171. string afterresult = GetPostString("afterresult");
  7172. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7173. string poscode = CurrentUser.UserPost.Post.Code;
  7174. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7175. {
  7176. string shopid = CurrentUser.User.pemShop;
  7177. lw.Add(string.Format("shopId in ({0})", shopid));
  7178. }
  7179. var mainwhere = string.Join(" and ", lw.ToArray());
  7180. string ro_json = "";
  7181. string type = GetPostString("gather_type");
  7182. int number = 0;
  7183. if (poscode == "AfterSale")
  7184. {
  7185. //处理中
  7186. if (type == "Handling")
  7187. {
  7188. 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) : ""));
  7189. DataTable dt = null;
  7190. try
  7191. {
  7192. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7193. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7194. }
  7195. catch (Exception e)
  7196. {
  7197. dt = new DataTable();
  7198. }
  7199. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7200. return;
  7201. }
  7202. if (type == "Wait")
  7203. {
  7204. //待处理
  7205. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7206. DataTable dt1 = null;
  7207. try
  7208. {
  7209. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7210. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7211. }
  7212. catch (Exception e)
  7213. {
  7214. dt1 = new DataTable();
  7215. }
  7216. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7217. return;
  7218. }
  7219. if (type == "back")
  7220. {
  7221. //打回
  7222. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7223. DataTable dt2 = null;
  7224. try
  7225. {
  7226. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7227. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7228. }
  7229. catch (Exception e)
  7230. {
  7231. dt2 = new DataTable();
  7232. }
  7233. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7234. return;
  7235. }
  7236. if (type == "preCompletion")
  7237. {
  7238. //预完成
  7239. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7240. DataTable dt3 = null;
  7241. try
  7242. {
  7243. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7244. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7245. }
  7246. catch (Exception e)
  7247. {
  7248. dt3 = new DataTable();
  7249. }
  7250. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7251. return;
  7252. }
  7253. if (type == "documentary")
  7254. {
  7255. //跟单中
  7256. 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) : ""));
  7257. DataTable dt4 = null;
  7258. try
  7259. {
  7260. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7261. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7262. }
  7263. catch (Exception e)
  7264. {
  7265. dt4 = new DataTable();
  7266. }
  7267. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7268. return;
  7269. }
  7270. if (type == "reBack")
  7271. {
  7272. //被打回
  7273. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7274. DataTable dt1 = null;
  7275. try
  7276. {
  7277. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7278. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7279. }
  7280. catch (Exception e)
  7281. {
  7282. dt1 = new DataTable();
  7283. }
  7284. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7285. return;
  7286. }
  7287. }
  7288. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7289. {
  7290. if (type == "puBack")
  7291. {
  7292. //退回
  7293. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7294. DataTable dt = null;
  7295. try
  7296. {
  7297. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7298. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7299. }
  7300. catch (Exception e)
  7301. {
  7302. dt = new DataTable();
  7303. }
  7304. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7305. return;
  7306. }
  7307. if (type == "reBack")
  7308. {
  7309. //打回
  7310. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7311. DataTable dt1 = null;
  7312. try
  7313. {
  7314. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7315. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7316. }
  7317. catch (Exception e)
  7318. {
  7319. dt1 = new DataTable();
  7320. }
  7321. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7322. return;
  7323. }
  7324. if (type == "examEd")
  7325. {
  7326. //已审核
  7327. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7328. DataTable dt2 = null;
  7329. try
  7330. {
  7331. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7332. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7333. }
  7334. catch (Exception e)
  7335. {
  7336. dt2 = new DataTable();
  7337. }
  7338. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7339. return;
  7340. }
  7341. if (type == "waitExam")
  7342. {
  7343. //待审核
  7344. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7345. DataTable dt3 = null;
  7346. try
  7347. {
  7348. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7349. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7350. }
  7351. catch (Exception e)
  7352. {
  7353. dt3 = new DataTable();
  7354. }
  7355. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7356. return;
  7357. }
  7358. if (type == "Handling")
  7359. {
  7360. //处理中
  7361. 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) : ""));
  7362. DataTable dt4 = null;
  7363. try
  7364. {
  7365. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7366. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7367. }
  7368. catch (Exception e)
  7369. {
  7370. dt4 = new DataTable();
  7371. }
  7372. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7373. return;
  7374. }
  7375. if (type == "Wait")
  7376. {
  7377. //待处理
  7378. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7379. DataTable dt5 = null;
  7380. try
  7381. {
  7382. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7383. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7384. }
  7385. catch (Exception e)
  7386. {
  7387. dt5 = new DataTable();
  7388. }
  7389. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7390. return;
  7391. }
  7392. if (type == "documentary")
  7393. {
  7394. //跟单中
  7395. 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) : ""));
  7396. DataTable dt6 = null;
  7397. try
  7398. {
  7399. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7400. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7401. }
  7402. catch (Exception e)
  7403. {
  7404. dt6 = new DataTable();
  7405. }
  7406. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7407. return;
  7408. }
  7409. }
  7410. returnSuccess(ro_json);
  7411. }
  7412. public void end_erp_aftersale()
  7413. {
  7414. if (UrlPostParmsCheck("ctid"))
  7415. {
  7416. string eid = GetPostString("ctid");
  7417. CeErpTradeCell entity = null;
  7418. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7419. if (entity != null)
  7420. {
  7421. string stype = GetPostString("stype");
  7422. string typeStr = stype;
  7423. entity.AfterSaleState = 4;
  7424. entity.FinishAfterSaleTime = DateTime.Now;
  7425. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7426. entity.Update();
  7427. ApiVo apiVo = new ApiVo();
  7428. apiVo.orderNumber = entity.ctid;
  7429. apiVo.actionName = "afterOver";
  7430. designHelper.API_WorkCore(apiVo); //afterOver
  7431. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7432. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7433. CeErpSukuraData.createInfo(entity.ctid, 8);
  7434. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7435. returnSuccessMsg("操作成功!");
  7436. return;
  7437. }
  7438. returnErrorMsg("找不到订单记录");
  7439. }
  7440. }
  7441. public void ins_erp_finishaftersale()
  7442. {
  7443. if (UrlPostParmsCheck("id"))
  7444. {
  7445. string eid = GetPostString("id");
  7446. CeErpTradeResponsible entity = null;
  7447. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7448. if (entity != null)
  7449. {
  7450. entity.VerifyState = 1;
  7451. entity.VerifyTime = DateTime.Now;
  7452. entity.Update();
  7453. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7454. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7455. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7456. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7457. if (dt.Rows.Count <= 0)
  7458. {
  7459. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7460. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7461. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7462. CeErpSukuraData.createInfo(entity.tid, 8);
  7463. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7464. {
  7465. CeErpDesignerBill.Del(entity.tid);
  7466. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7467. }
  7468. }
  7469. returnSuccessMsg("操作成功!");
  7470. return;
  7471. }
  7472. returnErrorMsg("找不到订单记录");
  7473. }
  7474. }
  7475. public void upd_erp_arbitrateaftersale()
  7476. {
  7477. if (UrlPostParmsCheck("id"))
  7478. {
  7479. string eid = GetPostString("id");
  7480. CeErpTradeResponsible entity = null;
  7481. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7482. if (entity != null)
  7483. {
  7484. entity.IsArbitrate = 1;
  7485. entity.ArbitradeMemo = GetPostString("reason");
  7486. entity.VerifyState = 2;
  7487. entity.Update();
  7488. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7489. if (tradecell != null)
  7490. {
  7491. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7492. tradecell.IsArbitrate = 1;
  7493. tradecell.Update();
  7494. }
  7495. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7496. returnSuccessMsg("操作成功!");
  7497. return;
  7498. }
  7499. returnErrorMsg("找不到订单记录");
  7500. }
  7501. }
  7502. public void upd_erp_backaftersale()
  7503. {
  7504. if (UrlPostParmsCheck("tid"))
  7505. {
  7506. string eid = GetPostString("tid");
  7507. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7508. int backNum = 0;
  7509. if (number != null)
  7510. {
  7511. backNum = number.BackNum;
  7512. }
  7513. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7514. CeErpTradeCell entity = null;
  7515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7516. if (entity != null)
  7517. {
  7518. entity.AfterSaleBackReason = GetPostString("backreason");
  7519. entity.AfterSaleState = 1;
  7520. entity.AfterSaleSupplierState = 0;
  7521. entity.UpdateTime = DateTime.Now;
  7522. entity.Update();
  7523. returnSuccessMsg("操作成功!");
  7524. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7525. return;
  7526. }
  7527. returnErrorMsg("找不到订单记录");
  7528. }
  7529. }
  7530. public void get_erp_supplieraftersalelist()
  7531. {
  7532. DataStruct dStruct = GetPostStruct();
  7533. List<string> lw = new List<string>();
  7534. string tid = GetPostString("ctid");
  7535. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7536. string shopname = GetPostString("shopname");
  7537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7538. string buyernick = GetPostString("buyer_nick");
  7539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7540. string sellermemo = GetPostString("seller_memo");
  7541. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7542. string orderState = GetPostString("orderState");
  7543. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7544. string afterState = GetPostString("afterstate");
  7545. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7546. string date1 = GetPostString("date1");
  7547. string date2 = GetPostString("date2");
  7548. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7549. if (dw.Length > 0) lw.Add(dw);
  7550. string price1 = GetPostString("price1");
  7551. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7552. string price2 = GetPostString("price2");
  7553. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7554. string reason = GetPostString("reason");
  7555. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7556. string method = GetPostString("method");
  7557. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7558. string handledate1 = GetPostString("handledate1");
  7559. string handledate2 = GetPostString("handledate2");
  7560. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7561. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7562. string handler = GetPostString("handler");
  7563. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7564. string afterdate1 = GetPostString("afterdate1");
  7565. string afterdate2 = GetPostString("afterdate2");
  7566. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7567. if (afterDate.Length > 0) lw.Add(afterDate);
  7568. string customer = GetPostString("customer");
  7569. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7570. string design = GetPostString("design");
  7571. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7572. string afterMemoType = GetPostString("aftermemotype");
  7573. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7574. string vstate = GetPostString("vstate");
  7575. if (vstate.Length > 0)
  7576. {
  7577. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7578. }
  7579. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7580. string supplier = GetPostString("supplier");
  7581. int supid = commonHelper.getSupplierIDByName(supplier);
  7582. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7583. string posCode = CurrentUser.UserPost.Post.Code;
  7584. if (posCode == "Supplier")
  7585. {
  7586. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7587. }
  7588. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7589. {
  7590. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7591. }
  7592. else
  7593. {
  7594. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7595. }
  7596. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7597. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7598. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7599. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7600. writeGridDataTableJson(dStruct.TotalCount, dt);
  7601. }
  7602. public void upd_erp_supverifyaftersale()
  7603. {
  7604. if (UrlPostParmsCheck("id"))
  7605. {
  7606. string id = GetPostString("id");
  7607. int st = GetPostInt("afterstate");
  7608. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7609. CeErpTradeCell entity = null;
  7610. if (ceErpTradeResponsible != null)
  7611. {
  7612. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7613. }
  7614. string afmemo = GetPostString("supmemo");
  7615. string image = GetPostString("image");
  7616. if (entity != null)
  7617. {
  7618. entity.AfterSaleSupplierState = st;
  7619. entity.AfterSaleSupplierMemo = afmemo;
  7620. if (st == 1)
  7621. {
  7622. ceErpTradeResponsible.VerifyState = 1;
  7623. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7624. ceErpTradeResponsible.Update();
  7625. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7626. if (isAll)
  7627. {
  7628. entity.AfterSaleState = 4;
  7629. entity.FinishAfterSaleTime = DateTime.Now;
  7630. }
  7631. }
  7632. else
  7633. {
  7634. CeErpTradeResponsible.dateByTid(entity.ctid);
  7635. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7636. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7637. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7638. if (num <= 1)
  7639. {
  7640. entity.AfterSaleState = 1;
  7641. }
  7642. else
  7643. {
  7644. entity.AfterSaleState = 5;
  7645. }
  7646. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7647. if (ceErpTradeAfterSaleExtend != null)
  7648. {
  7649. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7650. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7651. ceErpTradeAfterSaleExtend.Update();
  7652. }
  7653. else
  7654. {
  7655. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7656. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7657. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7658. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7659. ceErpTradeAfterSaleExtend.Create();
  7660. }
  7661. }
  7662. if (entity.AfterSaleState == 4)
  7663. {
  7664. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7665. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7666. {
  7667. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7668. }
  7669. ApiVo apiVo = new ApiVo();
  7670. apiVo.orderNumber = entity.ctid;
  7671. apiVo.actionName = "afterOver";
  7672. designHelper.API_WorkCore(apiVo); //afterOver
  7673. }
  7674. entity.UpdateTime = DateTime.Now;
  7675. entity.Update();
  7676. returnSuccessMsg("操作成功!");
  7677. CeErpSukuraData.createInfo(entity.ctid, 8);
  7678. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7679. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7680. return;
  7681. }
  7682. returnErrorMsg("找不到订单记录");
  7683. }
  7684. }
  7685. public void upd_erp_masteraftersale()
  7686. {
  7687. if (UrlPostParmsCheck("id"))
  7688. {
  7689. string id = GetPostString("id");
  7690. int st = GetPostInt("afterstate");
  7691. string afmemo = GetPostString("supmemo");
  7692. string image = GetPostString("image");
  7693. string textResult = GetPostString("textResult");
  7694. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7695. if (ceErpTradeResponsible != null)
  7696. {
  7697. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7698. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7699. ceErpTradeResponsible.Update();
  7700. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7701. if (entity != null)
  7702. {
  7703. entity.AfterSaleSupplierState = st;
  7704. entity.AfterSaleSupplierMemo = afmemo;
  7705. if (st == 1)
  7706. {
  7707. }
  7708. else
  7709. {
  7710. CeErpTradeResponsible.dateByTid(entity.ctid);
  7711. //退回到售后
  7712. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7713. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7714. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7715. if (num <= 1)
  7716. {
  7717. entity.AfterSaleState = 1;
  7718. }
  7719. else
  7720. {
  7721. entity.AfterSaleState = 5;
  7722. }
  7723. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7724. if (ceErpTradeAfterSaleExtend != null)
  7725. {
  7726. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7727. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7728. ceErpTradeAfterSaleExtend.Update();
  7729. }
  7730. else
  7731. {
  7732. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7733. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7734. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7735. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7736. ceErpTradeAfterSaleExtend.Create();
  7737. }
  7738. }
  7739. entity.UpdateTime = DateTime.Now;
  7740. entity.Update();
  7741. returnSuccessMsg("操作成功!");
  7742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7743. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7744. return;
  7745. }
  7746. }
  7747. returnErrorMsg("找不到订单记录");
  7748. }
  7749. }
  7750. public void upd_erp_personaftersale()
  7751. {
  7752. if (UrlPostParmsCheck("id"))
  7753. {
  7754. //林小连
  7755. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7756. {
  7757. upd_erp_masteraftersale();
  7758. return;
  7759. }
  7760. string id = GetPostString("id");
  7761. int st = GetPostInt("afterstate");
  7762. string afmemo = GetPostString("supmemo");
  7763. string image = GetPostString("image");
  7764. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7765. if (ceErpTradeResponsible != null)
  7766. {
  7767. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7768. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7769. ceErpTradeResponsible.Update();
  7770. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7771. if (entity != null)
  7772. {
  7773. entity.AfterSaleSupplierMemo = afmemo;
  7774. entity.AfterSaleSupplierState = st;
  7775. if (st == 1)
  7776. {
  7777. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7778. if (isAll)
  7779. {
  7780. entity.AfterSaleState = 4;
  7781. entity.FinishAfterSaleTime = DateTime.Now;
  7782. }
  7783. }
  7784. else
  7785. {
  7786. CeErpTradeResponsible.dateByTid(entity.ctid);
  7787. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7788. if (ceErpTradeAfterSaleExtend != null)
  7789. {
  7790. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7791. ceErpTradeAfterSaleExtend.Update();
  7792. }
  7793. else
  7794. {
  7795. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7796. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7797. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7798. ceErpTradeAfterSaleExtend.Create();
  7799. }
  7800. //退回到主管
  7801. //entity.AfterSaleState = 2;
  7802. }
  7803. if (entity.AfterSaleState == 4)
  7804. {
  7805. ApiVo apiVo = new ApiVo();
  7806. apiVo.orderNumber = entity.ctid;
  7807. apiVo.actionName = "afterOver";
  7808. designHelper.API_WorkCore(apiVo); //afterOver
  7809. }
  7810. entity.UpdateTime = DateTime.Now;
  7811. entity.Update();
  7812. returnSuccessMsg("操作成功!");
  7813. CeErpSukuraData.createInfo(entity.ctid, 8);
  7814. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7815. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7816. return;
  7817. }
  7818. }
  7819. returnErrorMsg("找不到订单记录");
  7820. }
  7821. }
  7822. public void set_erp_supplierrefundtag()
  7823. {
  7824. if (UrlPostParmsCheck("ctid"))
  7825. {
  7826. string eid = GetPostString("ctid");
  7827. CeErpTradeCell entity = null;
  7828. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7829. if (entity != null)
  7830. {
  7831. entity.IsSupplierRefund = GetPostInt("tag");
  7832. entity.Update();
  7833. returnSuccessMsg("操作成功!");
  7834. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7835. return;
  7836. }
  7837. returnErrorMsg("找不到订单记录");
  7838. }
  7839. }
  7840. public void get_erp_refundlist()
  7841. {
  7842. DataStruct dStruct = GetPostStruct();
  7843. List<string> lw = new List<string>();
  7844. string tid = GetPostString("tid");
  7845. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7846. //string rid = GetPostString("refund_id");
  7847. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7848. string shopname = GetPostString("shopname");
  7849. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7850. string buyernick = GetPostString("buyer_nick");
  7851. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7852. string customer = GetPostString("customer");
  7853. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7854. string design = GetPostString("design");
  7855. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7856. string sellermemo = GetPostString("seller_memo");
  7857. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7858. //string date1 = GetPostString("date1");
  7859. //string date2 = GetPostString("date2");
  7860. //string dateType = GetPostString("dateType");
  7861. //if (dateType.Length > 0)
  7862. //{
  7863. // if (dateType == "1001") dateType = "0";
  7864. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7865. // if (searchDT.Count == 2)
  7866. // {
  7867. // date1 = searchDT[0].ToString();
  7868. // date2 = searchDT[1].ToString();
  7869. // }
  7870. //}
  7871. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7872. //if (dw.Length > 0) lw.Add(dw);
  7873. string redate1 = GetPostString("refunddate1");
  7874. string redate2 = GetPostString("refunddate2");
  7875. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7876. if (dwdate.Length > 0) lw.Add(dwdate);
  7877. string price1 = GetPostString("price1");
  7878. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7879. string price2 = GetPostString("price2");
  7880. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7881. string ispartrefund = GetPostString("ispartrefund");
  7882. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7883. string refundState = GetPostString("refundvstate");
  7884. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7885. int st = GetInt("st");
  7886. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7887. {
  7888. string responsible = GetPostString("responsibleman");
  7889. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7890. lw.Add(string.Format("RefundState>={0}", st));
  7891. string code = CurrentUser.UserPost.Post.Code;
  7892. if (code == "CustomerService")
  7893. {
  7894. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7895. }
  7896. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7897. {
  7898. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7899. }
  7900. else if (code == "Place" || code == "PlaceMr")
  7901. {
  7902. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7903. }
  7904. dStruct.Order = "RefundState asc,created desc";
  7905. }
  7906. else if (st == 10)
  7907. {
  7908. string responsible = GetPostString("responsibleman");
  7909. if (responsible == "空白")
  7910. {
  7911. lw.Add(string.Format("ResponsibleUserName = ''"));
  7912. }
  7913. else if (responsible.Length > 0)
  7914. {
  7915. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7916. }
  7917. lw.Add(string.Format("RefundState>=0"));
  7918. dStruct.Order = "created desc";
  7919. }
  7920. else
  7921. {
  7922. string responsible = GetPostString("responsibleman");
  7923. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7924. lw.Add(string.Format("RefundState={0}", st));
  7925. dStruct.Order = "created desc";
  7926. }
  7927. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7928. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7929. dt.Columns.Add("refund_fees");
  7930. foreach (DataRow dr in dt.Rows)
  7931. {
  7932. String status = dr["status"].ToString();
  7933. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7934. {
  7935. dr["refund_fees"] = dr["refund_fee"];
  7936. }
  7937. else
  7938. {
  7939. dr["refund_fees"] = "0.0";
  7940. }
  7941. }
  7942. writeGridDataTableJson(dStruct.TotalCount, dt);
  7943. }
  7944. public void get_erp_refunddesignlist()
  7945. {
  7946. DataStruct dStruct = GetPostStruct();
  7947. List<string> lw = new List<string>();
  7948. string tid = GetPostString("tid");
  7949. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7950. string shopname = GetPostString("shopname");
  7951. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7952. string buyernick = GetPostString("buyer_nick");
  7953. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7954. string customer = GetPostString("customer");
  7955. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7956. string design = GetPostString("design");
  7957. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7958. string sellermemo = GetPostString("seller_memo");
  7959. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7960. string redate1 = GetPostString("refunddate1");
  7961. string redate2 = GetPostString("refunddate2");
  7962. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7963. if (dwdate.Length > 0) lw.Add(dwdate);
  7964. string price1 = GetPostString("price1");
  7965. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7966. string price2 = GetPostString("price2");
  7967. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7968. string ispartrefund = GetPostString("ispartrefund");
  7969. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7970. string designerorg = GetPostString("designerorg");
  7971. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7972. string refundState = GetPostString("refundState");
  7973. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7974. int myOrgid = CurrentUser.UserPost.OrgID;
  7975. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7976. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7977. {
  7978. if (CurrentUser.User.TeamIds.Length > 0)
  7979. {
  7980. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7981. }
  7982. else
  7983. {
  7984. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7985. }
  7986. }
  7987. else if ("SysAdmin".Equals(myOrgCode))
  7988. {
  7989. }
  7990. else
  7991. {
  7992. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7993. {
  7994. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7995. }
  7996. else
  7997. {
  7998. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7999. }
  8000. }
  8001. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8002. dStruct.Order = "created desc";
  8003. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8004. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8005. dt.Columns.Add("refund_fees");
  8006. foreach (DataRow dr in dt.Rows)
  8007. {
  8008. String status = dr["status"].ToString();
  8009. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8010. {
  8011. dr["refund_fees"] = dr["refund_fee"];
  8012. }
  8013. else
  8014. {
  8015. dr["refund_fees"] = "0.0";
  8016. }
  8017. }
  8018. writeGridDataTableJson(dStruct.TotalCount, dt);
  8019. }
  8020. public void handle_erp_refundtag()
  8021. {
  8022. if (UrlPostParmsCheck("refund_id"))
  8023. {
  8024. string eid = GetPostString("refund_id");
  8025. string respMan = GetPostString("ResponsibleName");
  8026. if (respMan.Length <= 0)
  8027. {
  8028. returnErrorMsg("责任人不能为空");
  8029. return;
  8030. }
  8031. CeErpTradeRefund entity = null;
  8032. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8033. if (entity != null)
  8034. {
  8035. entity.ResponsibleUserName = respMan;
  8036. string userid = GetPostString("ResponsibleUserId");
  8037. if (userid.Length > 0)
  8038. {
  8039. entity.ResponsibleUserId = userid;
  8040. }
  8041. entity.Memo = GetPostString("Memo");
  8042. if (respMan.IndexOf("客服") != -1 ||
  8043. respMan.IndexOf("设计师") != -1 ||
  8044. respMan.IndexOf("下单员") != -1)
  8045. {
  8046. entity.RefundState = 2;
  8047. }
  8048. else
  8049. {
  8050. entity.RefundState = 3;
  8051. }
  8052. entity.modified = DateTime.Now;
  8053. entity.Update();
  8054. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8055. returnSuccessMsg("操作成功!");
  8056. return;
  8057. }
  8058. returnErrorMsg("找不到订单记录");
  8059. }
  8060. }
  8061. public void handle_erp_designrefundtag()
  8062. {
  8063. if (UrlPostParmsCheck("refund_id"))
  8064. {
  8065. string eid = GetPostString("refund_id");
  8066. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8067. if (ceErpTradeCellExtend == null)
  8068. {
  8069. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8070. ceErpTradeCellExtend.ctid = eid;
  8071. }
  8072. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8073. if (ceErpTradeCellExtend.ID > 0)
  8074. {
  8075. ceErpTradeCellExtend.Update();
  8076. }
  8077. else
  8078. {
  8079. ceErpTradeCellExtend.Create();
  8080. }
  8081. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8082. returnSuccessMsg("操作成功!");
  8083. return;
  8084. }
  8085. returnErrorMsg("找不到订单记录");
  8086. }
  8087. public void upd_erp_refundverify()
  8088. {
  8089. if (UrlPostParmsCheck("refund_id"))
  8090. {
  8091. string eid = GetPostString("refund_id");
  8092. CeErpTradeRefund entity = null;
  8093. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8094. if (entity != null)
  8095. {
  8096. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8097. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8098. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8099. {
  8100. entity.RefundState = 2;
  8101. }
  8102. else
  8103. {
  8104. entity.RefundState = 3;
  8105. }
  8106. entity.Update();
  8107. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8108. returnSuccessMsg("操作成功!");
  8109. return;
  8110. }
  8111. returnErrorMsg("找不到订单记录");
  8112. }
  8113. }
  8114. public void upd_erp_refundapprove()
  8115. {
  8116. if (UrlPostParmsCheck("refund_id"))
  8117. {
  8118. string eid = GetPostString("refund_id");
  8119. CeErpTradeRefund entity = null;
  8120. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8121. if (entity != null)
  8122. {
  8123. int apr = GetPostInt("approve");
  8124. if (apr == 0)
  8125. {
  8126. entity.RefundState = 1;
  8127. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8128. }
  8129. else if (apr == 1)
  8130. {
  8131. entity.RefundState = 3;
  8132. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8133. }
  8134. entity.modified = DateTime.Now;
  8135. entity.Update();
  8136. returnSuccessMsg("操作成功!");
  8137. return;
  8138. }
  8139. returnErrorMsg("找不到订单记录");
  8140. }
  8141. }
  8142. public void get_erp_billlist()
  8143. {
  8144. DataStruct dStruct = GetPostStruct();
  8145. List<string> lw = new List<string>();
  8146. string title = GetPostString("title");
  8147. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8148. string tid = GetPostString("tid");
  8149. string tids = GetPostString("tids");
  8150. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8151. if (tids.Length > 0)
  8152. {
  8153. tids = "'" + tids + "'";
  8154. tids = tids.Replace(",", "','");
  8155. lw.Add(string.Format("tid in ({0})", tids));
  8156. }
  8157. string shopname = GetPostString("shopname");
  8158. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8159. string buyernick = GetPostString("buyer_nick");
  8160. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8161. string customer = GetPostString("customer");
  8162. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8163. string date1 = GetPostString("date1");
  8164. string date2 = GetPostString("date2");
  8165. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8166. if (dw.Length > 0) lw.Add(dw);
  8167. string price1 = GetPostString("price1");
  8168. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8169. string price2 = GetPostString("price2");
  8170. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8171. string returndate1 = GetPostString("returndate1");
  8172. string returndate2 = GetPostString("returndate2");
  8173. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8174. if (dw1.Length > 0) lw.Add(dw1);
  8175. string billtype = GetPostString("billtype");
  8176. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8177. string billstate = GetPostString("billstate");
  8178. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8179. string usershop = CurrentUser.User.pemShop;
  8180. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8181. dStruct.Order = "createTime desc";
  8182. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8183. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8184. //foreach (DataRow dr in dt.Rows)
  8185. //{
  8186. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8187. //}
  8188. writeGridDataTableJson(dStruct.TotalCount, dt);
  8189. }
  8190. public void modify_erp_billinfo()
  8191. {
  8192. if (UrlPostParmsCheck("ID"))
  8193. {
  8194. string eid = GetPostString("ID");
  8195. CeErpBill bill_entity = null;
  8196. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8197. if (bill_entity != null)
  8198. {
  8199. bill_entity.tid = GetPostString("tid");
  8200. bill_entity.title = GetPostString("title");
  8201. bill_entity.tax = GetPostString("tax");
  8202. bill_entity.bank = GetPostString("bank");
  8203. bill_entity.bankac = GetPostString("bankac");
  8204. bill_entity.address = GetPostString("address");
  8205. bill_entity.phone = GetPostString("phone");
  8206. bill_entity.price = GetPostString("price");
  8207. bill_entity.productId = GetPostInt("ProductName");
  8208. bill_entity.num = GetPostInt("num");
  8209. bill_entity.unit = GetPostString("unit");
  8210. bill_entity.type = GetPostString("type");
  8211. bill_entity.sendType = GetPostString("SendType");
  8212. bill_entity.email = GetPostString("email");
  8213. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8214. bill_entity.shopName = GetPostString("ShopName");
  8215. bill_entity.applymemo = GetPostString("applymemo");
  8216. bill_entity.modifyTime = DateTime.Now;
  8217. bill_entity.createTime = DateTime.Now;
  8218. bill_entity.state = 0;
  8219. bill_entity.Update();
  8220. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8221. returnSuccessMsg("发票修改成功!");
  8222. return;
  8223. }
  8224. returnErrorMsg("找不到对应记录");
  8225. }
  8226. }
  8227. public void set_erp_invoicing()
  8228. {
  8229. if (UrlPostParmsCheck("id"))
  8230. {
  8231. try
  8232. {
  8233. string eid = GetPostString("id");
  8234. CeErpBill bill_entity = null;
  8235. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8236. if (bill_entity != null)
  8237. {
  8238. int ComId = GetPostInt("ComId");
  8239. //string memo = GetPostString("Memo");
  8240. int allInfo = GetPostInt("allinfo");
  8241. string clert = CurrentUser.User.Name;
  8242. //string detailValue = GetPostString("detailvalue");
  8243. string billId = bill_entity.billOrderId;
  8244. string[] billIdList = billId.Split(',');
  8245. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8246. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8247. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8248. {
  8249. billCount += 1;
  8250. }
  8251. if (billId.Length <= 0 || billIdList.Length != billCount)
  8252. {
  8253. bill_entity.billOrderId = "";
  8254. string prebill = "ltb";
  8255. for (int idx = 1; idx <= billCount; idx++)
  8256. {
  8257. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8258. string billoid = prebill + idx + dtstr;
  8259. bill_entity.billOrderId += billoid;
  8260. if (idx < billCount)
  8261. {
  8262. bill_entity.billOrderId += ",";
  8263. }
  8264. }
  8265. }
  8266. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8267. if (bill_entity.state == 5)
  8268. {
  8269. string errMsg = bill_entity.failerror;
  8270. string[] errlist = errMsg.Split('|');
  8271. string[] errTags = new string[errlist.Length];
  8272. for (int itag = 0; itag < errlist.Length; itag++)
  8273. {
  8274. if (errlist[itag].Length <= 0) continue;
  8275. errTags[itag] = errlist[itag].Split('&')[0];
  8276. }
  8277. for (int iii = 0; iii < errTags.Length; iii++)
  8278. {
  8279. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8280. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8281. if (billOrderList.Length >= erroBillOrderTag)
  8282. {
  8283. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8284. if (needModifyBillId.Length <= 19)
  8285. {
  8286. needModifyBillId = needModifyBillId + "1";
  8287. }
  8288. else
  8289. {
  8290. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8291. last = last + 1;
  8292. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8293. }
  8294. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8295. }
  8296. }
  8297. }
  8298. bool isHaveBillSucces = false;
  8299. string totalRes = "";
  8300. bill_entity.failerror = "";
  8301. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8302. {
  8303. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8304. totalRes += res;
  8305. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8306. {
  8307. isHaveBillSucces = true;
  8308. bill_entity.comId = ComId;
  8309. bill_entity.state = 1;
  8310. bill_entity.executeTime = DateTime.Now;
  8311. bill_entity.executeUser = clert;
  8312. }
  8313. else
  8314. {
  8315. bill_entity.state = 5;
  8316. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8317. }
  8318. }
  8319. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8320. bill_entity.Update();
  8321. if (isHaveBillSucces)
  8322. {
  8323. StringBuilder sql = new StringBuilder();
  8324. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8325. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8326. }
  8327. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8328. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8329. {
  8330. returnErrorMsg("开票失败");
  8331. }
  8332. else
  8333. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8334. return;
  8335. }
  8336. returnErrorMsg("找不到对应记录");
  8337. }
  8338. catch (Exception ex)
  8339. {
  8340. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8341. returnErrorMsg("操作失败");
  8342. }
  8343. }
  8344. }
  8345. public void get_erp_invoicing_back()
  8346. {
  8347. if (UrlPostParmsCheck("id"))
  8348. {
  8349. try
  8350. {
  8351. string id = GetPostString("id");
  8352. CeErpBill entiy = CeErpBill.Get(id);
  8353. if (entiy != null)
  8354. {
  8355. if (entiy.state == 0)
  8356. {
  8357. returnErrorMsg("发票还未开具");
  8358. return;
  8359. }
  8360. string[] billOrderList = entiy.billOrderId.Split(',');
  8361. int iTag = 0;
  8362. entiy.fplsh = "";
  8363. entiy.fpdm = "";
  8364. entiy.fphm = "";
  8365. foreach (string billOrderId in billOrderList)
  8366. {
  8367. iTag++;
  8368. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8369. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8370. {
  8371. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8372. try
  8373. {
  8374. Invoicing_get_response_Obj iObj = null;
  8375. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8376. if (iObj != null)
  8377. {
  8378. entiy.state = 2;
  8379. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8380. entiy.fpdm += iObj.list[0].c_fpdm;
  8381. entiy.fphm += iObj.list[0].c_fphm;
  8382. if (iTag < billOrderList.Length)
  8383. {
  8384. entiy.fplsh += ",";
  8385. entiy.fpdm += ",";
  8386. entiy.fphm += ",";
  8387. }
  8388. entiy.Update();
  8389. }
  8390. StringBuilder sql = new StringBuilder();
  8391. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8392. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8393. returnSuccessMsg("开票成功");
  8394. }
  8395. catch (Exception ex)
  8396. {
  8397. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8398. }
  8399. return;
  8400. }
  8401. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8402. {
  8403. var res_obj = new
  8404. {
  8405. data = "开票中"
  8406. };
  8407. string ro_json = JsonConvert.SerializeObject(res_obj);
  8408. returnSuccess(ro_json);
  8409. return;
  8410. }
  8411. else
  8412. {
  8413. int eidx = res.IndexOf("c_resultmsg");
  8414. int lidx = res.IndexOf("c_status");
  8415. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8416. entiy.state = 5;
  8417. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8418. entiy.Update();
  8419. returnErrorMsg("开票失败");
  8420. return;
  8421. }
  8422. }
  8423. }
  8424. }
  8425. catch (Exception ex)
  8426. {
  8427. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8428. }
  8429. return;
  8430. }
  8431. }
  8432. public void get_erp_invoicing()
  8433. {
  8434. if (UrlPostParmsCheck("id"))
  8435. {
  8436. try
  8437. {
  8438. string id = GetPostString("id");
  8439. CeErpBill entiy = CeErpBill.Get(id);
  8440. if (entiy != null)
  8441. {
  8442. if (entiy.state == 0)
  8443. {
  8444. returnErrorMsg("发票还未开具");
  8445. return;
  8446. }
  8447. if (entiy.sendType == "纸质发票")
  8448. {
  8449. if (entiy.img.Length <= 0)
  8450. {
  8451. returnErrorMsg("查无纸质发票");
  8452. return;
  8453. }
  8454. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8455. returnSuccess(returnres);
  8456. return;
  8457. }
  8458. string[] billOrderList = entiy.billOrderId.Split(',');
  8459. int iTag = 0;
  8460. string fpUrl = "";
  8461. entiy.fplsh = "";
  8462. entiy.fpdm = "";
  8463. entiy.fphm = "";
  8464. foreach (string billOrderId in billOrderList)
  8465. {
  8466. iTag++;
  8467. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8468. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8469. {
  8470. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8471. Invoicing_get_response_Obj iObj = null;
  8472. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8473. if (iObj != null)
  8474. {
  8475. //entiy.state = 2;
  8476. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8477. entiy.fpdm += iObj.list[0].c_fpdm;
  8478. entiy.fphm += iObj.list[0].c_fphm;
  8479. if (iTag < billOrderList.Length)
  8480. {
  8481. entiy.fplsh += ",";
  8482. entiy.fpdm += ",";
  8483. entiy.fphm += ",";
  8484. }
  8485. entiy.Update();
  8486. fpUrl += iObj.list[0].c_url + ",";
  8487. }
  8488. //returnSuccess(res);
  8489. StringBuilder sql = new StringBuilder();
  8490. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8491. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8492. }
  8493. else
  8494. {
  8495. int eidx = res.IndexOf("c_resultmsg");
  8496. //int lidx = res.IndexOf("c_status");
  8497. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8498. //开票失败
  8499. entiy.state = 5;
  8500. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8501. entiy.Update();
  8502. returnErrorMsg("开票失败");
  8503. return;
  8504. }
  8505. }
  8506. var returnObj = new
  8507. {
  8508. data = fpUrl
  8509. };
  8510. string ro_json = JsonConvert.SerializeObject(returnObj);
  8511. returnSuccess(ro_json);
  8512. }
  8513. }
  8514. catch (Exception ex)
  8515. {
  8516. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8517. }
  8518. return;
  8519. }
  8520. }
  8521. public void save_erp_billimg()
  8522. {
  8523. if (UrlPostParmsCheck("id"))
  8524. {
  8525. string eid = GetPostString("id");
  8526. CeErpBill bill_entity = null;
  8527. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8528. if (bill_entity != null)
  8529. {
  8530. bill_entity.img = GetPostString("img");
  8531. bill_entity.executeTime = DateTime.Now;
  8532. bill_entity.state = 2;
  8533. bill_entity.Update();
  8534. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8535. returnSuccessMsg("保存成功");
  8536. }
  8537. return;
  8538. }
  8539. }
  8540. public void upd_erp_billreturnback()
  8541. {
  8542. if (UrlPostParmsCheck("id"))
  8543. {
  8544. int eid = GetPostInt("id");
  8545. CeErpBill bill_entity = null;
  8546. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8547. if (bill_entity != null)
  8548. {
  8549. bill_entity.state = 3;
  8550. bill_entity.returnReason = GetPostString("reason");
  8551. bill_entity.Update();
  8552. returnSuccessMsg("驳回成功!");
  8553. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8554. }
  8555. return;
  8556. }
  8557. }
  8558. public void cancel_erp_bill()
  8559. {
  8560. if (UrlPostParmsCheck("id"))
  8561. {
  8562. int eid = GetPostInt("id");
  8563. int detailValue = GetPostInt("detailvalue");
  8564. CeErpBill bill_entity = null;
  8565. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8566. string cres = "";
  8567. string gres = "";
  8568. if (bill_entity != null)
  8569. {
  8570. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8571. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8572. {
  8573. int iTag = 0;
  8574. bill_entity.fplsh = "";
  8575. bill_entity.fpdm = "";
  8576. bill_entity.fphm = "";
  8577. foreach (string billOrderId in billOrderList)
  8578. {
  8579. iTag++;
  8580. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8581. if (gres.IndexOf("success") != -1)
  8582. {
  8583. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8584. Invoicing_get_response_Obj iObj = null;
  8585. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8586. if (iObj != null)
  8587. {
  8588. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8589. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8590. bill_entity.fphm += iObj.list[0].c_fphm;
  8591. if (iTag < billOrderList.Length)
  8592. {
  8593. bill_entity.fplsh += ",";
  8594. bill_entity.fpdm += ",";
  8595. bill_entity.fphm += ",";
  8596. }
  8597. bill_entity.Update();
  8598. }
  8599. }
  8600. else
  8601. {
  8602. returnErrorMsg(gres);
  8603. return;
  8604. }
  8605. }
  8606. }
  8607. if (bill_entity.sendType == "纸质发票")
  8608. {
  8609. //作废
  8610. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8611. //if (DateTime.Now.Month == extime.Month)
  8612. //{
  8613. //cres = taobaoHelper.cancel_invoicing(eid);
  8614. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8615. //{
  8616. bill_entity.state = 4;//已作废
  8617. bill_entity.Update();
  8618. returnSuccessMsg("发票已作废");
  8619. return;
  8620. //}
  8621. //else
  8622. //{
  8623. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8624. // bill_entity.Update();
  8625. // returnErrorMsg(cres);
  8626. // return;
  8627. //}
  8628. //}
  8629. //else
  8630. //{
  8631. // returnErrorMsg("纸质发票只能作废本月的发票");
  8632. // return;
  8633. //}
  8634. }
  8635. //红冲
  8636. int redTag = 0;
  8637. string[] fpdmList = bill_entity.fpdm.Split(',');
  8638. string[] fphmList = bill_entity.fphm.Split(',');
  8639. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8640. {
  8641. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8642. return;
  8643. }
  8644. foreach (string billOrderId in billOrderList)
  8645. {
  8646. redTag++;
  8647. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8648. cres += onecres;
  8649. cres += ",";
  8650. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8651. {
  8652. bill_entity.state = 4;//已作废
  8653. //bill_entity.Update();
  8654. //returnSuccessMsg("发票已红冲");
  8655. }
  8656. else if (onecres.IndexOf("重复冲红") != -1)
  8657. {
  8658. bill_entity.state = 4;//已作废
  8659. //bill_entity.Update();
  8660. //returnSuccessMsg("发票已红冲");
  8661. }
  8662. else
  8663. {
  8664. string errmsg = commonHelper.KeepChinese(onecres);
  8665. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8666. }
  8667. }
  8668. bill_entity.Update();
  8669. if (cres.IndexOf("失败") != -1)
  8670. returnErrorMsg("红冲失败");
  8671. else
  8672. returnSuccessMsg("发票已红冲");
  8673. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8674. return;
  8675. }
  8676. return;
  8677. }
  8678. }
  8679. public void del_erp_billorder()
  8680. {
  8681. if (UrlPostParmsCheck("id"))
  8682. {
  8683. string eid = GetPostString("id");
  8684. CeErpBill.Del(eid);
  8685. CeErpBill bill = CeErpBill.Get(eid);
  8686. if (bill != null)
  8687. {
  8688. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8689. }
  8690. returnSuccessMsg("删除成功");
  8691. }
  8692. }
  8693. public void finish_erp_bill()
  8694. {
  8695. if (UrlPostParmsCheck("ids"))
  8696. {
  8697. string eids = GetPostString("ids");
  8698. string[] list = eids.Split(',');
  8699. foreach (string eid in list)
  8700. {
  8701. CeErpBill bill = CeErpBill.Get(eid);
  8702. if (bill != null)
  8703. {
  8704. bill.state = 2;
  8705. bill.Update();
  8706. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8707. }
  8708. }
  8709. returnSuccessMsg("操作成功");
  8710. }
  8711. }
  8712. public void get_erp_returncash()
  8713. {
  8714. DataStruct dStruct = GetPostStruct();
  8715. List<string> lw = new List<string>();
  8716. string tid = GetPostString("tid");
  8717. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8718. string shopname = GetPostString("shopname");
  8719. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8720. string buyernick = GetPostString("buyer_nick");
  8721. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8722. string customer = GetPostString("customer");
  8723. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8724. string returndate1 = GetPostString("returndate1");
  8725. string returndate2 = GetPostString("returndate2");
  8726. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8727. if (dw.Length > 0) lw.Add(dw);
  8728. string finishDate1 = GetPostString("finishdate1");
  8729. string finishDate2 = GetPostString("finishdate2");
  8730. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8731. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8732. string returntype = GetPostString("returntype");
  8733. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8734. string returnvstate = GetPostString("returnvstate");
  8735. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8736. dStruct.Order = "created desc";
  8737. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8738. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8739. writeGridDataTableJson(dStruct.TotalCount, dt);
  8740. }
  8741. public void get_erp_staygoods()
  8742. {
  8743. DataStruct dStruct = GetPostStruct();
  8744. List<string> lw = new List<string>();
  8745. string tid = GetPostString("tid");
  8746. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8747. string shopname = GetPostString("shopname");
  8748. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8749. string wangwang = GetPostString("wangwang");
  8750. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8751. string customer = GetPostString("customer");
  8752. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8753. string returndate1 = GetPostString("returndate1");
  8754. string returndate2 = GetPostString("returndate2");
  8755. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8756. if (dw.Length > 0) lw.Add(dw);
  8757. string finishDate1 = GetPostString("finishdate1");
  8758. string finishDate2 = GetPostString("finishdate2");
  8759. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8760. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8761. string returnvstate = GetPostString("returnvstate");
  8762. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8763. string persuadetype = GetPostString("persuadetype");
  8764. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8765. string customerOrg = GetPostString("customerOrg");
  8766. if (customerOrg.Length > 0)
  8767. {
  8768. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8769. }
  8770. dStruct.Order = "creata_time desc";
  8771. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8772. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8773. writeGridDataTableJson(dStruct.TotalCount, dt);
  8774. }
  8775. public void upd_erp_staygoods()
  8776. {
  8777. if (UrlPostParmsCheck("id"))
  8778. {
  8779. int eid = GetPostInt("id");
  8780. CeErpStayGoods entity = null;
  8781. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8782. if (entity != null)
  8783. {
  8784. entity.audit_type = 1;
  8785. entity.audit_time = DateTime.Now;
  8786. entity.audit_u_id = CurrentUser.UserID;
  8787. entity.audit_u_name = CurrentUser.UserName;
  8788. entity.Update();
  8789. returnSuccessMsg("审核成功!");
  8790. return;
  8791. }
  8792. returnErrorMsg("找不到订单记录");
  8793. }
  8794. }
  8795. public void upd_erp_stayGoodsback()
  8796. {
  8797. if (UrlPostParmsCheck("id"))
  8798. {
  8799. int eid = GetPostInt("id");
  8800. CeErpStayGoods entity = null;
  8801. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8802. if (entity != null)
  8803. {
  8804. entity.audit_text = GetPostString("reason");
  8805. entity.audit_type = 2;
  8806. entity.audit_time = DateTime.Now;
  8807. entity.audit_u_id = CurrentUser.UserID;
  8808. entity.audit_u_name = CurrentUser.UserName;
  8809. entity.Update();
  8810. returnSuccessMsg("退回成功!");
  8811. return;
  8812. }
  8813. returnErrorMsg("找不到订单记录");
  8814. }
  8815. }
  8816. public void upd_erp_returncashverify()
  8817. {
  8818. if (UrlPostParmsCheck("ID"))
  8819. {
  8820. int eid = GetPostInt("ID");
  8821. CeErpReturnCash entity = null;
  8822. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8823. if (entity != null)
  8824. {
  8825. entity.cashstate = 1;
  8826. entity.verifytime = DateTime.Now;
  8827. entity.verifyuserid = CurrentUser.UserID;
  8828. entity.Update();
  8829. returnSuccessMsg("审核成功!");
  8830. return;
  8831. }
  8832. returnErrorMsg("找不到订单记录");
  8833. }
  8834. }
  8835. public void upd_all_erp_returncashverify()
  8836. {
  8837. if (UrlPostParmsCheck("ID"))
  8838. {
  8839. String[] list = GetPostString("ID").Split(',');
  8840. CeErpReturnCash entity = null;
  8841. for (int i = 0; i < list.Length; i++)
  8842. {
  8843. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8844. if (entity != null)
  8845. {
  8846. if (entity.cashstate == 1)
  8847. {
  8848. returnErrorMsg("已审核过的订单不需要在审核!");
  8849. return;
  8850. }
  8851. entity.cashstate = 1;
  8852. entity.verifytime = DateTime.Now;
  8853. entity.verifyuserid = CurrentUser.UserID;
  8854. entity.Update();
  8855. }
  8856. }
  8857. returnSuccessMsg("审核成功!");
  8858. return;
  8859. }
  8860. }
  8861. public void upd_erp_returncashback()
  8862. {
  8863. if (UrlPostParmsCheck("ID"))
  8864. {
  8865. int eid = GetPostInt("ID");
  8866. CeErpReturnCash entity = null;
  8867. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8868. if (entity != null)
  8869. {
  8870. entity.backreason = GetPostString("reason");
  8871. entity.cashstate = 2;
  8872. entity.verifytime = DateTime.Now;
  8873. entity.verifyuserid = CurrentUser.UserID;
  8874. entity.Update();
  8875. returnSuccessMsg("退回成功!");
  8876. return;
  8877. }
  8878. returnErrorMsg("找不到订单记录");
  8879. }
  8880. }
  8881. public void upd_erp_returnprice()
  8882. {
  8883. if (UrlPostParmsCheck("ID"))
  8884. {
  8885. int eid = GetPostInt("ID");
  8886. CeErpReturnCash entity = null;
  8887. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8888. if (entity != null)
  8889. {
  8890. if (entity.cashstate == 1)
  8891. {
  8892. returnErrorMsg("审核通过了不能改");
  8893. return;
  8894. }
  8895. entity.returnprice = GetPostDouble("returnprice");
  8896. entity.Update();
  8897. returnSuccessMsg("修改成功!");
  8898. return;
  8899. }
  8900. returnErrorMsg("找不到订单记录");
  8901. }
  8902. }
  8903. public void del_erp_returncash()
  8904. {
  8905. if (UrlPostParmsCheck("ID"))
  8906. {
  8907. int eid = GetPostInt("ID");
  8908. CeErpReturnCash.Del(eid);
  8909. returnSuccessMsg("操作成功");
  8910. return;
  8911. }
  8912. }
  8913. public void test_for_do_sql()
  8914. {
  8915. string sql = GetPostString("sqlstr");
  8916. if (sql.Length > 0)
  8917. {
  8918. try
  8919. {
  8920. DbHelper.DbConn.ExecuteNonQuery(sql);
  8921. var res_obj = new
  8922. {
  8923. data = "成功",
  8924. };
  8925. string ro_json = JsonConvert.SerializeObject(res_obj);
  8926. returnSuccess(ro_json);
  8927. }
  8928. catch (Exception ex)
  8929. {
  8930. var res_obj = new
  8931. {
  8932. data = ex.Message,
  8933. };
  8934. string ro_json = JsonConvert.SerializeObject(res_obj);
  8935. returnSuccess(ro_json);
  8936. }
  8937. }
  8938. }
  8939. public void get_user_info()
  8940. {
  8941. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8942. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8943. }
  8944. public void get_total_data()
  8945. {
  8946. int userId = CurrentUser.UserID;
  8947. string sql = "";
  8948. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8949. {
  8950. 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);
  8951. }
  8952. else
  8953. {
  8954. 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 " +
  8955. "(select ID from CE_ErpUser where ID = {0}) d " +
  8956. "left join " +
  8957. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8958. ") a on d.ID = a.id left join " +
  8959. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8960. ") b on a.id = b.id1 left join" +
  8961. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8962. ") c on a.id = c.id2;", userId);
  8963. }
  8964. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8965. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8966. }
  8967. public void get_date_area_total_data2()
  8968. {
  8969. int userId = CurrentUser.UserID;
  8970. string date_type = GetPostString("timetype");
  8971. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8972. string sql = "";
  8973. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8974. {
  8975. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8976. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8977. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8978. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8979. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8980. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8981. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8982. ") a on e.ID = a.id left join " +
  8983. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8984. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8985. ") b on a.id = b.id1 " +
  8986. "left join " +
  8987. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8988. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8989. ") c on a.id = c.id2 " +
  8990. "left join " +
  8991. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8992. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8993. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8994. }
  8995. else
  8996. {
  8997. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8998. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8999. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9000. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9001. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9002. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9003. ") a on e.ID = a.id left join " +
  9004. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9005. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9006. ") c on a.id = c.id2 " +
  9007. "left join " +
  9008. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9009. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9010. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9011. }
  9012. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9013. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9014. }
  9015. public void get_date_area_total_data()
  9016. {
  9017. int userId = CurrentUser.UserID;
  9018. string date_type = GetPostString("timetype");
  9019. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9020. string date1 = searchDT[0].ToString();
  9021. string date2 = searchDT[1].ToString();
  9022. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9023. {
  9024. SqlParameter[] sqlParameter ={
  9025. new SqlParameter("@userId", SqlDbType.Int,4),
  9026. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9027. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9028. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9029. };
  9030. sqlParameter[0].Value = userId;
  9031. sqlParameter[1].Value = date1;
  9032. sqlParameter[2].Value = date2;
  9033. sqlParameter[3].Direction = ParameterDirection.Output;
  9034. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9035. string res = sqlParameter[3].Value.ToString();
  9036. var res_obj = new
  9037. {
  9038. data = res
  9039. };
  9040. string ro_json = JsonConvert.SerializeObject(res_obj);
  9041. returnSuccess(ro_json);
  9042. }
  9043. else
  9044. {
  9045. SqlParameter[] sqlParameter ={
  9046. new SqlParameter("@userId", SqlDbType.Int,4),
  9047. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9048. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9049. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9050. };
  9051. sqlParameter[0].Value = userId;
  9052. sqlParameter[1].Value = date1;
  9053. sqlParameter[2].Value = date2;
  9054. sqlParameter[3].Direction = ParameterDirection.Output;
  9055. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9056. string res = sqlParameter[3].Value.ToString();
  9057. var res_obj = new
  9058. {
  9059. data = res
  9060. };
  9061. string ro_json = JsonConvert.SerializeObject(res_obj);
  9062. returnSuccess(ro_json);
  9063. }
  9064. //writeGridDataViewJson(dt.Rows.Count, dv);
  9065. }
  9066. public void get_order_list()
  9067. {
  9068. string strFields = GetPostString("paraFields");
  9069. string strOrder = GetPostString("paraOrder");
  9070. string strWhere = GetPostString("paraWhere");
  9071. string strPageSize = GetPostString("paraPageSize");
  9072. DataStruct dStruct = GetPostStruct();
  9073. dStruct.PageSize = int.Parse(strPageSize);
  9074. dStruct.Fileds = strFields;
  9075. dStruct.Order = strOrder;
  9076. dStruct.MainWhere = strWhere;
  9077. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9078. writeGridDataTableJson(dStruct.TotalCount, dt);
  9079. }
  9080. ////获取待开始订单列表
  9081. //public void get_wait_design_order_list()
  9082. //{
  9083. // string date_type = GetPostString("date_type");
  9084. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9085. // DataStruct dStruct = GetPostStruct();
  9086. // dStruct.PageSize = 1000;
  9087. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9088. // List<string> lw = new List<string>();
  9089. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9090. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9091. // dStruct.Order = "WaitDesignTime asc";
  9092. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9093. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9094. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9095. //}
  9096. //获取完成单量排名
  9097. public void get_finish_order_count_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.orderCount, 0) as orderCount " +
  9102. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9103. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9104. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9105. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9106. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9107. writeGridDataTableJson(0, new DataTable());
  9108. }
  9109. public void get_finish_order_amount_ranking()
  9110. {
  9111. /*string date_type = GetPostString("date_type");
  9112. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9113. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9114. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9115. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9116. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9117. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9118. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9119. writeGridDataTableJson(0, new DataTable());
  9120. }
  9121. public void get_finish_refund_count_ranking()
  9122. {
  9123. string date_type = GetPostString("date_type");
  9124. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9125. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9126. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9127. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9128. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9129. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9130. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9131. writeGridDataTableJson(dt.Rows.Count, dt);
  9132. }
  9133. public void get_finish_refund_amount_ranking()
  9134. {
  9135. string date_type = GetPostString("date_type");
  9136. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9137. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9138. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9139. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9140. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9141. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9142. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9143. writeGridDataTableJson(dt.Rows.Count, dt);
  9144. }
  9145. public void set_erp_finishorder_director()
  9146. {
  9147. if (UrlPostParmsCheck("ctid"))
  9148. {
  9149. string eid = GetPostString("ctid");
  9150. CeErpTradeCell entity = null;
  9151. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9152. if (entity != null)
  9153. {
  9154. entity.OrderState = 8;
  9155. entity.Update();
  9156. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9157. returnSuccessMsg("操作成功!");
  9158. return;
  9159. }
  9160. returnErrorMsg("找不到记录");
  9161. }
  9162. }
  9163. public void get_erp_placeregistlist()
  9164. {
  9165. DataStruct dStruct = GetPostStruct();
  9166. List<string> lw = new List<string>();
  9167. string outsid = GetPostString("outsid");
  9168. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9169. string memo = GetPostString("memo");
  9170. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9171. string filename = GetPostString("filename");
  9172. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9173. string islate = GetPostString("islate");
  9174. if (islate.Length > 0)
  9175. {
  9176. if (islate == "1")
  9177. lw.Add(string.Format("OutLate>0"));
  9178. else
  9179. lw.Add(string.Format("OutLate=0"));
  9180. }
  9181. string placedate1 = GetPostString("placedate1");
  9182. string placedate2 = GetPostString("placedate2");
  9183. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9184. if (dw.Length > 0) lw.Add(dw);
  9185. string deliveryDate1 = GetPostString("deliverydate1");
  9186. string deliveryDate2 = GetPostString("deliverydate2");
  9187. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9188. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9189. dStruct.Order = "ID desc";
  9190. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9191. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9192. writeGridDataTableJson(dStruct.TotalCount, dt);
  9193. }
  9194. public void ins_erp_placeregist()
  9195. {
  9196. if (UrlPostParmsCheck("id"))
  9197. {
  9198. string eid = GetPostString("id");
  9199. CeErpPlaceRegister entity = null;
  9200. if (eid == "0")//新增
  9201. {
  9202. entity = new CeErpPlaceRegister();
  9203. string xdTime = GetPostString("placeTime");
  9204. if (xdTime.Length > 0)
  9205. {
  9206. entity.PlactTime = Convert.ToDateTime(xdTime);
  9207. }
  9208. string fhTime = GetPostString("deliveryTime");
  9209. if (fhTime.Length > 0)
  9210. {
  9211. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9212. }
  9213. string preTime = GetPostString("preOutTime");
  9214. if (preTime.Length > 0)
  9215. {
  9216. entity.PreOutTime = Convert.ToDateTime(preTime);
  9217. }
  9218. entity.DeliveryCount = GetPostInt("deliveryCount");
  9219. entity.ReceiveCount = GetPostInt("receiveCount");
  9220. entity.OutSid = GetPostString("outSid");
  9221. entity.FileName = GetPostString("fileName");
  9222. entity.Memo = GetPostString("memo");
  9223. entity.AddUserId = CurrentUser.UserID;
  9224. entity.CreateTime = DateTime.Now;
  9225. entity.Img = GetPostString("img");
  9226. entity.Supplier = GetPostInt("supplier");
  9227. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9228. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9229. {
  9230. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9231. DateTime dt2 = (DateTime)entity.PreOutTime;
  9232. TimeSpan span = dt1.Subtract(dt2);
  9233. if (span.Days > 0)
  9234. {
  9235. entity.OutLate = span.Days;
  9236. }
  9237. }
  9238. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9239. entity.Create();
  9240. returnSuccessMsg("添加成功!");
  9241. return;
  9242. }
  9243. else //修改
  9244. {
  9245. entity = CeErpPlaceRegister.Get(eid);
  9246. if (entity != null)
  9247. {
  9248. string xdTime = GetPostString("placeTime");
  9249. if (xdTime.Length > 0)
  9250. {
  9251. entity.PlactTime = Convert.ToDateTime(xdTime);
  9252. }
  9253. string fhTime = GetPostString("deliveryTime");
  9254. if (fhTime.Length > 0)
  9255. {
  9256. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9257. }
  9258. string preTime = GetPostString("preOutTime");
  9259. if (preTime.Length > 0)
  9260. {
  9261. entity.PreOutTime = Convert.ToDateTime(preTime);
  9262. }
  9263. entity.DeliveryCount = GetPostInt("deliveryCount");
  9264. entity.ReceiveCount = GetPostInt("receiveCount");
  9265. if (entity.DeliveryCount == entity.ReceiveCount)
  9266. {
  9267. entity.CurState = "已完成";
  9268. }
  9269. else
  9270. {
  9271. entity.CurState = "未完成";
  9272. }
  9273. entity.OutSid = GetPostString("outSid");
  9274. entity.FileName = GetPostString("fileName");
  9275. entity.Memo = GetPostString("memo");
  9276. entity.Img = GetPostString("img");
  9277. entity.Supplier = GetPostInt("supplier");
  9278. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9279. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9280. {
  9281. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9282. DateTime dt2 = (DateTime)entity.PreOutTime;
  9283. TimeSpan span = dt1.Subtract(dt2);
  9284. if (span.Days > 0)
  9285. {
  9286. entity.OutLate = span.Days;
  9287. }
  9288. }
  9289. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9290. entity.Update();
  9291. returnSuccessMsg("修改成功");
  9292. return;
  9293. }
  9294. returnErrorMsg("找不到对应的记录");
  9295. return;
  9296. }
  9297. }
  9298. returnErrorMsg("缺少必要参数");
  9299. }
  9300. public void del_erp_placeregist()
  9301. {
  9302. string eid = GetPostString("id");
  9303. CeErpPlaceRegister.Del(eid);
  9304. returnSuccessMsg("删除成功!");
  9305. return;
  9306. }
  9307. public void ins_erp_placeregistbyorder()
  9308. {
  9309. string ctid = GetPostString("ctid");
  9310. if (ctid.Length > 0)
  9311. {
  9312. StringBuilder sql = new StringBuilder();
  9313. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9314. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9315. if (dt.Rows.Count > 0)
  9316. {
  9317. foreach (DataRow dr in dt.Rows)
  9318. {
  9319. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9320. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9321. entity.AddUserId = CurrentUser.UserID;
  9322. entity.tid = dr["tid"].ToString();
  9323. entity.Did = Convert.ToString(dr["ctid"]);
  9324. entity.splitTag = dr["SplitTag"].ToString();
  9325. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9326. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9327. if (pre_ctid.Length > 0)
  9328. {
  9329. sellmemo = sellmemo.Replace(pre_ctid, "");
  9330. }
  9331. sellmemo = sellmemo.Replace("[", "");
  9332. sellmemo = sellmemo.Replace("]", "");
  9333. entity.FileName = sellmemo;
  9334. string count = dr["ProductCount"].ToString();
  9335. int usecount = commonHelper.getIntCountFromString(count);
  9336. entity.DeliveryCount = usecount;
  9337. entity.CurState = "未完成";
  9338. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9339. {
  9340. entity.Supplier = 24;//dl手提袋定制
  9341. }
  9342. else
  9343. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9344. entity.CreateTime = DateTime.Now;
  9345. entity.Create();
  9346. }
  9347. returnSuccessMsg("操作成功");
  9348. return;
  9349. }
  9350. returnErrorMsg("没有找到对应订单");
  9351. return;
  9352. }
  9353. returnErrorMsg("缺少订单编号");
  9354. return;
  9355. }
  9356. public void get_erp_persuadelist()
  9357. {
  9358. DataStruct dStruct = GetPostStruct();
  9359. List<string> lw = new List<string>();
  9360. string ctid = GetPostString("ctid");
  9361. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9362. string shopname = GetPostString("shopname");
  9363. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9364. string buyernick = GetPostString("buyer_nick");
  9365. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9366. string customer = GetPostString("customer");
  9367. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9368. string returndate1 = GetPostString("returndate1");
  9369. string returndate2 = GetPostString("returndate2");
  9370. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9371. if (dw.Length > 0) lw.Add(dw);
  9372. string finishDate1 = GetPostString("finishdate1");
  9373. string finishDate2 = GetPostString("finishdate2");
  9374. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9375. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9376. string persuadetype = GetPostString("persuadetype");
  9377. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9378. string returnvstate = GetPostString("returnvstate");
  9379. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9380. dStruct.Order = "created desc";
  9381. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9382. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9383. writeGridDataTableJson(dStruct.TotalCount, dt);
  9384. }
  9385. public void upd_erp_returnpersuadeback()
  9386. {
  9387. if (UrlPostParmsCheck("ID"))
  9388. {
  9389. int eid = GetPostInt("ID");
  9390. CeErpPersuade entity = null;
  9391. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9392. if (entity != null)
  9393. {
  9394. entity.backreason = GetPostString("reason");
  9395. entity.pstate = 2;
  9396. entity.verifytime = DateTime.Now;
  9397. entity.verifyuserid = CurrentUser.UserID;
  9398. entity.Update();
  9399. returnSuccessMsg("退回成功!");
  9400. return;
  9401. }
  9402. returnErrorMsg("找不到订单记录");
  9403. }
  9404. }
  9405. public void upd_erp_returnpersuadeverify()
  9406. {
  9407. if (UrlPostParmsCheck("ID"))
  9408. {
  9409. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9410. {
  9411. returnErrorMsg("暂无权限审核");
  9412. return;
  9413. }
  9414. int eid = GetPostInt("ID");
  9415. CeErpPersuade entity = null;
  9416. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9417. if (entity != null)
  9418. {
  9419. entity.pstate = 1;
  9420. entity.verifytime = DateTime.Now;
  9421. entity.verifyuserid = CurrentUser.UserID;
  9422. entity.Update();
  9423. returnSuccessMsg("审核成功!");
  9424. return;
  9425. }
  9426. returnErrorMsg("找不到订单记录");
  9427. }
  9428. }
  9429. public void del_erp_persuade()
  9430. {
  9431. if (UrlPostParmsCheck("ID"))
  9432. {
  9433. int eid = GetPostInt("ID");
  9434. CeErpPersuade.Del(eid);
  9435. returnSuccessMsg("操作成功");
  9436. return;
  9437. }
  9438. }
  9439. public void get_erp_oldcustoupload()
  9440. {
  9441. DataStruct dStruct = GetPostStruct();
  9442. List<string> lw = new List<string>();
  9443. string buyernick = GetPostString("buyer_nick");
  9444. if (buyernick.Length > 0)
  9445. {
  9446. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9447. }
  9448. else
  9449. return;
  9450. dStruct.Order = "pay_time desc";
  9451. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9452. DataTable dt = null;
  9453. dt = WebCache.GetData("view_erptradecell", dStruct);
  9454. writeGridDataTableJson(dStruct.TotalCount, dt);
  9455. }
  9456. public void get_erp_checkorderlist()
  9457. {
  9458. DataStruct dStruct = GetPostStruct();
  9459. List<string> lw = new List<string>();
  9460. string tid = GetPostString("ctid");
  9461. if (tid.Length > 0)
  9462. {
  9463. string select_tid = getTidByCtid(tid);
  9464. lw.Add(string.Format("tid='{0}'", select_tid));
  9465. }
  9466. string shopname = GetPostString("shopname");
  9467. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9468. string buyernick = GetPostString("buyer_nick");
  9469. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9470. string customer = GetPostString("customer");
  9471. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9472. string design = GetPostString("design");
  9473. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9474. string orderState = GetPostString("orderState");
  9475. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9476. string address = GetPostString("address");
  9477. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9478. string sellermemo = GetPostString("seller_memo");
  9479. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9480. string supplier = GetPostString("supplier");
  9481. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9482. {
  9483. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9484. }
  9485. else
  9486. {
  9487. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9488. }
  9489. string date1 = GetPostString("date1");
  9490. string date2 = GetPostString("date2");
  9491. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9492. if (dw.Length > 0) lw.Add(dw);
  9493. string placedate1 = GetPostString("placedate1");
  9494. string placedate2 = GetPostString("placedate2");
  9495. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9496. if (fdw.Length > 0) lw.Add(fdw);
  9497. string price1 = GetPostString("price1");
  9498. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9499. string price2 = GetPostString("price2");
  9500. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9501. string checkst = GetPostString("checkstate");
  9502. if (checkst.Length > 0 && "10".Equals(checkst))
  9503. {
  9504. lw.Add(string.Format("CheckOut>0"));
  9505. }
  9506. else
  9507. {
  9508. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9509. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9510. }
  9511. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9512. {
  9513. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9514. }
  9515. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9516. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9517. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9518. writeGridDataTableJson(dStruct.TotalCount, dt);
  9519. }
  9520. public void ins_erp_startCheck()
  9521. {
  9522. if (UrlPostParmsCheck("ctid"))
  9523. {
  9524. string eid = GetPostString("ctid");
  9525. CeErpTradeCell entity = null;
  9526. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9527. if (entity != null)
  9528. {
  9529. entity.MemoOpt = 4;
  9530. entity.UpdateTime = DateTime.Now;
  9531. entity.Update();
  9532. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9533. CeErpSukuraData.createInfo(entity.ctid, 6);
  9534. returnSuccessMsg("操作成功!");
  9535. return;
  9536. }
  9537. returnErrorMsg("找不到记录");
  9538. }
  9539. }
  9540. public void upd_erp_sendXlw()
  9541. {
  9542. if (UrlPostParmsCheck("ctid"))
  9543. {
  9544. string eid = GetPostString("ctid");
  9545. CeErpTradeCell entity = null;
  9546. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9547. if (entity != null)
  9548. {
  9549. if (entity.IsSendGift == 1)
  9550. {
  9551. returnErrorMsg("请勿重复标记");
  9552. return;
  9553. }
  9554. entity.IsSendGift = 1;
  9555. entity.Update();
  9556. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9557. returnSuccessMsg("操作成功!");
  9558. return;
  9559. }
  9560. returnErrorMsg("找不到记录");
  9561. }
  9562. }
  9563. public void cancel_sendXlw()
  9564. {
  9565. if (UrlPostParmsCheck("ctid"))
  9566. {
  9567. string eid = GetPostString("ctid");
  9568. CeErpTradeCell entity = null;
  9569. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9570. if (entity != null)
  9571. {
  9572. if (entity.IsSendGift == 0)
  9573. {
  9574. returnErrorMsg("未标记小礼物");
  9575. return;
  9576. }
  9577. entity.IsSendGift = 0;
  9578. entity.Update();
  9579. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9580. returnSuccessMsg("操作成功!");
  9581. return;
  9582. }
  9583. returnErrorMsg("找不到记录");
  9584. }
  9585. }
  9586. public void get_erp_designbill()
  9587. {
  9588. DataStruct dStruct = GetPostStruct();
  9589. List<string> lw = new List<string>();
  9590. int isMy = GetInt("my");
  9591. if (isMy == 1)
  9592. {
  9593. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9594. }
  9595. string tid = GetPostString("tid");
  9596. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9597. string userName = GetPostString("design");
  9598. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9599. string price1 = GetPostString("price1");
  9600. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9601. string price2 = GetPostString("price2");
  9602. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9603. string rePrice1 = GetPostString("rePrice1");
  9604. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9605. string rePrice2 = GetPostString("rePrice2");
  9606. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9607. string designerType = GetPostString("designerType");
  9608. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9609. string orderState = GetPostString("orderState");
  9610. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9611. string endTime1 = GetPostString("endTime1");
  9612. string endTime2 = GetPostString("endTime2");
  9613. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9614. if (dw.Length > 0) lw.Add(dw);
  9615. string isDk = GetPostString("isDk");
  9616. if (isDk == "1")
  9617. {
  9618. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9619. }
  9620. else if (isDk == "0")
  9621. {
  9622. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9623. }
  9624. dStruct.Order = "oid, create_time desc";
  9625. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9626. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9627. writeGridDataTableJson(dStruct.TotalCount, dt);
  9628. }
  9629. public void upd_erp_designerbill()
  9630. {
  9631. if (UrlPostParmsCheck("ID"))
  9632. {
  9633. string eid = GetPostString("ID");
  9634. CeErpDesignerBill entity = null;
  9635. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9636. if (entity != null)
  9637. {
  9638. if (GetPostDouble("designerpirce") > 0)
  9639. {
  9640. entity.realPrice = GetPostDouble("designerpirce");
  9641. entity.update_time = DateTime.Now;
  9642. entity.update_u_id = CurrentUser.UserID;
  9643. entity.update_u_name = CurrentUser.UserName;
  9644. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9645. entity.Update();
  9646. returnSuccessMsg("操作成功!");
  9647. return;
  9648. }
  9649. else
  9650. {
  9651. entity.price = GetPostDouble("price");
  9652. entity.update_time = DateTime.Now;
  9653. entity.update_u_id = CurrentUser.UserID;
  9654. entity.update_u_name = CurrentUser.UserName;
  9655. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9656. entity.Update();
  9657. returnSuccessMsg("操作成功!");
  9658. return;
  9659. }
  9660. }
  9661. returnErrorMsg("找不到记录");
  9662. }
  9663. }
  9664. public void audit_erp_designerbill()
  9665. {
  9666. if (UrlPostParmsCheck("ID"))
  9667. {
  9668. string eid = GetPostString("ID");
  9669. CeErpDesignerBill entity = null;
  9670. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9671. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9672. if (entity != null)
  9673. {
  9674. entity.realPrice = GetPostDouble("designerpirce");
  9675. entity.update_time = DateTime.Now;
  9676. entity.update_u_id = CurrentUser.UserID;
  9677. entity.update_u_name = CurrentUser.UserName;
  9678. entity.isAudit = 1;
  9679. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9680. entity.Update();
  9681. if (orderEntity != null)
  9682. {
  9683. orderEntity.IsReadTag = 3;
  9684. orderEntity.Update();
  9685. }
  9686. returnSuccessMsg("操作成功!");
  9687. return;
  9688. }
  9689. returnErrorMsg("找不到记录");
  9690. }
  9691. }
  9692. public void all_audit_erp_designerbill()
  9693. {
  9694. if (UrlPostParmsCheck("idList"))
  9695. {
  9696. string[] list = GetPostString("idList").Split(',');
  9697. CeErpDesignerBill entity = null;
  9698. for (int i = 0; i < list.Length; i++)
  9699. {
  9700. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9701. if (entity == null) return;
  9702. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9703. if (orderEntity == null) return;
  9704. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9705. entity.update_time = DateTime.Now;
  9706. entity.update_u_id = CurrentUser.UserID;
  9707. entity.update_u_name = CurrentUser.UserName;
  9708. entity.isAudit = 1;
  9709. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9710. entity.Update();
  9711. orderEntity.IsReadTag = 3;
  9712. orderEntity.Update();
  9713. }
  9714. returnSuccessMsg("操作成功!");
  9715. return;
  9716. }
  9717. }
  9718. public void get_erp_sameorders()
  9719. {
  9720. if (UrlPostParmsCheck("ctid"))
  9721. {
  9722. string eid = GetPostString("ctid");
  9723. CeErpTradeCell entity = null;
  9724. entity = CeErpTradeCell.GetByCtid(eid);
  9725. if (entity != null)
  9726. {
  9727. StringBuilder sql = new StringBuilder();
  9728. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9729. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9730. var res = new
  9731. {
  9732. data = dt.Rows.Count
  9733. };
  9734. string ro_jsond = JsonConvert.SerializeObject(res);
  9735. returnSuccess(ro_jsond);
  9736. return;
  9737. }
  9738. returnErrorMsg("未找到订单");
  9739. return;
  9740. }
  9741. returnErrorMsg("缺少必要的参数");
  9742. }
  9743. public void get_erp_islasthavesameorder()
  9744. {
  9745. if (UrlPostParmsCheck("ctid"))
  9746. {
  9747. string eid = GetPostString("ctid");
  9748. string[] ctidList = eid.Split(',');
  9749. StringBuilder sql = new StringBuilder();
  9750. string tisCtid = "";
  9751. foreach (string ctid in ctidList)
  9752. {
  9753. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9754. if (entity != null)
  9755. {
  9756. sql = new StringBuilder();
  9757. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9758. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9759. if (dth.Rows.Count > 0)
  9760. {
  9761. tisCtid += entity.ctid;
  9762. tisCtid += ",";
  9763. }
  9764. }
  9765. }
  9766. if (tisCtid.Length > 0)
  9767. {
  9768. var res = new
  9769. {
  9770. data = tisCtid
  9771. };
  9772. string ro_jsond = JsonConvert.SerializeObject(res);
  9773. returnSuccess(ro_jsond);
  9774. }
  9775. else
  9776. {
  9777. var res = new
  9778. {
  9779. data = ""
  9780. };
  9781. string ro_jsond = JsonConvert.SerializeObject(res);
  9782. returnSuccess(ro_jsond);
  9783. }
  9784. return;
  9785. }
  9786. returnErrorMsg("缺少必要的参数");
  9787. }
  9788. public void file_client_down_url()
  9789. {
  9790. if (!UrlPostParmsCheck("userId"))
  9791. {
  9792. returnErrorMsg("缺少必要的参数");
  9793. }
  9794. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9795. }
  9796. public void checkout_form_data()
  9797. {
  9798. if (!UrlPostParmsCheck("tid"))
  9799. {
  9800. returnErrorMsg("缺少必要的参数");
  9801. }
  9802. string tid = GetPostString("tid");
  9803. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9804. if (ceErpOrderFormData != null)
  9805. {
  9806. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9807. returnSuccess(ro_jsond);
  9808. return;
  9809. }
  9810. returnErrorMsg("尚未有文件!");
  9811. }
  9812. public void back_supplier_audit()
  9813. {
  9814. int userId = CurrentUser.UserID;
  9815. StringBuilder sql = new StringBuilder();
  9816. 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);
  9817. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9818. if (dt.Rows.Count > 0)
  9819. {
  9820. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9821. }
  9822. else
  9823. {
  9824. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9825. }
  9826. }
  9827. public void back_supplier_query()
  9828. {
  9829. string eid = GetPostString("ctid");
  9830. if (eid != "")
  9831. {
  9832. StringBuilder sql = new StringBuilder();
  9833. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9834. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9835. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9836. }
  9837. else
  9838. {
  9839. returnErrorMsg("找不到订单记录");
  9840. return;
  9841. }
  9842. }
  9843. public void verified_to_order()
  9844. {
  9845. int userId = CurrentUser.UserID;
  9846. StringBuilder sql = new StringBuilder();
  9847. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9848. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9849. if (dt.Rows.Count > 0)
  9850. {
  9851. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9852. }
  9853. else
  9854. {
  9855. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9856. }
  9857. }
  9858. public void upd_supplier_audit()
  9859. {
  9860. if (UrlPostParmsCheck("ctid"))
  9861. {
  9862. string eid = GetPostString("ctid");
  9863. string reason = GetPostString("returnreason");
  9864. CeErpTradeCell entity = null;
  9865. CeWithdraw withdraw = null;
  9866. withdraw = CeWithdraw.GetByTid(eid);
  9867. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9868. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9869. {
  9870. if (withdraw != null)
  9871. {
  9872. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9873. {
  9874. returnSuccessMsg("您没有权限操作!");
  9875. return;
  9876. }
  9877. else
  9878. {
  9879. if (reason.Equals("1"))
  9880. {
  9881. if (entity.OrderState == -1)
  9882. {
  9883. if (entity.FinishPlaceTime == null)
  9884. {
  9885. entity.OrderState = 2;
  9886. }
  9887. else
  9888. {
  9889. entity.OrderState = 6;
  9890. }
  9891. }
  9892. entity.Update();
  9893. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9894. if (withdraw != null)
  9895. {
  9896. withdraw.status = int.Parse(reason);
  9897. withdraw.Update();
  9898. }
  9899. returnSuccessMsg("操作成功!");
  9900. return;
  9901. }
  9902. else
  9903. {
  9904. withdraw.status = int.Parse(reason);
  9905. withdraw.acknowledgingtime = DateTime.Now;
  9906. withdraw.Update();
  9907. returnSuccessMsg("查看详细请点击线下订单查询");
  9908. return;
  9909. }
  9910. }
  9911. }
  9912. // 第一个字符是 'N'
  9913. }
  9914. if (eid[0] != 'N')
  9915. {
  9916. }
  9917. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9918. {
  9919. entity.IsVerifyToSupplier = false;
  9920. entity.IsReturn = 1;
  9921. entity.ReturnTime = DateTime.Now;
  9922. entity.ReturnReason = reason;
  9923. if (entity.OrderState == 6)
  9924. {
  9925. entity.OrderState = 5;
  9926. }
  9927. entity.Update();
  9928. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9929. if (withdraw != null)
  9930. {
  9931. withdraw.status = int.Parse(reason);
  9932. withdraw.Update();
  9933. }
  9934. returnSuccessMsg("操作成功!");
  9935. return;
  9936. }
  9937. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9938. {
  9939. ;
  9940. if (withdraw != null)
  9941. {
  9942. withdraw.status = int.Parse(reason);
  9943. withdraw.acknowledgingtime = DateTime.Now;
  9944. withdraw.Update();
  9945. returnSuccessMsg("供应商取消撤回!");
  9946. return;
  9947. }
  9948. }
  9949. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9950. {
  9951. if (entity.OrderState == -1)
  9952. {
  9953. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9954. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9955. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9956. {
  9957. returnErrorMsg("台湾客户需填写身份证!");
  9958. return;
  9959. }
  9960. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9961. {
  9962. returnErrorMsg("订单spu没有确认无法通过审核!");
  9963. return;
  9964. }
  9965. if (entity.FinishPlaceTime == null)
  9966. {
  9967. entity.OrderState = 2;
  9968. }
  9969. else
  9970. {
  9971. entity.OrderState = 3;
  9972. }
  9973. commonHelper.getCytPrice(entity);
  9974. }
  9975. entity.Update();
  9976. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9977. if (withdraw != null)
  9978. {
  9979. withdraw.status = int.Parse(reason);
  9980. withdraw.Update();
  9981. }
  9982. returnSuccessMsg("操作成功!");
  9983. return;
  9984. }
  9985. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9986. {
  9987. if (withdraw == null)
  9988. {
  9989. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9990. return;
  9991. }
  9992. }
  9993. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9994. {
  9995. if (withdraw != null)
  9996. {
  9997. withdraw.status = int.Parse(reason);
  9998. withdraw.acknowledgingtime = DateTime.Now;
  9999. withdraw.Update();
  10000. returnSuccessMsg("查看详细请点击线下订单查询");
  10001. return;
  10002. }
  10003. }
  10004. return;
  10005. }
  10006. }
  10007. //校验报价
  10008. public void refund_order_tip()
  10009. {
  10010. int userid = CurrentUser.UserID;
  10011. int sectionId = CurrentUser.UserPost.OrgID;
  10012. StringBuilder sql = new StringBuilder();
  10013. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10014. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10015. List<string> ids = new List<string>();
  10016. if (dth.Rows.Count > 0)
  10017. {
  10018. foreach (DataRow dr in dth.Rows)
  10019. {
  10020. ids.Add(dr["ID"].ToString());
  10021. }
  10022. try
  10023. {
  10024. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10025. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10026. }
  10027. catch (Exception ex)
  10028. {
  10029. }
  10030. }
  10031. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10032. }
  10033. public void refund_order_Design()
  10034. {
  10035. int userid = CurrentUser.UserID;
  10036. int sectionId = CurrentUser.UserPost.OrgID;
  10037. StringBuilder sql = new StringBuilder();
  10038. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10039. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10040. List<string> ids = new List<string>();
  10041. if (dth.Rows.Count > 0)
  10042. {
  10043. foreach (DataRow dr in dth.Rows)
  10044. {
  10045. ids.Add(dr["ID"].ToString());
  10046. }
  10047. try
  10048. {
  10049. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10050. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10051. }
  10052. catch (Exception ex)
  10053. {
  10054. }
  10055. }
  10056. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10057. }
  10058. public void change_order_info()
  10059. {
  10060. int userid = CurrentUser.UserID;
  10061. StringBuilder sql = new StringBuilder();
  10062. 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);
  10063. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10064. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10065. }
  10066. public void change_win_mome()
  10067. {
  10068. if (UrlPostParmsCheck("id,ctid"))
  10069. {
  10070. string id = GetPostString("id");
  10071. string ctid = GetPostString("ctid");
  10072. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10073. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10074. if (ce == null || ceErpMessageTip == null)
  10075. {
  10076. returnSuccessMsg("未找到对应的订单!");
  10077. return;
  10078. }
  10079. if (ce.OrderState >= 5)
  10080. {
  10081. ceErpMessageTip.isVisit = true;
  10082. ceErpMessageTip.Update();
  10083. returnSuccessMsg("已上传文件无法修改!");
  10084. return;
  10085. }
  10086. int type = GetPostInt("type");
  10087. string content = GetPostString("content");
  10088. if (type == 0)
  10089. {
  10090. content = content.Replace("(", "(");
  10091. content = content.Replace(")", ")");
  10092. string check = MidStrEx(content, "(", ")").Trim();
  10093. if (string.IsNullOrEmpty(check))
  10094. {
  10095. returnSuccessMsg("文件名格式不正确");
  10096. return;
  10097. }
  10098. }
  10099. ce.seller_memo = content;
  10100. ce.Update();
  10101. ceErpMessageTip.isVisit = true;
  10102. ceErpMessageTip.Update();
  10103. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10104. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10105. ApiVo apiVo = new ApiVo();
  10106. apiVo.orderNumber = ce.ctid;
  10107. apiVo.actionName = "demandDesign";
  10108. apiVo.orderRemarks = content;
  10109. apiVo.demandExamine = type + 1;
  10110. designHelper.API_WorkCore(apiVo);//demandDesign
  10111. returnSuccessMsg("修改成功!");
  10112. }
  10113. }
  10114. public static string MidStrEx(string sourse, string startstr, string endstr)
  10115. {
  10116. string result = string.Empty;
  10117. int startindex, endindex;
  10118. try
  10119. {
  10120. startindex = sourse.IndexOf(startstr);
  10121. if (startindex == -1)
  10122. return result;
  10123. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10124. endindex = tmpstr.IndexOf(endstr);
  10125. if (endindex == -1)
  10126. return result;
  10127. result = tmpstr.Remove(endindex);
  10128. }
  10129. catch (Exception ex)
  10130. {
  10131. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10132. }
  10133. return result;
  10134. }
  10135. public void refund_order_list()
  10136. {
  10137. int userid = CurrentUser.UserID;
  10138. int sectionId = CurrentUser.UserPost.OrgID;
  10139. StringBuilder sql = new StringBuilder();
  10140. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10141. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10142. DataStruct dStruct = GetPostStruct();
  10143. DataTable dt = null;
  10144. List<string> ids = new List<string>();
  10145. List<string> tids = new List<string>();
  10146. if (dth.Rows.Count > 0)
  10147. {
  10148. foreach (DataRow dr in dth.Rows)
  10149. {
  10150. tids.Add("'" + dr["tid"].ToString() + "'");
  10151. ids.Add(dr["id"].ToString());
  10152. }
  10153. try
  10154. {
  10155. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10156. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10157. List<string> lw = new List<string>();
  10158. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10159. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10160. dt = WebCache.GetData("view_orderlist", dStruct);
  10161. }
  10162. catch (Exception ex)
  10163. {
  10164. }
  10165. }
  10166. writeGridDataTableJson(dStruct.TotalCount, dt);
  10167. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10168. }
  10169. //新增
  10170. public void order_batch_downloads()
  10171. {
  10172. string ceid = GetPostString("tid");
  10173. String[] tid = ceid.Split(',');
  10174. order_batch_caiyingtong(tid);
  10175. /* (string success, string errors) = UploadFiles(tid);
  10176. returnSuccessMsg(success + errors);*/
  10177. return;
  10178. }
  10179. //报价接口
  10180. public void Get_To_Quote()
  10181. {
  10182. string ceid = GetPostString("ctid");
  10183. if (ceid != null)
  10184. {
  10185. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10186. if (entity != null)
  10187. {
  10188. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10189. {
  10190. return;
  10191. }
  10192. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10193. double price = 0;
  10194. if (cp == null)
  10195. {
  10196. JObject jsonObject12 = new JObject
  10197. {
  10198. { "UserId", "77886" },
  10199. { "Pwd", "lt666888" },
  10200. { "Filename", entity.seller_memo }
  10201. };
  10202. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10203. JObject jsonObjects1 = JObject.Parse(response1);
  10204. string ms1g = (string)jsonObjects1["msg"];
  10205. if (ms1g == "报价成功")
  10206. {
  10207. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10208. string data = (string)jsonObject1["price"];
  10209. 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 + "');";
  10210. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10211. returnSuccessMsg("获取报价成功:" + data);
  10212. price = Convert.ToDouble(data);
  10213. }
  10214. else
  10215. {
  10216. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10217. return;
  10218. }
  10219. }
  10220. String[] beizhu = entity.seller_memo.Split('-');
  10221. String chanp = "";
  10222. if (beizhu.Length > 0)
  10223. {
  10224. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10225. }
  10226. else
  10227. {
  10228. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10229. }
  10230. JObject jsonObject = new JObject
  10231. {
  10232. { "UserId", "77886" },
  10233. { "Pwd", "lt666888" },
  10234. { "Filename", chanp }
  10235. };
  10236. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10237. JObject jsonObjects = JObject.Parse(response);
  10238. string msg = (string)jsonObjects["msg"];
  10239. if (msg == "报价成功")
  10240. {
  10241. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10242. string data = (string)jsonObject1["price"];
  10243. 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 + "');";
  10244. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10245. returnSuccessMsg("获取报价成功:" + data);
  10246. price = Convert.ToDouble(data);
  10247. }
  10248. else
  10249. {
  10250. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10251. return;
  10252. }
  10253. if (price > 0)
  10254. {
  10255. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10256. if (ceErpTradeCellExtend == null)
  10257. {
  10258. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10259. ceErpTradeCellExtend.ctid = entity.ctid;
  10260. ceErpTradeCellExtend.payment_cyt = price;
  10261. ceErpTradeCellExtend.Create();
  10262. }
  10263. else
  10264. {
  10265. ceErpTradeCellExtend.payment_cyt = price;
  10266. ceErpTradeCellExtend.Update();
  10267. }
  10268. }
  10269. return;
  10270. }
  10271. }
  10272. else
  10273. {
  10274. returnErrorMsg("请至少选择一条数据");
  10275. return;
  10276. }
  10277. }
  10278. //新增
  10279. public void order_To_Supplier()
  10280. {
  10281. string ceid = GetPostString("tid");
  10282. String[] tid = ceid.Split(',');
  10283. if (tid.Length > 0)
  10284. {
  10285. try
  10286. {
  10287. for (int i = 0; i < tid.Length; i++)
  10288. {
  10289. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10290. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10291. entity.SupplierId = suid;
  10292. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10293. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10294. entity.Update();
  10295. }
  10296. }
  10297. catch (Exception ex)
  10298. {
  10299. returnErrorMsg("自动匹配供应商失败");
  10300. return;
  10301. }
  10302. }
  10303. else
  10304. {
  10305. returnErrorMsg("请至少选择一条数据");
  10306. return;
  10307. }
  10308. returnSuccessMsg("自动匹配供应商成功");
  10309. return;
  10310. }
  10311. public (string, string) UploadFiles(string[] urls)
  10312. {
  10313. string success = "";
  10314. string errors = "";
  10315. int userid = CurrentUser.UserID;
  10316. foreach (string url in urls)
  10317. {
  10318. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10319. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10320. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10321. {
  10322. JObject jsonObject = new JObject
  10323. {
  10324. { "Userid", "77886" },
  10325. { "pwd", "cyt86435015" },
  10326. { "content", base64FileContent },
  10327. { "ext", Path.GetExtension(fileName) }
  10328. };
  10329. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10330. JObject jsonObjects = JObject.Parse(response);
  10331. string msg = (string)jsonObjects["msg"];
  10332. if (msg.Equals("上传成功"))
  10333. {
  10334. success += url + " 上传成功";
  10335. }
  10336. else
  10337. {
  10338. errors += url + " 上传失败";
  10339. }
  10340. }
  10341. else
  10342. {
  10343. errors += url + " 格式出现问题";
  10344. }
  10345. }
  10346. if (urls.Length == 0)
  10347. {
  10348. return (success, errors);
  10349. }
  10350. return (success, errors);
  10351. }
  10352. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10353. {
  10354. return true; //总是接受
  10355. }
  10356. public static string HttpPost(string url, string param = null)
  10357. {
  10358. HttpWebRequest request;
  10359. //如果是发送HTTPS请求
  10360. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10361. {
  10362. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10363. request = WebRequest.Create(url) as HttpWebRequest;
  10364. request.ProtocolVersion = HttpVersion.Version10;
  10365. }
  10366. else
  10367. {
  10368. request = WebRequest.Create(url) as HttpWebRequest;
  10369. }
  10370. request.Method = "POST";
  10371. request.ContentType = "application/json";
  10372. request.Accept = "*/*";
  10373. request.Timeout = 120000;
  10374. request.AllowAutoRedirect = false;
  10375. StreamWriter requestStream = null;
  10376. WebResponse response = null;
  10377. string responseStr = null;
  10378. try
  10379. {
  10380. requestStream = new StreamWriter(request.GetRequestStream());
  10381. requestStream.Write(param);
  10382. requestStream.Close();
  10383. response = request.GetResponse();
  10384. if (response != null)
  10385. {
  10386. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10387. responseStr = reader.ReadToEnd();
  10388. reader.Close();
  10389. }
  10390. }
  10391. catch (Exception ex)
  10392. {
  10393. return ex.Message;
  10394. }
  10395. finally
  10396. {
  10397. request = null;
  10398. requestStream = null;
  10399. response = null;
  10400. }
  10401. return responseStr;
  10402. }
  10403. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10404. {
  10405. string base64FileContent;
  10406. string fileName;
  10407. using (WebClient webClient = new WebClient())
  10408. {
  10409. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10410. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10411. {
  10412. using (Stream stream = response.GetResponseStream())
  10413. {
  10414. using (MemoryStream memoryStream = new MemoryStream())
  10415. {
  10416. stream.CopyTo(memoryStream);
  10417. byte[] fileBytes = memoryStream.ToArray();
  10418. base64FileContent = Convert.ToBase64String(fileBytes);
  10419. fileName = response.Headers["Content-Disposition"];
  10420. if (!string.IsNullOrEmpty(fileName))
  10421. {
  10422. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10423. if (index >= 0)
  10424. {
  10425. fileName = fileName.Substring(index + 9).Trim('\"');
  10426. }
  10427. }
  10428. else
  10429. {
  10430. fileName = Path.GetFileName(downloadUrl);
  10431. }
  10432. }
  10433. }
  10434. }
  10435. }
  10436. return (fileName, base64FileContent);
  10437. }
  10438. //新增
  10439. public void order_batch_caiyingtong(string[] downloadUrls)
  10440. {
  10441. try
  10442. {
  10443. //遍历文件
  10444. DataStruct dStruct = GetPostStruct();
  10445. DataTable dt = null;
  10446. int userid = CurrentUser.UserID;
  10447. List<string> ids = new List<string>();//失败组
  10448. List<string> tids = new List<string>();
  10449. using (WebClient webClient = new WebClient())
  10450. {
  10451. foreach (var url in downloadUrls)
  10452. {
  10453. try
  10454. {
  10455. tids.Add("'" + url + "'");
  10456. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10457. if (entity != null)
  10458. {
  10459. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10460. if (cp == null)
  10461. {
  10462. JObject jsonObject = new JObject
  10463. {
  10464. { "Userid", "77886" },
  10465. { "pwd", "lt666888" },
  10466. { "Filename",entity.seller_memo }
  10467. };
  10468. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10469. JObject jsonObjects = JObject.Parse(response);
  10470. string msg = (string)jsonObjects["msg"];
  10471. if (msg == "报价成功")
  10472. {
  10473. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10474. DownloadAndConvertToBase64(url1);
  10475. }
  10476. else
  10477. {
  10478. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10479. }
  10480. }
  10481. else
  10482. {
  10483. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10484. JObject jsonObject = new JObject
  10485. {
  10486. { "Userid", "77886" },
  10487. { "pwd", "lt666888" },
  10488. { "Filename",chanp }
  10489. };
  10490. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10491. JObject jsonObjects = JObject.Parse(response);
  10492. string msg = (string)jsonObjects["msg"];
  10493. if (msg == "报价成功")
  10494. {
  10495. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10496. DownloadAndConvertToBase64(url1);
  10497. }
  10498. else
  10499. {
  10500. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10501. }
  10502. }
  10503. }
  10504. // 上传文件到FTP
  10505. }
  10506. catch (Exception ex)
  10507. {
  10508. Console.WriteLine($"An error occurred: {ex.Message}");
  10509. }
  10510. }
  10511. List<string> lw = new List<string>();
  10512. lw.Add(string.Format("( OrderState < 6 )"));
  10513. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10514. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10515. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10516. if (dt.Rows.Count > 0)
  10517. {
  10518. foreach (DataRow dr in dt.Rows)
  10519. {
  10520. ids.Add(dr["ctid"].ToString());
  10521. }
  10522. }
  10523. String ErrorMsgs = "";
  10524. foreach (String id in ids)
  10525. {
  10526. ErrorMsgs += id + ",";
  10527. }
  10528. if (ErrorMsgs.Length > 1)
  10529. {
  10530. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10531. }
  10532. if (ErrorMsgs.Length < 1)
  10533. {
  10534. ErrorMsgs = "上传成功";
  10535. returnSuccessMsg(ErrorMsgs);
  10536. }
  10537. else
  10538. {
  10539. returnErrorMsg("以下订单" + ErrorMsgs);
  10540. }
  10541. }
  10542. // 删除文件夹及其内容
  10543. /* Directory.Delete(localDirectory, true);*/
  10544. }
  10545. catch { }
  10546. }
  10547. public void get_center_data()
  10548. {
  10549. int userId = CurrentUser.UserID;
  10550. string postCode = CurrentUser.UserPost.Post.Code;
  10551. List<string> lw = new List<string>();
  10552. List<string> ww = new List<string>();
  10553. DateTime currentTime = DateTime.Now;
  10554. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10555. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10556. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10557. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10558. string sql = " SELECT ";
  10559. string startTime = "2023-10-01 11:22:31";
  10560. //设计
  10561. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10562. {
  10563. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10564. 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));
  10565. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10566. 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));
  10567. }
  10568. //客服
  10569. else if (postCode == "CustomerService" || postCode == "Director")
  10570. {
  10571. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10572. 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));
  10573. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10574. 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));
  10575. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10576. 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));
  10577. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10578. 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));
  10579. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10580. 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));
  10581. }
  10582. //售后
  10583. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10584. {
  10585. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10586. 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));
  10587. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10588. 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));
  10589. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10590. 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));
  10591. }
  10592. //下单部
  10593. else if (postCode == "Place" || postCode == "PlaceMr")
  10594. {
  10595. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10596. 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));
  10597. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10598. 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));
  10599. }
  10600. //车间
  10601. else if (postCode == "Supplier")
  10602. {
  10603. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10604. 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));
  10605. }
  10606. DataTable dt = new DataTable();
  10607. if (lw.Count > 0)
  10608. {
  10609. sql += string.Join(" , ", lw);
  10610. sql += " FROM ";
  10611. sql += string.Join(" , ", ww);
  10612. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10613. }
  10614. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10615. }
  10616. public void get_center_data_list()
  10617. {
  10618. int userId = CurrentUser.UserID;
  10619. string postCode = CurrentUser.UserPost.Post.Code;
  10620. string shopIds = CurrentUser.User.pemShop;
  10621. DataStruct dStruct = GetPostStruct();
  10622. List<string> lw = new List<string>();
  10623. DateTime currentTime = DateTime.Now;
  10624. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10625. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10626. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10627. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10628. string startTime = "2023-10-01 11:22:31";
  10629. int order_type = GetPostInt("order_type");
  10630. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10631. {
  10632. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10633. if (order_type == 0)
  10634. {
  10635. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10636. }
  10637. else if (order_type == 3)
  10638. {
  10639. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10640. }
  10641. else
  10642. {
  10643. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10644. }
  10645. }
  10646. //客服
  10647. if (postCode == "CustomerService" || postCode == "Director")
  10648. {
  10649. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10650. if (order_type == 0)
  10651. {
  10652. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10653. }
  10654. else if (order_type == 1)
  10655. {
  10656. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10657. }
  10658. else if (order_type == 2)
  10659. {
  10660. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10661. }
  10662. else if (order_type == 3)
  10663. {
  10664. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10665. }
  10666. else if (order_type == 4)
  10667. {
  10668. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10669. }
  10670. else
  10671. {
  10672. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10673. }
  10674. }
  10675. //售后
  10676. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10677. {
  10678. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10679. if (shopIds != "")
  10680. {
  10681. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10682. }
  10683. if (order_type == 2)
  10684. {
  10685. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10686. }
  10687. else if (order_type == 4)
  10688. {
  10689. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10690. }
  10691. else if (order_type == 5)
  10692. {
  10693. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10694. }
  10695. else
  10696. {
  10697. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10698. }
  10699. }
  10700. //下单部
  10701. if (postCode == "Place" || postCode == "PlaceMr")
  10702. {
  10703. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10704. if (shopIds != "")
  10705. {
  10706. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10707. }
  10708. else if (order_type == 1)
  10709. {
  10710. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10711. }
  10712. else if (order_type == 2)
  10713. {
  10714. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10715. }
  10716. else
  10717. {
  10718. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10719. }
  10720. }
  10721. //车间
  10722. if (postCode == "Supplier")
  10723. {
  10724. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10725. if (order_type == 5)
  10726. {
  10727. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10728. }
  10729. else
  10730. {
  10731. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10732. }
  10733. }
  10734. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10735. dStruct.Fileds = "tid,ctid";
  10736. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10737. writeGridDataTableJson(dStruct.TotalCount, dt);
  10738. }
  10739. public void aftersale_audit_master()
  10740. {
  10741. if (UrlPostParmsCheck("ctid"))
  10742. {
  10743. string ctid = GetPostString("ctid");
  10744. if (ctid.Length > 0)
  10745. {
  10746. bool result = aftersale_data_change(ctid);
  10747. if (result)
  10748. {
  10749. returnSuccessMsg("修改成功!");
  10750. return;
  10751. }
  10752. }
  10753. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10754. }
  10755. }
  10756. public void aftersale_batch_audit_master()
  10757. {
  10758. if (UrlPostParmsCheck("ctids"))
  10759. {
  10760. string ctids = GetPostString("ctids");
  10761. if (ctids.Length > 0)
  10762. {
  10763. List<string> list = new List<string>();
  10764. string[] ctid_list = ctids.Split(',');
  10765. foreach (var item in ctid_list)
  10766. {
  10767. bool result = aftersale_data_change(item);
  10768. if (!result)
  10769. {
  10770. list.Add(item);
  10771. }
  10772. }
  10773. if (list.Count > 0)
  10774. {
  10775. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10776. return;
  10777. }
  10778. returnSuccessMsg("修改成功!");
  10779. return;
  10780. }
  10781. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10782. }
  10783. }
  10784. public bool aftersale_data_change(string ctid)
  10785. {
  10786. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10787. if (ceErpTradeCell != null)
  10788. {
  10789. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10790. ceErpTradeCell.AfterSaleSupplierState = 0;
  10791. StringBuilder sql = new StringBuilder();
  10792. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10793. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10794. CeErpTradeResponsible.DelByTid(ctid, 0);
  10795. 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 == "不理赔")
  10796. {
  10797. CeErpTradeResponsible.DelByTid(ctid, 1);
  10798. ceErpTradeCell.AfterSaleSupplierState = 1;
  10799. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10800. ceErpTradeCell.AfterSaleState = 4;
  10801. }
  10802. else
  10803. {
  10804. ceErpTradeCell.AfterSaleState = 3;
  10805. }
  10806. bool needCyt = false;
  10807. if (dt != null)
  10808. {
  10809. if (dt.Rows.Count == 1)
  10810. {
  10811. bool isEnd = false;
  10812. foreach (DataRow dr in dt.Rows)
  10813. {
  10814. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10815. {
  10816. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10817. isEnd = true;
  10818. }
  10819. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10820. {
  10821. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10822. isEnd = true;
  10823. }
  10824. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10825. {
  10826. needCyt = true;
  10827. }
  10828. }
  10829. if (isEnd)
  10830. {
  10831. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10832. ceErpTradeCell.AfterSaleState = 4;
  10833. ceErpTradeCell.AfterSaleSupplierState = 1;
  10834. }
  10835. }
  10836. else
  10837. {
  10838. bool isAll = true;
  10839. foreach (DataRow dr in dt.Rows)
  10840. {
  10841. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10842. {
  10843. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10844. continue;
  10845. }
  10846. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10847. {
  10848. string path = "";
  10849. int OrgID = 0;
  10850. if (!Convert.IsDBNull(dr["OrgPath"]))
  10851. {
  10852. path = dr["OrgPath"].ToString();
  10853. }
  10854. if (!Convert.IsDBNull(dr["OrgID"]))
  10855. {
  10856. OrgID = Convert.ToInt32(dr["OrgID"]);
  10857. }
  10858. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10859. {
  10860. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10861. continue;
  10862. }
  10863. }
  10864. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10865. {
  10866. needCyt = true;
  10867. }
  10868. isAll = false;
  10869. }
  10870. if (isAll)
  10871. {
  10872. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10873. ceErpTradeCell.AfterSaleState = 4;
  10874. ceErpTradeCell.AfterSaleSupplierState = 1;
  10875. }
  10876. }
  10877. }
  10878. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10879. {
  10880. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10881. }
  10882. if (ceErpTradeCell.AfterSaleState == 4)
  10883. {
  10884. ApiVo apiVo = new ApiVo();
  10885. apiVo.orderNumber = ceErpTradeCell.ctid;
  10886. apiVo.actionName = "afterOver";
  10887. designHelper.API_WorkCore(apiVo); //afterOver
  10888. }
  10889. ceErpTradeCell.Update();
  10890. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10891. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10892. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10893. return true;
  10894. }
  10895. return false;
  10896. }
  10897. public void get_erp_wechatorder()
  10898. {
  10899. DataStruct dStruct = GetPostStruct();
  10900. List<string> lw = new List<string>();
  10901. string tid = GetPostString("tid");
  10902. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10903. string shopname = GetPostString("shopname");
  10904. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10905. string buyernick = GetPostString("buyer_nick");
  10906. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10907. string customer = GetPostString("customer");
  10908. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10909. string returndate1 = GetPostString("returndate1");
  10910. string returndate2 = GetPostString("returndate2");
  10911. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10912. if (dw.Length > 0) lw.Add(dw);
  10913. string finishDate1 = GetPostString("finishdate1");
  10914. string finishDate2 = GetPostString("finishdate2");
  10915. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10916. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10917. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10918. dStruct.Order = "created desc";
  10919. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10920. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10921. writeGridDataTableJson(dStruct.TotalCount, dt);
  10922. }
  10923. public void get_erp_wechatlist_sumprice()
  10924. {
  10925. DataStruct dStruct = GetPostStruct();
  10926. List<string> lw = new List<string>();
  10927. string tid = GetPostString("tid");
  10928. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10929. string shopname = GetPostString("shopname");
  10930. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10931. string buyernick = GetPostString("buyer_nick");
  10932. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10933. string customer = GetPostString("customer");
  10934. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10935. string returndate1 = GetPostString("returndate1");
  10936. string returndate2 = GetPostString("returndate2");
  10937. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10938. if (dw.Length > 0) lw.Add(dw);
  10939. string finishDate1 = GetPostString("finishdate1");
  10940. string finishDate2 = GetPostString("finishdate2");
  10941. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10942. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10943. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10944. string mainWhere = string.Join(" and ", lw.ToArray());
  10945. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10946. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10947. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10948. decimal total = 0;
  10949. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10950. {
  10951. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10952. }
  10953. var res = new
  10954. {
  10955. data = total
  10956. };
  10957. string ro_jsond = JsonConvert.SerializeObject(res);
  10958. returnSuccess(ro_jsond);
  10959. return;
  10960. }
  10961. public void get_erp_qr_waitdeliverylist()
  10962. {
  10963. DataStruct dStruct = GetPostStruct();
  10964. List<string> lw = new List<string>();
  10965. string tid = GetPostString("ctid");
  10966. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10967. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10968. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10969. var res_objz = new
  10970. {
  10971. restype = 1,
  10972. data = dt
  10973. };
  10974. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10975. returnSuccess(ro_jsonz);
  10976. }
  10977. public void get_erp_yield_list()
  10978. {
  10979. DataStruct dStruct = GetPostStruct();
  10980. List<string> lw = new List<string>();
  10981. string tid = GetPostString("ctid");
  10982. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10983. string shopname = GetPostString("shopname");
  10984. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10985. string buyernick = GetPostString("buyer_nick");
  10986. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10987. //if (tid.Length == 0 && buyernick.Length == 0)
  10988. //{
  10989. // lw.Add(string.Format("IsRefund<={0}", 1));
  10990. //}
  10991. string customer = GetPostString("customer");
  10992. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10993. string design = GetPostString("design");
  10994. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10995. string orderState = GetPostString("orderState");
  10996. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10997. string address = GetPostString("address");
  10998. 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));
  10999. string sellermemo = GetPostString("seller_memo");
  11000. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11001. string supplier = GetPostString("supplier");
  11002. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11003. string OrderArea = GetPostString("order_area");
  11004. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11005. string placedate1 = GetPostString("placedate1");
  11006. string placedate2 = GetPostString("placedate2");
  11007. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11008. if (fdw.Length > 0) lw.Add(fdw);
  11009. string price1 = GetPostString("price1");
  11010. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11011. string price2 = GetPostString("price2");
  11012. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11013. string unusualCon = GetPostString("unusualcon");
  11014. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11015. string posTag = CurrentUser.UserPost.Post.Code;
  11016. if (posTag == "Supplier")
  11017. {
  11018. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11019. }
  11020. lw.Add(string.Format("OrderState = 6 "));
  11021. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11022. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11023. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11024. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11025. writeGridDataTableJson(dStruct.TotalCount, dt);
  11026. }
  11027. public void change_erp_sup_state()
  11028. {
  11029. if (UrlPostParmsCheck("ctid"))
  11030. {
  11031. string ctid = GetPostString("ctid");
  11032. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11033. if (ceErpTradeCell != null)
  11034. {
  11035. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11036. if (ceErpTradeCellExtend == null)
  11037. {
  11038. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11039. ceErpTradeCellExtend.ctid = ctid;
  11040. ceErpTradeCellExtend.SupState = 1;
  11041. ceErpTradeCellExtend.Create();
  11042. }
  11043. else
  11044. {
  11045. ceErpTradeCellExtend.SupState = 1;
  11046. ceErpTradeCellExtend.Update();
  11047. }
  11048. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11049. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11050. return;
  11051. }
  11052. returnErrorMsg("找不到订单");
  11053. }
  11054. }
  11055. public void supplier_all_downs()
  11056. {
  11057. if (UrlPostParmsCheck("tids"))
  11058. {
  11059. string tids = GetPostString("tids");
  11060. if (tids != null && tids.Length > 0)
  11061. {
  11062. StringBuilder sql = new StringBuilder();
  11063. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11064. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11065. sql = new StringBuilder();
  11066. 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, "下载设计文件");
  11067. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11068. string[] list = tids.Split(',');
  11069. foreach (string ctid in list)
  11070. {
  11071. CeErpSukuraData.createInfo(ctid, 3);
  11072. }
  11073. designHelper.api_approveDesign(tids); //approveDesign
  11074. returnSuccessMsg("下载成功!");
  11075. return;
  11076. }
  11077. returnErrorMsg("下载订单更新失败");
  11078. }
  11079. }
  11080. public void uploaderFileSuccess()
  11081. {
  11082. if (UrlPostParmsCheck("fileName"))
  11083. {
  11084. string fileName = GetPostString("fileName");
  11085. ApiVo apiVo = new ApiVo();
  11086. apiVo.orderNumber = fileName;
  11087. apiVo.actionName = "finishDesign";
  11088. designHelper.API_WorkCore(apiVo);//finishDesign
  11089. returnSuccessMsg("");
  11090. }
  11091. }
  11092. public void get_sample2_order()
  11093. {
  11094. if (UrlPostParmsCheck("ctid"))
  11095. {
  11096. string ctid = GetPostString("ctid");
  11097. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11098. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11099. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11100. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11101. double total = 0.0;
  11102. double order_price = 0.0;
  11103. if (dt_bu.Rows.Count > 0)
  11104. {
  11105. foreach (DataRow dr in dt_bu.Rows)
  11106. {
  11107. total += Convert.ToDouble(dr["payment"]);
  11108. }
  11109. }
  11110. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11111. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11112. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11113. string tid = ctid.Replace("S_", "");
  11114. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11115. double paymant = 0.0;
  11116. if (entity != null)
  11117. {
  11118. paymant = entity.payment;
  11119. }
  11120. string return_reason = "";
  11121. if (dt_after != null && dt_after.Rows.Count > 0)
  11122. {
  11123. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11124. }
  11125. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11126. }
  11127. }
  11128. public void get_erp_design_status()
  11129. {
  11130. string designName = GetPostString("designName");
  11131. DataStruct dStruct = GetPostStruct();
  11132. if (designName.Length > 0)
  11133. {
  11134. 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";
  11135. sql_user += " and Name like '%" + designName + "%'";
  11136. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11137. List<string> ids_list = new List<string>();
  11138. if (user_table.Rows.Count > 0)
  11139. {
  11140. foreach (DataRow item in user_table.Rows)
  11141. {
  11142. ids_list.Add(item["id"].ToString());
  11143. string ids_s = item["TeamIds"].ToString();
  11144. if (ids_s.Length > 0)
  11145. {
  11146. ids_list.AddRange(ids_s.Split(','));
  11147. }
  11148. }
  11149. }
  11150. HashSet<string> set = new HashSet<string>(ids_list);
  11151. ids_list = set.ToList();
  11152. if (ids_list.Count > 0)
  11153. {
  11154. 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));
  11155. dStruct.MainWhere = sql;
  11156. DataTable dt = null;
  11157. dt = WebCache.GetData("view_ErpUser", dStruct);
  11158. writeGridDataTableJson(dStruct.TotalCount, dt);
  11159. }
  11160. }
  11161. }
  11162. public void change_erp_order_price()
  11163. {
  11164. string ctid = GetPostString("ctid");
  11165. double price = GetPostDouble("price");
  11166. if (ctid.Length > 0)
  11167. {
  11168. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11169. if (ceErpTradeCellExtend == null)
  11170. {
  11171. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11172. ceErpTradeCellExtend.ctid = ctid;
  11173. ceErpTradeCellExtend.payment_cyt = price;
  11174. ceErpTradeCellExtend.Create();
  11175. }
  11176. else
  11177. {
  11178. ceErpTradeCellExtend.payment_cyt = price;
  11179. ceErpTradeCellExtend.Update();
  11180. }
  11181. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11182. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11183. {
  11184. ceErpDataSendOrderInfo.isSync = false;
  11185. ceErpDataSendOrderInfo.Update();
  11186. }
  11187. if (ceErpDataSendOrderInfo == null)
  11188. {
  11189. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11190. ceErpDataSendOrderInfo.isSync = false;
  11191. ceErpDataSendOrderInfo.ctid = ctid;
  11192. ceErpDataSendOrderInfo.Create();
  11193. }
  11194. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11195. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11196. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11197. if (dth != null && dth.Rows.Count > 0)
  11198. {
  11199. dataSendOrderBean dataSendOrderBean = null;
  11200. foreach (DataRow item in dth.Rows)
  11201. {
  11202. try
  11203. {
  11204. dataSendOrderBean = new dataSendOrderBean();
  11205. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11206. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11207. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11208. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11209. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11210. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11211. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11212. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11213. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11214. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11215. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11216. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11217. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11218. if (result != null)
  11219. {
  11220. if ("0".Equals(result.errcode))
  11221. {
  11222. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11223. }
  11224. else
  11225. {
  11226. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11227. }
  11228. }
  11229. }
  11230. catch (Exception ex)
  11231. {
  11232. }
  11233. }
  11234. }
  11235. returnSuccessMsg("修改成功!");
  11236. return;
  11237. }
  11238. returnErrorMsg("找不到订单");
  11239. }
  11240. public void find_he_together()
  11241. {
  11242. string ctid = GetPostString("ctid");
  11243. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11244. List<string> list = new List<string>();
  11245. if (ceErpTradeCell != null)
  11246. {
  11247. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11248. {
  11249. 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);
  11250. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11251. if (table != null && table.Rows.Count > 0)
  11252. {
  11253. foreach (TableRow row in table.Rows)
  11254. {
  11255. }
  11256. }
  11257. }
  11258. }
  11259. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11260. }
  11261. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11262. {
  11263. //chy----19
  11264. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11265. //GD-CYT-----64
  11266. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11267. //ZHX----3
  11268. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11269. //JK----97
  11270. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11271. //ZT----70
  11272. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11273. //LHCY-----98
  11274. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11275. //XD-----90
  11276. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11277. //CYCY-----14
  11278. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11279. };
  11280. //其他改名
  11281. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11282. {
  11283. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11284. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11285. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11286. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11287. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11288. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11289. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11290. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11291. };
  11292. //不统计
  11293. List<int> no_suppliers = new List<int>()
  11294. {
  11295. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11296. };
  11297. //配件单
  11298. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11299. {
  11300. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11301. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11302. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11303. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11304. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11305. {"旗杆",new List<string>(){ "班旗" } },
  11306. {"牙签",new List<string>(){ "不干胶" } }
  11307. };
  11308. public void get_place_order_data()
  11309. {
  11310. string date1 = GetPostString("date1");
  11311. string date2 = GetPostString("date2");
  11312. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11313. DateTime start = DateTime.Parse(starttime);
  11314. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11315. DateTime end = DateTime.Parse(endtime);
  11316. if (date1 != null && date1.Length > 0)
  11317. {
  11318. DateTime dateTime = DateTime.Parse(date1);
  11319. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11320. start = DateTime.Parse(starttime);
  11321. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11322. end = DateTime.Parse(endtime);
  11323. }
  11324. if (date2 != null && date2.Length > 0)
  11325. {
  11326. DateTime dateTime = DateTime.Parse(date2);
  11327. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11328. end = DateTime.Parse(endtime);
  11329. }
  11330. 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);
  11331. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11332. //不干胶-----1,卡片-----29
  11333. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11334. foreach (DataRow row in data.Rows)
  11335. {
  11336. int productId = Convert.ToInt32(row["ProductId"]);
  11337. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11338. if (no_suppliers.Contains(supplierId))
  11339. {
  11340. continue;
  11341. }
  11342. string seller_memo = row["seller_memo"].ToString();
  11343. bool ispj = false;//是否配件单
  11344. bool isfirst = true;//第一个配
  11345. maps.Keys.ForEach(key =>
  11346. {
  11347. //备注包含配件
  11348. if (seller_memo.Contains(key) && isfirst)
  11349. {
  11350. List<string> list = maps[key];
  11351. ispj = true;
  11352. isfirst = false;
  11353. for (int i = 0; i < list.Count; i++)
  11354. {
  11355. if (seller_memo.Contains(list[i]))
  11356. {
  11357. ispj = false;
  11358. break;
  11359. }
  11360. }
  11361. }
  11362. });
  11363. if (ispj)
  11364. {
  11365. continue;
  11366. }
  11367. seller_memo = seller_memo.Replace("UV", "uv");
  11368. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11369. //吊牌归到卡片
  11370. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11371. seller_memo = seller_memo.Replace("卡套", "卡片");
  11372. seller_memo = seller_memo.Replace("封套", "卡片");
  11373. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11374. seller_memo = seller_memo.Replace("腰封", "卡片");
  11375. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11376. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11377. seller_memo = seller_memo.Replace("横幅", "条幅");
  11378. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11379. string map_key = "";
  11380. string type = "";
  11381. if (supplierMap.ContainsKey(supplierId))
  11382. {
  11383. foreach (var kvp in supplierMap[supplierId])
  11384. {
  11385. if (seller_memo.Contains(kvp.Key))
  11386. {
  11387. map_key = kvp.Value;
  11388. type = kvp.Value;
  11389. break;
  11390. }
  11391. }
  11392. }
  11393. if (map_key == "")
  11394. {
  11395. type = "其他";
  11396. map_key = "其他";
  11397. }
  11398. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11399. {
  11400. map_key = suppliers[supplierId];
  11401. }
  11402. if (supplierId == 70)
  11403. {
  11404. supplierId = 70;
  11405. }
  11406. map_key += "_" + row["SupplierName"].ToString();
  11407. Dictionary<string, int> map = null;
  11408. if (other_map.ContainsKey(map_key))
  11409. {
  11410. other_map.TryGetValue(map_key, out map);
  11411. }
  11412. else
  11413. {
  11414. map = new Dictionary<string, int>();
  11415. map.Add("dayDev", 0);//当天出货
  11416. map.Add("dayTotal", 0);//下单总数
  11417. map.Add("payTotal", 0);//500以上
  11418. map.Add("today", 0);//当天出货数量
  11419. map.Add("unusua", 0);//异常数
  11420. other_map.Add(map_key, map);
  11421. other_map.TryGetValue(map_key, out map);
  11422. }
  11423. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11424. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11425. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11426. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11427. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11428. {
  11429. map["dayTotal"]++;
  11430. if (supplierId == 97)
  11431. {
  11432. supplierId = 97;
  11433. }
  11434. }
  11435. if (Convert.ToDecimal(row["payment"]) >= 500)
  11436. {
  11437. map["payTotal"]++;
  11438. }
  11439. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11440. {
  11441. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11442. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11443. {
  11444. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11445. {
  11446. map["today"]++;
  11447. }
  11448. }
  11449. else
  11450. {
  11451. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11452. {
  11453. map["today"]++;
  11454. }
  11455. else
  11456. {
  11457. if (supplierId == 119)
  11458. {
  11459. Debug.WriteLine(row["seller_memo"].ToString());
  11460. }
  11461. }
  11462. }
  11463. }
  11464. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11465. {
  11466. map["unusua"]++;
  11467. }
  11468. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11469. //GD-CYT-----64
  11470. DateTime two = palceTimeStart.AddHours(14);
  11471. DateTime three = palceTimeStart.AddHours(15);
  11472. DateTime four = palceTimeStart.AddHours(16);
  11473. DateTime six = palceTimeStart.AddHours(18);
  11474. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11475. {
  11476. //下午四点前 500-1000
  11477. string count = row["ProductCount"].ToString();
  11478. if (count != null && count.Length > 0)
  11479. {
  11480. int productCount = commonHelper.getPlaceProductCount(count);
  11481. if (productCount >= 500 && productCount <= 1000)
  11482. {
  11483. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11484. {
  11485. map["dayDev"]++;
  11486. }
  11487. }
  11488. }
  11489. }
  11490. //UV
  11491. else if ("uv".Equals(type))
  11492. {
  11493. //ZT----70
  11494. //ZHX----3
  11495. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11496. {
  11497. map["dayDev"]++;
  11498. }
  11499. //JK----97
  11500. //HZX----105
  11501. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11502. {
  11503. map["dayDev"]++;
  11504. }
  11505. }
  11506. //帆布---52|条幅---27
  11507. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11508. {
  11509. //LHCY-----98
  11510. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11511. {
  11512. map["dayDev"]++;
  11513. }
  11514. }
  11515. //条幅
  11516. else if ("条幅".Equals(type))
  11517. {
  11518. //XD-----90
  11519. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11520. {
  11521. map["dayDev"]++;
  11522. }
  11523. }
  11524. //桌布
  11525. else if ("桌布".Equals(type))
  11526. {
  11527. //XD-----90
  11528. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11529. {
  11530. map["dayDev"]++;
  11531. }
  11532. }
  11533. //DL---10
  11534. //AYTW---119
  11535. //FS-CYT-DY ----80
  11536. //JK----97
  11537. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11538. {
  11539. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11540. {
  11541. map["dayDev"]++;
  11542. }
  11543. }
  11544. // QC---121
  11545. else if (supplierId == 121)
  11546. {
  11547. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11548. {
  11549. map["dayDev"]++;
  11550. }
  11551. }
  11552. }
  11553. DataTable dt = new DataTable();
  11554. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11555. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11556. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11557. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11558. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11559. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11560. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11561. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11562. other_map.Keys.ForEach(key =>
  11563. {
  11564. DataRow dr = dt.NewRow();
  11565. Dictionary<string, int> map = other_map[key];
  11566. string[] key_list = key.Split('_');
  11567. dr[0] = key_list[0];
  11568. dr[1] = key_list[1];
  11569. if (key_list.Length > 2)
  11570. {
  11571. dr[1] += "(" + key_list[2] + ")";
  11572. }
  11573. dr[2] = map["dayTotal"];
  11574. dr[3] = map["payTotal"];
  11575. dr[4] = map["today"];
  11576. dr[5] = map["unusua"];
  11577. dr[6] = map["dayDev"];
  11578. double rate = 0.00;
  11579. if (map["dayDev"] > 0)
  11580. {
  11581. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11582. }
  11583. dr[7] = rate.ToString();
  11584. dt.Rows.Add(dr);
  11585. });
  11586. DataView dv = new DataView(dt);
  11587. dv.Sort = "SupplierName";
  11588. //dv.Sort = "AllOrder desc";
  11589. DataTable dtNew = dv.ToTable();
  11590. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11591. }
  11592. public void check_order_desing_info()
  11593. {
  11594. string ctid = GetPostString("ctid");
  11595. if (!string.IsNullOrEmpty(ctid))
  11596. {
  11597. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11598. if (ceErpTradeCell != null)
  11599. {
  11600. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11601. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11602. return;
  11603. }
  11604. returnErrorMsg("找不到订单");
  11605. return;
  11606. }
  11607. returnErrorMsg("找不到订单");
  11608. }
  11609. public void get_timeout_detail()
  11610. {
  11611. string poscode = CurrentUser.UserPost.Post.Code;
  11612. DataStruct dStruct = GetPostStruct();
  11613. List<string> lw = new List<string>();
  11614. string id = GetPostString("id");
  11615. string pay_date1 = GetPostString("pay_date1");
  11616. string pay_date2 = GetPostString("pay_date2");
  11617. int type = GetPostInt("type");
  11618. if (type == 0)
  11619. {
  11620. if (pay_date1.Length > 0)
  11621. {
  11622. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11623. }
  11624. if (pay_date2.Length > 0)
  11625. {
  11626. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11627. }
  11628. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11629. }
  11630. if (type == 1)
  11631. {
  11632. if (pay_date1.Length > 0)
  11633. {
  11634. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11635. }
  11636. if (pay_date2.Length > 0)
  11637. {
  11638. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11639. }
  11640. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11641. }
  11642. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11643. DataTable dt = null;
  11644. dt = WebCache.GetData("view_orderlist", dStruct);
  11645. writeGridDataTableJson(dStruct.TotalCount, dt);
  11646. }
  11647. public void saveUrgentChargePrice()
  11648. {
  11649. string ctid = GetPostString("ctid");
  11650. if (!string.IsNullOrEmpty(ctid))
  11651. {
  11652. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11653. if (ceErpTradeCell != null)
  11654. {
  11655. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11656. if (prices <= 100)
  11657. {
  11658. returnErrorMsg("此订单金额不足100元,无法加急。");
  11659. return;
  11660. }
  11661. double price = GetPostDouble("price");
  11662. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11663. if (ceErpTradeCellExtend == null)
  11664. {
  11665. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11666. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11667. }
  11668. ceErpTradeCellExtend.urgentCharge = price;
  11669. if (ceErpTradeCellExtend.ID > 0)
  11670. {
  11671. ceErpTradeCellExtend.Update();
  11672. }
  11673. else
  11674. {
  11675. ceErpTradeCellExtend.Save();
  11676. }
  11677. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11678. returnSuccessMsg("修改成功!");
  11679. return;
  11680. }
  11681. returnErrorMsg("找不到订单");
  11682. return;
  11683. }
  11684. returnErrorMsg("找不到订单");
  11685. }
  11686. public void finish_erp_order()
  11687. {
  11688. string ctid = GetPostString("ctid");
  11689. if (!string.IsNullOrEmpty(ctid))
  11690. {
  11691. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11692. {
  11693. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11694. if (ceErpTradeCell != null)
  11695. {
  11696. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11697. ceErpTradeCell.Update();
  11698. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11699. returnSuccessMsg("修改成功!");
  11700. return;
  11701. }
  11702. }
  11703. }
  11704. returnErrorMsg("找不到订单");
  11705. }
  11706. public void get_trade_order_list()
  11707. {
  11708. string tid = GetPostString("tid");
  11709. if (!string.IsNullOrEmpty(tid))
  11710. {
  11711. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11712. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11713. writeGridDataTableJson(data.Rows.Count, data);
  11714. return;
  11715. }
  11716. returnErrorMsg("找不到订单");
  11717. }
  11718. public void save_cell_spu()
  11719. {
  11720. string ctid = GetPostString("ctid");
  11721. string spu_id = GetPostString("spu_id");
  11722. if (!string.IsNullOrEmpty(ctid))
  11723. {
  11724. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11725. if (ceErpTradeCellExtend == null)
  11726. {
  11727. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11728. ceErpTradeCellExtend.ctid = ctid;
  11729. }
  11730. ceErpTradeCellExtend.spu_id = spu_id;
  11731. if (!string.IsNullOrEmpty(spu_id))
  11732. {
  11733. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11734. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11735. }
  11736. if (ceErpTradeCellExtend.ID == 0)
  11737. {
  11738. ceErpTradeCellExtend.Create();
  11739. }
  11740. else
  11741. {
  11742. ceErpTradeCellExtend.Update();
  11743. }
  11744. returnSuccessMsg("修改成功!");
  11745. return;
  11746. }
  11747. returnErrorMsg("找不到订单");
  11748. }
  11749. public void change_express_info()
  11750. {
  11751. string ctid = GetPostString("ctid");
  11752. string transNo = GetPostString("transNo");
  11753. string transCom = GetPostString("transCom");
  11754. if (!string.IsNullOrEmpty(ctid))
  11755. {
  11756. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11757. if (ceErpTradeCellExtend == null)
  11758. {
  11759. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11760. ceErpTradeCellExtend.ctid = ctid;
  11761. }
  11762. ceErpTradeCellExtend.modExpressNo = transNo;
  11763. ceErpTradeCellExtend.modExpressCom = transCom;
  11764. ceErpTradeCellExtend.readMod = 2;
  11765. if (ceErpTradeCellExtend.ID == 0)
  11766. {
  11767. ceErpTradeCellExtend.Create();
  11768. }
  11769. else
  11770. {
  11771. ceErpTradeCellExtend.Update();
  11772. }
  11773. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11774. returnSuccessMsg("修改成功!");
  11775. return;
  11776. }
  11777. returnErrorMsg("找不到订单");
  11778. }
  11779. public void get_change_express_list()
  11780. {
  11781. DataStruct dStruct = GetPostStruct();
  11782. List<string> lw = new List<string>();
  11783. int st = 2;
  11784. string tid = GetPostString("ctid");
  11785. if (tid.Length > 0)
  11786. {
  11787. string select_tid = getTidByCtid(tid);
  11788. lw.Add(string.Format("tid='{0}'", select_tid));
  11789. }
  11790. string shopname = GetPostString("shopname");
  11791. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11792. string buyernick = GetPostString("buyer_nick");
  11793. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11794. string sellermemo = GetPostString("seller_memo");
  11795. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11796. string supplier = GetPostString("supplier");
  11797. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11798. string customer = GetPostString("customer");
  11799. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11800. string design = GetPostString("design");
  11801. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11802. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11803. string poscode = CurrentUser.UserPost.Post.Code;
  11804. if (poscode != "SysAdmin")
  11805. {
  11806. string shopid = CurrentUser.User.pemShop;
  11807. lw.Add(string.Format("shopId in ({0})", shopid));
  11808. }
  11809. lw.Add("readMod = 2");
  11810. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11811. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11812. writeGridDataTableJson(dStruct.TotalCount, dt);
  11813. }
  11814. public void deal_express_complete()
  11815. {
  11816. string ctid = GetPostString("ctid");
  11817. if (!string.IsNullOrEmpty(ctid))
  11818. {
  11819. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11820. if (ceErpTradeCellExtend == null)
  11821. {
  11822. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11823. ceErpTradeCellExtend.ctid = ctid;
  11824. }
  11825. ceErpTradeCellExtend.readMod = 1;
  11826. if (ceErpTradeCellExtend.ID == 0)
  11827. {
  11828. ceErpTradeCellExtend.Create();
  11829. }
  11830. else
  11831. {
  11832. ceErpTradeCellExtend.Update();
  11833. }
  11834. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11835. returnSuccessMsg("修改成功!");
  11836. return;
  11837. }
  11838. returnErrorMsg("找不到订单");
  11839. }
  11840. public void aftersale_return_visit()
  11841. {
  11842. string ctid = GetPostString("ctid");
  11843. if (!string.IsNullOrEmpty(ctid))
  11844. {
  11845. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11846. if (ceErpTradeCellExtend == null)
  11847. {
  11848. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11849. ceErpTradeCellExtend.ctid = ctid;
  11850. }
  11851. ceErpTradeCellExtend.returnVisit = 1;
  11852. if (ceErpTradeCellExtend.ID == 0)
  11853. {
  11854. ceErpTradeCellExtend.Create();
  11855. }
  11856. else
  11857. {
  11858. ceErpTradeCellExtend.Update();
  11859. }
  11860. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11861. if (ceErpTradeAfterSaleExtend != null)
  11862. {
  11863. ceErpTradeAfterSaleExtend.TextResult = "";
  11864. ceErpTradeAfterSaleExtend.Update();
  11865. }
  11866. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11867. returnSuccessMsg("修改成功!");
  11868. return;
  11869. }
  11870. returnErrorMsg("找不到订单");
  11871. }
  11872. public void orderPlaceInfo()
  11873. {
  11874. string ctids = GetPostString("ctids");
  11875. string[] list = ctids.Split(',');
  11876. foreach (string ctid in list)
  11877. {
  11878. CeErpSukuraData.createInfo(ctid, 3);
  11879. }
  11880. StringBuilder sql = new StringBuilder();
  11881. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11882. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11883. designHelper.api_approveDesign(ctids); //approveDesign
  11884. returnSuccessMsg("");
  11885. }
  11886. public void get_issue_list()
  11887. {
  11888. DataStruct dStruct = GetPostStruct();
  11889. List<string> lw = new List<string>();
  11890. int st = 2;
  11891. string tid = GetPostString("ctid");
  11892. if (tid.Length > 0)
  11893. {
  11894. string select_tid = getTidByCtid(tid);
  11895. lw.Add(string.Format("tid='{0}'", select_tid));
  11896. }
  11897. string shopname = GetPostString("shopname");
  11898. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11899. string buyernick = GetPostString("buyer_nick");
  11900. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11901. string sellermemo = GetPostString("seller_memo");
  11902. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11903. string supplier = GetPostString("supplier");
  11904. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11905. string customer = GetPostString("customer");
  11906. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11907. string design = GetPostString("design");
  11908. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11909. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11910. string poscode = CurrentUser.UserPost.Post.Code;
  11911. if (poscode != "SysAdmin")
  11912. {
  11913. string shopid = CurrentUser.User.pemShop;
  11914. lw.Add(string.Format("shopId in ({0})", shopid));
  11915. }
  11916. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11917. {
  11918. lw.Add("IssueState = 1");
  11919. }
  11920. lw.Add("IssueState > 0");
  11921. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11922. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11923. writeGridDataTableJson(dStruct.TotalCount, dt);
  11924. }
  11925. public void saveIssueContent()
  11926. {
  11927. string ctid = GetPostString("ctid");
  11928. if (!string.IsNullOrEmpty(ctid))
  11929. {
  11930. string content = GetPostString("content");
  11931. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11932. if (ceErpTradeAfterSaleExtend == null)
  11933. {
  11934. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11935. ceErpTradeAfterSaleExtend.tid = ctid;
  11936. }
  11937. ceErpTradeAfterSaleExtend.IssueContent = content;
  11938. ceErpTradeAfterSaleExtend.IssueState = 1;
  11939. if (ceErpTradeAfterSaleExtend.ID > 0)
  11940. {
  11941. ceErpTradeAfterSaleExtend.Update();
  11942. }
  11943. else
  11944. {
  11945. ceErpTradeAfterSaleExtend.Create();
  11946. }
  11947. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11948. returnSuccessMsg("添加成功!");
  11949. return;
  11950. }
  11951. returnErrorMsg("找不到订单");
  11952. }
  11953. public void dealIssueContent()
  11954. {
  11955. string ctid = GetPostString("ctid");
  11956. if (!string.IsNullOrEmpty(ctid))
  11957. {
  11958. string content = GetPostString("content");
  11959. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11960. if (ceErpTradeAfterSaleExtend != null)
  11961. {
  11962. ceErpTradeAfterSaleExtend.IssueState = 2;
  11963. ceErpTradeAfterSaleExtend.Update();
  11964. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11965. returnSuccessMsg("修改完成!");
  11966. return;
  11967. }
  11968. }
  11969. returnErrorMsg("找不到订单");
  11970. }
  11971. public void set_tid_attachments()
  11972. {
  11973. string tid = GetPostString("tid");
  11974. string atta = GetPostString("atta");
  11975. if (!string.IsNullOrEmpty(tid))
  11976. {
  11977. if (string.IsNullOrEmpty(atta))
  11978. {
  11979. returnErrorMsg("文件地址为空");
  11980. return;
  11981. }
  11982. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11983. if (ceErpTradeCell != null)
  11984. {
  11985. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11986. if (ceErpTrade == null)
  11987. {
  11988. returnErrorMsg("找不到订单");
  11989. return;
  11990. }
  11991. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11992. bool isSend = false;
  11993. if (dt != null && dt.Rows.Count > 0)
  11994. {
  11995. foreach (DataRow row in dt.Rows)
  11996. {
  11997. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11998. {
  11999. isSend = true;
  12000. }
  12001. }
  12002. if (isSend)
  12003. {
  12004. returnErrorMsg("已发货无法修改");
  12005. return;
  12006. }
  12007. ceErpTrade.Attachments = atta;
  12008. ceErpTrade.Update();
  12009. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12010. returnSuccessMsg("上传成功!");
  12011. return;
  12012. }
  12013. }
  12014. }
  12015. returnErrorMsg("找不到订单");
  12016. }
  12017. public void get_tid_attachments()
  12018. {
  12019. string tid = GetPostString("tid");
  12020. if (!string.IsNullOrEmpty(tid))
  12021. {
  12022. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12023. if (ceErpTradeCell != null)
  12024. {
  12025. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12026. if (ceErpTrade == null)
  12027. {
  12028. returnErrorMsg("找不到订单");
  12029. return;
  12030. }
  12031. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12032. return;
  12033. }
  12034. }
  12035. returnErrorMsg("找不到订单");
  12036. }
  12037. public void check_erp_sameorders()
  12038. {
  12039. if (UrlPostParmsCheck("ctid"))
  12040. {
  12041. string eid = GetPostString("ctid");
  12042. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12043. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12044. if (entity != null && ceErpTrade != null)
  12045. {
  12046. if (entity.OrderState > 6)
  12047. {
  12048. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12049. return;
  12050. }
  12051. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12052. List<string> ids = new List<string>();
  12053. if (dt != null && dt.Rows.Count > 1)
  12054. {
  12055. bool needhe = true;
  12056. foreach (DataRow dr in dt.Rows)
  12057. {
  12058. ids.Add("'" + dr["ctid"] + "'");
  12059. /* //备注有合包
  12060. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12061. {
  12062. needhe = true;
  12063. }
  12064. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12065. {
  12066. needhe = true;
  12067. }
  12068. //顺丰快递
  12069. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12070. {
  12071. needhe = true;
  12072. }*/
  12073. }
  12074. if (!needhe)
  12075. {
  12076. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12077. return;
  12078. }
  12079. StringBuilder sql = new StringBuilder();
  12080. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12081. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12082. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12083. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12084. foreach (DataRow dr in dt.Rows)
  12085. {
  12086. dr["dstate"] = 0;
  12087. dr["dnumber"] = 0;
  12088. foreach (DataRow row in dt1.Rows)
  12089. {
  12090. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12091. {
  12092. dr["dstate"] = 2;
  12093. dr["default"] = 1;
  12094. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12095. }
  12096. }
  12097. if (eid.Equals(dr["ctid"].ToString()))
  12098. {
  12099. dr["dstate"] = 1;
  12100. dr["default"] = 1;
  12101. }
  12102. }
  12103. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12104. return;
  12105. }
  12106. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12107. return;
  12108. }
  12109. returnErrorMsg("未找到订单");
  12110. return;
  12111. }
  12112. returnErrorMsg("缺少必要的参数");
  12113. }
  12114. public void get_mark_number()
  12115. {
  12116. string eid = GetPostString("ctid");
  12117. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12118. if (entity != null)
  12119. {
  12120. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12121. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12122. int current = 1;
  12123. if (ceErpDeliverMark == null)
  12124. {
  12125. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12126. List<string> ids = new List<string>();
  12127. if (dt != null && dt.Rows.Count > 1)
  12128. {
  12129. foreach (DataRow dr in dt.Rows)
  12130. {
  12131. ids.Add("'" + dr["ctid"] + "'");
  12132. }
  12133. //查询已有的编号
  12134. StringBuilder sql = new StringBuilder();
  12135. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12136. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12137. if (dt1 == null || dt1.Rows.Count == 0)
  12138. {
  12139. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12140. List<int> list_number = new List<int>();
  12141. foreach (DataRow row in numbers.Rows)
  12142. {
  12143. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12144. }
  12145. //查询空余编号
  12146. for (int i = 0; i < list_number.Count + 2; i++)
  12147. {
  12148. if (!list_number.Contains(current))
  12149. {
  12150. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12151. //防止查询过程中有新数据生成
  12152. if (ceErpDeliverMark1 == null)
  12153. {
  12154. break;
  12155. }
  12156. }
  12157. current++;
  12158. }
  12159. }
  12160. else
  12161. {
  12162. foreach (DataRow row in dt1.Rows)
  12163. {
  12164. current = Convert.ToInt32(row["markNumber"]);
  12165. }
  12166. }
  12167. ceErpDeliverMark = new CeErpDeliverMark();
  12168. ceErpDeliverMark.ctid = eid;
  12169. ceErpDeliverMark.createtime = DateTime.Now;
  12170. if (ceErpTrade != null)
  12171. {
  12172. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12173. }
  12174. ceErpDeliverMark.markNumber = current;
  12175. ceErpDeliverMark.Create();
  12176. }
  12177. }
  12178. else
  12179. {
  12180. current = ceErpDeliverMark.markNumber;
  12181. }
  12182. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12183. return;
  12184. }
  12185. }
  12186. public void aftersaleCytSend()
  12187. {
  12188. string ctid = GetPostString("ctid");
  12189. if (!string.IsNullOrEmpty(ctid))
  12190. {
  12191. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12192. if (ceErpTradeCell != null)
  12193. {
  12194. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12195. }
  12196. returnSuccessMsg("推送成功");
  12197. return;
  12198. }
  12199. returnErrorMsg("缺少必要的参数");
  12200. }
  12201. public void packOrderInfo()
  12202. {
  12203. string ctids = GetPostString("ctids");
  12204. if (!string.IsNullOrEmpty(ctids))
  12205. {
  12206. string[] ctid_list = ctids.Split(',');
  12207. if (ctid_list.Length > 20)
  12208. {
  12209. returnErrorMsg("单次下载次数不能超过20个");
  12210. return;
  12211. }
  12212. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12213. StringBuilder sql = new StringBuilder();
  12214. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12215. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12216. int supplierId = 0;
  12217. StringBuilder insterSql = new StringBuilder();
  12218. for (int i = 0; i < dt.Rows.Count; i++)
  12219. {
  12220. DataRow row = dt.Rows[i];
  12221. if (i == 0)
  12222. {
  12223. supplierId = Convert.ToInt32(row["SupplierId"]);
  12224. }
  12225. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12226. {
  12227. returnErrorMsg("同车间的订单才能一起打包");
  12228. return;
  12229. }
  12230. int orderState = Convert.ToInt32(row["OrderState"]);
  12231. if (orderState != 5)
  12232. {
  12233. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12234. return;
  12235. }
  12236. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12237. }
  12238. CeErpPackData ceErpPackData = new CeErpPackData();
  12239. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12240. ceErpPackData.supplierId = supplierId;
  12241. ceErpPackData.createtime = DateTime.Now;
  12242. ceErpPackData.createBy = CurrentUser.UserID;
  12243. ceErpPackData.createName = CurrentUser.UserName;
  12244. ceErpPackData.Create();
  12245. if (ceErpPackData.ID > 0)
  12246. {
  12247. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12248. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12249. }
  12250. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12251. returnSuccessMsg("打包成功");
  12252. return;
  12253. }
  12254. returnErrorMsg("缺少必要的参数");
  12255. }
  12256. public void rePackOrderInfo()
  12257. {
  12258. string id = GetPostString("id");
  12259. if (!string.IsNullOrEmpty(id))
  12260. {
  12261. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12262. if (ceErpPackData == null)
  12263. {
  12264. returnSuccessMsg("查无数据");
  12265. return;
  12266. }
  12267. ceErpPackData.upStatus = 0;
  12268. ceErpPackData.message = "";
  12269. ceErpPackData.Update();
  12270. returnSuccessMsg("打包成功");
  12271. return;
  12272. }
  12273. returnErrorMsg("缺少必要的参数");
  12274. }
  12275. public void backPackOrderInfo()
  12276. {
  12277. string id = GetPostString("id");
  12278. if (!string.IsNullOrEmpty(id))
  12279. {
  12280. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12281. if (ceErpPackData == null)
  12282. {
  12283. returnSuccessMsg("查无数据");
  12284. return;
  12285. }
  12286. ceErpPackData.upStatus = 4;
  12287. ceErpPackData.Update();
  12288. List<string> list = new List<string>();
  12289. StringBuilder sql = new StringBuilder();
  12290. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12291. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12292. for (int i = 0; i < dt.Rows.Count; i++)
  12293. {
  12294. DataRow row = dt.Rows[i];
  12295. list.Add("'" + row["ctid"].ToString() + "'");
  12296. }
  12297. string textCtids = string.Join(",", list);
  12298. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12299. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12300. returnSuccessMsg("退回成功");
  12301. return;
  12302. }
  12303. returnErrorMsg("缺少必要的参数");
  12304. }
  12305. public void addPackDownNum()
  12306. {
  12307. string id = GetPostString("id");
  12308. if (!string.IsNullOrEmpty(id))
  12309. {
  12310. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12311. returnSuccessMsg("下载成功");
  12312. return;
  12313. }
  12314. returnErrorMsg("缺少必要的参数");
  12315. }
  12316. public void get_pack_list()
  12317. {
  12318. DataStruct dStruct = GetPostStruct();
  12319. List<string> lw = new List<string>();
  12320. string supplier = GetPostString("supplier");
  12321. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12322. string posTag = CurrentUser.UserPost.Post.Code;
  12323. if (posTag == "Supplier")
  12324. {
  12325. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12326. }
  12327. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12328. dStruct.Order = "createtime desc";
  12329. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12330. writeGridDataTableJson(dStruct.TotalCount, dt);
  12331. }
  12332. public void get_pack_order_list()
  12333. {
  12334. string packId = GetPostString("packId");
  12335. if (string.IsNullOrEmpty(packId))
  12336. {
  12337. returnErrorMsg("缺少必要的参数");
  12338. return;
  12339. }
  12340. StringBuilder sql = new StringBuilder();
  12341. 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);
  12342. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12343. if (dt == null || dt.Rows.Count == 0)
  12344. {
  12345. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12346. return;
  12347. }
  12348. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12349. return;
  12350. }
  12351. public void get_supplier_product_time_list()
  12352. {
  12353. DataStruct dStruct = GetPostStruct();
  12354. List<string> lw = new List<string>();
  12355. string supplier = GetPostString("supplier");
  12356. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12357. string posTag = CurrentUser.UserPost.Post.Code;
  12358. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12359. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12360. writeGridDataTableJson(dStruct.TotalCount, dt);
  12361. }
  12362. public void saveSupplierProductTime()
  12363. {
  12364. string productId = GetPostString("productId");
  12365. if (string.IsNullOrEmpty(productId))
  12366. {
  12367. returnErrorMsg("缺少必要的参数");
  12368. return;
  12369. }
  12370. string productName = GetPostString("productName");
  12371. int supplierId = GetPostInt("supplierId");
  12372. if (supplierId == 0)
  12373. {
  12374. returnErrorMsg("缺少必要的参数");
  12375. return;
  12376. }
  12377. int quantity = GetPostInt("quantity");
  12378. int sendDay = GetPostInt("sendTime");
  12379. string supplierName = GetPostString("supplierName");
  12380. string craft = GetPostString("craft");
  12381. string deadLine = GetPostString("deadLine");
  12382. string dayDeadLine = GetPostString("dayDeadLine");
  12383. try
  12384. {
  12385. int eid = GetPostInt("eid");
  12386. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12387. if (ceErpSupplierProductTime == null)
  12388. {
  12389. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12390. }
  12391. ceErpSupplierProductTime.productId = productId;
  12392. ceErpSupplierProductTime.productName = productName;
  12393. ceErpSupplierProductTime.supplierId = supplierId;
  12394. ceErpSupplierProductTime.supplierName = supplierName;
  12395. ceErpSupplierProductTime.craft = craft;
  12396. ceErpSupplierProductTime.sendDay = sendDay;
  12397. ceErpSupplierProductTime.quantity = quantity;
  12398. if (!string.IsNullOrEmpty(deadLine))
  12399. {
  12400. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12401. }
  12402. if (!string.IsNullOrEmpty(dayDeadLine))
  12403. {
  12404. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12405. }
  12406. if (ceErpSupplierProductTime.ID == 0)
  12407. {
  12408. ceErpSupplierProductTime.Save();
  12409. }
  12410. else
  12411. {
  12412. ceErpSupplierProductTime.Update();
  12413. }
  12414. }
  12415. catch (Exception e)
  12416. {
  12417. }
  12418. returnSuccessMsg("保存成功");
  12419. return;
  12420. }
  12421. public void delSupplierProductTime()
  12422. {
  12423. int eid = GetPostInt("eid");
  12424. if (eid > 0)
  12425. {
  12426. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12427. if (ceErpSupplierProductTime == null)
  12428. {
  12429. returnErrorMsg("查无数据");
  12430. return;
  12431. }
  12432. ceErpSupplierProductTime.Delete();
  12433. returnSuccessMsg("保存成功");
  12434. return;
  12435. }
  12436. returnErrorMsg("缺少必要的参数");
  12437. }
  12438. public void getExpressInfo()
  12439. {
  12440. string ctid = GetPostString("ctid");
  12441. if (!string.IsNullOrEmpty(ctid))
  12442. {
  12443. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12444. if (ceErpTradeCell != null)
  12445. {
  12446. string outSid = ceErpTradeCell.OutSid;
  12447. if (outSid.Length > 0)
  12448. {
  12449. 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);
  12450. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12451. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12452. return;
  12453. }
  12454. }
  12455. returnErrorMsg("查无记录");
  12456. return;
  12457. }
  12458. returnErrorMsg("缺少必要的参数");
  12459. }
  12460. public void getExpressPostData()
  12461. {
  12462. string express = GetPostString("express");
  12463. if (!string.IsNullOrEmpty(express))
  12464. {
  12465. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12466. if (ceErpExpressInfo != null)
  12467. {
  12468. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12469. return;
  12470. }
  12471. }
  12472. returnErrorMsg("缺少必要的参数");
  12473. }
  12474. public void checkSupplierOrder()
  12475. {
  12476. string ctids = GetPostString("ctids");
  12477. if (ctids != null)
  12478. {
  12479. List<string> list = new List<string>();
  12480. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12481. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12482. for (int i = 0; i < dt.Rows.Count; i++)
  12483. {
  12484. DataRow row = dt.Rows[i];
  12485. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12486. {
  12487. continue;
  12488. }
  12489. list.Add(row["seller_memo"].ToString());
  12490. }
  12491. if (list.Count > 0)
  12492. {
  12493. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12494. return;
  12495. }
  12496. }
  12497. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12498. return;
  12499. }
  12500. public void addPersonId()
  12501. {
  12502. string tid = GetPostString("tid");
  12503. string personId = GetPostString("personId");
  12504. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12505. if (ceErpTrade != null)
  12506. {
  12507. ceErpTrade.receiver_zip = personId;
  12508. ceErpTrade.Update();
  12509. returnSuccessMsg("保存成功");
  12510. return;
  12511. }
  12512. returnErrorMsg("缺少必要的参数");
  12513. }
  12514. }
  12515. }