sync.order.cs 639 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. namespace SiteCore.Handler
  50. {
  51. public partial class sync
  52. {
  53. public void get_erp_orderlist()
  54. {
  55. string poscode = CurrentUser.UserPost.Post.Code;
  56. DataStruct dStruct = GetPostStruct();
  57. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\uv特殊工艺价格(1).xls");
  58. //apiHelper.Api_SyncOrderByTime("598825");
  59. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  60. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  61. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  62. //banniuApiHelper.sendLogisticsInfo(null);
  63. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  64. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  65. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  66. //int sid = commonHelper.autoDistributeToSupplier(entity);
  67. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  68. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1750324509000,\"deliveryType\":\"OFFLINE\",\"discountFee\":60.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1750867200000,\"lines\":[{\"latestDeliveryTime\":1750867200000,\"mark2\":[],\"num\":12,\"outerId\":\"XCCBTFB\",\"payment\":300.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/490100363/O1CN01QY84g81EYIfY4eEq2_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"2618419802494137080\",\"refSkuId\":\"0\",\"refSpuId\":\"703805468317\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":25.0,\"singleFee\":25.0,\"spuOuterId\":\"XCCBTFB\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"摆摊广告布定制推车贴纸三轮小吃车展示招牌喷绘夜市地摊帆布海报\",\"totalFee\":300.0,\"totalPrice\":360.0,\"totalSellPrice\":300.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1750397934000,\"openBuyerId\":\"AAHnRHraABkUZRHgSx2jBZ8l\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1750324223000,\"payTime\":1750324505000,\"payment\":300.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"三亚市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吉阳区\",\"receiverId\":\"d882d22254b88b1ed1b3d6d4645179dd$\",\"receiverState\":\"海南省\",\"receiverTown\":\"河东区街道\",\"refOid\":\"2618419802494137080\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"422x35cm-1张-帆布-摆摊布米白-打孔模切-tb908253750- 拾柒-100-送10米麻绳,200x35cm-1张-帆布-摆摊布米白-打孔模切-tb908253750- 拾柒-100-送10米麻绳,400x73cm-1张-帆布-摆摊布米白-打孔模切-tb908253750- 拾柒-100-送10米麻绳\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":300.0,\"totalPrice\":360.0,\"totalSellPrice\":300.0,\"type\":\"SALE\"}}");
  69. //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}}");
  70. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  71. //commonHelper.loginGetOrder(2152);
  72. //string res = apiHelper.API_GetWaybill("SF-CAINIAO-LYZSJF", "C1_4386726036959480136");
  73. List<string> lw = new List<string>();
  74. string tid = GetPostString("ctid");
  75. string date1 = GetPostString("date1");
  76. //12-1 修改
  77. string urgent = GetPostString("urgent");
  78. string back = GetPostString("back");
  79. string offlineSearch = GetPostString("offlineSearch");
  80. int paramsCount = 0;
  81. if (!string.IsNullOrWhiteSpace(urgent))
  82. {
  83. if (urgent.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(back))
  89. {
  90. if (back.Equals("true"))
  91. {
  92. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  93. }
  94. }
  95. if (!string.IsNullOrWhiteSpace(offlineSearch))
  96. {
  97. if (offlineSearch.Equals("true"))
  98. {
  99. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  100. }
  101. }
  102. //end
  103. string date2 = GetPostString("date2");
  104. string buyernick = GetPostString("buyer_nick");
  105. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  106. {
  107. if (tid.Length <= 0 && buyernick.Length <= 0)
  108. {
  109. return;
  110. }
  111. }
  112. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  113. {
  114. if (tid.Length > 0)
  115. {
  116. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  117. if (ceErpTradeCell != null)
  118. {
  119. tid = ceErpTradeCell.tid;
  120. }
  121. List<string> select_tid = getTidByCtidMore(tid);
  122. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  123. }
  124. if (buyernick.Length > 0)
  125. {
  126. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  127. }
  128. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  129. if (dw.Length > 0)
  130. {
  131. lw.Add(dw);
  132. }
  133. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. }
  138. }
  139. else
  140. {
  141. if (ex_psize == 0)
  142. {
  143. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  144. }
  145. if (PKey != "admin")
  146. {
  147. string usershop = CurrentUser.User.pemShop;
  148. lw.Add(string.Format("ShopId in ({0})", usershop));
  149. paramsCount++;
  150. }
  151. }
  152. string uploaddate1 = GetPostString("uploaddate1");
  153. string uploaddate2 = GetPostString("uploaddate2");
  154. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  155. if (update.Length > 0) lw.Add(update);
  156. string deliverydate1 = GetPostString("deliverydate1");
  157. string deliverydate2 = GetPostString("deliverydate2");
  158. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  159. if (deliverydate.Length > 0)
  160. {
  161. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  162. };
  163. string shopname = GetPostString("shopname");
  164. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  165. string addwechat = GetPostString("addwechat");
  166. if (addwechat.Length > 0)
  167. {
  168. int addWt = Convert.ToInt32(addwechat);
  169. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  170. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  171. }
  172. string customer = GetPostString("customer");
  173. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  174. string design = GetPostString("design");
  175. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  176. string orderState = GetPostString("orderState");
  177. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  178. string address = GetPostString("address");
  179. 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));
  180. string sellermemo = GetPostString("seller_memo");
  181. if (sellermemo.Length > 0)
  182. {
  183. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  184. }
  185. string backReason = GetPostString("backReason");
  186. if (backReason.Length > 0)
  187. {
  188. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  189. }
  190. string apdate1 = GetPostString("apdate1");
  191. string apdate2 = GetPostString("apdate2");
  192. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  193. if (dwap.Length > 0) lw.Add(dwap);
  194. string price1 = GetPostString("price1");
  195. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  196. string price2 = GetPostString("price2");
  197. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  198. string isoldcustomer = GetPostString("isoldcus");
  199. string spudata = GetPostString("spudata");
  200. if ("0".Equals(spudata))
  201. {
  202. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  203. }
  204. if ("1".Equals(spudata))
  205. {
  206. lw.Add(string.Format("spu_id <> ''"));
  207. }
  208. string finishdate1 = GetPostString("finishdate1");
  209. string finishdate2 = GetPostString("finishdate2");
  210. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  211. bool isFinish = false;
  212. if (finishdate.Length > 0)
  213. {
  214. lw.Add(finishdate);
  215. isFinish = true;
  216. paramsCount++;
  217. }
  218. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  219. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  220. if (ex_psize > 0)
  221. {
  222. int UserID = CurrentUser.UserID;
  223. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  224. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  225. {
  226. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  227. }
  228. dStruct.Order = "pay_time desc";
  229. }
  230. string isNew = GetPostString("isNew");
  231. if (isNew == "true")
  232. {
  233. lw.Add(string.Format("IsNew = {0}", 1));
  234. }
  235. string overtime = GetPostString("overtime");
  236. if (overtime == "1")
  237. {
  238. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  239. }
  240. String usePost = CurrentUser.UserPost.Post.Code;
  241. if (usePost.Equals("Operation") == true)
  242. {
  243. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  244. }
  245. else
  246. {
  247. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  248. }
  249. //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";
  250. if (dStruct.PageSize == 100000)
  251. {
  252. dStruct.Order = "";
  253. }
  254. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  255. DataTable dt = null;
  256. string tablename = "view_orderlist";
  257. if (isFinish)
  258. {
  259. tablename = "view_orderlist_end";
  260. }
  261. dt = WebCache.GetData(tablename, dStruct);
  262. if (dt != null && dt.Rows.Count > 0)
  263. {
  264. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  265. foreach (DataRow dr in dt.Rows)
  266. {
  267. try
  268. {
  269. if (dr["refund_fees"] != null)
  270. {
  271. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  272. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  273. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  274. if (payment == refund_fees)
  275. {
  276. dr["refund_fees"] = Math.Round(refund_fees, 2);
  277. }
  278. else if (refund_fees == total_fee)
  279. {
  280. dr["refund_fees"] = payment;
  281. }
  282. else
  283. {
  284. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  285. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  286. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  287. }
  288. }
  289. // 对象操作
  290. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  291. ceErpTradeCell.ctid = dr["ctid"].ToString();
  292. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  293. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  294. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  295. if (dStruct.PageSize != 100000)
  296. {
  297. if (dr["DispatchSort"].ToString() == "2")
  298. {
  299. dr["gongchuang"] = 200;
  300. }
  301. else if ("外协".Equals(dr["ToType"].ToString()))
  302. {
  303. dr["gongchuang"] = 200;
  304. }
  305. else if ("内部".Equals(dr["ToType"].ToString()))
  306. {
  307. dr["gongchuang"] = -1;
  308. }
  309. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  310. {
  311. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  312. dr["gongchuang"] = response.code;
  313. }
  314. }
  315. }
  316. catch (NullReferenceException ex)
  317. {
  318. // 处理空引用异常
  319. dr["refund_fees"] = "0.00";
  320. }
  321. }
  322. }
  323. writeGridDataTableJson(dStruct.TotalCount, dt);
  324. }
  325. public void get_erp_orderlist_sumprice()
  326. {
  327. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  328. return;
  329. List<string> lw = new List<string>();
  330. string tid = GetPostString("ctid");
  331. string date1 = GetPostString("date1");
  332. string date2 = GetPostString("date2");
  333. if (tid.Length > 0 || date1.Length > 0)
  334. {
  335. lw.Add(string.Format("ctid like '%{0}%'", tid));
  336. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  337. if (dw.Length > 0) lw.Add(dw);
  338. }
  339. else
  340. {
  341. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  342. }
  343. string shopname = GetPostString("shopname");
  344. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  345. string buyernick = GetPostString("buyer_nick");
  346. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  347. string customer = GetPostString("customer");
  348. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  349. string design = GetPostString("design");
  350. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  351. string orderState = GetPostString("orderState");
  352. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  353. string address = GetPostString("address");
  354. 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));
  355. string sellermemo = GetPostString("seller_memo");
  356. if (sellermemo.Length > 0)
  357. {
  358. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  359. }
  360. string apdate1 = GetPostString("apdate1");
  361. string apdate2 = GetPostString("apdate2");
  362. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  363. if (dwap.Length > 0) lw.Add(dwap);
  364. string price1 = GetPostString("price1");
  365. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  366. string price2 = GetPostString("price2");
  367. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  368. string isoldcustomer = GetPostString("isoldcus");
  369. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  370. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  371. if (PKey != "admin")
  372. {
  373. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  374. lw.Add(string.Format("shopId in ({0})", usershop));
  375. }
  376. //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";
  377. string mainWhere = string.Join(" and ", lw.ToArray());
  378. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  379. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  380. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  381. decimal total = 0;
  382. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  383. {
  384. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  385. }
  386. var res = new
  387. {
  388. data = total
  389. };
  390. string ro_jsond = JsonConvert.SerializeObject(res);
  391. returnSuccess(ro_jsond);
  392. return;
  393. }
  394. public void get_erp_CustomerServiceGather()
  395. {
  396. string userWhere = "", orderWhere = "";
  397. List<string> lw = new List<string>();
  398. string customer = GetPostString("customer");
  399. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  400. string shopname = GetPostString("shopname");
  401. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  402. string date1 = GetPostString("date1");
  403. string date2 = GetPostString("date2");
  404. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  405. if (dw.Length > 0) lw.Add(dw);
  406. orderWhere = string.Join(" and ", lw.ToArray());
  407. 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 " +
  408. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  409. "left join " +
  410. "( " +
  411. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  412. ") as b on a.ID = b.CustomerUserId " +
  413. "left join " +
  414. "( " +
  415. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  416. ") as d on a.ID = d.CustomerUserId " +
  417. "left join " +
  418. "( " +
  419. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  420. ") as e on a.ID = e.CustomerUserId " +
  421. "left join " +
  422. "( " +
  423. " select CustomerUserId, RefundCount, RefundSum from " +
  424. " ( " +
  425. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  426. " from CE_ErpTradeRefund a " +
  427. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  428. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  429. " group by CustomerUserId " +
  430. " ) as a " +
  431. ") as f on a.ID = f.CustomerUserId " +
  432. "where a.PostCode = 'CustomerService'",
  433. userWhere, orderWhere);
  434. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  435. writeGridDataTableJson(dt.Rows.Count, dt);
  436. //writeGridDataTableJson(dt.Rows.Count, dt);
  437. }
  438. //设计汇总
  439. public void get_erp_DesignerGather()
  440. {
  441. string userWhere = "", orderWhere = "";
  442. List<string> lw = new List<string>();
  443. string Designer = GetPostString("designer");
  444. int org = GetPostInt("org");
  445. if (Designer.Length > 0)
  446. {
  447. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  448. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  449. }
  450. else if (org > 0)
  451. {
  452. userWhere = string.Format(" where OrgID ={0}", org);
  453. }
  454. string shopname = GetPostString("shopname");
  455. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  456. string state = GetPostString("state");
  457. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  458. string OrderArea = GetPostString("order_area");
  459. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  460. string date1 = GetPostString("date1");
  461. string date2 = GetPostString("date2");
  462. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  463. if (dw.Length > 0) lw.Add(dw);
  464. string UpDate1 = GetPostString("UpDate1");
  465. string UpDate2 = GetPostString("UpDate2");
  466. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  467. if (dw.Length > 0) lw.Add(dw);
  468. orderWhere = string.Join(" and ", lw.ToArray());
  469. 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 (" +
  470. "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 " +
  471. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  472. "left join " +
  473. "( " +
  474. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  475. ") as b on a.ID = b.DesignUserId " +
  476. "left join " +
  477. "( " +
  478. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  479. ") as d on a.ID = d.DesignUserId " +
  480. "left join " +
  481. "( " +
  482. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  483. ") as e on a.ID = e.DesignUserId " +
  484. "left join " +
  485. "( " +
  486. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  487. ") as g on a.ID = g.DesignUserId " +
  488. "left join " +
  489. "( " +
  490. " select CustomerUserId, RefundCount, RefundSum from " +
  491. " ( " +
  492. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  493. " from CE_ErpTradeRefund a " +
  494. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  495. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  496. " group by CustomerUserId " +
  497. " ) as a " +
  498. ") as f on a.ID = f.CustomerUserId " +
  499. "where a.PostCode = 'Designer') as z",
  500. userWhere, orderWhere);
  501. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  502. writeGridDataTableJson(dt.Rows.Count, dt);
  503. }
  504. //删除tradecell的订单
  505. public void del_erp_cellorder()
  506. {
  507. if (UrlPostParmsCheck("ctid"))
  508. {
  509. string eid = GetPostString("ctid");
  510. CeErpTradeCell.DelByCtid(eid);
  511. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  512. returnSuccessMsg("删除成功");
  513. }
  514. }
  515. public void clear_erp_refundstate()
  516. {
  517. if (UrlPostParmsCheck("ids"))
  518. {
  519. string eids = GetPostString("ids");
  520. string[] ctidList = eids.Split(',');
  521. foreach (string ctid in ctidList)
  522. {
  523. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  524. if (entity != null)
  525. {
  526. entity.IsRefund = 0;
  527. entity.Update();
  528. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  529. }
  530. else
  531. continue;
  532. }
  533. returnSuccessMsg("操作成功");
  534. return;
  535. }
  536. returnErrorMsg("缺少必要参数");
  537. }
  538. public void set_erp_urgency()
  539. {
  540. if (UrlPostParmsCheck("ctid"))
  541. {
  542. string eid = GetPostString("ctid");
  543. CeErpTradeCell entity = null;
  544. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  545. if (entity != null)
  546. {
  547. double prices = commonHelper.calculationPrice(entity);
  548. if (prices <= 100)
  549. {
  550. returnErrorMsg("此订单金额不足100元,无法加急。");
  551. return;
  552. }
  553. string utime = GetPostString("urgencytime");
  554. if (utime.Length > 0)
  555. {
  556. entity.UrgencyTime = Convert.ToDateTime(utime);
  557. }
  558. else
  559. {
  560. returnErrorMsg("请选择加急时间");
  561. return;
  562. }
  563. if (entity.OrderState <= 4)
  564. {
  565. //entity.seller_memo = entity.seller_memo + "-加急";
  566. string smemo = entity.seller_memo;
  567. int kindex = smemo.IndexOf(")");
  568. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  569. if (lastoneStr != "-")
  570. {
  571. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  572. }
  573. string prememo = smemo.Substring(0, kindex + 2);
  574. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  575. int lastkindex = lastmemo.IndexOf("(");
  576. DateTime urgtime = Convert.ToDateTime(utime);
  577. string newlastmemo = "";
  578. if (lastkindex == 0)
  579. {
  580. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  581. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  582. }
  583. else
  584. {
  585. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  586. }
  587. entity.seller_memo = prememo + newlastmemo;
  588. }
  589. entity.IsUrgency = true;
  590. entity.UpdateTime = DateTime.Now;
  591. entity.Update();
  592. ApiVo apiVo = new ApiVo();
  593. apiVo.orderNumber = entity.ctid;
  594. apiVo.actionName = "changeDesign";
  595. apiVo.orderRemarks = entity.seller_memo;
  596. apiVo.remarkSign = 3;
  597. designHelper.API_WorkCore(apiVo); //changeDesign
  598. CeErpSukuraData.createInfo(entity.ctid, 7);
  599. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  600. returnSuccessMsg("设置成功!");
  601. return;
  602. }
  603. returnErrorMsg("找不到记录");
  604. }
  605. }
  606. public void set_erp_reset()
  607. {
  608. if (UrlPostParmsCheck("ctid"))
  609. {
  610. string eid = GetPostString("ctid");
  611. CeErpTradeCell entity = null;
  612. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  613. if (entity != null)
  614. {
  615. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  616. {
  617. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  618. {
  619. returnErrorMsg("财务要求已下单已发货无法重置");
  620. return;
  621. }
  622. }
  623. entity.IsUrgency = false;
  624. entity.seller_memo = "";
  625. entity.OtherMemo = "";
  626. entity.OrderState = 0;
  627. entity.IsReturn = 0;
  628. //entity.IsRefund = 0;
  629. entity.MemoOpt = 0;
  630. entity.AfterSaleState = 0;
  631. entity.AfterSaleResponsible = "";
  632. entity.AfterSaleUserId = 0;
  633. entity.IsNeedBill = 0;
  634. entity.CustomerUserId = 0;
  635. entity.DesignUserId = 0;
  636. entity.SupplierId = 0;
  637. entity.PlaceUserId = 0;
  638. entity.ptid = "";
  639. entity.IsSample = 0;
  640. entity.IsXianHuo = 0;
  641. entity.isDianziOrder = 0;
  642. entity.DispatchSort = 0;
  643. entity.FinishPlaceTime = null;
  644. entity.Update();
  645. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  646. if (trade != null)
  647. {
  648. trade.seller_memo = "";
  649. trade.Update();
  650. }
  651. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  652. returnSuccessMsg("重置成功!");
  653. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  654. if (desginBill != null)
  655. {
  656. desginBill.isDel = 1;
  657. desginBill.Update();
  658. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  659. }
  660. ApiVo apiVo = new ApiVo();
  661. apiVo.orderNumber = entity.ctid;
  662. apiVo.actionName = "resetDesign";
  663. designHelper.API_WorkCore(apiVo);//resetDesign
  664. return;
  665. }
  666. returnErrorMsg("找不到记录");
  667. }
  668. }
  669. public void save_erp_sellermemo()
  670. {
  671. if (UrlPostParmsCheck("ctid"))
  672. {
  673. string ctid = GetPostString("ctid");
  674. CeErpTradeCell entity = null;
  675. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  676. if (entity != null)
  677. {
  678. string memo = GetPostString("seller_memo");
  679. memo = memo.Replace(" ", "");
  680. if (memo.Contains("补差"))
  681. {
  682. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  683. return;
  684. }
  685. List<string> bitList = new List<string>
  686. {
  687. "\\","/",":","*","?", "\"","<" ,">","|"
  688. };
  689. bool isIn = false;
  690. foreach (string bit in bitList)
  691. {
  692. if (memo.Contains(bit))
  693. {
  694. isIn = true;
  695. }
  696. }
  697. if (isIn)
  698. {
  699. returnErrorMsg("不能使用 一些符合作为文件名");
  700. return;
  701. }
  702. if (entity.seller_memo != memo)
  703. {
  704. if (entity.IsSample == 2)
  705. {
  706. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  707. return;
  708. }
  709. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  710. {
  711. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  712. {
  713. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  714. return;
  715. }
  716. /*if (CurrentUser.UserPost.Post.Code != "Place")
  717. {
  718. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  719. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  720. {
  721. returnErrorMsg("售前系统订单无法再此修改!");
  722. return;
  723. }
  724. }*/
  725. }
  726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  727. }
  728. commonHelper.getCytPrice(entity);
  729. int memoopt = GetPostInt("MemoOpt");
  730. Boolean ismemoopt = false;
  731. if (memoopt > 0)
  732. {
  733. string stropt = "";
  734. if (memoopt == 1)
  735. {
  736. stropt = "“改稿”";
  737. ismemoopt = true;
  738. }
  739. else if (memoopt == 2)
  740. {
  741. stropt = "“定稿”";
  742. }
  743. else if (memoopt == 3)
  744. {
  745. stropt = "“查货”";
  746. CeErpSukuraData.createInfo(entity.ctid, 6);
  747. }
  748. entity.MemoOpt = Convert.ToInt32(memoopt);
  749. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  750. }
  751. if (entity.OrderState < 5)
  752. {
  753. memo = memo.Replace("(", "(");
  754. memo = memo.Replace(")", ")");
  755. }
  756. if (entity.OrderState < 3)
  757. {
  758. entity.DispatchSort = 0;
  759. }
  760. entity.seller_memo = memo;
  761. entity.UpdateTime = DateTime.Now;
  762. entity.Update();
  763. ApiVo apiVo = new ApiVo();
  764. apiVo.orderNumber = entity.ctid;
  765. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  766. apiVo.orderRemarks = memo;
  767. apiVo.remarkSign = memoopt;
  768. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  769. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  770. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  771. {
  772. dataHelper.api_orderBack(entity.ctid, "0", "");
  773. }
  774. if (entity.seller_memo.Contains("改稿"))
  775. {
  776. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  777. }
  778. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  779. returnSuccessMsg("保存成功!");
  780. return;
  781. }
  782. returnErrorMsg("找不到记录");
  783. }
  784. }
  785. public void ins_erp_checkorder()
  786. {
  787. if (UrlPostParmsCheck("ctid"))
  788. {
  789. string ctid = GetPostString("ctid");
  790. CeErpTradeCell entity = null;
  791. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  792. if (entity != null)
  793. {
  794. if (entity.OrderState < 6)
  795. {
  796. returnErrorMsg("下单完成后才可查货");
  797. return;
  798. }
  799. /*if (entity.OrderState > 6)
  800. {
  801. returnErrorMsg("订单已发货");
  802. return;
  803. }*/
  804. if (entity.FinishPlaceTime != null)
  805. {
  806. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  807. {
  808. returnErrorMsg("下单时间不足,无法查货");
  809. return;
  810. }
  811. }
  812. entity.MemoOpt = 3;
  813. entity.CheckOrderTime = DateTime.Now;
  814. entity.UpdateTime = DateTime.Now;
  815. entity.Update();
  816. CeErpSukuraData.createInfo(entity.ctid, 6);
  817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  818. returnSuccessMsg("操作成功!");
  819. return;
  820. }
  821. returnErrorMsg("找不到记录");
  822. }
  823. }
  824. public void save_erp_othermemo()
  825. {
  826. if (UrlPostParmsCheck("ctid"))
  827. {
  828. string ctid = GetPostString("ctid");
  829. CeErpTradeCell entity = null;
  830. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  831. if (entity != null)
  832. {
  833. entity.OtherMemo = GetPostString("otherMemo");
  834. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  835. {
  836. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  837. StringBuilder sql = new StringBuilder();
  838. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  839. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  840. if (dt != null && dt.Rows.Count > 0)
  841. {
  842. foreach (DataRow dr in dt.Rows)
  843. {
  844. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  845. {
  846. //品类一直
  847. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  848. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  849. if (ceErpSampleCustomer == null)
  850. {
  851. ceErpSampleCustomer = new CeErpSampleCustomer();
  852. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  853. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  854. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  855. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  856. ceErpSampleCustomer.shopId = entity.ShopId;
  857. }
  858. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  859. ceErpSampleCustomer.lastTid = entity.tid;
  860. if (ceErpSampleCustomer.ID > 0)
  861. {
  862. ceErpSampleCustomer.Update();
  863. }
  864. else
  865. {
  866. ceErpSampleCustomer.Create();
  867. }
  868. }
  869. }
  870. }
  871. }
  872. //if (entity.IsOldCustomer == 1)
  873. //{
  874. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  875. //{
  876. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  877. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  878. //}
  879. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  880. //{
  881. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  882. // {
  883. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  884. // {
  885. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  886. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  887. // }
  888. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  889. // {
  890. // entity.OrderState = 2;
  891. // entity.DesignUserId = 0;
  892. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  893. // }
  894. // else
  895. // {
  896. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  897. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  898. // }
  899. // }
  900. //}
  901. //}
  902. entity.UpdateTime = DateTime.Now;
  903. entity.Update();
  904. returnSuccessMsg("保存成功!");
  905. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  906. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  907. if (entity.OtherMemo.Contains("改稿"))
  908. {
  909. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  910. }
  911. return;
  912. }
  913. returnErrorMsg("找不到记录");
  914. }
  915. }
  916. public void save_erp_customermemo()
  917. {
  918. if (UrlPostParmsCheck("ctid"))
  919. {
  920. string ctid = GetPostString("ctid");
  921. CeErpTradeCell entity = null;
  922. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  923. if (entity != null)
  924. {
  925. entity.UpdateTime = DateTime.Now;
  926. entity.CustomerMemo = GetPostString("CustomerMemo");
  927. entity.Update();
  928. ApiVo apiVo = new ApiVo();
  929. apiVo.orderNumber = entity.ctid;
  930. apiVo.actionName = "followRemarks";
  931. apiVo.orderRemarks = entity.CustomerMemo;
  932. designHelper.API_WorkCore(apiVo);//followRemarks
  933. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  934. returnSuccessMsg("保存成功!");
  935. return;
  936. }
  937. returnErrorMsg("找不到记录");
  938. }
  939. }
  940. public void upd_erp_addmemotag()
  941. {
  942. if (UrlPostParmsCheck("ctid"))
  943. {
  944. ;
  945. string eid = GetPostString("ctid");
  946. string sfTagstr = GetPostString("memotag");
  947. CeErpTradeCell entity = null;
  948. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  949. if (entity != null)
  950. {
  951. ApiVo apiVo = new ApiVo();
  952. if (entity.OrderState == 0)
  953. {
  954. returnErrorMsg("请先领单");
  955. return;
  956. }
  957. //撤销顺丰
  958. if (sfTagstr == "撤销顺丰")
  959. {
  960. entity.IsSF = 0;
  961. string reMsg = "";
  962. string oldmemo = entity.seller_memo;
  963. if (entity.OrderState < 5)
  964. {
  965. oldmemo = oldmemo.Replace("顺丰到付", "");
  966. oldmemo = oldmemo.Replace("顺丰寄付", "");
  967. entity.seller_memo = oldmemo;
  968. }
  969. else
  970. {
  971. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  972. {
  973. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  974. }
  975. }
  976. entity.Update();
  977. apiVo.orderNumber = entity.ctid;
  978. apiVo.actionName = "orderRemarks";
  979. apiVo.orderRemarks = entity.seller_memo;
  980. apiVo.isSf = entity.IsSF.ToString();
  981. designHelper.API_WorkCore(apiVo);//orderRemarks
  982. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  983. returnSuccessMsg("撤销成功!" + reMsg);
  984. return;
  985. }
  986. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  987. {
  988. //string oldmemo = entity.seller_memo;
  989. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  990. string sfStr = GetPostString("memotag");
  991. string smemo = entity.seller_memo;
  992. int kindex = smemo.IndexOf(")");
  993. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  994. if (lastoneStr != "-")
  995. {
  996. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  997. }
  998. string prememo = smemo.Substring(0, kindex + 2);
  999. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1000. int lastkindex = lastmemo.IndexOf("(");
  1001. string newlastmemo = "";
  1002. if (lastkindex == 0)
  1003. {
  1004. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1005. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1006. }
  1007. else
  1008. {
  1009. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1010. }
  1011. entity.seller_memo = prememo + newlastmemo;
  1012. }
  1013. string sfTagMSg = "";
  1014. if (sfTagstr == "顺丰寄付")
  1015. {
  1016. entity.IsSF = 1;
  1017. sfTagMSg = "顺丰寄付";
  1018. }
  1019. else if (sfTagstr == "顺丰到付")
  1020. {
  1021. entity.IsSF = 2;
  1022. sfTagMSg = "顺丰到付";
  1023. }
  1024. entity.Update();
  1025. apiVo = new ApiVo();
  1026. apiVo.orderNumber = entity.ctid;
  1027. apiVo.actionName = "orderRemarks";
  1028. apiVo.orderRemarks = entity.seller_memo;
  1029. apiVo.isSf = entity.IsSF.ToString();
  1030. designHelper.API_WorkCore(apiVo);//orderRemarks
  1031. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1032. returnSuccessMsg("标记成功!");
  1033. return;
  1034. }
  1035. returnErrorMsg("找不到记录");
  1036. }
  1037. }
  1038. public void upd_erp_ordertag()
  1039. {
  1040. if (UrlPostParmsCheck("ctid"))
  1041. {
  1042. string eid = GetPostString("ctid");
  1043. CeErpTradeCell entity = null;
  1044. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1045. if (entity != null)
  1046. {
  1047. int tag = GetPostInt("wechattag");
  1048. //if(tag==4 && entity.IsSample == 2)
  1049. //{
  1050. // returnErrorMsg("补差价单不能标记微信单");
  1051. // return;
  1052. //}
  1053. entity.wechatTag = tag;
  1054. entity.Update();
  1055. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1056. if (tag == 1)
  1057. {
  1058. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1059. if (cash == null)
  1060. {
  1061. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1062. cash = new CeErpReturnCash();
  1063. cash.tid = entity.tid;
  1064. cash.seller_nick = main.seller_nick;
  1065. cash.payment = trade.payment;
  1066. cash.buyer_nick = main.buyer_nick;
  1067. cash.cashstate = 0;
  1068. cash.rtype = "微信返现";
  1069. cash.returnprice = 0;
  1070. cash.created = DateTime.Now;
  1071. cash.con = "订单标记微信单";
  1072. cash.img = "";
  1073. cash.applyuserid = CurrentUser.UserID;
  1074. cash.Create();
  1075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1076. }
  1077. else
  1078. {
  1079. cash.cashstate = 0;
  1080. cash.Update();
  1081. }
  1082. CeErpSukuraData.createInfo(entity.ctid, 9);
  1083. }
  1084. else if (tag == 2)
  1085. {
  1086. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1087. if (cash == null)
  1088. {
  1089. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1090. cash = new CeErpReturnCash();
  1091. cash.tid = entity.tid;
  1092. cash.seller_nick = main.seller_nick;
  1093. cash.payment = trade.payment;
  1094. cash.buyer_nick = main.buyer_nick;
  1095. cash.cashstate = 0;
  1096. cash.rtype = "推购返现";
  1097. cash.returnprice = 5;
  1098. cash.created = DateTime.Now;
  1099. cash.con = "订单标记推购单";
  1100. cash.img = "";
  1101. cash.applyuserid = CurrentUser.UserID;
  1102. cash.Create();
  1103. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1104. }
  1105. else
  1106. {
  1107. cash.cashstate = 0;
  1108. cash.Update();
  1109. }
  1110. CeErpSukuraData.createInfo(entity.ctid, 9);
  1111. }
  1112. else if (tag == 3)
  1113. {
  1114. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1115. if (pers == null)
  1116. {
  1117. pers = new CeErpPersuade();
  1118. pers.ctid = entity.ctid;
  1119. pers.pstate = 0;
  1120. pers.created = DateTime.Now;
  1121. pers.applyuserid = CurrentUser.UserID;
  1122. pers.Create();
  1123. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1124. }
  1125. else
  1126. {
  1127. pers.pstate = 0;
  1128. pers.Update();
  1129. }
  1130. }
  1131. else if (tag == 4 || tag == 5)
  1132. {
  1133. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1134. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1135. if (pers == null)
  1136. {
  1137. pers = new CeErpStayGoods();
  1138. pers.t_id = entity.tid;
  1139. pers.status = "待审核";
  1140. pers.audit_type = 0;
  1141. if (tag == 4)
  1142. {
  1143. pers.stay_type = "微信推购";
  1144. }
  1145. else
  1146. {
  1147. pers.stay_type = "旺旺推购";
  1148. }
  1149. if (entity.IsXianHuo == 0)
  1150. {
  1151. pers.product_id = entity.ProductId;
  1152. }
  1153. pers.wangwang = main.buyer_nick;
  1154. pers.shop_name = main.seller_nick;
  1155. pers.creata_time = DateTime.Now;
  1156. pers.create_u_id = CurrentUser.UserID;
  1157. pers.create_u_name = CurrentUser.UserName;
  1158. pers.Create();
  1159. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1160. }
  1161. else
  1162. {
  1163. pers.audit_type = 0;
  1164. pers.Update();
  1165. }
  1166. CeErpSukuraData.createInfo(entity.ctid, 10);
  1167. }
  1168. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1169. returnSuccessMsg("标记成功!");
  1170. return;
  1171. }
  1172. returnErrorMsg("找不到记录");
  1173. }
  1174. }
  1175. public void upd_erp_ordertag_cancel()
  1176. {
  1177. if (UrlPostParmsCheck("ctid"))
  1178. {
  1179. string eid = GetPostString("ctid");
  1180. CeErpTradeCell entity = null;
  1181. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1182. if (entity != null)
  1183. {
  1184. entity.wechatTag = 0;
  1185. entity.Update();
  1186. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1187. if (pers != null)
  1188. {
  1189. pers.status = "取消推购";
  1190. pers.audit_type = 3;
  1191. pers.Update();
  1192. }
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1194. returnSuccessMsg("标记成功!");
  1195. return;
  1196. }
  1197. returnErrorMsg("找不到记录");
  1198. }
  1199. }
  1200. public void upd_erp_addweichattag()
  1201. {
  1202. if (UrlPostParmsCheck("ctid"))
  1203. {
  1204. ;
  1205. string eid = GetPostString("ctid");
  1206. CeErpTradeCell entity = null;
  1207. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1208. if (entity != null)
  1209. {
  1210. if (entity.IsAddWechat > 0)
  1211. {
  1212. returnErrorMsg("此单已经标记过了");
  1213. return;
  1214. }
  1215. 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);
  1216. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1217. if (dt.Rows.Count > 0)
  1218. {
  1219. entity.IsAddWechat = 2;
  1220. }
  1221. else
  1222. {
  1223. entity.IsAddWechat = 1;
  1224. }
  1225. entity.Update();
  1226. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1227. returnSuccessMsg("标记成功!");
  1228. return;
  1229. }
  1230. returnErrorMsg("找不到记录");
  1231. }
  1232. }
  1233. public void upd_erp_getmyorder()
  1234. {
  1235. if (UrlPostParmsCheck("ctid"))
  1236. {
  1237. ;
  1238. string eid = GetPostString("ctid");
  1239. CeErpTradeCell entity = null;
  1240. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1241. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1242. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1243. {
  1244. returnErrorMsg("台湾客户需填写身份证号!");
  1245. return;
  1246. }
  1247. if (entity != null)
  1248. {
  1249. if (entity.ctid.IndexOf("C") != -1)
  1250. {
  1251. StringBuilder sql = new StringBuilder();
  1252. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1253. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1254. if (dt.Rows.Count > 0)
  1255. {
  1256. decimal total = 0;
  1257. foreach (DataRow dr in dt.Rows)
  1258. {
  1259. total += Convert.ToDecimal(dr["payment"]);
  1260. }
  1261. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1262. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1263. {
  1264. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1265. return;
  1266. }
  1267. }
  1268. }
  1269. if (entity.OrderState == -1)
  1270. {
  1271. returnErrorMsg("待审核订单无法领取!");
  1272. return;
  1273. }
  1274. entity.CustomerUserId = CurrentUser.UserID;
  1275. if (entity.OrderState < 2)
  1276. {
  1277. entity.OrderState = 2;
  1278. if (entity.ShopId != 0)
  1279. {
  1280. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1281. }
  1282. }
  1283. entity.UpdateTime = DateTime.Now;
  1284. entity.Update();
  1285. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1286. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1287. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1288. {
  1289. dataHelper.api_orderBack(entity.ctid, "0", "");
  1290. }
  1291. returnSuccessMsg("领单成功!");
  1292. return;
  1293. }
  1294. returnErrorMsg("找不到记录");
  1295. }
  1296. }
  1297. public void getmyorder_from_init()
  1298. {
  1299. if (UrlPostParmsCheck("ctid"))
  1300. {
  1301. string eid = GetPostString("ctid");
  1302. CeErpTradeCell entity = null;
  1303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1304. if (entity != null)
  1305. {
  1306. string sellerMemo = GetPostString("sellerMemo");
  1307. if (sellerMemo.Length > 0)
  1308. {
  1309. entity.seller_memo = sellerMemo;
  1310. }
  1311. string oterhMemo = GetPostString("otherMemo");
  1312. if (oterhMemo.Length > 0)
  1313. {
  1314. entity.OtherMemo = oterhMemo;
  1315. }
  1316. int urg = GetPostInt("urgency");
  1317. entity.IsUrgency = (urg == 1 ? true : false);
  1318. int wechat = GetPostInt("wechat");
  1319. int command = GetPostInt("command");
  1320. if (wechat == 1)
  1321. {
  1322. entity.wechatTag = 1;
  1323. }
  1324. if (command == 1)
  1325. {
  1326. entity.wechatTag = 2;
  1327. }
  1328. string pPro = GetPostString("pprofession");
  1329. if (pPro.Length > 0)
  1330. {
  1331. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1332. string spro = GetPostString("profession");
  1333. if (spro.Length > 0)
  1334. {
  1335. entity.ProfessionId = Convert.ToInt32(spro);
  1336. }
  1337. }
  1338. string proId = GetPostString("productId");
  1339. if (proId.Length > 0)
  1340. {
  1341. entity.ProductId = Convert.ToInt32(proId);
  1342. }
  1343. entity.Material = GetPostString("material");
  1344. entity.Craft = GetPostString("craft");
  1345. entity.CustomerUserId = CurrentUser.UserID;
  1346. if (entity.OrderState < 2)
  1347. {
  1348. entity.OrderState = 2;
  1349. if (entity.ShopId != 0)
  1350. {
  1351. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1352. }
  1353. }
  1354. entity.Update();
  1355. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1356. returnSuccessMsg("领单成功!");
  1357. return;
  1358. }
  1359. returnErrorMsg("找不到记录");
  1360. }
  1361. }
  1362. public void upd_erp_setrelationorder()
  1363. {
  1364. if (UrlPostParmsCheck("ctid"))
  1365. {
  1366. ;
  1367. string eid = GetPostString("ctid");
  1368. string ftid = GetPostString("ftid");
  1369. CeErpTradeCell entity = null;
  1370. CeErpTradeCell fentity = null;
  1371. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1372. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1373. if (fentity == null)
  1374. {
  1375. returnErrorMsg("找不到关联的主订单");
  1376. return;
  1377. }
  1378. if (entity != null)
  1379. {
  1380. if (entity.OrderState >= 5)
  1381. {
  1382. returnErrorMsg("本单已经设计完成无法关联");
  1383. return;
  1384. }
  1385. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1386. {
  1387. returnErrorMsg("线下单续审核后才能关联!");
  1388. return;
  1389. }
  1390. entity.ptid = ftid;
  1391. entity.OrderState = fentity.OrderState;
  1392. //entity.status = fentity.status;
  1393. entity.CustomerUserId = fentity.CustomerUserId;
  1394. entity.DesignUserId = fentity.DesignUserId;
  1395. entity.seller_memo = "补差价单:" + ftid;
  1396. entity.IsSample = 2;
  1397. entity.Update();
  1398. ApiVo apiVo = new ApiVo();
  1399. apiVo.orderNumber = ftid;
  1400. apiVo.payment = entity.payment;
  1401. apiVo.actionName = "repairDesign";
  1402. designHelper.API_WorkCore(apiVo);//repairDesign
  1403. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1404. returnSuccessMsg("关联成功!");
  1405. return;
  1406. }
  1407. else
  1408. returnErrorMsg("找不到记录");
  1409. }
  1410. }
  1411. public void download_erp_neworder()
  1412. {
  1413. string seller = GetPostString("seller_nick");
  1414. string tid = GetPostString("tid");
  1415. if (seller.Length <= 0 || tid.Length <= 0)
  1416. {
  1417. returnErrorMsg("数据错误");
  1418. }
  1419. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1420. //{
  1421. // returnErrorMsg("找不到店铺Sessionkey");
  1422. //}
  1423. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1424. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1425. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1426. if (res.IndexOf("refOid") == -1)
  1427. {
  1428. returnErrorMsg("下载订单数据失败");
  1429. return;
  1430. }
  1431. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1432. returnSuccessMsg("下载完成");
  1433. //tmcHelper.createNewOrder(res);
  1434. //CeErpTrade entr = null;
  1435. //entr = CeErpTrade.Get(tid);
  1436. //if (entr != null)
  1437. //{
  1438. // returnSuccess("下载成功");
  1439. // //下载成功之后,Cell表生成对应的订单;
  1440. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1441. //}
  1442. //else
  1443. //{
  1444. // returnErrorMsg("下载失败或者创建订单失败");
  1445. //}
  1446. }
  1447. public void set_erp_atersale()
  1448. {
  1449. if (UrlPostParmsCheck("ctid"))
  1450. {
  1451. string eid = GetPostString("ctid");
  1452. string reason = GetPostString("AfterSaleReason");
  1453. CeErpTradeCell entity = null;
  1454. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1455. if (entity != null)
  1456. {
  1457. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1458. {
  1459. returnErrorMsg("此订单已经在售后");
  1460. return;
  1461. }
  1462. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1463. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1464. entity.AfterSaleTime = DateTime.Now;
  1465. entity.Update();
  1466. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1467. returnSuccessMsg("转售后成功!");
  1468. return;
  1469. }
  1470. returnErrorMsg("找不到记录");
  1471. }
  1472. }
  1473. public void set_erp_withdraw()
  1474. {
  1475. if (UrlPostParmsCheck("ctid"))
  1476. {
  1477. try
  1478. {
  1479. string eid = GetPostString("ctid");//商品id
  1480. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1481. CeWithdraw ceWithdrawSelect = null;
  1482. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1483. if (ceWithdrawSelect != null)
  1484. {
  1485. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1486. {
  1487. ceWithdrawSelect.status = -1;
  1488. ceWithdrawSelect.Update();
  1489. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1490. returnSuccessMsg("重新发起审核成功");
  1491. return;
  1492. }
  1493. else
  1494. {
  1495. returnSuccessMsg("请勿重复申请!");
  1496. return;
  1497. }
  1498. }
  1499. else
  1500. {
  1501. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1502. if (string.IsNullOrEmpty(CustomerUserId))
  1503. {
  1504. CustomerUserId = "-1";
  1505. }
  1506. int Userid = CurrentUser.UserID;//用户id
  1507. CeWithdraw ceWithdraw = new CeWithdraw();
  1508. ceWithdraw.tid = eid;
  1509. ceWithdraw.userid = Userid;
  1510. ceWithdraw.providerid = CustomerUserId;
  1511. ceWithdraw.status = 3;
  1512. ceWithdraw.creationtime = DateTime.Now;
  1513. ceWithdraw.Create();
  1514. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1515. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1516. return;
  1517. }
  1518. }
  1519. catch
  1520. {
  1521. returnErrorMsg("申请撤回订单失败");
  1522. return;
  1523. }
  1524. }
  1525. }
  1526. public void ins_erp_billinfo()
  1527. {
  1528. if (UrlPostParmsCheck("ctid"))
  1529. {
  1530. string eid = GetPostString("ctid");
  1531. CeErpTradeCell entity = null;
  1532. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1533. if (entity != null)
  1534. {
  1535. CeErpBill bill = CeErpBill.GetByTid(eid);
  1536. bool isHave = false;
  1537. if (bill != null)
  1538. {
  1539. isHave = true;
  1540. if (bill.state != 4)
  1541. {
  1542. returnErrorMsg("此单已经申请过发票了");
  1543. return;
  1544. }
  1545. }
  1546. if (entity.IsNeedBill == 0)
  1547. {
  1548. entity.IsNeedBill = 1;
  1549. }
  1550. entity.Update();
  1551. string errjson = "";
  1552. try
  1553. {
  1554. CeErpBill bill_entity = new CeErpBill();
  1555. bill_entity.tid = entity.tid;
  1556. bill_entity.title = GetPostString("title");
  1557. string taxstr = GetPostString("tax");
  1558. taxstr = taxstr.Replace(" ", "");
  1559. bill_entity.tax = taxstr;
  1560. bill_entity.bank = GetPostString("bank");
  1561. string bankacstr = GetPostString("bankac");
  1562. bankacstr = bankacstr.Replace(" ", "");
  1563. bill_entity.bankac = bankacstr;
  1564. bill_entity.address = GetPostString("address");
  1565. bill_entity.phone = GetPostString("phone");
  1566. bill_entity.price = GetPostString("price");
  1567. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1568. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1569. {
  1570. billCount += 1;
  1571. }
  1572. string prebill = "ltb";
  1573. for (int idx = 1; idx <= billCount; idx++)
  1574. {
  1575. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1576. string billoid = prebill + idx + dtstr;
  1577. bill_entity.billOrderId += billoid;
  1578. if (idx < billCount)
  1579. {
  1580. bill_entity.billOrderId += ",";
  1581. }
  1582. }
  1583. bill_entity.productId = GetPostInt("ProductName");
  1584. bill_entity.num = GetPostInt("num");
  1585. bill_entity.unit = GetPostString("unit");
  1586. bill_entity.type = GetPostString("type");
  1587. bill_entity.sendType = GetPostString("SendType");
  1588. bill_entity.email = GetPostString("email");
  1589. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1590. bill_entity.shopName = GetPostString("ShopName");
  1591. bill_entity.applymemo = GetPostString("applyMemo");
  1592. bill_entity.createTime = DateTime.Now;
  1593. bill_entity.state = 0;
  1594. bill_entity.userId = CurrentUser.UserID;
  1595. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1596. bill_entity.Create();
  1597. }
  1598. catch (Exception ex)
  1599. {
  1600. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1601. returnErrorMsg("创建发票出错!");
  1602. return;
  1603. }
  1604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1605. returnSuccessMsg("发票申请成功!");
  1606. return;
  1607. }
  1608. returnErrorMsg("找不到记录");
  1609. }
  1610. }
  1611. public void ins_erp_neworder()
  1612. {
  1613. if (UrlPostParmsCheck("receiver_name"))
  1614. {
  1615. CeErpTrade entity = new CeErpTrade();
  1616. string plat_form = GetPostString("platform");
  1617. string preStr = "N_";
  1618. if (plat_form == "拼多多")
  1619. {
  1620. preStr = "P_";
  1621. }
  1622. else if (plat_form == "阿里巴巴")
  1623. {
  1624. preStr = "A_";
  1625. }
  1626. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1627. entity.seller_nick = GetPostString("seller_nick");
  1628. entity.buyer_nick = GetPostString("buyer_nick");
  1629. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1630. entity.total_fee = entity.payment;
  1631. entity.pay_time = DateTime.Now;
  1632. entity.status = "NOT_SHIPPED";
  1633. entity.receiver_name = GetPostString("receiver_name");
  1634. entity.receiver_mobile = GetPostString("receiver_mobile");
  1635. entity.receiver_state = GetPostString("receiver_state");
  1636. entity.receiver_city = GetPostString("receiver_city");
  1637. entity.receiver_district = GetPostString("receiver_district");
  1638. entity.receiver_address = GetPostString("receiver_address");
  1639. if (entity.receiver_state == "" || entity.receiver_city == "")
  1640. {
  1641. returnErrorMsg("收件地址不能为空");
  1642. return;
  1643. }
  1644. int shopId = 0;
  1645. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1646. if (nShop != null)
  1647. {
  1648. shopId = nShop.ID;
  1649. }
  1650. if (shopId != 34 && entity.payment == 0)
  1651. {
  1652. returnErrorMsg("公司自用的单金额才能为0");
  1653. return;
  1654. }
  1655. entity.Create();
  1656. CeErpTradeCell entitycell = new CeErpTradeCell();
  1657. entitycell.ctid = entity.tid;
  1658. entitycell.tid = entity.tid;
  1659. entitycell.ShopId = shopId;
  1660. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1661. entitycell.OrderState = 0;
  1662. entitycell.pay_time = entity.pay_time;
  1663. entitycell.IsOffLineOrder = 1;
  1664. entitycell.Create();
  1665. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1666. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1667. return;
  1668. }
  1669. }
  1670. public void ins_erp_neworder2()
  1671. {
  1672. if (UrlPostParmsCheck("receiver_name"))
  1673. {
  1674. //string plat_form = GetPostString("platform");
  1675. string preStr = "X_";
  1676. string memo = GetPostString("memo");
  1677. string productId = GetPostString("productId");
  1678. string primg = GetPostString("proofimg");
  1679. string sellerNick = GetPostString("seller_nick");
  1680. string addFrom = GetPostString("addfrom");
  1681. if (addFrom == "1")
  1682. {
  1683. preStr = "N_";
  1684. }
  1685. int shopId = 0;
  1686. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1687. if (nShop != null)
  1688. {
  1689. shopId = nShop.ID;
  1690. }
  1691. else
  1692. {
  1693. returnErrorMsg("找不到对应店铺");
  1694. return;
  1695. }
  1696. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1697. {
  1698. returnErrorMsg("必须上传付款凭证");
  1699. return;
  1700. }
  1701. CeErpTrade entity = new CeErpTrade();
  1702. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1703. entity.seller_nick = sellerNick;
  1704. entity.buyer_nick = GetPostString("buyer_nick");
  1705. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1706. entity.total_fee = entity.payment;
  1707. entity.pay_time = DateTime.Now;
  1708. entity.status = "NOT_SHIPPED";
  1709. entity.receiver_name = GetPostString("receiver_name");
  1710. entity.receiver_mobile = GetPostString("receiver_mobile");
  1711. entity.receiver_state = GetPostString("receiver_state");
  1712. entity.receiver_city = GetPostString("receiver_city");
  1713. entity.receiver_district = GetPostString("receiver_district");
  1714. entity.receiver_address = GetPostString("receiver_address");
  1715. entity.seller_memo = memo;
  1716. entity.orderFrom = 20;
  1717. entity.orderType = 15;
  1718. if (entity.receiver_state == "" || entity.receiver_city == "")
  1719. {
  1720. returnErrorMsg("收件地址不能为空");
  1721. return;
  1722. }
  1723. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1724. {
  1725. returnErrorMsg("公司自用的单金额才能为0");
  1726. return;
  1727. }
  1728. entity.Create();
  1729. string toWhere = GetPostString("towhere");
  1730. CeErpTradeCell entitycell = new CeErpTradeCell();
  1731. entitycell.ctid = entity.tid;
  1732. //唯一标识
  1733. entitycell.OrderSn = entity.tid;
  1734. string orderSn = dataHelper.getSaleOrderSn();
  1735. if (orderSn != "")
  1736. {
  1737. entitycell.OrderSn = orderSn;
  1738. }
  1739. entitycell.tid = entity.tid;
  1740. //if (preStr == "X_")
  1741. //{
  1742. entitycell.IsOffLineOrder = 1;
  1743. //}
  1744. entitycell.CustomerUserId = CurrentUser.UserID;
  1745. entitycell.PayProofImg = primg;
  1746. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1747. entitycell.ProductId = Convert.ToInt32(productId);
  1748. entitycell.ShopId = shopId;
  1749. entitycell.UpdateTime = DateTime.Now;
  1750. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1751. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1752. {
  1753. entitycell.IsXianHuo = 1;
  1754. }
  1755. entitycell.pay_time = entity.pay_time;
  1756. if (toWhere == "1")
  1757. {
  1758. entitycell.OrderState = 2;
  1759. }
  1760. else
  1761. {
  1762. entitycell.OrderState = 6;
  1763. entitycell.FinishPlaceTime = entitycell.pay_time;
  1764. }
  1765. if (shopId == 94)
  1766. {
  1767. entitycell.OrderState = 4;
  1768. entitycell.WaitDesignTime = entitycell.pay_time;
  1769. entitycell.StartDesignTime = entitycell.pay_time;
  1770. entitycell.DesignUserId = 218;
  1771. }
  1772. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1773. {
  1774. entitycell.OrderState = -1;//修改12-5
  1775. CeWithdraw ceWithdraw = new CeWithdraw();
  1776. ceWithdraw.tid = entity.tid;
  1777. ceWithdraw.providerid = "-1";
  1778. ceWithdraw.status = -1;
  1779. ceWithdraw.creationtime = DateTime.Now;
  1780. ceWithdraw.userid = 1337;
  1781. ceWithdraw.Create();
  1782. }
  1783. entitycell.Create();
  1784. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1785. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1786. {
  1787. addPlaceRegist(entitycell, CurrentUser.UserID);
  1788. }
  1789. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1790. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1791. return;
  1792. }
  1793. }
  1794. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1795. {
  1796. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1797. entity.PlactTime = tradecell.pay_time;
  1798. entity.AddUserId = userid;
  1799. entity.FileName = tradecell.seller_memo;
  1800. entity.Supplier = 24;
  1801. entity.CreateTime = DateTime.Now;
  1802. entity.Did = tradecell.ctid;
  1803. entity.tid = tradecell.tid;
  1804. entity.splitTag = tradecell.SplitTag;
  1805. entity.CurState = "未完成";
  1806. entity.Create();
  1807. }
  1808. public void get_erp_offlinelist()
  1809. {
  1810. DataStruct dStruct = GetPostStruct();
  1811. List<string> lw = new List<string>();
  1812. string tid = GetPostString("ctid");
  1813. string date1 = GetPostString("date1");
  1814. string date2 = GetPostString("date2");
  1815. if (tid.Length > 0 || date1.Length > 0)
  1816. {
  1817. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1818. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1819. if (dw.Length > 0) lw.Add(dw);
  1820. }
  1821. else
  1822. {
  1823. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1824. }
  1825. string shopname = GetPostString("shopname");
  1826. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1827. string buyernick = GetPostString("buyer_nick");
  1828. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1829. string customer = GetPostString("customer");
  1830. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1831. string design = GetPostString("design");
  1832. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1833. string orderState = GetPostString("orderState");
  1834. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1835. string address = GetPostString("address");
  1836. 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));
  1837. string sellermemo = GetPostString("seller_memo");
  1838. if (sellermemo.Length > 0)
  1839. {
  1840. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1841. }
  1842. string price1 = GetPostString("price1");
  1843. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1844. string price2 = GetPostString("price2");
  1845. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1846. //if (PKey != "admin")
  1847. //{
  1848. // string usershop = CurrentUser.User.pemShop;
  1849. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1850. //}
  1851. //if (ex_psize > 0)
  1852. //{
  1853. dStruct.Order = "pay_time desc";
  1854. //}
  1855. //else
  1856. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1857. lw.Add(string.Format("IsOffLineOrder=1"));
  1858. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1859. DataTable dt = null;
  1860. dt = WebCache.GetData("view_erptradecell", dStruct);
  1861. writeGridDataTableJson(dStruct.TotalCount, dt);
  1862. }
  1863. public void get_erp_returncashrecord()
  1864. {
  1865. DataStruct dStruct = GetPostStruct();
  1866. List<string> lw = new List<string>();
  1867. string tid = GetPostString("ctid");
  1868. if (tid.Length > 0)
  1869. {
  1870. lw.Add(string.Format("tid like '%{0}%'", tid));
  1871. dStruct.Order = "id desc";
  1872. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1873. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1874. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1875. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1876. return;
  1877. }
  1878. returnErrorMsg("id数据错误!");
  1879. }
  1880. public void ins_erp_returncashrecord()
  1881. {
  1882. if (UrlPostParmsCheck("tid"))
  1883. {
  1884. string tid = GetPostString("tid");
  1885. string retype = GetPostString("type");
  1886. StringBuilder sql = new StringBuilder();
  1887. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1889. if (dt.Rows.Count > 0)
  1890. {
  1891. returnErrorMsg("相同返现类型记录已存在");
  1892. return;
  1893. }
  1894. CeErpReturnCash entity = new CeErpReturnCash();
  1895. entity.tid = tid;
  1896. entity.seller_nick = GetPostString("seller_nick");
  1897. string pment = GetPostString("payment");
  1898. if (pment.Length > 0)
  1899. {
  1900. entity.payment = Convert.ToDouble(pment);
  1901. }
  1902. entity.buyer_nick = GetPostString("buyer_nick");
  1903. entity.cashstate = 0;
  1904. entity.rtype = retype;
  1905. string rPrice = GetPostString("returnprice");
  1906. if (rPrice.Length > 0)
  1907. {
  1908. entity.returnprice = Convert.ToDouble(rPrice);
  1909. }
  1910. entity.created = DateTime.Now;
  1911. entity.con = GetPostString("con");
  1912. entity.img = GetPostString("img");
  1913. entity.applyuserid = CurrentUser.UserID;
  1914. entity.Create();
  1915. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1916. returnSuccessMsg("操作成功!");
  1917. return;
  1918. }
  1919. }
  1920. public void set_erp_predelivery()
  1921. {
  1922. if (UrlPostParmsCheck("ctid"))
  1923. {
  1924. string eid = GetPostString("ctid");
  1925. CeErpTradeCell entity = null;
  1926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1927. if (entity != null)
  1928. {
  1929. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1930. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1931. //{
  1932. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1933. // return;
  1934. //}
  1935. entity.IsPreDelivery = 1;
  1936. entity.Update();
  1937. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1938. returnSuccessMsg("预发货成功!");
  1939. return;
  1940. //string shop = GetPostString("seller_nick");
  1941. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1942. //string comName = GetPostString("comName");
  1943. //string comCode = GetPostString("comCode");
  1944. //string outSid = GetPostString("outSid");//运单号
  1945. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1946. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1947. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1948. //string apires = "";
  1949. //if (deliveryType == "虚拟发货")
  1950. //{
  1951. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1952. //}
  1953. //else
  1954. //{
  1955. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1956. //}
  1957. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1958. ////{
  1959. //if (apires.IndexOf("发货成功") != -1)
  1960. //{
  1961. // if (deliveryType != "虚拟发货")
  1962. // {
  1963. // //还要插入快递信息到 快递信息表
  1964. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1965. // exinfo.tid = eid;
  1966. // exinfo.out_sid = outSid;
  1967. // exinfo.company_code = comCode;
  1968. // exinfo.company_name = comName;
  1969. // exinfo.delivery_memo = deliveryMemo;
  1970. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1971. // exinfo.deliveryType = deliveryType;
  1972. // exinfo.Create();
  1973. // }
  1974. // returnSuccessMsg("发货成功!");
  1975. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1976. //}
  1977. //else
  1978. //{
  1979. // returnErrorMsg("淘宝发货失败!!");
  1980. //}
  1981. //return;
  1982. }
  1983. returnErrorMsg("找不到订单记录");
  1984. }
  1985. }
  1986. public void get_erp_unusuallist()
  1987. {
  1988. DataStruct dStruct = GetPostStruct();
  1989. List<string> lw = new List<string>();
  1990. string tid = GetPostString("ctid");
  1991. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1992. string shopname = GetPostString("shopname");
  1993. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1994. string buyernick = GetPostString("buyer_nick");
  1995. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1996. string ResponsibleMan = GetPostString("responsible");
  1997. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1998. string date1 = GetPostString("date1");
  1999. string date2 = GetPostString("date2");
  2000. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2001. if (dw.Length > 0) lw.Add(dw);
  2002. string price1 = GetPostString("price1");
  2003. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2004. string price2 = GetPostString("price2");
  2005. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2006. string orderState = GetPostString("orderState");
  2007. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2008. string sellermemo = GetPostString("seller_memo");
  2009. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2010. lw.Add(string.Format("UnusualTag > 0"));
  2011. lw.Add(string.Format("IsRefund<={0}", 1));
  2012. dStruct.Order = "pay_time desc";
  2013. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2014. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2015. writeGridDataTableJson(dStruct.TotalCount, dt);
  2016. }
  2017. public void set_erp_unusualtonomal()
  2018. {
  2019. if (UrlPostParmsCheck("ctid"))
  2020. {
  2021. string eid = GetPostString("ctid");
  2022. CeErpTradeCell entity = null;
  2023. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2024. if (entity != null)
  2025. {
  2026. entity.UnusualTag = -1;
  2027. entity.Update();
  2028. returnSuccessMsg("忽略成功!");
  2029. return;
  2030. }
  2031. returnErrorMsg("找不到记录");
  2032. }
  2033. }
  2034. public void ins_erp_unusualreason()
  2035. {
  2036. if (UrlPostParmsCheck("ctid"))
  2037. {
  2038. string eid = GetPostString("ctid");
  2039. CeErpTradeCell entity = null;
  2040. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2041. if (entity != null)
  2042. {
  2043. entity.MemoOpt = 4;
  2044. entity.UnusualCon = GetPostString("con");
  2045. entity.Update();
  2046. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2047. if (trade != null)
  2048. {
  2049. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2050. }
  2051. //查货是否超时
  2052. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2053. if (ceErpTradeCellExtend == null)
  2054. {
  2055. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2056. ceErpTradeCellExtend.ctid = entity.ctid;
  2057. }
  2058. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2059. {
  2060. ceErpTradeCellExtend.CheckOut += 1;
  2061. }
  2062. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2063. if (ceErpTradeCellExtend.ID > 0)
  2064. {
  2065. ceErpTradeCellExtend.Update();
  2066. }
  2067. else
  2068. {
  2069. ceErpTradeCellExtend.Create();
  2070. }
  2071. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2072. returnSuccessMsg("操作成功!");
  2073. return;
  2074. }
  2075. returnErrorMsg("找不到记录");
  2076. }
  2077. }
  2078. public void upd_erp_sampleorder()
  2079. {
  2080. if (UrlPostParmsCheck("ctid"))
  2081. {
  2082. string eid = GetPostString("ctid");
  2083. string[] eArr = eid.Split(',');
  2084. if (eArr.Length > 1)
  2085. {
  2086. List<string> eLst = new List<string>();
  2087. for (int i = 0; i < eArr.Length; i++)
  2088. {
  2089. eLst.Add("'" + eArr[i] + "'");
  2090. }
  2091. eid = string.Join(",", eLst.ToArray());
  2092. }
  2093. else
  2094. {
  2095. eid = "'" + eid + "'";
  2096. }
  2097. StringBuilder sql = new StringBuilder();
  2098. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2099. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2100. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2101. if (dt.Rows.Count > 0)
  2102. {
  2103. string errmsg = "";
  2104. foreach (DataRow dr in dt.Rows)
  2105. {
  2106. StringBuilder sqlsb = new StringBuilder();
  2107. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2108. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2109. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2110. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2111. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2112. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2113. {
  2114. continue;
  2115. }
  2116. else
  2117. {
  2118. string emsg = commonHelper.KeepChinese(apires);
  2119. errmsg += emsg;
  2120. }
  2121. }
  2122. if (errmsg.Length > 0)
  2123. {
  2124. returnErrorMsg(errmsg);
  2125. return;
  2126. }
  2127. returnSuccessMsg("操作成功");
  2128. return;
  2129. }
  2130. returnErrorMsg("找不到记录");
  2131. }
  2132. }
  2133. public void upd_erp_transcustomer()
  2134. {
  2135. if (UrlPostParmsCheck("ctid"))
  2136. {
  2137. string eid = GetPostString("ctid");
  2138. int userid = GetPostInt("CustomerUserId");
  2139. CeErpTradeCell entity = null;
  2140. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2141. if (entity != null)
  2142. {
  2143. //string[] mlist = entity.seller_memo.Split('-');
  2144. //string sql = "select * from view_erpuser where id=" + userid;
  2145. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2146. //if (dt != null && dt.Rows.Count > 0)
  2147. //{
  2148. // string nmemo = "";
  2149. // for(int i = 0; i < mlist.Length - 1; i++)
  2150. // {
  2151. // nmemo += mlist[i];
  2152. // nmemo += "-";
  2153. // }
  2154. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2155. // entity.seller_memo = nmemo;
  2156. //}
  2157. entity.CustomerUserId = userid;
  2158. entity.Update();
  2159. returnSuccessMsg("操作成功!");
  2160. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2161. return;
  2162. }
  2163. returnErrorMsg("找不到记录");
  2164. }
  2165. }
  2166. public void upd_erp_transdesigner()
  2167. {
  2168. if (UrlPostParmsCheck("ctid"))
  2169. {
  2170. string eids = GetPostString("ctid");
  2171. string[] ctidList = eids.Split(',');
  2172. int userid = GetPostInt("DesignUserId");
  2173. foreach (string ctid in ctidList)
  2174. {
  2175. CeErpTradeCell entity = null;
  2176. CeErpDesignerBill entitys = null;
  2177. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2178. entitys = CeErpDesignerBill.GetByTid(ctid);
  2179. if (entity != null)
  2180. {
  2181. if (entity.OrderState > 4)
  2182. {
  2183. continue;
  2184. }
  2185. //存在退款不能流转
  2186. if (entity.IsRefund > 0)
  2187. {
  2188. continue;
  2189. }
  2190. entity.DesignUserId = userid;
  2191. entity.WaitDesignTime = DateTime.Now;
  2192. entity.Update();
  2193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2194. }
  2195. }
  2196. returnSuccessMsg("操作成功!");
  2197. }
  2198. }
  2199. public void upd_erp_distributedesigner()
  2200. {
  2201. if (UrlPostParmsCheck("ctid"))
  2202. {
  2203. string eid = GetPostString("ctid");
  2204. int userid = GetPostInt("DesignUserId");
  2205. string[] idlist = eid.Split(',');
  2206. if (idlist.Length <= 0)
  2207. {
  2208. returnErrorMsg("订单不能为空");
  2209. return;
  2210. }
  2211. foreach (string ctid in idlist)
  2212. {
  2213. CeErpTradeCell entity = null;
  2214. CeErpDesignerBill entitys = null;
  2215. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2216. else continue;
  2217. if (entity != null)
  2218. {
  2219. if (userid == 2125 || userid == 3542)
  2220. { }
  2221. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2222. {
  2223. returnErrorMsg("金额错误的订单无法指派");
  2224. return;
  2225. }
  2226. if (entity.OrderState >= 5)
  2227. {
  2228. returnErrorMsg("已经设计完成无法指派");
  2229. return;
  2230. }
  2231. if (entity.OrderState == -1)
  2232. {
  2233. returnErrorMsg("审核中的订单无法指派");
  2234. return;
  2235. }
  2236. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2237. {
  2238. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2239. return;
  2240. }
  2241. //157赖橙帆 159林晨 73 静之颖
  2242. 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)
  2243. {
  2244. returnErrorMsg("指派设计共创无法再次指派!");
  2245. return;
  2246. }
  2247. entity.OrderState = 3;
  2248. if (entity.SupplierId == 0)
  2249. {
  2250. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2251. entity.SupplierId = suid;
  2252. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2253. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2254. }
  2255. if (userid == 2125 && entity.seller_memo != "")
  2256. {
  2257. apiDesign.API_GetPrintData_CreateOrder(entity);
  2258. }
  2259. if (userid == 3542 && entity.seller_memo != "")
  2260. {
  2261. string userPost = CurrentUser.UserPost.Post.Code;
  2262. if (CurrentUser.UserID == 73)
  2263. {
  2264. userPost = "SysAdmin";
  2265. }
  2266. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2267. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2268. if (response.msg != "设计共创:成功")
  2269. {
  2270. returnErrorMsg(response.msg);
  2271. return;
  2272. }
  2273. entity.DispatchSort = 2;
  2274. }
  2275. else
  2276. {
  2277. if (entity.DispatchSort == 2)
  2278. {
  2279. ApiVo apiVo = new ApiVo();
  2280. apiVo.actionName = "closeDesign";
  2281. apiVo.orderNumber = entity.ctid;
  2282. designHelper.API_WorkCore(apiVo);//closeDesign
  2283. }
  2284. entity.DispatchSort = 0;
  2285. }
  2286. entity.DesignUserId = userid;
  2287. entity.WaitDesignTime = DateTime.Now;
  2288. entity.UpdateTime = DateTime.Now;
  2289. entity.Update();
  2290. string name = commonHelper.getUserNameById(userid);
  2291. commonHelper.UpdateRelationOrder(entity.ctid);
  2292. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2293. }
  2294. }
  2295. returnSuccessMsg("操作成功!");
  2296. return;
  2297. }
  2298. }
  2299. public string getTidByCtid(string ctid)
  2300. {
  2301. string tid = "";
  2302. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2303. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2304. if (dataTable != null && dataTable.Rows.Count > 0)
  2305. {
  2306. tid = dataTable.Rows[0]["tid"].ToString();
  2307. }
  2308. return tid;
  2309. }
  2310. public List<string> getTidByCtidMore(string ctid)
  2311. {
  2312. 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);
  2313. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2314. List<string> list = new List<string>();
  2315. if (dataTable != null && dataTable.Rows.Count > 0)
  2316. {
  2317. foreach (DataRow item in dataTable.Rows)
  2318. {
  2319. list.Add("'" + item["tid"].ToString() + "'");
  2320. }
  2321. }
  2322. return list;
  2323. }
  2324. public List<string> getTidByCtidLike(string ctid)
  2325. {
  2326. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2327. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2328. List<string> list = new List<string>();
  2329. if (dataTable != null && dataTable.Rows.Count > 0)
  2330. {
  2331. foreach (DataRow item in dataTable.Rows)
  2332. {
  2333. list.Add("'" + item["tid"].ToString() + "'");
  2334. }
  2335. }
  2336. return list;
  2337. }
  2338. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2339. {
  2340. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2341. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2342. List<string> list = new List<string>();
  2343. if (dataTable != null && dataTable.Rows.Count > 0)
  2344. {
  2345. foreach (DataRow item in dataTable.Rows)
  2346. {
  2347. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2348. {
  2349. continue;
  2350. }
  2351. list.Add("'" + item["receiverId"].ToString() + "'");
  2352. }
  2353. }
  2354. return list;
  2355. }
  2356. public void get_erp_myorderlist()
  2357. {
  2358. DataStruct dStruct = GetPostStruct();
  2359. List<string> lw = new List<string>();
  2360. string tid = GetPostString("ctid");
  2361. if (tid.Length > 0)
  2362. {
  2363. string select_tid = getTidByCtid(tid);
  2364. lw.Add(string.Format("tid='{0}'", select_tid));
  2365. }
  2366. else
  2367. {
  2368. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2369. }
  2370. //12-1 修改
  2371. string urgent = GetPostString("urgent");
  2372. string back = GetPostString("back");
  2373. string offlineSearch = GetPostString("offlineSearch");
  2374. if (!string.IsNullOrWhiteSpace(urgent))
  2375. {
  2376. if (urgent.Equals("true"))
  2377. {
  2378. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2379. }
  2380. }
  2381. if (!string.IsNullOrWhiteSpace(back))
  2382. {
  2383. if (back.Equals("true"))
  2384. {
  2385. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2386. }
  2387. }
  2388. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2389. {
  2390. if (offlineSearch.Equals("true"))
  2391. {
  2392. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2393. }
  2394. }
  2395. //end
  2396. string shopname = GetPostString("shopname");
  2397. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2398. string buyernick = GetPostString("buyer_nick");
  2399. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2400. string design = GetPostString("design");
  2401. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2402. string orderState = GetPostString("orderState");
  2403. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2404. string sellermemo = GetPostString("seller_memo");
  2405. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2406. string date1 = GetPostString("date1");
  2407. string date2 = GetPostString("date2");
  2408. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2409. if (dw.Length > 0) lw.Add(dw);
  2410. string price1 = GetPostString("price1");
  2411. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2412. string price2 = GetPostString("price2");
  2413. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2414. string urgency = GetPostString("urgency");
  2415. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2416. string after = GetPostString("after");
  2417. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2418. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2419. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2420. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2421. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2422. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2423. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2424. if (dt != null && dt.Rows.Count > 0)
  2425. {
  2426. foreach (DataRow dr in dt.Rows)
  2427. {
  2428. try
  2429. {
  2430. // 对象操作
  2431. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2432. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2433. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2434. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2435. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2436. if (dStruct.PageSize != 100000)
  2437. {
  2438. if (dr["DispatchSort"].ToString() == "2")
  2439. {
  2440. dr["gongchuang"] = 200;
  2441. }
  2442. else if ("外协".Equals(dr["ToType"].ToString()))
  2443. {
  2444. dr["gongchuang"] = 200;
  2445. }
  2446. else if ("内部".Equals(dr["ToType"].ToString()))
  2447. {
  2448. dr["gongchuang"] = -1;
  2449. }
  2450. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2451. {
  2452. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2453. dr["gongchuang"] = response.code;
  2454. }
  2455. }
  2456. }
  2457. catch (NullReferenceException ex)
  2458. {
  2459. }
  2460. }
  2461. }
  2462. writeGridDataTableJson(dStruct.TotalCount, dt);
  2463. }
  2464. public void get_erp_myreturnorderlist()
  2465. {
  2466. DataStruct dStruct = GetPostStruct();
  2467. List<string> lw = new List<string>();
  2468. string tid = GetPostString("ctid");
  2469. if (tid.Length > 0)
  2470. {
  2471. string select_tid = getTidByCtid(tid);
  2472. lw.Add(string.Format("tid='{0}'", select_tid));
  2473. }
  2474. else
  2475. {
  2476. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2477. }
  2478. string shopname = GetPostString("shopname");
  2479. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2480. string buyernick = GetPostString("buyer_nick");
  2481. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2482. string design = GetPostString("design");
  2483. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2484. string orderState = GetPostString("orderState");
  2485. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2486. string sellermemo = GetPostString("seller_memo");
  2487. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2488. string date1 = GetPostString("date1");
  2489. string date2 = GetPostString("date2");
  2490. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2491. if (dw.Length > 0) lw.Add(dw);
  2492. string price1 = GetPostString("price1");
  2493. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2494. string price2 = GetPostString("price2");
  2495. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2496. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2497. {
  2498. lw.Add(string.Format("CusOrgID = 94"));
  2499. }
  2500. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2501. {
  2502. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2503. }
  2504. else
  2505. {
  2506. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2507. }
  2508. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2509. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2510. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2511. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2512. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2513. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2514. if (dt != null && dt.Rows.Count > 0)
  2515. {
  2516. foreach (DataRow dr in dt.Rows)
  2517. {
  2518. try
  2519. {
  2520. // 对象操作
  2521. if (dStruct.PageSize != 100000)
  2522. {
  2523. if (dr["DispatchSort"].ToString() == "2")
  2524. {
  2525. dr["gongchuang"] = 200;
  2526. }
  2527. else if ("外协".Equals(dr["ToType"].ToString()))
  2528. {
  2529. dr["gongchuang"] = 200;
  2530. }
  2531. else if ("内部".Equals(dr["ToType"].ToString()))
  2532. {
  2533. dr["gongchuang"] = -1;
  2534. }
  2535. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2536. {
  2537. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2538. dr["gongchuang"] = response.code;
  2539. }
  2540. }
  2541. }
  2542. catch (NullReferenceException ex)
  2543. {
  2544. // 处理空引用异常
  2545. }
  2546. }
  2547. }
  2548. writeGridDataTableJson(dStruct.TotalCount, dt);
  2549. }
  2550. public void get_erp_myorderlist_pregather()
  2551. {
  2552. string date1 = GetPostString("date1");
  2553. string date2 = GetPostString("date2");
  2554. int userId = CurrentUser.UserID; //客服id
  2555. string orderWhere = "";
  2556. List<string> lw = new List<string>();
  2557. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2558. if (dw.Length > 0) lw.Add(dw);
  2559. lw.Add(string.Format("CustomerUserId={0}", userId));
  2560. lw.Add(string.Format("OrderState<9"));
  2561. orderWhere = string.Join(" and ", lw.ToArray());
  2562. string orderWhere2 = "";
  2563. List<string> lw2 = new List<string>();
  2564. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2565. if (dw2.Length > 0) lw2.Add(dw2);
  2566. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2567. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2568. string sql = string.Format("select *" +
  2569. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2570. "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 " +
  2571. "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 " +
  2572. "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");
  2573. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2574. //writeGridDataTableJson(dt.Rows.Count, dt);
  2575. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2576. }
  2577. public void upd_erp_publishorder()
  2578. {
  2579. if (UrlPostParmsCheck("ctid"))
  2580. {
  2581. string eid = GetPostString("ctid");
  2582. CeErpTradeCell entity = null;
  2583. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2584. if (entity != null)
  2585. {
  2586. entity.OrderState = 0; //发布后,变为待抢单
  2587. entity.Update();
  2588. commonHelper.UpdateRelationOrder(entity.ctid);
  2589. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2590. returnSuccessMsg("发布成功!");
  2591. return;
  2592. }
  2593. returnErrorMsg("找不到记录");
  2594. }
  2595. }
  2596. public void get_erp_my_tiporder()
  2597. {
  2598. StringBuilder sql = new StringBuilder();
  2599. int userId = 0;
  2600. if (CurrentUser != null) userId = CurrentUser.UserID;
  2601. string posCode = CurrentUser.UserPost.Post.Code;
  2602. string isTipedAfterSaleVerify = GetPostString("af");
  2603. DataTable dt = new DataTable();
  2604. if (posCode != "Supplier")
  2605. {
  2606. if (posCode == "CustomerService" || posCode == "Director")
  2607. {
  2608. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2609. }
  2610. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2611. {
  2612. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2613. }
  2614. else
  2615. {
  2616. string teamIds = CurrentUser.User.TeamIds;
  2617. if (teamIds == "")
  2618. {
  2619. teamIds = "0";
  2620. }
  2621. 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);
  2622. }
  2623. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2624. }
  2625. if (dt.Rows.Count <= 0)
  2626. {
  2627. string key = "aftersale_order_" + userId;
  2628. if (RedisHelper.HasKey(key))
  2629. {
  2630. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2631. dt.Columns.Add("ctid", typeof(string));
  2632. dt.Columns.Add("IsReadTag", typeof(int));
  2633. foreach (var i in list)
  2634. {
  2635. DataRow data = dt.NewRow();
  2636. data["ctid"] = i;
  2637. data["IsReadTag"] = 4;
  2638. dt.Rows.Add(data);
  2639. }
  2640. RedisHelper.StringDelete(key);
  2641. }
  2642. }
  2643. if (dt.Rows.Count <= 0)
  2644. {
  2645. sql = new StringBuilder();
  2646. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2647. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2648. }
  2649. if (posCode == "Supplier")
  2650. {
  2651. string ids = CurrentUser.User.pemVend;
  2652. if (ids != null && ids.Length > 0)
  2653. {
  2654. string[] ids_list = ids.Split(',');
  2655. foreach (var item in ids_list)
  2656. {
  2657. string key = "return_order_" + item;
  2658. if (RedisHelper.HasKey(key))
  2659. {
  2660. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2661. dt.Columns.Add("ctid", typeof(string));
  2662. dt.Columns.Add("IsReadTag", typeof(int));
  2663. foreach (var i in list)
  2664. {
  2665. DataRow data = dt.NewRow();
  2666. data["ctid"] = i;
  2667. data["IsReadTag"] = 1;
  2668. dt.Rows.Add(data);
  2669. }
  2670. RedisHelper.StringDelete(key);
  2671. }
  2672. }
  2673. }
  2674. if (dt.Rows.Count <= 0)
  2675. {
  2676. sql = new StringBuilder();
  2677. 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);
  2678. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2679. }
  2680. }
  2681. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2682. }
  2683. public void reset_erp_tiporder()
  2684. {
  2685. string ids = GetPostString("ids");
  2686. string[] ctidList = ids.Split(',');
  2687. foreach (string ctid in ctidList)
  2688. {
  2689. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2690. if (enty != null)
  2691. {
  2692. enty.IsReadTag = 0;
  2693. enty.Update();
  2694. }
  2695. }
  2696. returnSuccessMsg("成功!");
  2697. return;
  2698. }
  2699. public void get_erp_designlist()
  2700. {
  2701. DataStruct dStruct = GetPostStruct();
  2702. List<string> lw = new List<string>();
  2703. string tid = GetPostString("ctid");
  2704. if (tid.Length > 0)
  2705. {
  2706. string select_tid = getTidByCtid(tid);
  2707. lw.Add(string.Format("tid='{0}'", select_tid));
  2708. }
  2709. string shopname = GetPostString("shopname");
  2710. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2711. string buyernick = GetPostString("buyer_nick");
  2712. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2713. string customer = GetPostString("customer");
  2714. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2715. string design = GetPostString("design");
  2716. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2717. string orderState = GetPostString("orderState");
  2718. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2719. lw.Add(string.Format("OrderState<6"));
  2720. string address = GetPostString("address");
  2721. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2722. string sellermemo = GetPostString("seller_memo");
  2723. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2724. string date1 = GetPostString("date1");
  2725. string date2 = GetPostString("date2");
  2726. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2727. if (dw.Length > 0) lw.Add(dw);
  2728. string apdate1 = GetPostString("apdate1");
  2729. string apdate2 = GetPostString("apdate2");
  2730. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2731. if (dwap.Length > 0) lw.Add(dwap);
  2732. string price1 = GetPostString("price1");
  2733. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2734. string price2 = GetPostString("price2");
  2735. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2736. string designTime = GetPostString("designtime");
  2737. if (designTime.Length > 0)
  2738. {
  2739. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2740. }
  2741. string usershop = CurrentUser.User.pemShop;
  2742. if (usershop.Length > 0)
  2743. {
  2744. lw.Add(string.Format("shopId in ({0})", usershop));
  2745. }
  2746. int myOrgid = CurrentUser.UserPost.OrgID;
  2747. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2748. if (myOrgCode.IndexOf("Designer") != -1)
  2749. {
  2750. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2751. {
  2752. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2753. }
  2754. else
  2755. {
  2756. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2757. }
  2758. }
  2759. else
  2760. {
  2761. string orgId = GetPostString("designerhd");
  2762. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2763. }
  2764. if (tid.Length > 0 || buyernick.Length > 0)
  2765. {
  2766. lw.Add(string.Format("OrderState >= 3"));
  2767. }
  2768. else
  2769. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2770. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2771. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2772. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2773. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2774. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2775. if (dt != null && dt.Rows.Count > 0)
  2776. {
  2777. foreach (DataRow dr in dt.Rows)
  2778. {
  2779. try
  2780. {
  2781. // 对象操作
  2782. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2783. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2784. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2785. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2786. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2787. if (dStruct.PageSize != 100000)
  2788. {
  2789. if (dr["DispatchSort"].ToString() == "2")
  2790. {
  2791. dr["gongchuang"] = 200;
  2792. }
  2793. else if ("外协".Equals(dr["ToType"].ToString()))
  2794. {
  2795. dr["gongchuang"] = 200;
  2796. }
  2797. else if ("内部".Equals(dr["ToType"].ToString()))
  2798. {
  2799. dr["gongchuang"] = -1;
  2800. }
  2801. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2802. {
  2803. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2804. dr["gongchuang"] = response.code;
  2805. }
  2806. }
  2807. }
  2808. catch (NullReferenceException ex)
  2809. {
  2810. }
  2811. }
  2812. }
  2813. writeGridDataTableJson(dStruct.TotalCount, dt);
  2814. }
  2815. public void get_erp_mydesignlist()
  2816. {
  2817. DataStruct dStruct = GetPostStruct();
  2818. List<string> lw = new List<string>();
  2819. string tid = GetPostString("ctid");
  2820. if (tid.Length > 0)
  2821. {
  2822. string select_tid = getTidByCtid(tid);
  2823. lw.Add(string.Format("tid='{0}'", select_tid));
  2824. }
  2825. string shopname = GetPostString("shopname");
  2826. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2827. string buyernick = GetPostString("buyer_nick");
  2828. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2829. string customer = GetPostString("customer");
  2830. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2831. string orderState = GetPostString("orderState");
  2832. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2833. //lw.Add(string.Format("OrderState<6"));
  2834. string date1 = GetPostString("date1");
  2835. string date2 = GetPostString("date2");
  2836. string dw = GetDateWhere("pay_time", date1, date2);
  2837. if (dw.Length > 0) lw.Add(dw);
  2838. string apdate1 = GetPostString("apdate1");
  2839. string apdate2 = GetPostString("apdate2");
  2840. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2841. if (dwap.Length > 0) lw.Add(dwap);
  2842. string price1 = GetPostString("price1");
  2843. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2844. string price2 = GetPostString("price2");
  2845. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2846. string olddownload = GetPostString("olddown");
  2847. if (olddownload == "1")
  2848. {
  2849. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2850. }
  2851. else if (olddownload == "2")
  2852. {
  2853. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2854. }
  2855. string sellermemo = GetPostString("seller_memo");
  2856. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2857. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2858. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2859. {
  2860. if (CurrentUser.User.TeamIds.Length > 0)
  2861. {
  2862. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2863. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2864. else
  2865. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2866. }
  2867. else
  2868. {
  2869. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2870. }
  2871. }
  2872. if (tid.Length <= 0)
  2873. {
  2874. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2875. }
  2876. lw.Add(string.Format("IsReturn!=3"));
  2877. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2878. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2879. string teamids = CurrentUser.User.TeamIds.ToString();
  2880. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2881. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2882. if (dt != null && dt.Rows.Count > 0)
  2883. {
  2884. foreach (DataRow dr in dt.Rows)
  2885. {
  2886. try
  2887. {
  2888. // 对象操作
  2889. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2890. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2891. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2892. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2893. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2894. if (dStruct.PageSize != 100000)
  2895. {
  2896. if (dr["DispatchSort"].ToString() == "2")
  2897. {
  2898. dr["gongchuang"] = 200;
  2899. }
  2900. else if ("外协".Equals(dr["ToType"].ToString()))
  2901. {
  2902. dr["gongchuang"] = 200;
  2903. }
  2904. else if ("内部".Equals(dr["ToType"].ToString()))
  2905. {
  2906. dr["gongchuang"] = -1;
  2907. }
  2908. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2909. {
  2910. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2911. dr["gongchuang"] = response.code;
  2912. }
  2913. }
  2914. }
  2915. catch (NullReferenceException ex)
  2916. {
  2917. }
  2918. }
  2919. }
  2920. writeGridDataTableJson(dStruct.TotalCount, dt);
  2921. }
  2922. public void set_erp_startdesign()
  2923. {
  2924. if (UrlPostParmsCheck("ctid"))
  2925. {
  2926. string eid = GetPostString("ctid");
  2927. CeErpTradeCell entity = null;
  2928. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2929. if (entity != null)
  2930. {
  2931. if (entity.OrderState != 3)
  2932. {
  2933. returnErrorMsg("请刷新,订单已经设计了");
  2934. return;
  2935. }
  2936. entity.StartDesignTime = DateTime.Now;
  2937. entity.OrderState = 4;
  2938. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2939. {
  2940. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2941. entity.SupplierId = suid;
  2942. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2943. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2944. }
  2945. entity.UpdateTime = DateTime.Now;
  2946. //entity.MakeSupplier = suname;
  2947. entity.Update();
  2948. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2949. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2950. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2951. commonHelper.getCytPrice(entity);
  2952. returnSuccessMsg("操作成功!");
  2953. return;
  2954. }
  2955. returnErrorMsg("找不到记录");
  2956. }
  2957. }
  2958. public void ins_erp_designselfmemo()
  2959. {
  2960. if (UrlPostParmsCheck("ctid"))
  2961. {
  2962. string eid = GetPostString("ctid");
  2963. string con = GetPostString("con");
  2964. CeErpTradeCell entity = null;
  2965. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2966. if (entity != null)
  2967. {
  2968. entity.DesignSelfMemo = con;
  2969. entity.Update();
  2970. returnSuccessMsg("操作成功!");
  2971. return;
  2972. }
  2973. returnErrorMsg("找不到记录");
  2974. }
  2975. }
  2976. public void ins_erp_designprice()
  2977. {
  2978. if (UrlPostParmsCheck("ctid"))
  2979. {
  2980. string eid = GetPostString("ctid");
  2981. int uid = CurrentUser.UserID;
  2982. string userName = CurrentUser.UserName;
  2983. CeErpTradeCell entity = null;
  2984. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2985. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2986. if (entitys == null)
  2987. {
  2988. entitys = new CeErpDesignerBill();
  2989. }
  2990. if (entity != null)
  2991. {
  2992. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2993. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2994. entity.StartDesignTime = DateTime.Now;
  2995. entity.OrderState = 4;
  2996. string suname = "";
  2997. if (entity.SupplierId == 0)
  2998. {
  2999. int sid = commonHelper.autoDistributeToSupplier(entity);
  3000. entity.SupplierId = sid;
  3001. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3002. }
  3003. entity.Update();
  3004. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3005. if (ceErpUserPost != null)
  3006. {
  3007. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3008. if (ceErpPost != null)
  3009. {
  3010. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3011. {
  3012. entitys.tid = entity.ctid;
  3013. entitys.oid = entity.tid;
  3014. entitys.uid = uid;
  3015. entitys.userName = userName;
  3016. entitys.designerType = 1;
  3017. entitys.designerTypeText = "内部设计师";
  3018. entitys.price = Convert.ToDouble(GetPostString("price"));
  3019. entitys.designNum = GetPostInt("designNum");
  3020. entitys.modifyNum = GetPostInt("modifyNum");
  3021. entitys.designSize = GetPostString("designSize");
  3022. entitys.modifySize = GetPostString("modifySize");
  3023. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3024. {
  3025. entitys.create_time = DateTime.Now;
  3026. entitys.create_u_id = uid;
  3027. entitys.create_u_name = userName;
  3028. entitys.Save();
  3029. }
  3030. else
  3031. {
  3032. entitys.update_time = DateTime.Now;
  3033. entitys.update_u_id = uid;
  3034. entitys.update_u_name = userName;
  3035. entitys.Update();
  3036. }
  3037. }
  3038. }
  3039. }
  3040. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3041. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3042. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3043. if (suname != "")
  3044. {
  3045. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3046. }
  3047. commonHelper.getCytPrice(entity);
  3048. returnSuccessMsg("操作成功!");
  3049. return;
  3050. }
  3051. returnErrorMsg("找不到记录");
  3052. }
  3053. }
  3054. public void upload_erp_filecomplete()
  3055. {
  3056. if (UrlPostParmsCheck("ctid"))
  3057. {
  3058. string eid = GetPostString("ctid");
  3059. CeErpTradeCell entity = null;
  3060. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3061. if (entity != null)
  3062. {
  3063. entity.OrderState = 5; //设计完成
  3064. entity.Update();
  3065. returnSuccessMsg(eid + "上传成功,设计完成!");
  3066. return;
  3067. }
  3068. returnErrorMsg("找不到订单记录");
  3069. }
  3070. }
  3071. public void get_erp_designovertimelist()
  3072. {
  3073. DataStruct dStruct = GetPostStruct();
  3074. List<string> lw = new List<string>();
  3075. string tid = GetPostString("ctid");
  3076. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3077. string shopname = GetPostString("shopname");
  3078. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3079. string buyernick = GetPostString("buyer_nick");
  3080. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3081. string ResponsibleMan = GetPostString("responsible");
  3082. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3083. string date1 = GetPostString("date1");
  3084. string date2 = GetPostString("date2");
  3085. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3086. if (dw.Length > 0) lw.Add(dw);
  3087. string price1 = GetPostString("price1");
  3088. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3089. string price2 = GetPostString("price2");
  3090. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3091. string orderState = GetPostString("orderState");
  3092. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3093. string sellermemo = GetPostString("seller_memo");
  3094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3095. lw.Add(string.Format("UnusualTag=3"));
  3096. lw.Add(string.Format("IsRefund<={0}", 1));
  3097. dStruct.Order = "WaitDesignTime desc";
  3098. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3099. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3100. writeGridDataTableJson(dStruct.TotalCount, dt);
  3101. }
  3102. //设计管理 获取抢单大厅列表
  3103. public void get_erp_grabinglist()
  3104. {
  3105. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3106. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3107. bool oldOrder = false;
  3108. if (org != null)
  3109. {
  3110. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3111. }
  3112. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3113. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3114. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3115. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3116. //先处理订单数据
  3117. if (dt.Rows.Count > 0)
  3118. {
  3119. Dictionary<string, int> design = null;
  3120. int count = 0;
  3121. foreach (DataRow row in dt.Rows)
  3122. {
  3123. if (map.ContainsKey(row["ShopId"].ToString()))
  3124. {
  3125. map.TryGetValue(row["ShopId"].ToString(), out design);
  3126. }
  3127. else
  3128. {
  3129. design = new Dictionary<string, int>();
  3130. }
  3131. if (design.ContainsKey(row["ProductId"].ToString()))
  3132. {
  3133. design.TryGetValue(row["ProductId"].ToString(), out count);
  3134. }
  3135. count++;
  3136. design[row["ProductId"].ToString()] = count;
  3137. map[row["ShopId"].ToString()] = design;
  3138. }
  3139. }
  3140. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3141. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3142. //把店铺排序和技能排序分类
  3143. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3144. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3145. if (design_dt.Rows.Count > 0)
  3146. {
  3147. Dictionary<string, string> design = null;
  3148. List<string> shopIds = null;
  3149. foreach (DataRow row in design_dt.Rows)
  3150. {
  3151. if ("0".Equals(row["designId"].ToString()))
  3152. {
  3153. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3154. {
  3155. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3156. }
  3157. else
  3158. {
  3159. shopIds = new List<string>();
  3160. }
  3161. shopIds.Add(row["shopId"].ToString());
  3162. shop_orders[row["orders"].ToString()] = shopIds;
  3163. }
  3164. else
  3165. {
  3166. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3167. {
  3168. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3169. }
  3170. else
  3171. {
  3172. design = new Dictionary<string, string>();
  3173. }
  3174. design[row["orders"].ToString()] = row["designId"].ToString();
  3175. design_orders[row["shopId"].ToString()] = design;
  3176. }
  3177. }
  3178. //处理成key value后根据key排序
  3179. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3180. foreach (List<string> val in shop_orders.Values)
  3181. {
  3182. if (val != null)
  3183. {
  3184. foreach (string key in val)
  3185. {
  3186. if (design_orders.ContainsKey(key.ToString()))
  3187. {
  3188. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3189. }
  3190. }
  3191. }
  3192. }
  3193. }
  3194. //校验哪个优先级有订单
  3195. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3196. foreach (string key in shop_orders.Keys)
  3197. {
  3198. List<string> ids = null;
  3199. shop_orders.TryGetValue(key, out ids);
  3200. //id为shopid
  3201. foreach (string id in ids)
  3202. {
  3203. Dictionary<string, int> list = null;
  3204. Dictionary<string, string> desing = null;
  3205. map.TryGetValue(id, out list);
  3206. design_orders.TryGetValue(id, out desing);
  3207. if (list != null && desing != null)
  3208. {
  3209. foreach (var item in desing)
  3210. {
  3211. int count = 0;
  3212. if (list.ContainsKey(item.Value))
  3213. {
  3214. list.TryGetValue(item.Value, out count);
  3215. if (count > 0)
  3216. {
  3217. designIds[id] = item.Value;
  3218. break;
  3219. }
  3220. }
  3221. }
  3222. }
  3223. }
  3224. if (designIds.Count > 0)
  3225. {
  3226. break;
  3227. }
  3228. }
  3229. DataTable table = new DataTable();
  3230. table.Columns.Add("tid", typeof(string));
  3231. table.Columns.Add("ctid", typeof(string));
  3232. table.Columns.Add("seller_nick", typeof(string));
  3233. table.Columns.Add("productName", typeof(string));
  3234. table.Columns.Add("pay_time", typeof(string));
  3235. table.Columns.Add("seller_memo", typeof(string));
  3236. if (designIds.Count > 0)
  3237. {
  3238. string shopId = "";
  3239. string productId = "";
  3240. foreach (var designInfo in designIds)
  3241. {
  3242. shopId = designInfo.Key;
  3243. productId = designInfo.Value;
  3244. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3245. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3246. if (dt.Rows.Count > 0)
  3247. {
  3248. foreach (DataRow row in dt.Rows)
  3249. {
  3250. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3251. {
  3252. DataRow data = table.NewRow();
  3253. data["ctid"] = row["ctid"].ToString();
  3254. data["tid"] = row["tid"].ToString();
  3255. data["seller_nick"] = ceErpShop.ShopName;
  3256. data["pay_time"] = row["pay_time"].ToString();
  3257. data["seller_memo"] = row["seller_memo"].ToString();
  3258. data["productName"] = ceErpProduct.PType;
  3259. table.Rows.Add(data);
  3260. }
  3261. }
  3262. }
  3263. }
  3264. }
  3265. writeGridDataTableJson(table.Rows.Count, table);
  3266. }
  3267. private object rushLockObject = new object();
  3268. public void set_erp_grabingorder()
  3269. {
  3270. if (UrlPostParmsCheck("ctid"))
  3271. {
  3272. int total = CurrentUser.User.Person.Total;
  3273. int userId = CurrentUser.User.ID;
  3274. int noFinish = CurrentUser.User.Person.NoFinish;
  3275. int finalization = CurrentUser.User.Person.Finalization;
  3276. string eids = GetPostString("ctid");
  3277. string key = "RushKey_" + userId;
  3278. int count = 0;
  3279. if (erpRedis.RedisHelper.KeyExists(key))
  3280. {
  3281. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3282. if (redisCount != null)
  3283. {
  3284. count = Convert.ToInt32(redisCount);
  3285. }
  3286. }
  3287. if (count >= total)
  3288. {
  3289. returnErrorMsg("半小时内已经抢" + total + "单");
  3290. return;
  3291. }
  3292. string[] ctidlist = eids.Split(',');
  3293. if (count + ctidlist.Length > total)
  3294. {
  3295. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3296. return;
  3297. }
  3298. int itag = 0;
  3299. lock (rushLockObject)
  3300. {
  3301. if (ctidlist.Length > 0)
  3302. {
  3303. string[] dtList = new string[ctidlist.Length];
  3304. for (int i = 0; i < ctidlist.Length; i++)
  3305. {
  3306. dtList[i] = "'" + ctidlist[i] + "'";
  3307. }
  3308. 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"));
  3309. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3310. if (dt_user.Rows.Count > 0)
  3311. {
  3312. int doing = 0;//未定稿
  3313. int finish = 0;//已完成
  3314. foreach (DataRow dr in dt_user.Rows)
  3315. {
  3316. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3317. {
  3318. doing++;
  3319. }
  3320. else
  3321. {
  3322. finish++;
  3323. }
  3324. }
  3325. if (doing >= noFinish)
  3326. {
  3327. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3328. return;
  3329. }
  3330. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3331. {
  3332. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3333. return;
  3334. }
  3335. }
  3336. //校验选择单子状态
  3337. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3338. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3339. if (dt.Rows.Count > 0)
  3340. {
  3341. List<string> list = new List<string>();
  3342. foreach (DataRow dr in dt.Rows)
  3343. {
  3344. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3345. {
  3346. list.Add(dr["ctid"].ToString());
  3347. }
  3348. }
  3349. if (list.Count > 0)
  3350. {
  3351. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3352. return;
  3353. }
  3354. }
  3355. foreach (string ctid in ctidlist)
  3356. {
  3357. CeErpTradeCell entity = null;
  3358. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3359. if (entity != null)
  3360. {
  3361. entity.OrderState = 3;
  3362. entity.DesignUserId = CurrentUser.UserID;
  3363. entity.WaitDesignTime = DateTime.Now;
  3364. entity.StartDesignTime = DateTime.Now;
  3365. entity.Update();
  3366. commonHelper.UpdateRelationOrder(entity.ctid);
  3367. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3368. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3369. itag++;
  3370. }
  3371. }
  3372. }
  3373. }
  3374. count += ctidlist.Length;
  3375. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3376. if (itag == 0)
  3377. returnErrorMsg("没有找到相关订单");
  3378. else
  3379. returnSuccessMsg("抢单成功!");
  3380. return;
  3381. }
  3382. }
  3383. public void get_erp_waitorderlist()
  3384. {
  3385. DataStruct dStruct = GetPostStruct();
  3386. List<string> lw = new List<string>();
  3387. string tid = GetPostString("ctid");
  3388. if (tid.Length > 0)
  3389. {
  3390. string select_tid = getTidByCtid(tid);
  3391. lw.Add(string.Format("tid='{0}'", select_tid));
  3392. }
  3393. string shopname = GetPostString("shopname");
  3394. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3395. string buyernick = GetPostString("buyer_nick");
  3396. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3397. string customer = GetPostString("customer");
  3398. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3399. string design = GetPostString("design");
  3400. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3401. string orderState = GetPostString("orderState");
  3402. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3403. string supplier = GetPostString("supplier");
  3404. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3405. string sellermemo = GetPostString("seller_memo");
  3406. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3407. string otherMemo = GetPostString("otherMemo");
  3408. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3409. string address = GetPostString("address");
  3410. 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));
  3411. string date1 = GetPostString("date1");
  3412. string date2 = GetPostString("date2");
  3413. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3414. if (dw.Length > 0) lw.Add(dw);
  3415. string price1 = GetPostString("price1");
  3416. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3417. string price2 = GetPostString("price2");
  3418. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3419. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3420. lw.Add(string.Format("IsSample != 2 "));
  3421. lw.Add(string.Format("OrderState = 5 "));
  3422. lw.Add(string.Format("IsRefund<={0}", 1));
  3423. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3424. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3425. string pagesize = GetPostString("pagesize");
  3426. if (pagesize != null)
  3427. {
  3428. dStruct.PageSize = 200;
  3429. }
  3430. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3431. List<string> tids = new List<string>();
  3432. if (dt != null)
  3433. {
  3434. dt.Columns.Add("compenPrice", typeof(double));
  3435. foreach (DataRow dr in dt.Rows)
  3436. {
  3437. if (Convert.IsDBNull(dr["compenPrice"]))
  3438. {
  3439. dr["compenPrice"] = 0;
  3440. }
  3441. tids.Add("'" + dr["tid"].ToString() + "'");
  3442. 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();
  3443. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3444. {
  3445. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3446. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3447. entity.SupplierId = suid;
  3448. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3449. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3450. entity.Update();
  3451. }
  3452. }
  3453. }
  3454. if (tids.Count > 0)
  3455. {
  3456. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3457. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3458. if (dt_price != null && dt_price.Rows.Count > 0)
  3459. {
  3460. foreach (DataRow dr in dt_price.Rows)
  3461. {
  3462. foreach (DataRow row in dt.Rows)
  3463. {
  3464. if (row["tid"].Equals(dr["ptid"]))
  3465. {
  3466. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3467. break;
  3468. }
  3469. }
  3470. }
  3471. }
  3472. }
  3473. writeGridDataTableJson(dStruct.TotalCount, dt);
  3474. }
  3475. public void get_erp_supplierwaitorderlist()
  3476. {
  3477. DataStruct dStruct = GetPostStruct();
  3478. List<string> lw = new List<string>();
  3479. string tid = GetPostString("ctid");
  3480. if (tid.Length > 0)
  3481. {
  3482. string select_tid = getTidByCtid(tid);
  3483. lw.Add(string.Format("tid='{0}'", select_tid));
  3484. }
  3485. string shopname = GetPostString("shopname");
  3486. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3487. string sellermemo = GetPostString("seller_memo");
  3488. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3489. string date1 = GetPostString("date1");
  3490. string date2 = GetPostString("date2");
  3491. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3492. if (dw.Length > 0) lw.Add(dw);
  3493. lw.Add(string.Format("OrderState = 5 "));
  3494. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3495. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3496. {
  3497. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3498. }
  3499. string supplier = GetPostString("supplier");
  3500. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3501. {
  3502. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3503. }
  3504. lw.Add(string.Format("IsRefund<={0}", 1));
  3505. dStruct.Order = "FinishDesignTime desc";
  3506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3507. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3508. if (dt != null)
  3509. {
  3510. foreach (DataRow dr in dt.Rows)
  3511. {
  3512. 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();
  3513. }
  3514. }
  3515. writeGridDataTableJson(dStruct.TotalCount, dt);
  3516. }
  3517. public void upd_erp_verifytosupplier()
  3518. {
  3519. if (UrlPostParmsCheck("ctid"))
  3520. {
  3521. string eids = GetPostString("ctid");
  3522. CeErpTradeCell entity = null;
  3523. string[] eidsList = eids.Split(',');
  3524. if (eidsList.Length <= 0)
  3525. {
  3526. returnErrorMsg("订单号不能空");
  3527. return;
  3528. }
  3529. List<string> tLst = new List<string>();
  3530. foreach (string ctidstr in eidsList)
  3531. {
  3532. tLst.Add("'" + ctidstr + "'");
  3533. CeErpDataSendOrderInfo.createObject(ctidstr);
  3534. }
  3535. string needtids = string.Join(",", tLst.ToArray());
  3536. StringBuilder sql = new StringBuilder();
  3537. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3538. 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);
  3539. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3540. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3541. returnSuccessMsg("操作成功!");
  3542. return;
  3543. /**foreach (string ctidstr in eidsList)
  3544. {
  3545. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3546. if (entity != null)
  3547. {
  3548. if (entity.SupplierId == 0)
  3549. {
  3550. continue;
  3551. }
  3552. entity.IsVerifyToSupplier = true;
  3553. if (entity.IsReturn == 1) //1是供应商打回
  3554. {
  3555. entity.IsReturn = 0;
  3556. }
  3557. entity.FinishPlaceTime = DateTime.Now;
  3558. entity.PlaceUserId = CurrentUser.UserID;
  3559. entity.Update();
  3560. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3561. }
  3562. }
  3563. returnSuccessMsg("操作成功!");
  3564. return;**/
  3565. }
  3566. }
  3567. public void upd_erp_supplierback()
  3568. {
  3569. if (UrlPostParmsCheck("ctid"))
  3570. {
  3571. string eid = GetPostString("ctid");
  3572. string reason = GetPostString("returnreason");
  3573. CeErpTradeCell entity = null;
  3574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3575. if (entity != null)
  3576. {
  3577. string message = "操作成功!";
  3578. string isDown = "";
  3579. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3580. {
  3581. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3582. isDown = "被点击下载";
  3583. }
  3584. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3585. {
  3586. string key = "return_order_" + entity.SupplierId;
  3587. List<string> list = new List<string>();
  3588. if (RedisHelper.HasKey(key))
  3589. {
  3590. object data = RedisHelper.StringGet(key);
  3591. list = Convert.ToString(data).Split(',').ToList();
  3592. }
  3593. list.Add(eid);
  3594. RedisHelper.StringSet(key, string.Join(",", list));
  3595. }
  3596. entity.IsVerifyToSupplier = false;
  3597. entity.IsReturn = 1;
  3598. entity.IsHaveNewOrder = 0;
  3599. entity.ReturnTime = DateTime.Now;
  3600. entity.ReturnReason = reason;
  3601. if (entity.OrderState == 6)
  3602. {
  3603. entity.OrderState = 5;
  3604. }
  3605. entity.Update();
  3606. CeErpSukuraData.createInfo(entity.ctid, 5);
  3607. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3608. returnSuccessMsg(message);
  3609. return;
  3610. }
  3611. returnErrorMsg("找不到订单记录");
  3612. }
  3613. }
  3614. public void upd_erp_toaftersaleorder()
  3615. {
  3616. if (UrlPostParmsCheck("ctid"))
  3617. {
  3618. string eid = GetPostString("ctid");
  3619. string reason = GetPostString("returnreason");
  3620. CeErpTradeCell entity = null;
  3621. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3622. if (entity != null)
  3623. {
  3624. if (entity.isAfterSaleOrder != 1)
  3625. {
  3626. returnErrorMsg("带S的售后单才能打回给售后");
  3627. return;
  3628. }
  3629. if (entity.OrderState >= 5)
  3630. {
  3631. returnErrorMsg("已经设计完成了不能打回给售后");
  3632. return;
  3633. }
  3634. entity.OrderState = 0;
  3635. entity.IsReturn = 3;
  3636. entity.ReturnTime = DateTime.Now;
  3637. entity.UpdateTime = DateTime.Now;
  3638. entity.ReturnReason = reason;
  3639. entity.Update();
  3640. CeErpSukuraData.createInfo(entity.ctid, 5);
  3641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3642. returnSuccessMsg("操作成功!");
  3643. return;
  3644. }
  3645. returnErrorMsg("找不到订单记录");
  3646. }
  3647. }
  3648. public void upd_erp_aftersaletodesign()
  3649. {
  3650. if (UrlPostParmsCheck("ctid"))
  3651. {
  3652. string eid = GetPostString("ctid");
  3653. CeErpTradeCell entity = null;
  3654. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3655. if (entity != null)
  3656. {
  3657. entity.OrderState = 3;
  3658. entity.IsReturn = 0;
  3659. entity.UpdateTime = DateTime.Now;
  3660. entity.Update();
  3661. CeErpSukuraData.createInfo(entity.ctid, 5);
  3662. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3663. returnSuccessMsg("操作成功!");
  3664. return;
  3665. }
  3666. returnErrorMsg("找不到订单记录");
  3667. }
  3668. }
  3669. public void assign_erp_supplier()
  3670. {
  3671. if (UrlPostParmsCheck("ctid"))
  3672. {
  3673. string eids = GetPostString("ctid");
  3674. int sid = GetPostInt("SupplierName");
  3675. string fromTag = GetPostString("tag");
  3676. string[] eidList = eids.Split(',');
  3677. if (eidList.Length <= 0)
  3678. {
  3679. returnErrorMsg("指派不能为空");
  3680. return;
  3681. }
  3682. string errMsg = "";
  3683. string suname = commonHelper.getSupplierNameById(sid);
  3684. foreach (string ctid in eidList)
  3685. {
  3686. CeErpTradeCell entity = null;
  3687. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3688. if (entity != null)
  3689. {
  3690. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3691. {
  3692. errMsg += (ctid + "指派失败!!!");
  3693. continue;
  3694. }
  3695. entity.SupplierId = sid;
  3696. entity.Update();
  3697. commonHelper.UpdateRelationOrder(entity.ctid);
  3698. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3699. if (entity.OrderState >= 6)
  3700. {
  3701. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3702. //{
  3703. // string msl = entity.MakeSupplier;
  3704. // string[] mslist = msl.Split(',');
  3705. // 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);
  3706. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3707. //}
  3708. //else
  3709. //{
  3710. StringBuilder sql = new StringBuilder();
  3711. 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);
  3712. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3713. //}
  3714. }
  3715. }
  3716. else
  3717. {
  3718. continue;
  3719. }
  3720. }
  3721. if (errMsg.Length > 0)
  3722. {
  3723. returnErrorMsg(errMsg);
  3724. return;
  3725. }
  3726. returnSuccessMsg("操作成功!");
  3727. return;
  3728. }
  3729. }
  3730. public void assign_erp_makesupplier()
  3731. {
  3732. if (UrlPostParmsCheck("ctid"))
  3733. {
  3734. string eids = GetPostString("ctid");
  3735. string sname = GetPostString("SupplierName");
  3736. string[] eidList = eids.Split(',');
  3737. if (eidList.Length <= 0)
  3738. {
  3739. returnErrorMsg("指派不能为空");
  3740. return;
  3741. }
  3742. List<string> tLst = new List<string>();
  3743. foreach (string ctid in eidList)
  3744. {
  3745. CeErpTradeCell entity = null;
  3746. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3747. if (entity != null)
  3748. {
  3749. entity.MakeSupplier = sname;
  3750. entity.Update();
  3751. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3752. tLst.Add("'" + ctid + "'");
  3753. }
  3754. else
  3755. {
  3756. continue;
  3757. }
  3758. }
  3759. string ctids = string.Join(",", tLst.ToArray());
  3760. StringBuilder sql2 = new StringBuilder();
  3761. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3762. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3763. returnSuccessMsg("操作成功!");
  3764. return;
  3765. }
  3766. }
  3767. public void ins_erp_returnreason()
  3768. {
  3769. if (UrlPostParmsCheck("ctid"))
  3770. {
  3771. string eid = GetPostString("ctid");
  3772. CeErpTradeCell entity = null;
  3773. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3774. string userpost = CurrentUser.UserPost.Post.Code;
  3775. if (entity != null)
  3776. {
  3777. bool isPlace = false;
  3778. if (entity.OrderState > 6)
  3779. {
  3780. returnErrorMsg("已发货无法打回!");
  3781. return;
  3782. }
  3783. if (entity.OrderState == 6)
  3784. {
  3785. isPlace = true;
  3786. }
  3787. bool isNeedUpdateCell2 = false;
  3788. if (entity.OrderState >= 6)
  3789. {
  3790. isNeedUpdateCell2 = true;
  3791. }
  3792. int returnTag = 2;
  3793. if (userpost == "Supplier")
  3794. {
  3795. returnTag = 1;
  3796. }
  3797. int toType = GetPostInt("totype");
  3798. string fromType = "3";
  3799. if (entity.OrderState < 5)
  3800. {
  3801. fromType = "3";
  3802. }
  3803. else
  3804. {
  3805. fromType = "4";
  3806. }
  3807. if (entity.IsXianHuo == 0)
  3808. {
  3809. if (returnTag == 2)
  3810. {
  3811. if (toType == 1)
  3812. {
  3813. entity.OrderState = 0;
  3814. entity.ReturnUserType = 1;
  3815. string clearman = GetPostString("clearman");
  3816. if (!string.IsNullOrEmpty(clearman))
  3817. {
  3818. entity.DesignUserId = 0;
  3819. }
  3820. }
  3821. else
  3822. {
  3823. entity.OrderState = 3;
  3824. entity.ReturnUserType = 2;
  3825. }
  3826. entity.IsReadTag = 1;
  3827. }
  3828. else if (returnTag == 1)
  3829. {
  3830. entity.OrderState = 5;
  3831. }
  3832. entity.IsVerifyToSupplier = false;
  3833. }
  3834. if (entity.IsXianHuo == 1)
  3835. {
  3836. entity.OrderState = 5;
  3837. }
  3838. entity.UnusualTag = 0;
  3839. entity.UnusualTime = null;
  3840. entity.UnusualCon = "";
  3841. entity.IsReturn = returnTag;
  3842. entity.ReturnTime = DateTime.Now;
  3843. entity.UpdateTime = DateTime.Now;
  3844. entity.ReturnReason = GetPostString("returnreason");
  3845. entity.Update();
  3846. if (entity.OrderState == 3)
  3847. {
  3848. ApiVo apiVo = new ApiVo();
  3849. apiVo.orderNumber = entity.ctid;
  3850. apiVo.actionName = "rebutDesign";
  3851. apiVo.orderRemarks = entity.ReturnReason;
  3852. designHelper.API_WorkCore(apiVo);//rebutDesign
  3853. }
  3854. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3855. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3856. {
  3857. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3858. }
  3859. CeErpSukuraData.createInfo(entity.ctid, 5);
  3860. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3862. if (isPlace)
  3863. {
  3864. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3865. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3866. if (dth != null && dth.Rows.Count > 0)
  3867. {
  3868. dataSendOrderBean dataSendOrderBean = null;
  3869. foreach (DataRow item in dth.Rows)
  3870. {
  3871. try
  3872. {
  3873. dataSendOrderBean = new dataSendOrderBean();
  3874. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3875. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3876. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3877. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3878. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3879. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3880. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3881. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3882. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3883. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3884. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3885. dataSendOrderBean.Radio1723534706288 = "打回";
  3886. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3887. if (result != null)
  3888. {
  3889. if ("0".Equals(result.errcode))
  3890. {
  3891. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3892. }
  3893. else
  3894. {
  3895. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3896. }
  3897. }
  3898. }
  3899. catch (Exception ex)
  3900. {
  3901. }
  3902. }
  3903. }
  3904. }
  3905. if (isNeedUpdateCell2)
  3906. {
  3907. if (entity.MakeSupplier.IndexOf(",") != -1)
  3908. {
  3909. StringBuilder sql2 = new StringBuilder();
  3910. 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);
  3911. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3912. }
  3913. else
  3914. {
  3915. StringBuilder sql2 = new StringBuilder();
  3916. 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);
  3917. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3918. }
  3919. }
  3920. returnSuccessMsg("操作成功!");
  3921. return;
  3922. }
  3923. returnErrorMsg("找不到订单记录");
  3924. }
  3925. }
  3926. public void cyt_erp_returnreason()
  3927. {
  3928. if (UrlPostParmsCheck("ctid"))
  3929. {
  3930. string eid = GetPostString("ctid");
  3931. CeErpTradeCell entity = null;
  3932. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3933. string userpost = CurrentUser.UserPost.Post.Code;
  3934. if (entity != null)
  3935. {
  3936. if (entity.OrderState > 6)
  3937. {
  3938. returnErrorMsg("已发货无法打回!");
  3939. return;
  3940. }
  3941. JObject jsonObject = new JObject
  3942. {
  3943. { "Userid", "77886" },
  3944. { "Pwd", "lt666888" },
  3945. { "LTOrderId",eid }
  3946. };
  3947. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3948. JObject jsonObjects = JObject.Parse(response);
  3949. string msg = (string)jsonObjects["msg"];
  3950. if (msg != "取消成功")
  3951. {
  3952. returnErrorMsg(msg);
  3953. return;
  3954. }
  3955. bool isNeedUpdateCell2 = false;
  3956. if (entity.OrderState >= 6)
  3957. {
  3958. isNeedUpdateCell2 = true;
  3959. }
  3960. int returnTag = 2;
  3961. if (userpost == "Supplier")
  3962. {
  3963. returnTag = 1;
  3964. }
  3965. if (entity.IsXianHuo == 0)
  3966. {
  3967. if (returnTag == 2)
  3968. {
  3969. int toType = GetPostInt("totype");
  3970. if (toType == 1)
  3971. {
  3972. entity.OrderState = 0;
  3973. entity.ReturnUserType = 1;
  3974. }
  3975. else
  3976. {
  3977. entity.OrderState = 4;
  3978. entity.ReturnUserType = 2;
  3979. }
  3980. entity.IsReadTag = 1;
  3981. }
  3982. else if (returnTag == 1)
  3983. {
  3984. entity.OrderState = 5;
  3985. }
  3986. entity.IsVerifyToSupplier = false;
  3987. }
  3988. entity.UnusualTag = 0;
  3989. entity.UnusualTime = null;
  3990. entity.UnusualCon = "";
  3991. entity.IsReturn = returnTag;
  3992. entity.ReturnTime = DateTime.Now;
  3993. entity.ReturnReason = GetPostString("returnreason");
  3994. entity.Update();
  3995. if (entity.OrderState == 4)
  3996. {
  3997. ApiVo apiVo = new ApiVo();
  3998. apiVo.orderNumber = entity.ctid;
  3999. apiVo.actionName = "rebutDesign";
  4000. apiVo.orderRemarks = entity.ReturnReason;
  4001. designHelper.API_WorkCore(apiVo);//rebutDesign
  4002. }
  4003. CeErpSukuraData.createInfo(entity.ctid, 5);
  4004. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4005. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4006. if (isNeedUpdateCell2)
  4007. {
  4008. if (entity.MakeSupplier.IndexOf(",") != -1)
  4009. {
  4010. StringBuilder sql2 = new StringBuilder();
  4011. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 2 ID from ce_erptradecell2 where ctid='{1}' order by ID desc) ", entity.ReturnReason, entity.ctid, returnTag);
  4012. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4013. }
  4014. else
  4015. {
  4016. StringBuilder sql2 = new StringBuilder();
  4017. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 1 ID from ce_erptradecell2 where ctid='{1}' order by ID desc)", entity.ReturnReason, entity.ctid, returnTag);
  4018. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4019. }
  4020. }
  4021. returnSuccessMsg("操作成功!");
  4022. return;
  4023. }
  4024. returnErrorMsg("找不到订单记录");
  4025. }
  4026. }
  4027. public void upd_erp_xianhuoreturntag()
  4028. {
  4029. if (UrlPostParmsCheck("ctid"))
  4030. {
  4031. string eids = GetPostString("ctid");
  4032. string[] ctids = eids.Split(',');
  4033. foreach (string ctid in ctids)
  4034. {
  4035. CeErpTradeCell entity = null;
  4036. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4037. if (entity != null)
  4038. {
  4039. entity.IsReturn = 0;
  4040. entity.Update();
  4041. CeErpSukuraData.createInfo(entity.ctid, 5);
  4042. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4043. }
  4044. }
  4045. returnSuccessMsg("操作成功!");
  4046. return;
  4047. }
  4048. }
  4049. public void get_erp_waitdeliverylist()
  4050. {
  4051. DataStruct dStruct = GetPostStruct();
  4052. List<string> lw = new List<string>();
  4053. string tid = GetPostString("ctid");
  4054. if (tid.Length > 0)
  4055. {
  4056. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4057. if (tid.Length > 5)
  4058. {
  4059. List<string> tids = getTidByCtidLike(tid);
  4060. if (tids.Count > 0 && tids.Count < 10)
  4061. {
  4062. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4063. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4064. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4065. {
  4066. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4067. }*/
  4068. }
  4069. }
  4070. lw.Add(tid_sql);
  4071. }
  4072. string shopname = GetPostString("shopname");
  4073. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4074. string buyernick = GetPostString("buyer_nick");
  4075. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4076. //if (tid.Length == 0 && buyernick.Length == 0)
  4077. //{
  4078. // lw.Add(string.Format("IsRefund<={0}", 1));
  4079. //}
  4080. string customer = GetPostString("customer");
  4081. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4082. string design = GetPostString("design");
  4083. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4084. string orderState = GetPostString("orderState");
  4085. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4086. string address = GetPostString("address");
  4087. 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));
  4088. string sellermemo = GetPostString("seller_memo");
  4089. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4090. string supplier = GetPostString("supplier");
  4091. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4092. string OrderArea = GetPostString("order_area");
  4093. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4094. string placedate1 = GetPostString("placedate1");
  4095. string placedate2 = GetPostString("placedate2");
  4096. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4097. if (fdw.Length > 0) lw.Add(fdw);
  4098. string price1 = GetPostString("price1");
  4099. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4100. string price2 = GetPostString("price2");
  4101. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4102. string unusualCon = GetPostString("unusualcon");
  4103. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4104. string otherMemo = GetPostString("otherMemo");
  4105. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4106. string posTag = CurrentUser.UserPost.Post.Code;
  4107. if (posTag == "Supplier")
  4108. {
  4109. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4110. }
  4111. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4112. lw.Add(string.Format("type != 'PDD' "));
  4113. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4114. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4116. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4117. writeGridDataTableJson(dStruct.TotalCount, dt);
  4118. }
  4119. public void get_erp_changedeliverylist()
  4120. {
  4121. DataStruct dStruct = GetPostStruct();
  4122. List<string> lw = new List<string>();
  4123. string tid = GetPostString("ctid");
  4124. if (tid.Length > 0)
  4125. {
  4126. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4127. if (tid.Length > 5)
  4128. {
  4129. List<string> tids = getTidByCtidLike(tid);
  4130. if (tids.Count > 0 && tids.Count < 10)
  4131. {
  4132. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4133. }
  4134. }
  4135. lw.Add(tid_sql);
  4136. }
  4137. string shopname = GetPostString("shopname");
  4138. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4139. string buyernick = GetPostString("buyer_nick");
  4140. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4141. //if (tid.Length == 0 && buyernick.Length == 0)
  4142. //{
  4143. // lw.Add(string.Format("IsRefund<={0}", 1));
  4144. //}
  4145. string customer = GetPostString("customer");
  4146. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4147. string design = GetPostString("design");
  4148. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4149. string orderState = GetPostString("orderState");
  4150. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4151. string address = GetPostString("address");
  4152. 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));
  4153. string sellermemo = GetPostString("seller_memo");
  4154. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4155. string supplier = GetPostString("supplier");
  4156. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4157. string OrderArea = GetPostString("order_area");
  4158. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4159. string placedate1 = GetPostString("placedate1");
  4160. string placedate2 = GetPostString("placedate2");
  4161. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4162. if (fdw.Length > 0) lw.Add(fdw);
  4163. string price1 = GetPostString("price1");
  4164. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4165. string price2 = GetPostString("price2");
  4166. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4167. string unusualCon = GetPostString("unusualcon");
  4168. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4169. string otherMemo = GetPostString("otherMemo");
  4170. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4171. string posTag = CurrentUser.UserPost.Post.Code;
  4172. if (posTag == "Supplier")
  4173. {
  4174. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4175. }
  4176. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4177. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4178. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4179. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4180. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4181. /*if (tid.Length > 0)
  4182. {
  4183. List<string> tids = new List<string>();
  4184. if (dt != null && dt.Rows.Count > 0)
  4185. {
  4186. foreach (DataRow item in dt.Rows)
  4187. {
  4188. tids.Add("'" + item["tid"] + "'");
  4189. }
  4190. }
  4191. if (tids.Count > 0)
  4192. {
  4193. lw.RemoveAt(0);
  4194. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4195. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4196. dt = WebCache.GetData("view_erptradecell", dStruct);
  4197. }
  4198. }*/
  4199. writeGridDataTableJson(dStruct.TotalCount, dt);
  4200. }
  4201. public void get_erp_pddderiving()
  4202. {
  4203. DataStruct dStruct = GetPostStruct();
  4204. List<string> lw = new List<string>();
  4205. string tid = GetPostString("ctid");
  4206. if (tid.Length > 0)
  4207. {
  4208. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4209. if (tid.Length > 5)
  4210. {
  4211. List<string> tids = getTidByCtidLike(tid);
  4212. if (tids.Count > 0 && tids.Count < 10)
  4213. {
  4214. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4215. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4216. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4217. {
  4218. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4219. }*/
  4220. }
  4221. }
  4222. lw.Add(tid_sql);
  4223. }
  4224. string shopname = GetPostString("shopname");
  4225. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4226. string buyernick = GetPostString("buyer_nick");
  4227. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4228. //if (tid.Length == 0 && buyernick.Length == 0)
  4229. //{
  4230. // lw.Add(string.Format("IsRefund<={0}", 1));
  4231. //}
  4232. string customer = GetPostString("customer");
  4233. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4234. string design = GetPostString("design");
  4235. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4236. string orderState = GetPostString("orderState");
  4237. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4238. string address = GetPostString("address");
  4239. 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));
  4240. string sellermemo = GetPostString("seller_memo");
  4241. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4242. string supplier = GetPostString("supplier");
  4243. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4244. string OrderArea = GetPostString("order_area");
  4245. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4246. string placedate1 = GetPostString("placedate1");
  4247. string placedate2 = GetPostString("placedate2");
  4248. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4249. if (fdw.Length > 0) lw.Add(fdw);
  4250. string price1 = GetPostString("price1");
  4251. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4252. string price2 = GetPostString("price2");
  4253. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4254. string unusualCon = GetPostString("unusualcon");
  4255. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4256. string posTag = CurrentUser.UserPost.Post.Code;
  4257. if (posTag == "Supplier")
  4258. {
  4259. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4260. }
  4261. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4262. lw.Add(string.Format("type = 'PDD' "));
  4263. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4264. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4265. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4266. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4267. /*if (tid.Length > 0)
  4268. {
  4269. List<string> tids = new List<string>();
  4270. if (dt != null && dt.Rows.Count > 0)
  4271. {
  4272. foreach (DataRow item in dt.Rows)
  4273. {
  4274. tids.Add("'" + item["tid"] + "'");
  4275. }
  4276. }
  4277. if (tids.Count > 0)
  4278. {
  4279. lw.RemoveAt(0);
  4280. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4281. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4282. dt = WebCache.GetData("view_erptradecell", dStruct);
  4283. }
  4284. }*/
  4285. writeGridDataTableJson(dStruct.TotalCount, dt);
  4286. }
  4287. public void get_erp_jdderiving()
  4288. {
  4289. DataStruct dStruct = GetPostStruct();
  4290. List<string> lw = new List<string>();
  4291. string tid = GetPostString("ctid");
  4292. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4293. string shopname = GetPostString("shopname");
  4294. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4295. string buyernick = GetPostString("buyer_nick");
  4296. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4297. //if (tid.Length == 0 && buyernick.Length == 0)
  4298. //{
  4299. // lw.Add(string.Format("IsRefund<={0}", 1));
  4300. //}
  4301. string customer = GetPostString("customer");
  4302. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4303. string design = GetPostString("design");
  4304. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4305. string orderState = GetPostString("orderState");
  4306. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4307. string address = GetPostString("address");
  4308. 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));
  4309. string sellermemo = GetPostString("seller_memo");
  4310. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4311. string supplier = GetPostString("supplier");
  4312. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4313. string OrderArea = GetPostString("order_area");
  4314. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4315. string placedate1 = GetPostString("placedate1");
  4316. string placedate2 = GetPostString("placedate2");
  4317. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4318. if (fdw.Length > 0) lw.Add(fdw);
  4319. string price1 = GetPostString("price1");
  4320. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4321. string price2 = GetPostString("price2");
  4322. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4323. string unusualCon = GetPostString("unusualcon");
  4324. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4325. string posTag = CurrentUser.UserPost.Post.Code;
  4326. if (posTag == "Supplier")
  4327. {
  4328. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4329. }
  4330. lw.Add(string.Format("OrderState = 6 "));
  4331. lw.Add(string.Format("type = 'JD' "));
  4332. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4333. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4334. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4335. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4336. writeGridDataTableJson(dStruct.TotalCount, dt);
  4337. }
  4338. public void get_erp_demoorderlist()
  4339. {
  4340. DataStruct dStruct = GetPostStruct();
  4341. List<string> lw = new List<string>();
  4342. string tid = GetPostString("ctid");
  4343. if (tid.Length > 0)
  4344. {
  4345. string select_tid = getTidByCtid(tid);
  4346. lw.Add(string.Format("tid='{0}'", select_tid));
  4347. }
  4348. string shopname = GetPostString("shopname");
  4349. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4350. string buyernick = GetPostString("buyer_nick");
  4351. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4352. string customer = GetPostString("customer");
  4353. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4354. string design = GetPostString("design");
  4355. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4356. string orderState = GetPostString("orderState");
  4357. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4358. string address = GetPostString("address");
  4359. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4360. string sellermemo = GetPostString("seller_memo");
  4361. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4362. string supplier = GetPostString("supplier");
  4363. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4364. string OrderArea = GetPostString("order_area");
  4365. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4366. string date1 = GetPostString("date1");
  4367. string date2 = GetPostString("date2");
  4368. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4369. if (dw.Length > 0) lw.Add(dw);
  4370. string price1 = GetPostString("price1");
  4371. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4372. string price2 = GetPostString("price2");
  4373. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4374. string posTag = CurrentUser.UserPost.Post.Code;
  4375. if (posTag == "Supplier")
  4376. {
  4377. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4378. }
  4379. //lw.Add(string.Format("OrderState = 6 "));
  4380. lw.Add(string.Format("IsSample={0}", 3));
  4381. lw.Add(string.Format("IsRefund<={0}", 1));
  4382. dStruct.Order = "pay_time desc";
  4383. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4384. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4385. writeGridDataTableJson(dStruct.TotalCount, dt);
  4386. }
  4387. public void save_erp_checkmemo()
  4388. {
  4389. if (UrlPostParmsCheck("ctid"))
  4390. {
  4391. string ctid = GetPostString("ctid");
  4392. CeErpTradeCell entity = null;
  4393. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4394. if (entity != null)
  4395. {
  4396. entity.CheckMemo = GetPostString("CheckMemo");
  4397. entity.Update();
  4398. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4399. if (trade != null)
  4400. {
  4401. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4402. }
  4403. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4404. returnSuccessMsg("保存成功!");
  4405. return;
  4406. }
  4407. returnErrorMsg("找不到记录");
  4408. }
  4409. }
  4410. public void get_erp_returnlist()
  4411. {
  4412. DataStruct dStruct = GetPostStruct();
  4413. List<string> lw = new List<string>();
  4414. string tid = GetPostString("ctid");
  4415. if (tid.Length > 0)
  4416. {
  4417. string select_tid = getTidByCtid(tid);
  4418. lw.Add(string.Format("tid='{0}'", select_tid));
  4419. }
  4420. string shopname = GetPostString("shopname");
  4421. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4422. string buyernick = GetPostString("buyer_nick");
  4423. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4424. string customer = GetPostString("customer");
  4425. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4426. string design = GetPostString("design");
  4427. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4428. string orderState = GetPostString("orderState");
  4429. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4430. string address = GetPostString("address");
  4431. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4432. string sellermemo = GetPostString("seller_memo");
  4433. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4434. string supplier = GetPostString("supplier");
  4435. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4436. string date1 = GetPostString("date1");
  4437. string date2 = GetPostString("date2");
  4438. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4439. if (dw.Length > 0) lw.Add(dw);
  4440. string bdate1 = GetPostString("backdate1");
  4441. string bdate2 = GetPostString("backdate2");
  4442. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4443. if (dw_back.Length > 0) lw.Add(dw_back);
  4444. string price1 = GetPostString("price1");
  4445. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4446. string price2 = GetPostString("price2");
  4447. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4448. lw.Add(string.Format("IsReturn>0"));
  4449. lw.Add(string.Format("IsXianHuo=0"));
  4450. lw.Add(string.Format("IsReturn!=3"));
  4451. string backtype = GetPostString("backtype");
  4452. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4453. dStruct.Order = "FinishDesignTime desc";
  4454. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4455. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4456. writeGridDataTableJson(dStruct.TotalCount, dt);
  4457. }
  4458. public void get_erp_today_sumreturn()
  4459. {
  4460. DataStruct dStruct = GetPostStruct();
  4461. List<string> lw = new List<string>();
  4462. string bdate1 = GetPostString("returnTimeS");
  4463. string bdate2 = GetPostString("returnTimeE");
  4464. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4465. if (dw_back.Length > 0) lw.Add(dw_back);
  4466. lw.Add(string.Format("IsReturn=0"));
  4467. lw.Add(string.Format("IsXianHuo=0"));
  4468. string mainWhere = string.Join(" and ", lw.ToArray());
  4469. string sql = "";
  4470. if (dw_back.Length > 0)
  4471. {
  4472. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4473. }
  4474. else
  4475. {
  4476. 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 + "'";
  4477. }
  4478. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4479. decimal total = 0, today_finish = 0;
  4480. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4481. {
  4482. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4483. }
  4484. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4485. {
  4486. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4487. }
  4488. var res = new
  4489. {
  4490. data = total,
  4491. data1 = today_finish,
  4492. };
  4493. string ro_jsond = JsonConvert.SerializeObject(res);
  4494. returnSuccess(ro_jsond);
  4495. return;
  4496. }
  4497. public void get_erp_allreturnlist()
  4498. {
  4499. DataStruct dStruct = GetPostStruct();
  4500. List<string> lw = new List<string>();
  4501. string tid = GetPostString("ctid");
  4502. if (tid.Length > 0)
  4503. {
  4504. string select_tid = getTidByCtid(tid);
  4505. lw.Add(string.Format("tid='{0}'", select_tid));
  4506. }
  4507. string shopname = GetPostString("shopname");
  4508. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4509. string buyernick = GetPostString("buyer_nick");
  4510. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4511. string customer = GetPostString("customer");
  4512. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4513. string design = GetPostString("design");
  4514. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4515. string orderState = GetPostString("orderState");
  4516. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4517. string address = GetPostString("address");
  4518. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4519. string sellermemo = GetPostString("seller_memo");
  4520. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4521. string supplier = GetPostString("supplier");
  4522. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4523. string date1 = GetPostString("date1");
  4524. string date2 = GetPostString("date2");
  4525. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4526. if (dw.Length > 0) lw.Add(dw);
  4527. string bdate1 = GetPostString("backdate1");
  4528. string bdate2 = GetPostString("backdate2");
  4529. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4530. if (dw_back.Length > 0) lw.Add(dw_back);
  4531. string price1 = GetPostString("price1");
  4532. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4533. string price2 = GetPostString("price2");
  4534. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4535. string backreason = GetPostString("backreason");
  4536. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4537. lw.Add(string.Format("IsXianHuo=0"));
  4538. lw.Add(string.Format("ReturnTime != ''"));
  4539. string backtype = GetPostString("backtype");
  4540. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4541. dStruct.Order = "FinishDesignTime desc";
  4542. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4543. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4544. writeGridDataTableJson(dStruct.TotalCount, dt);
  4545. }
  4546. public void get_erp_aftersalereturnlist()
  4547. {
  4548. DataStruct dStruct = GetPostStruct();
  4549. List<string> lw = new List<string>();
  4550. string tid = GetPostString("ctid");
  4551. if (tid.Length > 0)
  4552. {
  4553. string select_tid = getTidByCtid(tid);
  4554. lw.Add(string.Format("tid='{0}'", select_tid));
  4555. }
  4556. string shopname = GetPostString("shopname");
  4557. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4558. string buyernick = GetPostString("buyer_nick");
  4559. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4560. string customer = GetPostString("customer");
  4561. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4562. string design = GetPostString("design");
  4563. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4564. string orderState = GetPostString("orderState");
  4565. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4566. string address = GetPostString("address");
  4567. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4568. string sellermemo = GetPostString("seller_memo");
  4569. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4570. string supplier = GetPostString("supplier");
  4571. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4572. string date1 = GetPostString("date1");
  4573. string date2 = GetPostString("date2");
  4574. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4575. if (dw.Length > 0) lw.Add(dw);
  4576. string bdate1 = GetPostString("backdate1");
  4577. string bdate2 = GetPostString("backdate2");
  4578. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4579. if (dw_back.Length > 0) lw.Add(dw_back);
  4580. string price1 = GetPostString("price1");
  4581. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4582. string price2 = GetPostString("price2");
  4583. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4584. lw.Add(string.Format("IsReturn=3"));
  4585. string backtype = GetPostString("backtype");
  4586. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4587. string backreason = GetPostString("backreason");
  4588. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4589. dStruct.Order = "ReturnTime desc";
  4590. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4591. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4592. writeGridDataTableJson(dStruct.TotalCount, dt);
  4593. }
  4594. public void get_erp_xianhuoreturnlist()
  4595. {
  4596. DataStruct dStruct = GetPostStruct();
  4597. List<string> lw = new List<string>();
  4598. string tid = GetPostString("ctid");
  4599. if (tid.Length > 0)
  4600. {
  4601. string select_tid = getTidByCtid(tid);
  4602. lw.Add(string.Format("tid='{0}'", select_tid));
  4603. }
  4604. string shopname = GetPostString("shopname");
  4605. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4606. string buyernick = GetPostString("buyer_nick");
  4607. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4608. string customer = GetPostString("customer");
  4609. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4610. string design = GetPostString("design");
  4611. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4612. string orderState = GetPostString("orderState");
  4613. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4614. string address = GetPostString("address");
  4615. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4616. string sellermemo = GetPostString("seller_memo");
  4617. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4618. string supplier = GetPostString("supplier");
  4619. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4620. string OrderArea = GetPostString("order_area");
  4621. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4622. string date1 = GetPostString("date1");
  4623. string date2 = GetPostString("date2");
  4624. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4625. if (dw.Length > 0) lw.Add(dw);
  4626. string price1 = GetPostString("price1");
  4627. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4628. string price2 = GetPostString("price2");
  4629. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4630. string posTag = CurrentUser.UserPost.Post.Code;
  4631. if (posTag == "Supplier")
  4632. {
  4633. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4634. }
  4635. lw.Add(string.Format("OrderState=6 "));
  4636. lw.Add(string.Format("IsXianHuo=1 "));
  4637. lw.Add(string.Format("IsReturn>0 "));
  4638. lw.Add(string.Format("IsReturn!=3"));
  4639. lw.Add(string.Format("IsRefund<={0}", 1));
  4640. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4641. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4642. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4643. writeGridDataTableJson(dStruct.TotalCount, dt);
  4644. }
  4645. public void set_erp_orderdelivery()
  4646. {
  4647. if (UrlPostParmsCheck("ctid"))
  4648. {
  4649. string eid = GetPostString("ctid");
  4650. CeErpTradeCell entity = null;
  4651. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4652. if (entity != null)
  4653. {
  4654. if (entity.OrderState >= 7)
  4655. {
  4656. returnErrorMsg("此单已发货,无需重复发货");
  4657. return;
  4658. }
  4659. if (entity.OrderState != 6)
  4660. {
  4661. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4662. return;
  4663. }
  4664. string shop = GetPostString("seller_nick");
  4665. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4666. string comName = GetPostString("comName");
  4667. string comCode = GetPostString("comCode");
  4668. string outSid = GetPostString("outSid");
  4669. string deliveryType = GetPostString("deliveryType");
  4670. string deliveryMemo = GetPostString("deliveryMemo");
  4671. outSid = outSid.Trim();
  4672. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4673. if (mainEn == null)
  4674. {
  4675. returnErrorMsg("找不到原始订单记录");
  4676. return;
  4677. }
  4678. bool isInitOrderDeliv = false;
  4679. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4680. {
  4681. isInitOrderDeliv = true;
  4682. }
  4683. string apires = "";
  4684. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4685. 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)
  4686. {
  4687. apires = "发货成功true";
  4688. }
  4689. else
  4690. {
  4691. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4692. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4693. }
  4694. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4695. {
  4696. entity.OrderState = 7;//发货后订单已发货
  4697. entity.OutSid = outSid;
  4698. entity.MemoOpt = 0;
  4699. entity.UpdateTime = DateTime.Now;
  4700. entity.FinishDeliveryTime = DateTime.Now;
  4701. entity.Update();
  4702. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4703. commonHelper.UpdateRelationOrder(entity.ctid);
  4704. //还要插入快递信息到 快递信息表
  4705. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4706. exinfo.tid = eid;
  4707. exinfo.out_sid = outSid;
  4708. exinfo.company_code = comCode;
  4709. exinfo.company_name = comName;
  4710. exinfo.delivery_memo = deliveryMemo;
  4711. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4712. exinfo.deliveryType = deliveryType;
  4713. exinfo.Create();
  4714. returnSuccessMsg("发货操作成功!");
  4715. commonHelper.UpdateRelationOrder(entity.ctid);
  4716. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4717. CeErpSukuraData.createInfo(entity.ctid, 4);
  4718. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4719. {
  4720. commonHelper.sendCytExpress(exinfo);
  4721. }
  4722. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4723. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4724. }
  4725. else
  4726. {
  4727. string errmsg = commonHelper.KeepChinese(apires);
  4728. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4729. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4730. }
  4731. return;
  4732. }
  4733. returnErrorMsg("找不到订单记录");
  4734. }
  4735. }
  4736. public void set_erp_multidelivery()
  4737. {
  4738. string eids = GetPostString("tids");
  4739. string[] eidList = eids.Split(',');
  4740. if (eidList.Length <= 0)
  4741. {
  4742. returnErrorMsg("发货不能为空");
  4743. return;
  4744. }
  4745. foreach (string ctid in eidList)
  4746. {
  4747. if (ctid.Length <= 0) continue;
  4748. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4749. if (expInfo != null)
  4750. {
  4751. StringBuilder sql = new StringBuilder();
  4752. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4753. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4754. if (dt.Rows.Count > 0)
  4755. {
  4756. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4757. {
  4758. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4759. expInfo.state = "异常";
  4760. expInfo.isMultiDelivery = 1;
  4761. expInfo.Update();
  4762. continue;
  4763. }
  4764. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4765. {
  4766. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4767. expInfo.state = "异常";
  4768. expInfo.Update();
  4769. continue;
  4770. }
  4771. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4772. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4773. bool isInitOrderDeliv = false;
  4774. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4775. {
  4776. isInitOrderDeliv = true;
  4777. expInfo.isMultiDelivery = 1;
  4778. }
  4779. if (ctid.IndexOf("N") != -1)
  4780. {
  4781. StringBuilder sqlbucha = new StringBuilder();
  4782. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4783. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4784. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4785. commonHelper.UpdateRelationOrder(ctid);
  4786. expInfo.delivery_memo = "发货成功";
  4787. expInfo.state = "发货成功";
  4788. expInfo.isMultiDelivery = 1;
  4789. expInfo.Update();
  4790. }
  4791. else
  4792. {
  4793. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4794. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4795. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4796. {
  4797. expInfo.delivery_memo = "发货成功";
  4798. expInfo.state = "发货成功";
  4799. expInfo.isMultiDelivery = 1;
  4800. expInfo.Update();
  4801. commonHelper.UpdateRelationOrder(ctid);
  4802. CeErpSukuraData.createInfo(ctid, 4);
  4803. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4804. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4805. }
  4806. else
  4807. {
  4808. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4809. expInfo.state = "异常";
  4810. expInfo.Update();
  4811. }
  4812. }
  4813. }
  4814. }
  4815. }
  4816. returnSuccessMsg("操作完成");
  4817. }
  4818. public void reset_erp_memoopt()
  4819. {
  4820. if (UrlPostParmsCheck("ctid"))
  4821. {
  4822. string eid = GetPostString("ctid");
  4823. CeErpTradeCell entity = null;
  4824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4825. if (entity != null)
  4826. {
  4827. string stropt = "";
  4828. if (entity.MemoOpt == 1)
  4829. {
  4830. stropt = "“改稿”";
  4831. }
  4832. else if (entity.MemoOpt == 2)
  4833. {
  4834. stropt = "“定稿”";
  4835. }
  4836. else if (entity.MemoOpt == 3)
  4837. {
  4838. stropt = "“完成查货”";
  4839. CeErpSukuraData.createInfo(entity.ctid, 6);
  4840. }
  4841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4842. entity.UpdateTime = DateTime.Now;
  4843. entity.MemoOpt = 0;
  4844. entity.Update();
  4845. returnSuccessMsg("操作成功!");
  4846. return;
  4847. }
  4848. returnErrorMsg("找不到记录");
  4849. }
  4850. }
  4851. public void get_erp_deliveryunusual()
  4852. {
  4853. DataStruct dStruct = GetPostStruct();
  4854. List<string> lw = new List<string>();
  4855. string tid = GetPostString("ctid");
  4856. if (tid.Length > 0)
  4857. {
  4858. string select_tid = getTidByCtid(tid);
  4859. lw.Add(string.Format("tid='{0}'", select_tid));
  4860. }
  4861. string shopname = GetPostString("shopname");
  4862. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4863. string buyernick = GetPostString("buyer_nick");
  4864. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4865. string customer = GetPostString("customer");
  4866. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4867. string design = GetPostString("design");
  4868. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4869. string sellermemo = GetPostString("seller_memo");
  4870. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4871. string supplier = GetPostString("supplier");
  4872. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4873. string date1 = GetPostString("date1");
  4874. string date2 = GetPostString("date2");
  4875. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4876. if (dw.Length > 0) lw.Add(dw);
  4877. string placedate1 = GetPostString("placedate1");
  4878. string placedate2 = GetPostString("placedate2");
  4879. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4880. if (dw_place.Length > 0) lw.Add(dw_place);
  4881. string price1 = GetPostString("price1");
  4882. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4883. string price2 = GetPostString("price2");
  4884. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4885. string unusualCon = GetPostString("unusualcon");
  4886. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4887. string posTag = CurrentUser.UserPost.Post.Code;
  4888. if (posTag == "Supplier")
  4889. {
  4890. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4891. }
  4892. lw.Add(string.Format("OrderState = 6"));
  4893. lw.Add(string.Format("UnusualTag = 5"));
  4894. lw.Add(string.Format("IsRefund<={0}", 1));
  4895. dStruct.Order = "FinishPlaceTime desc";
  4896. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4897. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4898. writeGridDataTableJson(dStruct.TotalCount, dt);
  4899. }
  4900. public void get_erp_deliveryedlist()
  4901. {
  4902. DataStruct dStruct = GetPostStruct();
  4903. List<string> lw = new List<string>();
  4904. string tid = GetPostString("ctid");
  4905. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4906. string shopname = GetPostString("shopname");
  4907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4908. string buyernick = GetPostString("buyer_nick");
  4909. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4910. string customer = GetPostString("customer");
  4911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4912. string design = GetPostString("design");
  4913. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4914. string sellermemo = GetPostString("seller_memo");
  4915. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4916. string logistics = GetPostString("logistics");
  4917. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4918. string date1 = GetPostString("date1");
  4919. string date2 = GetPostString("date2");
  4920. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4921. //if (dw.Length > 0) lw.Add(dw);
  4922. string placedate1 = GetPostString("placedate1");
  4923. string placedate2 = GetPostString("placedate2");
  4924. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4925. if (fdw.Length > 0) lw.Add(fdw);
  4926. string devdate1 = GetPostString("deliverydate1");
  4927. string devdate2 = GetPostString("deliverydate2");
  4928. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4929. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4930. string price1 = GetPostString("price1");
  4931. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4932. string price2 = GetPostString("price2");
  4933. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4934. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4935. {
  4936. if (tid.Length > 0)
  4937. {
  4938. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4939. if (tid.Length > 5)
  4940. {
  4941. List<string> tids = getTidByCtidLike(tid);
  4942. if (tids.Count > 0 && tids.Count < 10)
  4943. {
  4944. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4945. }
  4946. }
  4947. lw.Add(tid_sql);
  4948. }
  4949. if (buyernick.Length > 0)
  4950. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4952. if (dw.Length > 0) lw.Add(dw);
  4953. }
  4954. else
  4955. {
  4956. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4957. }
  4958. string posTag = CurrentUser.UserPost.Post.Code;
  4959. if (posTag == "Supplier")
  4960. {
  4961. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4962. }
  4963. else
  4964. {
  4965. string supplier = GetPostString("supplier");
  4966. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4967. }
  4968. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4969. lw.Add(string.Format("type != 'PDD' "));
  4970. lw.Add(string.Format("IsRefund!={0}", 2));
  4971. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4973. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4974. /*if (tid.Length > 0)
  4975. {
  4976. List<string> tids = new List<string>();
  4977. if (dt != null && dt.Rows.Count > 0)
  4978. {
  4979. foreach (DataRow item in dt.Rows)
  4980. {
  4981. tids.Add("'" + item["tid"] + "'");
  4982. }
  4983. }
  4984. if (tids.Count > 0)
  4985. {
  4986. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4987. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4989. dt = WebCache.GetData("view_erptradecell", dStruct);
  4990. }
  4991. }*/
  4992. if (dt != null)
  4993. {
  4994. foreach (DataRow dr in dt.Rows)
  4995. {
  4996. 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();
  4997. }
  4998. }
  4999. writeGridDataTableJson(dStruct.TotalCount, dt);
  5000. }
  5001. public void get_erp_pdddeliveryed()
  5002. {
  5003. DataStruct dStruct = GetPostStruct();
  5004. List<string> lw = new List<string>();
  5005. string tid = GetPostString("ctid");
  5006. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5007. string shopname = GetPostString("shopname");
  5008. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5009. string buyernick = GetPostString("buyer_nick");
  5010. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5011. string customer = GetPostString("customer");
  5012. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5013. string design = GetPostString("design");
  5014. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5015. string sellermemo = GetPostString("seller_memo");
  5016. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5017. string logistics = GetPostString("logistics");
  5018. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5019. string date1 = GetPostString("date1");
  5020. string date2 = GetPostString("date2");
  5021. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5022. //if (dw.Length > 0) lw.Add(dw);
  5023. string placedate1 = GetPostString("placedate1");
  5024. string placedate2 = GetPostString("placedate2");
  5025. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5026. if (fdw.Length > 0) lw.Add(fdw);
  5027. string devdate1 = GetPostString("deliverydate1");
  5028. string devdate2 = GetPostString("deliverydate2");
  5029. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5030. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5031. string price1 = GetPostString("price1");
  5032. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5033. string price2 = GetPostString("price2");
  5034. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5035. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5036. {
  5037. if (tid.Length > 0)
  5038. {
  5039. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5040. if (tid.Length > 5)
  5041. {
  5042. List<string> tids = getTidByCtidLike(tid);
  5043. if (tids.Count > 0 && tids.Count < 10)
  5044. {
  5045. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5046. }
  5047. }
  5048. lw.Add(tid_sql);
  5049. }
  5050. if (buyernick.Length > 0)
  5051. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5052. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5053. if (dw.Length > 0) lw.Add(dw);
  5054. }
  5055. else
  5056. {
  5057. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5058. }
  5059. string posTag = CurrentUser.UserPost.Post.Code;
  5060. if (posTag == "Supplier")
  5061. {
  5062. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5063. }
  5064. else
  5065. {
  5066. string supplier = GetPostString("supplier");
  5067. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5068. }
  5069. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5070. lw.Add(string.Format("type = 'PDD' "));
  5071. lw.Add(string.Format("IsRefund!={0}", 2));
  5072. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5073. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5074. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5075. /* if (tid.Length > 0)
  5076. {
  5077. List<string> tids = new List<string>();
  5078. if (dt != null && dt.Rows.Count > 0)
  5079. {
  5080. foreach (DataRow item in dt.Rows)
  5081. {
  5082. tids.Add("'" + item["tid"] + "'");
  5083. }
  5084. }
  5085. if (tids.Count > 0)
  5086. {
  5087. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5088. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5089. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5090. dt = WebCache.GetData("view_erptradecell", dStruct);
  5091. }
  5092. }*/
  5093. foreach (DataRow dr in dt.Rows)
  5094. {
  5095. 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();
  5096. }
  5097. writeGridDataTableJson(dStruct.TotalCount, dt);
  5098. }
  5099. public void get_erp_jddeliveryed()
  5100. {
  5101. DataStruct dStruct = GetPostStruct();
  5102. List<string> lw = new List<string>();
  5103. string tid = GetPostString("ctid");
  5104. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5105. string shopname = GetPostString("shopname");
  5106. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5107. string buyernick = GetPostString("buyer_nick");
  5108. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5109. string customer = GetPostString("customer");
  5110. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5111. string design = GetPostString("design");
  5112. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5113. string sellermemo = GetPostString("seller_memo");
  5114. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5115. string date1 = GetPostString("date1");
  5116. string date2 = GetPostString("date2");
  5117. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5118. //if (dw.Length > 0) lw.Add(dw);
  5119. string placedate1 = GetPostString("placedate1");
  5120. string placedate2 = GetPostString("placedate2");
  5121. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5122. if (fdw.Length > 0) lw.Add(fdw);
  5123. string devdate1 = GetPostString("deliverydate1");
  5124. string devdate2 = GetPostString("deliverydate2");
  5125. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5126. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5127. string price1 = GetPostString("price1");
  5128. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5129. string price2 = GetPostString("price2");
  5130. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5131. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5132. {
  5133. if (tid.Length > 0)
  5134. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5135. if (buyernick.Length > 0)
  5136. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5137. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5138. if (dw.Length > 0) lw.Add(dw);
  5139. }
  5140. else
  5141. {
  5142. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5143. }
  5144. string posTag = CurrentUser.UserPost.Post.Code;
  5145. if (posTag == "Supplier")
  5146. {
  5147. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5148. }
  5149. else
  5150. {
  5151. string supplier = GetPostString("supplier");
  5152. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5153. }
  5154. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5155. lw.Add(string.Format("type = 'JD' "));
  5156. lw.Add(string.Format("IsRefund!={0}", 2));
  5157. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5158. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5159. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5160. foreach (DataRow dr in dt.Rows)
  5161. {
  5162. 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();
  5163. }
  5164. writeGridDataTableJson(dStruct.TotalCount, dt);
  5165. }
  5166. public void get_erp_allplacelist()
  5167. {
  5168. DataStruct dStruct = GetPostStruct();
  5169. List<string> lw = new List<string>();
  5170. string tid = GetPostString("ctid");
  5171. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5172. string shopname = GetPostString("shopname");
  5173. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5174. string buyernick = GetPostString("buyer_nick");
  5175. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5176. string customer = GetPostString("customer");
  5177. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5178. string design = GetPostString("design");
  5179. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5180. string sellermemo = GetPostString("seller_memo");
  5181. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5182. string supplier = GetPostString("supplier");
  5183. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5184. string date1 = GetPostString("date1");
  5185. string date2 = GetPostString("date2");
  5186. string pldate1 = GetPostString("placedate1");
  5187. string pldate2 = GetPostString("placedate2");
  5188. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5189. //if (dw.Length > 0) lw.Add(dw);
  5190. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5191. {
  5192. if (tid.Length > 0)
  5193. {
  5194. string select_tid = getTidByCtid(tid);
  5195. lw.Add(string.Format("tid='{0}'", select_tid));
  5196. }
  5197. if (buyernick.Length > 0)
  5198. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5199. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5200. if (dw.Length > 0) lw.Add(dw);
  5201. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5202. if (dw_place.Length > 0) lw.Add(dw_place);
  5203. }
  5204. else
  5205. {
  5206. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5207. {
  5208. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5209. }
  5210. }
  5211. string price1 = GetPostString("price1");
  5212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5213. string price2 = GetPostString("price2");
  5214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5215. string posTag = CurrentUser.UserPost.Post.Code;
  5216. if (posTag == "Supplier")
  5217. {
  5218. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5219. }
  5220. lw.Add(string.Format("OrderState >= 6"));
  5221. lw.Add(string.Format("IsSample != 2 "));
  5222. //lw.Add(string.Format("isDianziOrder = 0 "));
  5223. lw.Add(string.Format("SupplierId > 0 "));
  5224. //lw.Add(string.Format("IsRefund<={0}", 1));
  5225. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5226. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5227. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5228. foreach (DataRow dr in dt.Rows)
  5229. {
  5230. 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();
  5231. }
  5232. writeGridDataTableJson(dStruct.TotalCount, dt);
  5233. }
  5234. public void get_erp_financeallplacelist()
  5235. {
  5236. DataStruct dStruct = GetPostStruct();
  5237. List<string> lw = new List<string>();
  5238. string tid = GetPostString("ctid");
  5239. string shopname = GetPostString("shopname");
  5240. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5241. string buyernick = GetPostString("buyer_nick");
  5242. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5243. string customer = GetPostString("customer");
  5244. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5245. string design = GetPostString("design");
  5246. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5247. string sellermemo = GetPostString("seller_memo");
  5248. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5249. string supplier = GetPostString("supplier");
  5250. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5251. string date1 = GetPostString("date1");
  5252. string date2 = GetPostString("date2");
  5253. string pldate1 = GetPostString("placedate1");
  5254. string pldate2 = GetPostString("placedate2");
  5255. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5256. {
  5257. if (tid.Length > 0)
  5258. {
  5259. string select_tid = getTidByCtid(tid);
  5260. lw.Add(string.Format("tid='{0}'", select_tid));
  5261. }
  5262. if (buyernick.Length > 0)
  5263. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5264. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5265. if (dw.Length > 0) lw.Add(dw);
  5266. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5267. if (dw_place.Length > 0) lw.Add(dw_place);
  5268. }
  5269. else
  5270. {
  5271. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5272. {
  5273. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5274. }
  5275. }
  5276. string price1 = GetPostString("price1");
  5277. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5278. string price2 = GetPostString("price2");
  5279. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5280. string posTag = CurrentUser.UserPost.Post.Code;
  5281. if (posTag == "Supplier")
  5282. {
  5283. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5284. }
  5285. //lw.Add(string.Format("OrderState >= 6"));
  5286. lw.Add(string.Format("IsSample != 2 "));
  5287. lw.Add(string.Format("isDianziOrder = 0 "));
  5288. //lw.Add(string.Format("IsRefund<={0}", 1));
  5289. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5290. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5291. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5292. foreach (DataRow dr in dt.Rows)
  5293. {
  5294. 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();
  5295. }
  5296. writeGridDataTableJson(dStruct.TotalCount, dt);
  5297. }
  5298. public void get_erp_expresslist()
  5299. {
  5300. int listtype = GetInt("ltype");
  5301. DataStruct dStruct = GetPostStruct();
  5302. List<string> lw = new List<string>();
  5303. string tid = GetPostString("tid");
  5304. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5305. string outsid = GetPostString("out_sid");
  5306. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5307. string importer = GetPostString("ImportUserName");
  5308. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5309. string file = GetPostString("import_file");
  5310. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5311. string printman = GetPostString("printman");
  5312. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5313. string date1 = GetPostString("date1");
  5314. string date2 = GetPostString("date2");
  5315. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5316. if (dw.Length > 0) lw.Add(dw);
  5317. string fdate1 = GetPostString("finishdate1");
  5318. string fdate2 = GetPostString("finishdate2");
  5319. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5320. if (fdw.Length > 0) lw.Add(fdw);
  5321. string supplierId = GetPostString("supplierId");
  5322. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5323. if (listtype == 1)
  5324. {
  5325. lw.Add(string.Format("importUserId !=0"));
  5326. }
  5327. string posTag = CurrentUser.UserPost.Post.Code;
  5328. if (posTag == "Supplier")
  5329. {
  5330. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5331. }
  5332. if (dStruct.PageSize != 100000)
  5333. {
  5334. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5335. }
  5336. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5337. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5338. writeGridDataTableJson(dStruct.TotalCount, dt);
  5339. }
  5340. public void set_erp_buchaorderdelivery()
  5341. {
  5342. if (UrlPostParmsCheck("ctid"))
  5343. {
  5344. string eid = GetPostString("ctid");
  5345. CeErpTradeCell entity = null;
  5346. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5347. if (entity != null)
  5348. {
  5349. if (entity.IsSample != 2)
  5350. {
  5351. returnErrorMsg("补差价单才能标记为已发货");
  5352. return;
  5353. }
  5354. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5355. entity.OrderState = 7;
  5356. entity.Update();
  5357. returnSuccessMsg("操作成功!");
  5358. return;
  5359. }
  5360. returnErrorMsg("找不到记录");
  5361. }
  5362. }
  5363. public void get_stdtemplates()
  5364. {
  5365. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5366. //string res = taobaoHelper.test();
  5367. string res = apiHelper.API_PrintTemplate();
  5368. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5369. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5370. {
  5371. int sidx = res.IndexOf("error_code");
  5372. int eidx = res.IndexOf("success");
  5373. string msg = res.Substring(sidx, eidx - sidx);
  5374. returnErrorMsg(msg);
  5375. return;
  5376. }
  5377. if (res.Length <= 0)
  5378. {
  5379. returnErrorMsg("模板数据为空!");
  5380. return;
  5381. }
  5382. ReturnSuccess(res);
  5383. }
  5384. public void cancel_print_order()
  5385. {
  5386. if (UrlPostParmsCheck("ctid"))
  5387. {
  5388. string ctid = GetPostString("ctid");
  5389. CeErpTradeCell entity = null;
  5390. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5391. if (entity != null)
  5392. {
  5393. string res = "";
  5394. string code = entity.LastBillWaybillCode;
  5395. if (code == "")
  5396. {
  5397. code = entity.OutSid;
  5398. }
  5399. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5400. XLog.SaveLog(0, "取消面单" + res);
  5401. }
  5402. }
  5403. }
  5404. public void set_erp_printwaybill()
  5405. {
  5406. if (UrlPostParmsCheck("ctid"))
  5407. {
  5408. string ctid = GetPostString("ctid");
  5409. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5410. string cpName = GetPostString("cpname");
  5411. string isTogether = GetPostString("together");
  5412. string printType = GetPostString("printType");
  5413. //var res_obj = new
  5414. //{
  5415. // restype = 1,
  5416. // 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\"}"
  5417. //};
  5418. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5419. //ReturnSuccess(ro_json);
  5420. //return;
  5421. bool isUseLastWayBillCode = false;
  5422. CeErpTradeCell entity = null;
  5423. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5424. if (entity != null)
  5425. {
  5426. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5427. {
  5428. isUseLastWayBillCode = true;
  5429. }
  5430. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5431. {
  5432. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5433. return;
  5434. }
  5435. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5436. {
  5437. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5438. return;
  5439. }
  5440. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5441. {
  5442. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5443. return;
  5444. }
  5445. }
  5446. string res = "";
  5447. Api_waybill_code_response_Obj fullObj = null;
  5448. string pData_str = "";
  5449. string curUseWayBillCode = "";
  5450. if (isUseLastWayBillCode == false)
  5451. {
  5452. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5453. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5454. if (res.IndexOf("failure") != -1)
  5455. {
  5456. //int idx = res.IndexOf("sub_message");
  5457. //int idx2 = res.IndexOf("flag");
  5458. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5459. string errMsgNeed = commonHelper.KeepChinese(res);
  5460. var res_objd = new
  5461. {
  5462. restype = 0,
  5463. data = "获取面单失败" + errMsgNeed
  5464. };
  5465. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5466. returnSuccess(ro_jsond);
  5467. if (res.IndexOf("停发") != -1)
  5468. {
  5469. entity.UnusualCon = "物流停发";
  5470. entity.Update();
  5471. }
  5472. //returnErrorMsg("获取面单失败,"+emsg);
  5473. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5474. return;
  5475. }
  5476. else if (res.IndexOf("errorMsg") != -1)
  5477. {
  5478. //int idx = res.IndexOf("errorMsg");
  5479. //int idx2 = res.IndexOf("}]}");
  5480. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5481. string errMsgNeed = commonHelper.KeepChinese(res);
  5482. var res_objf = new
  5483. {
  5484. restype = 0,
  5485. data = "获取面单失败2" + errMsgNeed
  5486. };
  5487. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5488. if (res.IndexOf("停发") != -1)
  5489. {
  5490. entity.UnusualCon = "物流停发";
  5491. entity.Update();
  5492. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5493. if (trade != null)
  5494. {
  5495. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5496. }
  5497. }
  5498. returnSuccess(ro_jsonf);
  5499. //returnErrorMsg("获取面单失败," + emsg);
  5500. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5501. return;
  5502. }
  5503. try
  5504. {
  5505. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5506. //res = res.Replace(" ", "");
  5507. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5508. }
  5509. catch (Exception ex)
  5510. {
  5511. XLog.SaveLog(0, "生成fullObj" + res);
  5512. var res_objf = new
  5513. {
  5514. restype = 0,
  5515. data = "生成fullObj发生错误" + ex.Message
  5516. };
  5517. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5518. returnSuccess(ro_jsonf);
  5519. return;
  5520. }
  5521. if (fullObj.response.data.content.Count > 0)
  5522. {
  5523. ContentItem codeObj = fullObj.response.data.content[0];
  5524. if (cpCode.IndexOf("SFFQ-") != -1)
  5525. {
  5526. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5527. }
  5528. else
  5529. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5530. curUseWayBillCode = codeObj.waybillCode;
  5531. }
  5532. else
  5533. {
  5534. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5535. var res_objf = new
  5536. {
  5537. restype = 0,
  5538. data = "生成fullObj找不到快递单号waybillCode"
  5539. };
  5540. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5541. returnSuccess(ro_jsonf);
  5542. return;
  5543. }
  5544. }
  5545. else
  5546. {
  5547. //使用上次打印的快递单号
  5548. if (cpCode == "SFFQ-LY")
  5549. {
  5550. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5551. }
  5552. else
  5553. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5554. curUseWayBillCode = entity.LastBillWaybillCode;
  5555. }
  5556. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5557. {
  5558. var res_obje = new
  5559. {
  5560. restype = 0,
  5561. data = "获取加密打印数据失败"
  5562. };
  5563. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5564. returnSuccess(ro_jsone);
  5565. entity.LastBillCpCode = cpCode;
  5566. entity.LastBillWaybillCode = curUseWayBillCode;
  5567. entity.Update();
  5568. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5569. //returnErrorMsg("获取加密打印数据失败");
  5570. return;
  5571. }
  5572. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5573. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5574. string btnType = "";
  5575. string errorMsg = "";
  5576. if (entity != null)
  5577. {
  5578. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5579. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5580. //cpcode是 YTO-CAINIAO
  5581. //string comCode = cpCode.Split('-')[0].ToString();
  5582. string apires = "";
  5583. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5584. //isTogether=2是新的合包弹窗
  5585. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5586. {
  5587. if (ctid.IndexOf("N") != -1)
  5588. {
  5589. apires = "发货成功";
  5590. }
  5591. else
  5592. {
  5593. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5594. }
  5595. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5596. //打单后发货
  5597. StringBuilder sql = new StringBuilder();
  5598. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5599. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5600. {
  5601. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5602. }
  5603. else
  5604. {
  5605. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5606. }
  5607. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5608. foreach (DataRow row in dt.Rows)
  5609. {
  5610. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5611. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5612. {
  5613. try
  5614. {
  5615. btnType = "待发货";
  5616. entity.OutSid = curUseWayBillCode;
  5617. entity.OrderState = 7;
  5618. entity.IsUrgency = false;
  5619. entity.LastBillCpCode = "";
  5620. entity.LastBillWaybillCode = "";
  5621. entity.FinishDeliveryTime = DateTime.Now;
  5622. entity.IsReturn = 0;
  5623. entity.MemoOpt = 0;
  5624. entity.UpdateTime = DateTime.Now;
  5625. entity.Update();
  5626. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5627. //还要插入快递信息到 快递信息表
  5628. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5629. exinfo.tid = entity.ctid;
  5630. exinfo.out_sid = curUseWayBillCode;
  5631. exinfo.company_code = cpCode;
  5632. exinfo.company_name = cpName;
  5633. exinfo.supplierUserName = supplierName;
  5634. exinfo.deliveryType = "发货成功";
  5635. exinfo.print_time = DateTime.Now;
  5636. exinfo.printUser = CurrentUser.UserName;
  5637. exinfo.postData = pData_str;
  5638. exinfo.Create();
  5639. commonHelper.UpdateRelationOrder(entity.ctid);
  5640. CeErpSukuraData.createInfo(ctid, 4);
  5641. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5642. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5643. {
  5644. commonHelper.sendCytExpress(exinfo);
  5645. }
  5646. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5647. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5648. }
  5649. catch (Exception ex)
  5650. {
  5651. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5652. }
  5653. }
  5654. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5655. {
  5656. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5657. if (entity.OrderState == 6)
  5658. {
  5659. entity.OrderState = 7;
  5660. }
  5661. entity.UpdateTime = DateTime.Now;
  5662. entity.FinishDeliveryTime = DateTime.Now;
  5663. btnType = "已发货";
  5664. entity.Update();
  5665. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5666. exinfo.tid = entity.ctid;
  5667. exinfo.out_sid = curUseWayBillCode;
  5668. exinfo.company_code = cpCode;
  5669. exinfo.company_name = cpName;
  5670. exinfo.supplierUserName = supplierName;
  5671. exinfo.deliveryType = "发货成功";
  5672. exinfo.print_time = DateTime.Now;
  5673. exinfo.printUser = CurrentUser.UserName;
  5674. exinfo.postData = pData_str;
  5675. exinfo.Create();
  5676. commonHelper.UpdateRelationOrder(entity.ctid);
  5677. CeErpSukuraData.createInfo(entity.ctid, 4);
  5678. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5679. {
  5680. commonHelper.sendCytExpress(exinfo);
  5681. }
  5682. //不处理
  5683. }
  5684. else
  5685. {
  5686. entity.UpdateTime = DateTime.Now;
  5687. entity.LastBillCpCode = cpCode;
  5688. entity.LastBillWaybillCode = curUseWayBillCode;
  5689. entity.Update();
  5690. string errmsg = commonHelper.KeepChinese(apires);
  5691. var res_objz = new
  5692. {
  5693. restype = 0,
  5694. data = "打单后发货失败"
  5695. };
  5696. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5697. returnSuccess(ro_jsonz);
  5698. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5699. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5700. return;
  5701. }
  5702. }
  5703. }
  5704. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5705. {
  5706. string ctids = GetPostString("ctids");
  5707. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5708. List<string> list = new List<string>();
  5709. List<string> send_list = new List<string>();
  5710. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5711. CeErpTrade ceErpTrade = new CeErpTrade();
  5712. //可合包的合并一起发货
  5713. if (dt == null && string.IsNullOrEmpty(ctids))
  5714. {
  5715. var res_objz = new
  5716. {
  5717. restype = 0,
  5718. data = "打单后发货失败"
  5719. };
  5720. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5721. returnSuccess(ro_jsonz);
  5722. return;
  5723. }
  5724. if (!string.IsNullOrEmpty(ctids))
  5725. {
  5726. StringBuilder sql = new StringBuilder();
  5727. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5728. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5729. }
  5730. foreach (DataRow row in dt.Rows)
  5731. {
  5732. list.Add("'" + row["ctid"] + "'");
  5733. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5734. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5735. if (ctid.IndexOf("N") != -1)
  5736. {
  5737. apires = "发货成功";
  5738. }
  5739. else
  5740. {
  5741. if (!send_list.Contains(ceErpTrade.tid))
  5742. {
  5743. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5744. }
  5745. else
  5746. {
  5747. apires = "发货成功";
  5748. }
  5749. }
  5750. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5751. {
  5752. send_list.Add(ceErpTrade.tid);
  5753. try
  5754. {
  5755. btnType = "待发货";
  5756. ceErpTradeCell.OutSid = curUseWayBillCode;
  5757. ceErpTradeCell.OrderState = 7;
  5758. ceErpTradeCell.IsUrgency = false;
  5759. ceErpTradeCell.LastBillCpCode = "";
  5760. ceErpTradeCell.LastBillWaybillCode = "";
  5761. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5762. ceErpTradeCell.IsReturn = 0;
  5763. ceErpTradeCell.MemoOpt = 0;
  5764. ceErpTradeCell.UpdateTime = DateTime.Now;
  5765. ceErpTradeCell.Update();
  5766. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5767. //还要插入快递信息到 快递信息表
  5768. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5769. exinfo.tid = ceErpTradeCell.ctid;
  5770. exinfo.out_sid = curUseWayBillCode;
  5771. exinfo.company_code = cpCode;
  5772. exinfo.company_name = cpName;
  5773. exinfo.supplierUserName = supplierName;
  5774. exinfo.deliveryType = "发货成功";
  5775. exinfo.print_time = DateTime.Now;
  5776. exinfo.printUser = CurrentUser.UserName;
  5777. exinfo.postData = pData_str;
  5778. exinfo.Create();
  5779. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5780. CeErpSukuraData.createInfo(ctid, 4);
  5781. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5782. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5783. {
  5784. commonHelper.sendCytExpress(exinfo);
  5785. }
  5786. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5787. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5788. }
  5789. catch (Exception ex)
  5790. {
  5791. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5792. }
  5793. }
  5794. else
  5795. {
  5796. ceErpTradeCell.UpdateTime = DateTime.Now;
  5797. ceErpTradeCell.LastBillCpCode = cpCode;
  5798. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5799. ceErpTradeCell.Update();
  5800. string errmsg = commonHelper.KeepChinese(apires);
  5801. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5802. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5803. }
  5804. }
  5805. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5806. }
  5807. }
  5808. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5809. var res_obj = new
  5810. {
  5811. restype = 1,
  5812. data = pData_str,
  5813. errorMsg
  5814. };
  5815. string ro_json = JsonConvert.SerializeObject(res_obj);
  5816. ReturnSuccess(ro_json);
  5817. return;
  5818. }
  5819. }
  5820. private string GetUTF8String(byte[] vs)
  5821. {
  5822. throw new NotImplementedException();
  5823. }
  5824. public void set_erp_printwaybill_cn()
  5825. {
  5826. if (UrlPostParmsCheck("ctid"))
  5827. {
  5828. string ctid = GetPostString("ctid");
  5829. string cpCode = GetPostString("cpcode");
  5830. string cpName = GetPostString("cpname");
  5831. string tempUrl = GetPostString("tempurl");
  5832. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5833. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5834. //string res = taobaoHelper.test();
  5835. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5836. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5837. {
  5838. int sidx = res.IndexOf("errorMsg");
  5839. int eidx = res.IndexOf("}");
  5840. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5841. var res_objzxx = new
  5842. {
  5843. restype = 0,
  5844. data = msg
  5845. };
  5846. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5847. returnSuccess(ro_jsonzxx);
  5848. //returnErrorMsg(msg);
  5849. return;
  5850. }
  5851. int idx = res.IndexOf("waybillCode");
  5852. int idx2 = res.IndexOf("printData");
  5853. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5854. string eid = GetPostString("ctid");
  5855. CeErpTradeCell entity = null;
  5856. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5857. if (entity != null)
  5858. {
  5859. string osid = entity.OutSid;
  5860. entity.OutSid = osid + "," + outsid;
  5861. entity.FinishDeliveryTime = DateTime.Now;
  5862. entity.OrderState = 7;
  5863. entity.UpdateTime = DateTime.Now;
  5864. entity.IsReturn = 0;
  5865. entity.Update();
  5866. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5867. exinfo.tid = entity.ctid;
  5868. exinfo.out_sid = outsid;
  5869. exinfo.company_code = cpCode;
  5870. exinfo.company_name = cpName;
  5871. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5872. exinfo.deliveryType = "发货成功";
  5873. exinfo.print_time = DateTime.Now;
  5874. exinfo.printUser = CurrentUser.UserName;
  5875. exinfo.Create();
  5876. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5877. {
  5878. commonHelper.sendCytExpress(exinfo);
  5879. }
  5880. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5881. }
  5882. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5883. var res_objz = new
  5884. {
  5885. restype = 1,
  5886. data = res
  5887. };
  5888. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5889. returnSuccess(ro_jsonz);
  5890. //ReturnSuccess(res);
  5891. }
  5892. }
  5893. ////打单,打印面单 获取面单号
  5894. //public void set_erp_printwaybill()
  5895. //{
  5896. // if (UrlPostParmsCheck("ctid"))
  5897. // {
  5898. // string ctid = GetPostString("ctid");
  5899. // string cpCode = GetPostString("cpcode");
  5900. // string tempUrl = GetPostString("tempurl");
  5901. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5902. // //string res = taobaoHelper.test();
  5903. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5904. // if (res.IndexOf("error_response") != -1)
  5905. // {
  5906. // int sidx = res.IndexOf("sub_msg");
  5907. // int eidx = res.IndexOf("request_id");
  5908. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5909. // returnErrorMsg(msg);
  5910. // return;
  5911. // }
  5912. // int idx = res.IndexOf("waybill_code");
  5913. // int idx2 = res.IndexOf("}]}");
  5914. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5915. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5916. // ReturnSuccess(res);
  5917. // }
  5918. //}
  5919. public void cancel_erp_aftersale()
  5920. {
  5921. if (UrlPostParmsCheck("ctid"))
  5922. {
  5923. string eid = GetPostString("ctid");
  5924. CeErpTradeCell entity = null;
  5925. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5926. if (entity != null)
  5927. {
  5928. //有过处理的售后,取消也不能删除 售 字,保留
  5929. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5930. {
  5931. entity.AfterSaleState = 4;
  5932. }
  5933. else
  5934. entity.AfterSaleState = 0;
  5935. entity.UpdateTime = DateTime.Now;
  5936. entity.Update();
  5937. returnSuccessMsg("操作成功!");
  5938. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5939. return;
  5940. }
  5941. returnErrorMsg("找不到订单记录");
  5942. }
  5943. }
  5944. public void get_erp_aftersalelist()
  5945. {
  5946. DataStruct dStruct = GetPostStruct();
  5947. List<string> lw = new List<string>();
  5948. int st = GetInt("st");
  5949. string tid = GetPostString("ctid");
  5950. if (st == 3)
  5951. {
  5952. if (tid.Length > 0)
  5953. {
  5954. string select_tid = getTidByCtid(tid);
  5955. lw.Add(string.Format("tid='{0}'", select_tid));
  5956. }
  5957. }
  5958. else
  5959. {
  5960. if (tid.Length > 0)
  5961. {
  5962. string select_tid = getTidByCtid(tid);
  5963. lw.Add(string.Format("tid='{0}'", select_tid));
  5964. }
  5965. }
  5966. string shopname = GetPostString("shopname");
  5967. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5968. string buyernick = GetPostString("buyer_nick");
  5969. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5970. string sellermemo = GetPostString("seller_memo");
  5971. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5972. string orderState = GetPostString("orderState");
  5973. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5974. string afterState = GetPostString("afterstate");
  5975. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5976. string date1 = GetPostString("date1");
  5977. string date2 = GetPostString("date2");
  5978. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5979. if (dw.Length > 0) lw.Add(dw);
  5980. string price1 = GetPostString("price1");
  5981. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5982. string price2 = GetPostString("price2");
  5983. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5984. //lw.Add(string.Format("IsRefund!={0}", 1));
  5985. string reason = GetPostString("reason");
  5986. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5987. string method = GetPostString("method");
  5988. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5989. string handler = GetPostString("handler");
  5990. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5991. string handledate1 = GetPostString("handledate1");
  5992. string handledate2 = GetPostString("handledate2");
  5993. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5994. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5995. string finish1 = GetPostString("finishdate1");
  5996. string finish2 = GetPostString("finishdate2");
  5997. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5998. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5999. string afterdate1 = GetPostString("afterdate1");
  6000. string afterdate2 = GetPostString("afterdate2");
  6001. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6002. if (afterDate.Length > 0) lw.Add(afterDate);
  6003. string supplier = GetPostString("supplier");
  6004. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6005. string responsible = GetPostString("responsibleman");
  6006. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6007. string customer = GetPostString("customer");
  6008. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6009. string design = GetPostString("design");
  6010. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6011. string afterMemoType = GetPostString("aftermemotype");
  6012. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6013. string posCode = CurrentUser.UserPost.Post.Code;
  6014. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6015. //{
  6016. // string vstate = GetPostString("vstate");
  6017. // if (vstate.Length > 0)
  6018. // {
  6019. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6020. // }
  6021. // if (posCode == "Supplier")
  6022. // {
  6023. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6024. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6025. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6026. // }
  6027. // else
  6028. // {
  6029. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6030. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6031. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6032. // {
  6033. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6034. // }
  6035. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6036. // {
  6037. // int orgid = CurrentUser.UserPost.OrgID;
  6038. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6039. // }
  6040. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6041. // {
  6042. // string shopid = CurrentUser.User.pemShop;
  6043. // lw.Add(string.Format("shopId in ({0})", shopid));
  6044. // }
  6045. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6046. // //{
  6047. // // int org_id = CurrentUser.UserPost.OrgID;
  6048. // // lw.Add(string.Format("OrgID={0}", org_id));
  6049. // //}
  6050. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6051. // }
  6052. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6053. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6054. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6055. //}
  6056. if (st == 5)
  6057. {
  6058. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6059. {
  6060. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6061. {
  6062. string shopid = CurrentUser.User.pemShop;
  6063. lw.Add(string.Format("shopId in ({0})", shopid));
  6064. }
  6065. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6066. {
  6067. int mrOrgid = CurrentUser.UserPost.OrgID;
  6068. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6069. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6070. }
  6071. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6072. //{
  6073. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6074. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6075. //}
  6076. else
  6077. {
  6078. string userIdStr = "";
  6079. if (posCode == "CustomerService")
  6080. {
  6081. userIdStr = CurrentUser.UserID + "_k";
  6082. }
  6083. else if (posCode == "Designer" || posCode == "wxDesigner")
  6084. {
  6085. userIdStr = CurrentUser.UserID + "_s";
  6086. }
  6087. else if (posCode == "Place")
  6088. {
  6089. userIdStr = CurrentUser.UserID + "_x";
  6090. }
  6091. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6092. }
  6093. }
  6094. string placedate1 = GetPostString("placedate1");
  6095. string placedate2 = GetPostString("placedate2");
  6096. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6097. if (dwplace.Length > 0) lw.Add(dwplace);
  6098. string supState = GetPostString("supState");
  6099. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6100. string searchType = GetPostString("searchType");
  6101. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6102. {
  6103. lw.Add(string.Format("BackNum>1"));
  6104. }
  6105. lw.Add(string.Format("AfterSaleState>0"));
  6106. if (ex_psize > 0)
  6107. {
  6108. if (CurrentUser.UserPost.Post.Code == "Finance")
  6109. dStruct.Order = "pay_time desc";
  6110. else
  6111. dStruct.Order = "HandleTime desc";
  6112. }
  6113. else
  6114. dStruct.Order = "HandleTime desc";
  6115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6116. DataTable dt = WebCache.GetData("view_test", dStruct);
  6117. writeGridDataTableJson(dStruct.TotalCount, dt);
  6118. }
  6119. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6120. //{
  6121. // lw.Add(string.Format("AfterSaleState=4"));
  6122. // string code = CurrentUser.UserPost.Post.Code;
  6123. // if (code == "CustomerService")
  6124. // {
  6125. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6126. // }
  6127. // else if (code == "Designer" || code == "DesignerMr")
  6128. // {
  6129. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6130. // }
  6131. // else if (code == "Place" || code == "PlaceMr")
  6132. // {
  6133. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6134. // }
  6135. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6136. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6137. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6138. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6139. //}
  6140. //else //处理中的售后,待处理和处理中合并
  6141. //{
  6142. // if (afterState.Length <= 0)
  6143. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6144. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6145. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6146. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6147. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6148. //}
  6149. }
  6150. public void get_erp_disagreeftersalelist()
  6151. {
  6152. DataStruct dStruct = GetPostStruct();
  6153. List<string> lw = new List<string>();
  6154. int st = 2;
  6155. string tid = GetPostString("ctid");
  6156. if (tid.Length > 0)
  6157. {
  6158. string select_tid = getTidByCtid(tid);
  6159. lw.Add(string.Format("tid='{0}'", select_tid));
  6160. }
  6161. string shopname = GetPostString("shopname");
  6162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6163. string buyernick = GetPostString("buyer_nick");
  6164. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6165. string sellermemo = GetPostString("seller_memo");
  6166. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6167. string orderState = GetPostString("orderState");
  6168. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6169. string afterState = GetPostString("afterstate");
  6170. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6171. string date1 = GetPostString("date1");
  6172. string date2 = GetPostString("date2");
  6173. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6174. if (dw.Length > 0) lw.Add(dw);
  6175. string price1 = GetPostString("price1");
  6176. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6177. string price2 = GetPostString("price2");
  6178. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6179. //lw.Add(string.Format("IsRefund!={0}", 1));
  6180. string reason = GetPostString("reason");
  6181. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6182. string method = GetPostString("method");
  6183. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6184. string handler = GetPostString("handler");
  6185. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6186. string handledate1 = GetPostString("handledate1");
  6187. string handledate2 = GetPostString("handledate2");
  6188. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6189. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6190. string afterdate1 = GetPostString("afterdate1");
  6191. string afterdate2 = GetPostString("afterdate2");
  6192. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6193. if (afterDate.Length > 0) lw.Add(afterDate);
  6194. string backdate1 = GetPostString("backdate1");
  6195. string backdate2 = GetPostString("backdate2");
  6196. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6197. if (backDate.Length > 0) lw.Add(backDate);
  6198. string supplier = GetPostString("supplier");
  6199. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6200. string responsible = GetPostString("responsibleman");
  6201. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6202. string customer = GetPostString("customer");
  6203. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6204. string design = GetPostString("design");
  6205. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6206. string afterSaleMemo = GetPostString("afterSaleMemo");
  6207. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6208. string afterMemoType = GetPostString("aftermemotype");
  6209. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6210. string aftersakereason = GetPostString("aftersakereason");
  6211. if (aftersakereason.Length > 0)
  6212. {
  6213. if (aftersakereason == "1")
  6214. {
  6215. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6216. }
  6217. if (aftersakereason == "2")
  6218. {
  6219. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6220. }
  6221. }
  6222. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6223. string poscode = CurrentUser.UserPost.Post.Code;
  6224. if (poscode != "SysAdmin")
  6225. {
  6226. string shopid = CurrentUser.User.pemShop;
  6227. lw.Add(string.Format("shopId in ({0})", shopid));
  6228. }
  6229. string searchType = GetPostString("searchType");
  6230. if (searchType == "wait")
  6231. {
  6232. lw.Add(string.Format("HandleTime is null"));
  6233. }
  6234. if (searchType == "handling")
  6235. {
  6236. lw.Add(string.Format("HandleTime is not null "));
  6237. }
  6238. if (searchType == "back" || searchType == "puBack")
  6239. {
  6240. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6241. }
  6242. if (searchType == "reBack")
  6243. {
  6244. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6245. }
  6246. if (searchType == "moreBack")
  6247. {
  6248. lw.Add(string.Format("backNum > 1"));
  6249. }
  6250. lw.Add(string.Format("(AfterSaleState=5)"));
  6251. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6253. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6254. writeGridDataTableJson(dStruct.TotalCount, dt);
  6255. }
  6256. public void get_erp_handlingaftersalelist()
  6257. {
  6258. DataStruct dStruct = GetPostStruct();
  6259. List<string> lw = new List<string>();
  6260. int st = 2;
  6261. string tid = GetPostString("ctid");
  6262. if (tid.Length > 0)
  6263. {
  6264. string select_tid = getTidByCtid(tid);
  6265. lw.Add(string.Format("tid='{0}'", select_tid));
  6266. }
  6267. string shopname = GetPostString("shopname");
  6268. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6269. string buyernick = GetPostString("buyer_nick");
  6270. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6271. string sellermemo = GetPostString("seller_memo");
  6272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6273. string orderState = GetPostString("orderState");
  6274. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6275. string afterState = GetPostString("afterstate");
  6276. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6277. string date1 = GetPostString("date1");
  6278. string date2 = GetPostString("date2");
  6279. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6280. if (dw.Length > 0) lw.Add(dw);
  6281. string price1 = GetPostString("price1");
  6282. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6283. string price2 = GetPostString("price2");
  6284. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6285. //lw.Add(string.Format("IsRefund!={0}", 1));
  6286. string reason = GetPostString("reason");
  6287. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6288. string method = GetPostString("method");
  6289. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6290. string handler = GetPostString("handler");
  6291. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6292. string handledate1 = GetPostString("handledate1");
  6293. string handledate2 = GetPostString("handledate2");
  6294. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6295. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6296. string afterdate1 = GetPostString("afterdate1");
  6297. string afterdate2 = GetPostString("afterdate2");
  6298. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6299. if (afterDate.Length > 0) lw.Add(afterDate);
  6300. string supplier = GetPostString("supplier");
  6301. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6302. string responsible = GetPostString("responsibleman");
  6303. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6304. string customer = GetPostString("customer");
  6305. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6306. string design = GetPostString("design");
  6307. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6308. string afterSaleMemo = GetPostString("afterSaleMemo");
  6309. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6310. string afterMemoType = GetPostString("aftermemotype");
  6311. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6312. string afterresult = GetPostString("afterresult");
  6313. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6314. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6315. string poscode = CurrentUser.UserPost.Post.Code;
  6316. if (poscode != "SysAdmin")
  6317. {
  6318. string shopid = CurrentUser.User.pemShop;
  6319. lw.Add(string.Format("shopId in ({0})", shopid));
  6320. }
  6321. string searchType = GetPostString("searchType");
  6322. if (searchType == "wait")
  6323. {
  6324. lw.Add(string.Format("HandleTime is null"));
  6325. }
  6326. if (searchType == "documentary")
  6327. {
  6328. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6329. }
  6330. if (searchType == "handling")
  6331. {
  6332. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6333. }
  6334. if (searchType == "back" || searchType == "puBack")
  6335. {
  6336. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6337. }
  6338. if (searchType == "reBack")
  6339. {
  6340. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6341. }
  6342. if (afterState.Length <= 0)
  6343. {
  6344. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6345. }
  6346. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6347. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6348. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6349. writeGridDataTableJson(dStruct.TotalCount, dt);
  6350. }
  6351. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6352. //public void get_erp_back_handlingaftersalelist()
  6353. //{
  6354. // DataStruct dStruct = GetPostStruct();
  6355. // List<string> lw = new List<string>();
  6356. // string tid = GetPostString("ctid");
  6357. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6358. // string shopname = GetPostString("shopname");
  6359. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6360. // string buyernick = GetPostString("buyer_nick");
  6361. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6362. // string sellermemo = GetPostString("seller_memo");
  6363. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6364. // string orderState = GetPostString("orderState");
  6365. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6366. // string afterState = GetPostString("afterstate");
  6367. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6368. // string date1 = GetPostString("date1");
  6369. // string date2 = GetPostString("date2");
  6370. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6371. // if (dw.Length > 0) lw.Add(dw);
  6372. // string price1 = GetPostString("price1");
  6373. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6374. // string price2 = GetPostString("price2");
  6375. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6376. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6377. // string reason = GetPostString("reason");
  6378. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6379. // string method = GetPostString("method");
  6380. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6381. // string handler = GetPostString("handler");
  6382. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6383. // string handledate1 = GetPostString("handledate1");
  6384. // string handledate2 = GetPostString("handledate2");
  6385. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6386. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6387. // string afterdate1 = GetPostString("afterdate1");
  6388. // string afterdate2 = GetPostString("afterdate2");
  6389. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6390. // if (afterDate.Length > 0) lw.Add(afterDate);
  6391. // string supplier = GetPostString("supplier");
  6392. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6393. // string responsible = GetPostString("responsibleman");
  6394. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6395. // string customer = GetPostString("customer");
  6396. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6397. // string design = GetPostString("design");
  6398. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6399. // string afterMemoType = GetPostString("aftermemotype");
  6400. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6401. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6402. // if (afterState.Length <= 0)
  6403. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6404. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6405. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6406. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6407. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6408. //}
  6409. public void get_erp_aftersaleverifylist()
  6410. {
  6411. DataStruct dStruct = GetPostStruct();
  6412. List<string> lw = new List<string>();
  6413. string tid = GetPostString("ctid");
  6414. if (tid.Length > 0)
  6415. {
  6416. string select_tid = getTidByCtid(tid);
  6417. lw.Add(string.Format("otid='{0}'", select_tid));
  6418. }
  6419. string shopname = GetPostString("shopname");
  6420. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6421. string buyernick = GetPostString("buyer_nick");
  6422. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6423. string sellermemo = GetPostString("seller_memo");
  6424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6425. string orderState = GetPostString("orderState");
  6426. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6427. //lw.Add(string.Format("IsRefund!={0}", 1));
  6428. string reason = GetPostString("reason");
  6429. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6430. string method = GetPostString("method");
  6431. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6432. string handler = GetPostString("handler");
  6433. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6434. string handledate1 = GetPostString("handledate1");
  6435. string handledate2 = GetPostString("handledate2");
  6436. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6437. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6438. string finish1 = GetPostString("finishdate1");
  6439. string finish2 = GetPostString("finishdate2");
  6440. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6441. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6442. string supplier = GetPostString("supplier");
  6443. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6444. string responsible = GetPostString("responsibleman");
  6445. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6446. string posCode = CurrentUser.UserPost.Post.Code;
  6447. string vstate = GetPostString("vstate");
  6448. if (vstate.Length > 0)
  6449. {
  6450. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6451. }
  6452. if (posCode == "Supplier")
  6453. {
  6454. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6455. lw.Add(string.Format("VerifyState = 0"));
  6456. lw.Add("type = 1");
  6457. lw.Add(string.Format("AfterSaleState={0}", 3));
  6458. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6459. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6460. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6461. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6462. writeGridDataTableJson(dStruct.TotalCount, dt);
  6463. }
  6464. else if (posCode == "logistics")
  6465. {
  6466. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6467. lw.Add(string.Format("VerifyState = 0"));
  6468. lw.Add("type = 2");
  6469. lw.Add(string.Format("AfterSaleState={0}", 3));
  6470. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6471. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6472. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6473. writeGridDataTableJson(dStruct.TotalCount, dt);
  6474. }
  6475. else
  6476. {
  6477. lw.Add(string.Format("(AfterSaleState = 3)"));
  6478. string reasonState = GetPostString("reasonState");
  6479. lw.Add("type = 0");
  6480. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6481. || posCode == "Summarize" || posCode == "Finance")
  6482. {
  6483. if (reasonState == "2")
  6484. {
  6485. lw.Add("VerifyState = 3");
  6486. }
  6487. else if (reasonState == "1")
  6488. {
  6489. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6490. }
  6491. else
  6492. {
  6493. lw.Add("VerifyState in (0,3)");
  6494. }
  6495. //不加条件,可以看全部
  6496. }
  6497. 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")
  6498. {
  6499. int orgid = CurrentUser.UserPost.OrgID;
  6500. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6501. if (string.IsNullOrEmpty(manageOrgId))
  6502. {
  6503. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6504. }
  6505. else
  6506. {
  6507. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6508. }
  6509. if (reasonState == "1")
  6510. {
  6511. lw.Add("VerifyState = 3");
  6512. }
  6513. else if (reasonState == "2")
  6514. {
  6515. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6516. }
  6517. else
  6518. {
  6519. }
  6520. }
  6521. else
  6522. {
  6523. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6524. }
  6525. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6526. //{
  6527. // int org_id = CurrentUser.UserPost.OrgID;
  6528. // lw.Add(string.Format("OrgID={0}", org_id));
  6529. //}
  6530. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6531. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6532. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6533. writeGridDataTableJson(dStruct.TotalCount, dt);
  6534. }
  6535. }
  6536. public void get_erp_finishaftersalelist()
  6537. {
  6538. DataStruct dStruct = GetPostStruct();
  6539. List<string> lw = new List<string>();
  6540. int st = 4;
  6541. string tid = GetPostString("ctid");
  6542. if (tid.Length > 0)
  6543. {
  6544. string select_tid = getTidByCtid(tid);
  6545. lw.Add(string.Format("otid='{0}'", select_tid));
  6546. }
  6547. string shopname = GetPostString("shopname");
  6548. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6549. //lw.Add(string.Format("IsRefund!={0}", 1));
  6550. string reason = GetPostString("reason");
  6551. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6552. string method = GetPostString("method");
  6553. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6554. string buyernick = GetPostString("buyer_nick");
  6555. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6556. string handler = GetPostString("handler");
  6557. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6558. string handledate1 = GetPostString("handledate1");
  6559. string handledate2 = GetPostString("handledate2");
  6560. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6561. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6562. string finish1 = GetPostString("finishdate1");
  6563. string finish2 = GetPostString("finishdate2");
  6564. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6565. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6566. string supplier = GetPostString("supplier");
  6567. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6568. string responsible = GetPostString("responsibleman");
  6569. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6570. string vstate = GetPostString("vstate");
  6571. if (vstate.Length > 0)
  6572. {
  6573. if ("3".Equals(vstate))
  6574. {
  6575. lw.Add(string.Format("IsTem=1"));
  6576. }
  6577. else
  6578. {
  6579. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6580. }
  6581. }
  6582. lw.Add(string.Format("AfterSaleState=4"));
  6583. string code = CurrentUser.UserPost.Post.Code;
  6584. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6585. {
  6586. //不加条件,可以看全部
  6587. }
  6588. else if (code == "Supplier")
  6589. {
  6590. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6591. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6592. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6593. }
  6594. else if (code == "logistics")
  6595. {
  6596. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6597. lw.Add("type = 2");
  6598. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6599. }
  6600. 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")
  6601. {
  6602. int orgid = CurrentUser.UserPost.OrgID;
  6603. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6604. if (string.IsNullOrEmpty(manageOrgIds))
  6605. {
  6606. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6607. }
  6608. else
  6609. {
  6610. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6611. }
  6612. }
  6613. else
  6614. {
  6615. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6616. }
  6617. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6618. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6619. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6620. writeGridDataTableJson(dStruct.TotalCount, dt);
  6621. }
  6622. public void handle_erp_aftersale()
  6623. {
  6624. if (UrlPostParmsCheck("ctid"))
  6625. {
  6626. string eid = GetPostString("ctid");
  6627. string responStr = GetPostString("AfterSaleResponsible");
  6628. if (responStr.Length <= 0)
  6629. {
  6630. returnErrorMsg("售后责任人不能为空");
  6631. return;
  6632. }
  6633. bool isDesign = false;
  6634. double designFree = 0.00;
  6635. int responsibleId = 0;
  6636. CeErpTradeCell entity = null;
  6637. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6638. if (entity != null)
  6639. {
  6640. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6641. string afterMethod = GetPostString("AfterSaleMethod");
  6642. if (isNeedNewOrder == 1)
  6643. {
  6644. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6645. bool ishav = true;
  6646. if (newentity == null)
  6647. {
  6648. newentity = entity.Clone() as CeErpTradeCell;
  6649. ishav = false;
  6650. newentity.ctid = "S_" + entity.ctid;
  6651. newentity.OrderState = 0;
  6652. //唯一标识
  6653. newentity.OrderSn = newentity.ctid;
  6654. string orderSn = dataHelper.getSaleOrderSn();
  6655. if (orderSn != "")
  6656. {
  6657. newentity.OrderSn = orderSn;
  6658. }
  6659. }
  6660. newentity.UpdateTime = DateTime.Now;
  6661. newentity.AfterSaleState = 0;
  6662. newentity.AfterSaleMethod = afterMethod;
  6663. if (!ishav)
  6664. {
  6665. string memo_str = newentity.seller_memo;
  6666. memo_str = memo_str.Replace("(", "(");
  6667. memo_str = memo_str.Replace(")", ")");
  6668. int sIndex = memo_str.IndexOf("(");
  6669. int eIndex = memo_str.IndexOf(")");
  6670. if (sIndex == -1 || eIndex == -1)
  6671. {
  6672. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6673. return;
  6674. }
  6675. string first = memo_str.Substring(0, sIndex + 1);
  6676. string memoCtid = newentity.OrderSn;
  6677. //if (memoCtid.IndexOf("C") != -1)
  6678. //{
  6679. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6680. //if (CIdx.IndexOf("+") != -1)
  6681. //{
  6682. //CIdx = "C" + CIdx.Split('+')[1];
  6683. //}
  6684. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6685. //}
  6686. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6687. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6688. string newMemo = first + memoCtid + last;
  6689. newentity.seller_memo = newMemo;
  6690. newentity.FinishPlaceTime = null;
  6691. newentity.UnusualTag = 0;
  6692. newentity.UnusualCon = "";
  6693. newentity.UnusualTime = null;
  6694. newentity.AfterSaleMemo = "";
  6695. newentity.AfterSaleMethod = afterMethod;
  6696. newentity.AfterSalePreTime = null;
  6697. newentity.AfterSaleReason = "";
  6698. newentity.AfterSaleResponsible = "";
  6699. newentity.AfterSaleState = 0;
  6700. newentity.AfterSaleTime = null;
  6701. newentity.AfterSaleUserId = 0;
  6702. newentity.AfterSaleSupplierState = 0;
  6703. newentity.LastBillWaybillCode = "";
  6704. newentity.LastBillCpCode = "";
  6705. newentity.FinishAfterSaleTime = null;
  6706. newentity.HandleTime = null;
  6707. newentity.IsSF = 0;
  6708. newentity.IsOldCustomer = 0;
  6709. newentity.UrgencyTime = null;
  6710. newentity.ResponsibleUserId = "";
  6711. newentity.IsVerifyToSupplier = false;
  6712. newentity.payment = 0;
  6713. newentity.CheckMemo = "";
  6714. newentity.OutSid = "";
  6715. newentity.CheckOrderTime = null;
  6716. newentity.MemoOpt = 0;
  6717. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6718. }
  6719. newentity.isAfterSaleOrder = 1;
  6720. newentity.IsRefund = 0;
  6721. string receiveMobile = GetPostString("receiver_mobile");
  6722. if (receiveMobile.Length > 0)
  6723. {
  6724. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6725. if (trade != null)
  6726. {
  6727. trade.receiver_name = GetPostString("receiver_name");
  6728. trade.receiver_mobile = receiveMobile;
  6729. trade.receiver_state = GetPostString("receiver_state");
  6730. trade.receiver_city = GetPostString("receiver_city");
  6731. trade.receiver_district = GetPostString("receiver_district");
  6732. trade.receiver_address = GetPostString("receiver_address");
  6733. newentity.IsOffLineOrder = 1;
  6734. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6735. }
  6736. }
  6737. string st = GetPostString("ToState");
  6738. if (st.Length > 0)
  6739. {
  6740. if (newentity.OrderState <= 3)
  6741. {
  6742. newentity.WaitDesignTime = DateTime.Now;
  6743. newentity.StartDesignTime = null;
  6744. newentity.FinishDesignTime = null;
  6745. newentity.OrderState = 3;
  6746. if (st == "下单员")
  6747. {
  6748. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6749. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6750. {
  6751. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6752. }
  6753. }
  6754. else
  6755. {
  6756. newentity.WaitDesignTime = DateTime.Now;
  6757. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6758. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6759. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6760. {
  6761. DataRow user = dt1.Rows[0];
  6762. //找主管
  6763. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6764. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6765. if (dt != null && dt.Rows.Count > 0)
  6766. {
  6767. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6768. newentity.DesignUserId = designMr;
  6769. string key = "aftersale_order_" + designMr;
  6770. if (RedisHelper.HasKey(key))
  6771. {
  6772. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6773. list.Add(newentity.ctid);
  6774. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6775. }
  6776. }
  6777. //账号正常
  6778. if (user["State"].ToString() == "0")
  6779. {
  6780. newentity.DesignUserId = entity.DesignUserId;
  6781. string key = "aftersale_order_" + entity.DesignUserId;
  6782. if (RedisHelper.HasKey(key))
  6783. {
  6784. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6785. list.Add(newentity.ctid);
  6786. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6787. }
  6788. }
  6789. }
  6790. }
  6791. }
  6792. if (entity.IsXianHuo == 1)
  6793. {
  6794. newentity.OrderState = 6;
  6795. entity.FinishPlaceTime = DateTime.Now;
  6796. }
  6797. }
  6798. if (ishav)
  6799. {
  6800. newentity.Update();
  6801. }
  6802. else
  6803. {
  6804. newentity.Create();
  6805. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6806. newCellExtend.ctid = newentity.ctid;
  6807. newCellExtend.orderFrom = 20;
  6808. newCellExtend.orderType = 30;
  6809. if (st == "下单员")
  6810. {
  6811. }
  6812. else
  6813. {
  6814. newCellExtend.ReprintTime = DateTime.Now;
  6815. }
  6816. newCellExtend.Create();
  6817. }
  6818. if (st != "下单员")
  6819. {
  6820. if (entity.DispatchSort == 2)
  6821. {
  6822. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6823. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6824. }
  6825. }
  6826. }
  6827. //处理售后扩展
  6828. string resIdStr = GetPostString("ResponsibleUserId");
  6829. string refundFees = GetPostString("refundFrees");
  6830. int IsComplain = GetPostInt("isComplain");
  6831. int IsBad = GetPostInt("isBad");
  6832. string IsOriginal = GetPostString("isOriginal");
  6833. double diffResultPrice = GetPostDouble("diffResultPrice");
  6834. string textResult = GetPostString("textResult");
  6835. string supplierResponsible = GetPostString("supplierResponsible");
  6836. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6837. if (ceErpTradeAfterSaleExtend == null)
  6838. {
  6839. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6840. ceErpTradeAfterSaleExtend.tid = eid;
  6841. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6842. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6843. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6844. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6845. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6846. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6847. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6848. ceErpTradeAfterSaleExtend.Create();
  6849. }
  6850. else
  6851. {
  6852. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6853. {
  6854. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6855. }
  6856. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6857. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6858. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6859. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6860. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6861. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6862. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6863. ceErpTradeAfterSaleExtend.Update();
  6864. }
  6865. int gysid = GetPostInt("ResponsibleSupId");
  6866. if (entity.AfterSaleUserId == 0)
  6867. {
  6868. entity.AfterSaleUserId = CurrentUser.UserID;
  6869. }
  6870. entity.ResponsibleUserId = resIdStr;
  6871. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6872. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6873. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6874. {
  6875. CeErpTradeResponsible.DelByTid(eid, -1);
  6876. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6877. int backNum = 0;
  6878. if (number != null)
  6879. {
  6880. backNum = number.BackNum;
  6881. }
  6882. char[] separator = { ',' };
  6883. string[] sArray = resIdStr.Split(separator);
  6884. string[] refundFreeList = { };
  6885. if (refundFees.Length > 0)
  6886. {
  6887. refundFreeList = refundFees.Split(separator);
  6888. }
  6889. int index = -1;
  6890. foreach (string i in sArray)
  6891. {
  6892. index++;
  6893. if (i.Length <= 0) continue;
  6894. char[] separator2 = { '_' };
  6895. string idstr = i.Split(separator2)[0];
  6896. string idtype = i.Split(separator2)[1];
  6897. double refudFree = 0;
  6898. if (refundFreeList.Length > 0)
  6899. {
  6900. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6901. }
  6902. if (idtype == "s")
  6903. {
  6904. isDesign = true;
  6905. designFree = refudFree;
  6906. }
  6907. int userId = Convert.ToInt32(idstr);
  6908. int type = 0;
  6909. if (idtype == "g")
  6910. {
  6911. type = 1;
  6912. }
  6913. if (idtype == "w")
  6914. {
  6915. type = 2;
  6916. }
  6917. if (idtype == "t")
  6918. {
  6919. type = 3;
  6920. }
  6921. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6922. if (ceErpTradeResponsible == null)
  6923. {
  6924. ceErpTradeResponsible = new CeErpTradeResponsible();
  6925. ceErpTradeResponsible.tid = eid;
  6926. ceErpTradeResponsible.UserId = userId;
  6927. ceErpTradeResponsible.createdTime = DateTime.Now;
  6928. ceErpTradeResponsible.type = type;
  6929. if (type == 1)
  6930. {
  6931. ceErpTradeResponsible.IsSup = 1;
  6932. }
  6933. if (type == 2)
  6934. {
  6935. ceErpTradeResponsible.IsFlow = 1;
  6936. }
  6937. }
  6938. ceErpTradeResponsible.RefundFee = refudFree;
  6939. ceErpTradeResponsible.VerifyState = 0;
  6940. if (userId == 2125 || idtype == "w")
  6941. {
  6942. ceErpTradeResponsible.VerifyState = 1;
  6943. }
  6944. if (idtype == "w" && userId == 101)
  6945. {
  6946. ceErpTradeResponsible.VerifyState = 0;
  6947. }
  6948. if (ceErpTradeResponsible.ID > 0)
  6949. {
  6950. ceErpTradeResponsible.Update();
  6951. }
  6952. else
  6953. {
  6954. ceErpTradeResponsible.Create();
  6955. }
  6956. if (isDesign)
  6957. {
  6958. responsibleId = ceErpTradeResponsible.ID;
  6959. }
  6960. }
  6961. CeErpTradeResponsible.NumByTid(backNum, eid);
  6962. }
  6963. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6964. if (ceErpTradeCellExtend != null)
  6965. {
  6966. ceErpTradeCellExtend.returnVisit = 0;
  6967. ceErpTradeCellExtend.Update();
  6968. }
  6969. if (entity.HandleTime != null)
  6970. {
  6971. if (entity.AfterSaleState == 1)
  6972. {
  6973. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6974. }
  6975. else
  6976. {
  6977. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6978. }
  6979. }
  6980. else
  6981. {
  6982. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6983. entity.HandleTime = DateTime.Now;
  6984. }
  6985. bool isCompale = false;
  6986. if (entity.AfterSaleState == 5)
  6987. {
  6988. isCompale = true;
  6989. entity.AfterSaleState = 3;
  6990. }
  6991. entity.AfterSaleSupplierState = 0;
  6992. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6993. {
  6994. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6995. }
  6996. string sImgs = GetPostString("img");
  6997. entity.AfterSaleSupplierImg = sImgs;
  6998. entity.supRefundType = GetPostString("supRefundType");
  6999. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7000. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7001. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7002. entity.AfterSaleMemoType = GetPostString("MemoType");
  7003. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7004. {
  7005. //entity.AfterSaleSupplierState = 2;
  7006. }
  7007. string df = GetPostString("DeductFee");
  7008. if (df == "")
  7009. {
  7010. df = "0";
  7011. }
  7012. string rf = GetPostString("RefundFee");
  7013. if (rf == "")
  7014. {
  7015. rf = "0";
  7016. }
  7017. string pm = GetPostString("AfterSalePayment");
  7018. if (pm == "")
  7019. {
  7020. pm = "0";
  7021. }
  7022. entity.AfterSalePayment = Convert.ToDouble(pm);
  7023. entity.DeductFee = Convert.ToDouble(df);
  7024. entity.RefundFee = Convert.ToDouble(rf);
  7025. entity.UpdateTime = DateTime.Now;
  7026. entity.Update();
  7027. string toState = GetPostString("ToState");
  7028. string original = GetPostString("isOriginal");
  7029. ApiVo apiVo = new ApiVo();
  7030. apiVo.orderNumber = entity.ctid;
  7031. apiVo.actionName = "afterDesign";
  7032. apiVo.orderRemarks = entity.AfterSaleMethod;
  7033. apiVo.reasonRemarks = entity.AfterSaleReason;
  7034. apiVo.isDesign = isDesign;
  7035. apiVo.designFree = designFree;
  7036. apiVo.responsibleId = responsibleId;
  7037. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7038. if (toState == "设计师")
  7039. {
  7040. apiVo.isOriginal = Convert.ToBoolean(original);
  7041. }
  7042. designHelper.API_WorkCore(apiVo);//afterDesign
  7043. CeErpMethod methodSql = new CeErpMethod();
  7044. methodSql.con = entity.AfterSaleMethod;
  7045. methodSql.addTime = DateTime.Now;
  7046. methodSql.Create();
  7047. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7048. CeErpMethod.ExecuteNonQuery(delsql);
  7049. if (isCompale)
  7050. {
  7051. aftersale_data_change(entity.ctid);
  7052. }
  7053. returnSuccessMsg("操作成功!");
  7054. return;
  7055. }
  7056. returnErrorMsg("找不到订单记录");
  7057. }
  7058. }
  7059. public void ins_erp_toresponsible()
  7060. {
  7061. if (UrlPostParmsCheck("ctid"))
  7062. {
  7063. string eid = GetPostString("ctid");
  7064. CeErpTradeCell entity = null;
  7065. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7066. if (entity != null)
  7067. {
  7068. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7069. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7070. {
  7071. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7072. return;
  7073. }
  7074. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7075. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7076. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7077. if (entity.AfterSalePreTime == null)
  7078. {
  7079. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7080. {
  7081. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7082. }
  7083. }
  7084. entity.AfterSalePreTime = DateTime.Now;
  7085. //预完成给售后主管审核客户问题直接完成
  7086. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7087. {
  7088. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7089. {
  7090. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7091. }
  7092. }
  7093. ceErpTradeAfterSaleExtend.Update();
  7094. entity.AfterSaleState = 2;
  7095. entity.UpdateTime = DateTime.Now;
  7096. entity.Update();
  7097. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7098. aftersale_data_change(entity.ctid);
  7099. returnSuccessMsg("操作成功!");
  7100. return;
  7101. }
  7102. returnErrorMsg("找不到订单记录");
  7103. }
  7104. }
  7105. public void cancel_erp_aftersaleanddelnew()
  7106. {
  7107. if (UrlPostParmsCheck("ctid"))
  7108. {
  7109. string eid = GetPostString("ctid");
  7110. CeErpTradeCell entity = null;
  7111. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7112. if (entity != null)
  7113. {
  7114. entity.AfterSaleState = 0;
  7115. entity.AfterSaleReason = "";
  7116. entity.AfterSaleMethod = "";
  7117. entity.AfterSaleMemo = "";
  7118. entity.AfterSaleResponsible = "";
  7119. entity.ResponsibleUserId = "";
  7120. entity.DeductFee = 0;
  7121. entity.RefundFee = 0;
  7122. entity.IsArbitrate = 0;
  7123. CeErpTradeResponsible.DelByTid(eid, -1);
  7124. entity.Update();
  7125. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7126. if (after != null)
  7127. {
  7128. if (after.OrderState < 5)
  7129. CeErpTradeCell.DelByCtid("S_" + eid);
  7130. }
  7131. returnSuccessMsg("操作成功!");
  7132. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7133. return;
  7134. }
  7135. returnErrorMsg("找不到订单记录");
  7136. }
  7137. }
  7138. public void get_erp_aftersale_pregather()
  7139. {
  7140. List<string> lw = new List<string>();
  7141. int st = GetInt("st");
  7142. string tid = GetPostString("ctid");
  7143. if (tid.Length > 0)
  7144. {
  7145. string select_tid = getTidByCtid(tid);
  7146. lw.Add(string.Format("tid='{0}'", select_tid));
  7147. }
  7148. string shopname = GetPostString("shopname");
  7149. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7150. string buyernick = GetPostString("buyer_nick");
  7151. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7152. string sellermemo = GetPostString("seller_memo");
  7153. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7154. string orderState = GetPostString("orderState");
  7155. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7156. string reason = GetPostString("reason");
  7157. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7158. string method = GetPostString("method");
  7159. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7160. string handler = GetPostString("handler");
  7161. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7162. string handledate1 = GetPostString("handledate1");
  7163. string handledate2 = GetPostString("handledate2");
  7164. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7165. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7166. string supplier = GetPostString("supplier");
  7167. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7168. string responsible = GetPostString("responsibleman");
  7169. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7170. string customer = GetPostString("customer");
  7171. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7172. string design = GetPostString("design");
  7173. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7174. string afterMemoType = GetPostString("aftermemotype");
  7175. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7176. string afterSaleMemo = GetPostString("afterSaleMemo");
  7177. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7178. string afterresult = GetPostString("afterresult");
  7179. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7180. string poscode = CurrentUser.UserPost.Post.Code;
  7181. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7182. {
  7183. string shopid = CurrentUser.User.pemShop;
  7184. lw.Add(string.Format("shopId in ({0})", shopid));
  7185. }
  7186. var mainwhere = string.Join(" and ", lw.ToArray());
  7187. string ro_json = "";
  7188. string type = GetPostString("gather_type");
  7189. int number = 0;
  7190. if (poscode == "AfterSale")
  7191. {
  7192. //处理中
  7193. if (type == "Handling")
  7194. {
  7195. 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) : ""));
  7196. DataTable dt = null;
  7197. try
  7198. {
  7199. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7200. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7201. }
  7202. catch (Exception e)
  7203. {
  7204. dt = new DataTable();
  7205. }
  7206. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7207. return;
  7208. }
  7209. if (type == "Wait")
  7210. {
  7211. //待处理
  7212. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7213. DataTable dt1 = null;
  7214. try
  7215. {
  7216. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7217. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7218. }
  7219. catch (Exception e)
  7220. {
  7221. dt1 = new DataTable();
  7222. }
  7223. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7224. return;
  7225. }
  7226. if (type == "back")
  7227. {
  7228. //打回
  7229. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7230. DataTable dt2 = null;
  7231. try
  7232. {
  7233. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7234. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7235. }
  7236. catch (Exception e)
  7237. {
  7238. dt2 = new DataTable();
  7239. }
  7240. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7241. return;
  7242. }
  7243. if (type == "preCompletion")
  7244. {
  7245. //预完成
  7246. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7247. DataTable dt3 = null;
  7248. try
  7249. {
  7250. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7251. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7252. }
  7253. catch (Exception e)
  7254. {
  7255. dt3 = new DataTable();
  7256. }
  7257. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7258. return;
  7259. }
  7260. if (type == "documentary")
  7261. {
  7262. //跟单中
  7263. 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) : ""));
  7264. DataTable dt4 = null;
  7265. try
  7266. {
  7267. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7268. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7269. }
  7270. catch (Exception e)
  7271. {
  7272. dt4 = new DataTable();
  7273. }
  7274. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7275. return;
  7276. }
  7277. if (type == "reBack")
  7278. {
  7279. //被打回
  7280. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7281. DataTable dt1 = null;
  7282. try
  7283. {
  7284. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7285. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7286. }
  7287. catch (Exception e)
  7288. {
  7289. dt1 = new DataTable();
  7290. }
  7291. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7292. return;
  7293. }
  7294. }
  7295. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7296. {
  7297. if (type == "puBack")
  7298. {
  7299. //退回
  7300. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7301. DataTable dt = null;
  7302. try
  7303. {
  7304. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7305. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7306. }
  7307. catch (Exception e)
  7308. {
  7309. dt = new DataTable();
  7310. }
  7311. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7312. return;
  7313. }
  7314. if (type == "reBack")
  7315. {
  7316. //打回
  7317. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7318. DataTable dt1 = null;
  7319. try
  7320. {
  7321. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7322. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7323. }
  7324. catch (Exception e)
  7325. {
  7326. dt1 = new DataTable();
  7327. }
  7328. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7329. return;
  7330. }
  7331. if (type == "examEd")
  7332. {
  7333. //已审核
  7334. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7335. DataTable dt2 = null;
  7336. try
  7337. {
  7338. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7339. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7340. }
  7341. catch (Exception e)
  7342. {
  7343. dt2 = new DataTable();
  7344. }
  7345. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7346. return;
  7347. }
  7348. if (type == "waitExam")
  7349. {
  7350. //待审核
  7351. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7352. DataTable dt3 = null;
  7353. try
  7354. {
  7355. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7356. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7357. }
  7358. catch (Exception e)
  7359. {
  7360. dt3 = new DataTable();
  7361. }
  7362. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7363. return;
  7364. }
  7365. if (type == "Handling")
  7366. {
  7367. //处理中
  7368. 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) : ""));
  7369. DataTable dt4 = null;
  7370. try
  7371. {
  7372. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7373. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7374. }
  7375. catch (Exception e)
  7376. {
  7377. dt4 = new DataTable();
  7378. }
  7379. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7380. return;
  7381. }
  7382. if (type == "Wait")
  7383. {
  7384. //待处理
  7385. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7386. DataTable dt5 = null;
  7387. try
  7388. {
  7389. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7390. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7391. }
  7392. catch (Exception e)
  7393. {
  7394. dt5 = new DataTable();
  7395. }
  7396. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7397. return;
  7398. }
  7399. if (type == "documentary")
  7400. {
  7401. //跟单中
  7402. 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) : ""));
  7403. DataTable dt6 = null;
  7404. try
  7405. {
  7406. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7407. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7408. }
  7409. catch (Exception e)
  7410. {
  7411. dt6 = new DataTable();
  7412. }
  7413. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7414. return;
  7415. }
  7416. }
  7417. returnSuccess(ro_json);
  7418. }
  7419. public void end_erp_aftersale()
  7420. {
  7421. if (UrlPostParmsCheck("ctid"))
  7422. {
  7423. string eid = GetPostString("ctid");
  7424. CeErpTradeCell entity = null;
  7425. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7426. if (entity != null)
  7427. {
  7428. string stype = GetPostString("stype");
  7429. string typeStr = stype;
  7430. entity.AfterSaleState = 4;
  7431. entity.FinishAfterSaleTime = DateTime.Now;
  7432. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7433. entity.Update();
  7434. ApiVo apiVo = new ApiVo();
  7435. apiVo.orderNumber = entity.ctid;
  7436. apiVo.actionName = "afterOver";
  7437. designHelper.API_WorkCore(apiVo); //afterOver
  7438. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7439. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7440. CeErpSukuraData.createInfo(entity.ctid, 8);
  7441. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7442. returnSuccessMsg("操作成功!");
  7443. return;
  7444. }
  7445. returnErrorMsg("找不到订单记录");
  7446. }
  7447. }
  7448. public void ins_erp_finishaftersale()
  7449. {
  7450. if (UrlPostParmsCheck("id"))
  7451. {
  7452. string eid = GetPostString("id");
  7453. CeErpTradeResponsible entity = null;
  7454. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7455. if (entity != null)
  7456. {
  7457. entity.VerifyState = 1;
  7458. entity.VerifyTime = DateTime.Now;
  7459. entity.Update();
  7460. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7461. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7462. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7463. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7464. if (dt.Rows.Count <= 0)
  7465. {
  7466. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7467. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7468. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7469. CeErpSukuraData.createInfo(entity.tid, 8);
  7470. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7471. {
  7472. CeErpDesignerBill.Del(entity.tid);
  7473. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7474. }
  7475. }
  7476. returnSuccessMsg("操作成功!");
  7477. return;
  7478. }
  7479. returnErrorMsg("找不到订单记录");
  7480. }
  7481. }
  7482. public void upd_erp_arbitrateaftersale()
  7483. {
  7484. if (UrlPostParmsCheck("id"))
  7485. {
  7486. string eid = GetPostString("id");
  7487. CeErpTradeResponsible entity = null;
  7488. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7489. if (entity != null)
  7490. {
  7491. entity.IsArbitrate = 1;
  7492. entity.ArbitradeMemo = GetPostString("reason");
  7493. entity.VerifyState = 2;
  7494. entity.Update();
  7495. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7496. if (tradecell != null)
  7497. {
  7498. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7499. tradecell.IsArbitrate = 1;
  7500. tradecell.Update();
  7501. }
  7502. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7503. returnSuccessMsg("操作成功!");
  7504. return;
  7505. }
  7506. returnErrorMsg("找不到订单记录");
  7507. }
  7508. }
  7509. public void upd_erp_backaftersale()
  7510. {
  7511. if (UrlPostParmsCheck("tid"))
  7512. {
  7513. string eid = GetPostString("tid");
  7514. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7515. int backNum = 0;
  7516. if (number != null)
  7517. {
  7518. backNum = number.BackNum;
  7519. }
  7520. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7521. CeErpTradeCell entity = null;
  7522. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7523. if (entity != null)
  7524. {
  7525. entity.AfterSaleBackReason = GetPostString("backreason");
  7526. entity.AfterSaleState = 1;
  7527. entity.AfterSaleSupplierState = 0;
  7528. entity.UpdateTime = DateTime.Now;
  7529. entity.Update();
  7530. returnSuccessMsg("操作成功!");
  7531. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7532. return;
  7533. }
  7534. returnErrorMsg("找不到订单记录");
  7535. }
  7536. }
  7537. public void get_erp_supplieraftersalelist()
  7538. {
  7539. DataStruct dStruct = GetPostStruct();
  7540. List<string> lw = new List<string>();
  7541. string tid = GetPostString("ctid");
  7542. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7543. string shopname = GetPostString("shopname");
  7544. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7545. string buyernick = GetPostString("buyer_nick");
  7546. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7547. string sellermemo = GetPostString("seller_memo");
  7548. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7549. string orderState = GetPostString("orderState");
  7550. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7551. string afterState = GetPostString("afterstate");
  7552. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7553. string date1 = GetPostString("date1");
  7554. string date2 = GetPostString("date2");
  7555. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7556. if (dw.Length > 0) lw.Add(dw);
  7557. string price1 = GetPostString("price1");
  7558. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7559. string price2 = GetPostString("price2");
  7560. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7561. string reason = GetPostString("reason");
  7562. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7563. string method = GetPostString("method");
  7564. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7565. string handledate1 = GetPostString("handledate1");
  7566. string handledate2 = GetPostString("handledate2");
  7567. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7568. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7569. string handler = GetPostString("handler");
  7570. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7571. string afterdate1 = GetPostString("afterdate1");
  7572. string afterdate2 = GetPostString("afterdate2");
  7573. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7574. if (afterDate.Length > 0) lw.Add(afterDate);
  7575. string customer = GetPostString("customer");
  7576. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7577. string design = GetPostString("design");
  7578. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7579. string afterMemoType = GetPostString("aftermemotype");
  7580. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7581. string vstate = GetPostString("vstate");
  7582. if (vstate.Length > 0)
  7583. {
  7584. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7585. }
  7586. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7587. string supplier = GetPostString("supplier");
  7588. int supid = commonHelper.getSupplierIDByName(supplier);
  7589. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7590. string posCode = CurrentUser.UserPost.Post.Code;
  7591. if (posCode == "Supplier")
  7592. {
  7593. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7594. }
  7595. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7596. {
  7597. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7598. }
  7599. else
  7600. {
  7601. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7602. }
  7603. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7604. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7605. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7606. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7607. writeGridDataTableJson(dStruct.TotalCount, dt);
  7608. }
  7609. public void upd_erp_supverifyaftersale()
  7610. {
  7611. if (UrlPostParmsCheck("id"))
  7612. {
  7613. string id = GetPostString("id");
  7614. int st = GetPostInt("afterstate");
  7615. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7616. CeErpTradeCell entity = null;
  7617. if (ceErpTradeResponsible != null)
  7618. {
  7619. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7620. }
  7621. string afmemo = GetPostString("supmemo");
  7622. string image = GetPostString("image");
  7623. if (entity != null)
  7624. {
  7625. entity.AfterSaleSupplierState = st;
  7626. entity.AfterSaleSupplierMemo = afmemo;
  7627. if (st == 1)
  7628. {
  7629. ceErpTradeResponsible.VerifyState = 1;
  7630. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7631. ceErpTradeResponsible.Update();
  7632. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7633. if (isAll)
  7634. {
  7635. entity.AfterSaleState = 4;
  7636. entity.FinishAfterSaleTime = DateTime.Now;
  7637. }
  7638. }
  7639. else
  7640. {
  7641. CeErpTradeResponsible.dateByTid(entity.ctid);
  7642. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7643. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7644. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7645. if (num <= 1)
  7646. {
  7647. entity.AfterSaleState = 1;
  7648. }
  7649. else
  7650. {
  7651. entity.AfterSaleState = 5;
  7652. }
  7653. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7654. if (ceErpTradeAfterSaleExtend != null)
  7655. {
  7656. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7657. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7658. ceErpTradeAfterSaleExtend.Update();
  7659. }
  7660. else
  7661. {
  7662. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7663. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7664. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7665. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7666. ceErpTradeAfterSaleExtend.Create();
  7667. }
  7668. }
  7669. if (entity.AfterSaleState == 4)
  7670. {
  7671. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7672. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7673. {
  7674. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7675. }
  7676. ApiVo apiVo = new ApiVo();
  7677. apiVo.orderNumber = entity.ctid;
  7678. apiVo.actionName = "afterOver";
  7679. designHelper.API_WorkCore(apiVo); //afterOver
  7680. }
  7681. entity.UpdateTime = DateTime.Now;
  7682. entity.Update();
  7683. returnSuccessMsg("操作成功!");
  7684. CeErpSukuraData.createInfo(entity.ctid, 8);
  7685. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7686. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7687. return;
  7688. }
  7689. returnErrorMsg("找不到订单记录");
  7690. }
  7691. }
  7692. public void upd_erp_masteraftersale()
  7693. {
  7694. if (UrlPostParmsCheck("id"))
  7695. {
  7696. string id = GetPostString("id");
  7697. int st = GetPostInt("afterstate");
  7698. string afmemo = GetPostString("supmemo");
  7699. string image = GetPostString("image");
  7700. string textResult = GetPostString("textResult");
  7701. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7702. if (ceErpTradeResponsible != null)
  7703. {
  7704. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7705. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7706. ceErpTradeResponsible.Update();
  7707. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7708. if (entity != null)
  7709. {
  7710. entity.AfterSaleSupplierState = st;
  7711. entity.AfterSaleSupplierMemo = afmemo;
  7712. if (st == 1)
  7713. {
  7714. }
  7715. else
  7716. {
  7717. CeErpTradeResponsible.dateByTid(entity.ctid);
  7718. //退回到售后
  7719. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7720. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7721. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7722. if (num <= 1)
  7723. {
  7724. entity.AfterSaleState = 1;
  7725. }
  7726. else
  7727. {
  7728. entity.AfterSaleState = 5;
  7729. }
  7730. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7731. if (ceErpTradeAfterSaleExtend != null)
  7732. {
  7733. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7734. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7735. ceErpTradeAfterSaleExtend.Update();
  7736. }
  7737. else
  7738. {
  7739. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7740. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7741. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7742. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7743. ceErpTradeAfterSaleExtend.Create();
  7744. }
  7745. }
  7746. entity.UpdateTime = DateTime.Now;
  7747. entity.Update();
  7748. returnSuccessMsg("操作成功!");
  7749. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7750. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7751. return;
  7752. }
  7753. }
  7754. returnErrorMsg("找不到订单记录");
  7755. }
  7756. }
  7757. public void upd_erp_personaftersale()
  7758. {
  7759. if (UrlPostParmsCheck("id"))
  7760. {
  7761. //林小连
  7762. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7763. {
  7764. upd_erp_masteraftersale();
  7765. return;
  7766. }
  7767. string id = GetPostString("id");
  7768. int st = GetPostInt("afterstate");
  7769. string afmemo = GetPostString("supmemo");
  7770. string image = GetPostString("image");
  7771. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7772. if (ceErpTradeResponsible != null)
  7773. {
  7774. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7775. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7776. ceErpTradeResponsible.Update();
  7777. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7778. if (entity != null)
  7779. {
  7780. entity.AfterSaleSupplierMemo = afmemo;
  7781. entity.AfterSaleSupplierState = st;
  7782. if (st == 1)
  7783. {
  7784. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7785. if (isAll)
  7786. {
  7787. entity.AfterSaleState = 4;
  7788. entity.FinishAfterSaleTime = DateTime.Now;
  7789. }
  7790. }
  7791. else
  7792. {
  7793. CeErpTradeResponsible.dateByTid(entity.ctid);
  7794. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7795. if (ceErpTradeAfterSaleExtend != null)
  7796. {
  7797. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7798. ceErpTradeAfterSaleExtend.Update();
  7799. }
  7800. else
  7801. {
  7802. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7803. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7804. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7805. ceErpTradeAfterSaleExtend.Create();
  7806. }
  7807. //退回到主管
  7808. //entity.AfterSaleState = 2;
  7809. }
  7810. if (entity.AfterSaleState == 4)
  7811. {
  7812. ApiVo apiVo = new ApiVo();
  7813. apiVo.orderNumber = entity.ctid;
  7814. apiVo.actionName = "afterOver";
  7815. designHelper.API_WorkCore(apiVo); //afterOver
  7816. }
  7817. entity.UpdateTime = DateTime.Now;
  7818. entity.Update();
  7819. returnSuccessMsg("操作成功!");
  7820. CeErpSukuraData.createInfo(entity.ctid, 8);
  7821. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7822. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7823. return;
  7824. }
  7825. }
  7826. returnErrorMsg("找不到订单记录");
  7827. }
  7828. }
  7829. public void set_erp_supplierrefundtag()
  7830. {
  7831. if (UrlPostParmsCheck("ctid"))
  7832. {
  7833. string eid = GetPostString("ctid");
  7834. CeErpTradeCell entity = null;
  7835. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7836. if (entity != null)
  7837. {
  7838. entity.IsSupplierRefund = GetPostInt("tag");
  7839. entity.Update();
  7840. returnSuccessMsg("操作成功!");
  7841. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7842. return;
  7843. }
  7844. returnErrorMsg("找不到订单记录");
  7845. }
  7846. }
  7847. public void get_erp_refundlist()
  7848. {
  7849. DataStruct dStruct = GetPostStruct();
  7850. List<string> lw = new List<string>();
  7851. string tid = GetPostString("tid");
  7852. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7853. //string rid = GetPostString("refund_id");
  7854. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7855. string shopname = GetPostString("shopname");
  7856. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7857. string buyernick = GetPostString("buyer_nick");
  7858. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7859. string customer = GetPostString("customer");
  7860. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7861. string design = GetPostString("design");
  7862. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7863. string sellermemo = GetPostString("seller_memo");
  7864. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7865. //string date1 = GetPostString("date1");
  7866. //string date2 = GetPostString("date2");
  7867. //string dateType = GetPostString("dateType");
  7868. //if (dateType.Length > 0)
  7869. //{
  7870. // if (dateType == "1001") dateType = "0";
  7871. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7872. // if (searchDT.Count == 2)
  7873. // {
  7874. // date1 = searchDT[0].ToString();
  7875. // date2 = searchDT[1].ToString();
  7876. // }
  7877. //}
  7878. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7879. //if (dw.Length > 0) lw.Add(dw);
  7880. string redate1 = GetPostString("refunddate1");
  7881. string redate2 = GetPostString("refunddate2");
  7882. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7883. if (dwdate.Length > 0) lw.Add(dwdate);
  7884. string price1 = GetPostString("price1");
  7885. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7886. string price2 = GetPostString("price2");
  7887. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7888. string ispartrefund = GetPostString("ispartrefund");
  7889. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7890. string refundState = GetPostString("refundvstate");
  7891. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7892. int st = GetInt("st");
  7893. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7894. {
  7895. string responsible = GetPostString("responsibleman");
  7896. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7897. lw.Add(string.Format("RefundState>={0}", st));
  7898. string code = CurrentUser.UserPost.Post.Code;
  7899. if (code == "CustomerService")
  7900. {
  7901. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7902. }
  7903. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7904. {
  7905. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7906. }
  7907. else if (code == "Place" || code == "PlaceMr")
  7908. {
  7909. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7910. }
  7911. dStruct.Order = "RefundState asc,created desc";
  7912. }
  7913. else if (st == 10)
  7914. {
  7915. string responsible = GetPostString("responsibleman");
  7916. if (responsible == "空白")
  7917. {
  7918. lw.Add(string.Format("ResponsibleUserName = ''"));
  7919. }
  7920. else if (responsible.Length > 0)
  7921. {
  7922. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7923. }
  7924. lw.Add(string.Format("RefundState>=0"));
  7925. dStruct.Order = "created desc";
  7926. }
  7927. else
  7928. {
  7929. string responsible = GetPostString("responsibleman");
  7930. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7931. lw.Add(string.Format("RefundState={0}", st));
  7932. dStruct.Order = "created desc";
  7933. }
  7934. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7935. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7936. dt.Columns.Add("refund_fees");
  7937. foreach (DataRow dr in dt.Rows)
  7938. {
  7939. String status = dr["status"].ToString();
  7940. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7941. {
  7942. dr["refund_fees"] = dr["refund_fee"];
  7943. }
  7944. else
  7945. {
  7946. dr["refund_fees"] = "0.0";
  7947. }
  7948. }
  7949. writeGridDataTableJson(dStruct.TotalCount, dt);
  7950. }
  7951. public void get_erp_refunddesignlist()
  7952. {
  7953. DataStruct dStruct = GetPostStruct();
  7954. List<string> lw = new List<string>();
  7955. string tid = GetPostString("tid");
  7956. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7957. string shopname = GetPostString("shopname");
  7958. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7959. string buyernick = GetPostString("buyer_nick");
  7960. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7961. string customer = GetPostString("customer");
  7962. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7963. string design = GetPostString("design");
  7964. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7965. string sellermemo = GetPostString("seller_memo");
  7966. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7967. string redate1 = GetPostString("refunddate1");
  7968. string redate2 = GetPostString("refunddate2");
  7969. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7970. if (dwdate.Length > 0) lw.Add(dwdate);
  7971. string price1 = GetPostString("price1");
  7972. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7973. string price2 = GetPostString("price2");
  7974. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7975. string ispartrefund = GetPostString("ispartrefund");
  7976. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7977. string designerorg = GetPostString("designerorg");
  7978. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7979. string refundState = GetPostString("refundState");
  7980. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7981. int myOrgid = CurrentUser.UserPost.OrgID;
  7982. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7983. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7984. {
  7985. if (CurrentUser.User.TeamIds.Length > 0)
  7986. {
  7987. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7988. }
  7989. else
  7990. {
  7991. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7992. }
  7993. }
  7994. else if ("SysAdmin".Equals(myOrgCode))
  7995. {
  7996. }
  7997. else
  7998. {
  7999. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8000. {
  8001. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8002. }
  8003. else
  8004. {
  8005. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8006. }
  8007. }
  8008. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8009. dStruct.Order = "created desc";
  8010. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8011. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8012. dt.Columns.Add("refund_fees");
  8013. foreach (DataRow dr in dt.Rows)
  8014. {
  8015. String status = dr["status"].ToString();
  8016. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8017. {
  8018. dr["refund_fees"] = dr["refund_fee"];
  8019. }
  8020. else
  8021. {
  8022. dr["refund_fees"] = "0.0";
  8023. }
  8024. }
  8025. writeGridDataTableJson(dStruct.TotalCount, dt);
  8026. }
  8027. public void handle_erp_refundtag()
  8028. {
  8029. if (UrlPostParmsCheck("refund_id"))
  8030. {
  8031. string eid = GetPostString("refund_id");
  8032. string respMan = GetPostString("ResponsibleName");
  8033. if (respMan.Length <= 0)
  8034. {
  8035. returnErrorMsg("责任人不能为空");
  8036. return;
  8037. }
  8038. CeErpTradeRefund entity = null;
  8039. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8040. if (entity != null)
  8041. {
  8042. entity.ResponsibleUserName = respMan;
  8043. string userid = GetPostString("ResponsibleUserId");
  8044. if (userid.Length > 0)
  8045. {
  8046. entity.ResponsibleUserId = userid;
  8047. }
  8048. entity.Memo = GetPostString("Memo");
  8049. if (respMan.IndexOf("客服") != -1 ||
  8050. respMan.IndexOf("设计师") != -1 ||
  8051. respMan.IndexOf("下单员") != -1)
  8052. {
  8053. entity.RefundState = 2;
  8054. }
  8055. else
  8056. {
  8057. entity.RefundState = 3;
  8058. }
  8059. entity.modified = DateTime.Now;
  8060. entity.Update();
  8061. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8062. returnSuccessMsg("操作成功!");
  8063. return;
  8064. }
  8065. returnErrorMsg("找不到订单记录");
  8066. }
  8067. }
  8068. public void handle_erp_designrefundtag()
  8069. {
  8070. if (UrlPostParmsCheck("refund_id"))
  8071. {
  8072. string eid = GetPostString("refund_id");
  8073. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8074. if (ceErpTradeCellExtend == null)
  8075. {
  8076. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8077. ceErpTradeCellExtend.ctid = eid;
  8078. }
  8079. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8080. if (ceErpTradeCellExtend.ID > 0)
  8081. {
  8082. ceErpTradeCellExtend.Update();
  8083. }
  8084. else
  8085. {
  8086. ceErpTradeCellExtend.Create();
  8087. }
  8088. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8089. returnSuccessMsg("操作成功!");
  8090. return;
  8091. }
  8092. returnErrorMsg("找不到订单记录");
  8093. }
  8094. public void upd_erp_refundverify()
  8095. {
  8096. if (UrlPostParmsCheck("refund_id"))
  8097. {
  8098. string eid = GetPostString("refund_id");
  8099. CeErpTradeRefund entity = null;
  8100. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8101. if (entity != null)
  8102. {
  8103. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8104. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8105. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8106. {
  8107. entity.RefundState = 2;
  8108. }
  8109. else
  8110. {
  8111. entity.RefundState = 3;
  8112. }
  8113. entity.Update();
  8114. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8115. returnSuccessMsg("操作成功!");
  8116. return;
  8117. }
  8118. returnErrorMsg("找不到订单记录");
  8119. }
  8120. }
  8121. public void upd_erp_refundapprove()
  8122. {
  8123. if (UrlPostParmsCheck("refund_id"))
  8124. {
  8125. string eid = GetPostString("refund_id");
  8126. CeErpTradeRefund entity = null;
  8127. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8128. if (entity != null)
  8129. {
  8130. int apr = GetPostInt("approve");
  8131. if (apr == 0)
  8132. {
  8133. entity.RefundState = 1;
  8134. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8135. }
  8136. else if (apr == 1)
  8137. {
  8138. entity.RefundState = 3;
  8139. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8140. }
  8141. entity.modified = DateTime.Now;
  8142. entity.Update();
  8143. returnSuccessMsg("操作成功!");
  8144. return;
  8145. }
  8146. returnErrorMsg("找不到订单记录");
  8147. }
  8148. }
  8149. public void get_erp_billlist()
  8150. {
  8151. DataStruct dStruct = GetPostStruct();
  8152. List<string> lw = new List<string>();
  8153. string title = GetPostString("title");
  8154. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8155. string tid = GetPostString("tid");
  8156. string tids = GetPostString("tids");
  8157. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8158. if (tids.Length > 0)
  8159. {
  8160. tids = "'" + tids + "'";
  8161. tids = tids.Replace(",", "','");
  8162. lw.Add(string.Format("tid in ({0})", tids));
  8163. }
  8164. string shopname = GetPostString("shopname");
  8165. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8166. string buyernick = GetPostString("buyer_nick");
  8167. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8168. string customer = GetPostString("customer");
  8169. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8170. string date1 = GetPostString("date1");
  8171. string date2 = GetPostString("date2");
  8172. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8173. if (dw.Length > 0) lw.Add(dw);
  8174. string price1 = GetPostString("price1");
  8175. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8176. string price2 = GetPostString("price2");
  8177. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8178. string returndate1 = GetPostString("returndate1");
  8179. string returndate2 = GetPostString("returndate2");
  8180. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8181. if (dw1.Length > 0) lw.Add(dw1);
  8182. string billtype = GetPostString("billtype");
  8183. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8184. string billstate = GetPostString("billstate");
  8185. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8186. string usershop = CurrentUser.User.pemShop;
  8187. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8188. dStruct.Order = "createTime desc";
  8189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8190. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8191. //foreach (DataRow dr in dt.Rows)
  8192. //{
  8193. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8194. //}
  8195. writeGridDataTableJson(dStruct.TotalCount, dt);
  8196. }
  8197. public void modify_erp_billinfo()
  8198. {
  8199. if (UrlPostParmsCheck("ID"))
  8200. {
  8201. string eid = GetPostString("ID");
  8202. CeErpBill bill_entity = null;
  8203. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8204. if (bill_entity != null)
  8205. {
  8206. bill_entity.tid = GetPostString("tid");
  8207. bill_entity.title = GetPostString("title");
  8208. bill_entity.tax = GetPostString("tax");
  8209. bill_entity.bank = GetPostString("bank");
  8210. bill_entity.bankac = GetPostString("bankac");
  8211. bill_entity.address = GetPostString("address");
  8212. bill_entity.phone = GetPostString("phone");
  8213. bill_entity.price = GetPostString("price");
  8214. bill_entity.productId = GetPostInt("ProductName");
  8215. bill_entity.num = GetPostInt("num");
  8216. bill_entity.unit = GetPostString("unit");
  8217. bill_entity.type = GetPostString("type");
  8218. bill_entity.sendType = GetPostString("SendType");
  8219. bill_entity.email = GetPostString("email");
  8220. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8221. bill_entity.shopName = GetPostString("ShopName");
  8222. bill_entity.applymemo = GetPostString("applymemo");
  8223. bill_entity.modifyTime = DateTime.Now;
  8224. bill_entity.createTime = DateTime.Now;
  8225. bill_entity.state = 0;
  8226. bill_entity.Update();
  8227. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8228. returnSuccessMsg("发票修改成功!");
  8229. return;
  8230. }
  8231. returnErrorMsg("找不到对应记录");
  8232. }
  8233. }
  8234. public void set_erp_invoicing()
  8235. {
  8236. if (UrlPostParmsCheck("id"))
  8237. {
  8238. try
  8239. {
  8240. string eid = GetPostString("id");
  8241. CeErpBill bill_entity = null;
  8242. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8243. if (bill_entity != null)
  8244. {
  8245. int ComId = GetPostInt("ComId");
  8246. //string memo = GetPostString("Memo");
  8247. int allInfo = GetPostInt("allinfo");
  8248. string clert = CurrentUser.User.Name;
  8249. //string detailValue = GetPostString("detailvalue");
  8250. string billId = bill_entity.billOrderId;
  8251. string[] billIdList = billId.Split(',');
  8252. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8253. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8254. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8255. {
  8256. billCount += 1;
  8257. }
  8258. if (billId.Length <= 0 || billIdList.Length != billCount)
  8259. {
  8260. bill_entity.billOrderId = "";
  8261. string prebill = "ltb";
  8262. for (int idx = 1; idx <= billCount; idx++)
  8263. {
  8264. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8265. string billoid = prebill + idx + dtstr;
  8266. bill_entity.billOrderId += billoid;
  8267. if (idx < billCount)
  8268. {
  8269. bill_entity.billOrderId += ",";
  8270. }
  8271. }
  8272. }
  8273. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8274. if (bill_entity.state == 5)
  8275. {
  8276. string errMsg = bill_entity.failerror;
  8277. string[] errlist = errMsg.Split('|');
  8278. string[] errTags = new string[errlist.Length];
  8279. for (int itag = 0; itag < errlist.Length; itag++)
  8280. {
  8281. if (errlist[itag].Length <= 0) continue;
  8282. errTags[itag] = errlist[itag].Split('&')[0];
  8283. }
  8284. for (int iii = 0; iii < errTags.Length; iii++)
  8285. {
  8286. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8287. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8288. if (billOrderList.Length >= erroBillOrderTag)
  8289. {
  8290. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8291. if (needModifyBillId.Length <= 19)
  8292. {
  8293. needModifyBillId = needModifyBillId + "1";
  8294. }
  8295. else
  8296. {
  8297. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8298. last = last + 1;
  8299. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8300. }
  8301. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8302. }
  8303. }
  8304. }
  8305. bool isHaveBillSucces = false;
  8306. string totalRes = "";
  8307. bill_entity.failerror = "";
  8308. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8309. {
  8310. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8311. totalRes += res;
  8312. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8313. {
  8314. isHaveBillSucces = true;
  8315. bill_entity.comId = ComId;
  8316. bill_entity.state = 1;
  8317. bill_entity.executeTime = DateTime.Now;
  8318. bill_entity.executeUser = clert;
  8319. }
  8320. else
  8321. {
  8322. bill_entity.state = 5;
  8323. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8324. }
  8325. }
  8326. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8327. bill_entity.Update();
  8328. if (isHaveBillSucces)
  8329. {
  8330. StringBuilder sql = new StringBuilder();
  8331. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8332. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8333. }
  8334. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8335. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8336. {
  8337. returnErrorMsg("开票失败");
  8338. }
  8339. else
  8340. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8341. return;
  8342. }
  8343. returnErrorMsg("找不到对应记录");
  8344. }
  8345. catch (Exception ex)
  8346. {
  8347. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8348. returnErrorMsg("操作失败");
  8349. }
  8350. }
  8351. }
  8352. public void get_erp_invoicing_back()
  8353. {
  8354. if (UrlPostParmsCheck("id"))
  8355. {
  8356. try
  8357. {
  8358. string id = GetPostString("id");
  8359. CeErpBill entiy = CeErpBill.Get(id);
  8360. if (entiy != null)
  8361. {
  8362. if (entiy.state == 0)
  8363. {
  8364. returnErrorMsg("发票还未开具");
  8365. return;
  8366. }
  8367. string[] billOrderList = entiy.billOrderId.Split(',');
  8368. int iTag = 0;
  8369. entiy.fplsh = "";
  8370. entiy.fpdm = "";
  8371. entiy.fphm = "";
  8372. foreach (string billOrderId in billOrderList)
  8373. {
  8374. iTag++;
  8375. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8376. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8377. {
  8378. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8379. try
  8380. {
  8381. Invoicing_get_response_Obj iObj = null;
  8382. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8383. if (iObj != null)
  8384. {
  8385. entiy.state = 2;
  8386. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8387. entiy.fpdm += iObj.list[0].c_fpdm;
  8388. entiy.fphm += iObj.list[0].c_fphm;
  8389. if (iTag < billOrderList.Length)
  8390. {
  8391. entiy.fplsh += ",";
  8392. entiy.fpdm += ",";
  8393. entiy.fphm += ",";
  8394. }
  8395. entiy.Update();
  8396. }
  8397. StringBuilder sql = new StringBuilder();
  8398. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8399. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8400. returnSuccessMsg("开票成功");
  8401. }
  8402. catch (Exception ex)
  8403. {
  8404. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8405. }
  8406. return;
  8407. }
  8408. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8409. {
  8410. var res_obj = new
  8411. {
  8412. data = "开票中"
  8413. };
  8414. string ro_json = JsonConvert.SerializeObject(res_obj);
  8415. returnSuccess(ro_json);
  8416. return;
  8417. }
  8418. else
  8419. {
  8420. int eidx = res.IndexOf("c_resultmsg");
  8421. int lidx = res.IndexOf("c_status");
  8422. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8423. entiy.state = 5;
  8424. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8425. entiy.Update();
  8426. returnErrorMsg("开票失败");
  8427. return;
  8428. }
  8429. }
  8430. }
  8431. }
  8432. catch (Exception ex)
  8433. {
  8434. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8435. }
  8436. return;
  8437. }
  8438. }
  8439. public void get_erp_invoicing()
  8440. {
  8441. if (UrlPostParmsCheck("id"))
  8442. {
  8443. try
  8444. {
  8445. string id = GetPostString("id");
  8446. CeErpBill entiy = CeErpBill.Get(id);
  8447. if (entiy != null)
  8448. {
  8449. if (entiy.state == 0)
  8450. {
  8451. returnErrorMsg("发票还未开具");
  8452. return;
  8453. }
  8454. if (entiy.sendType == "纸质发票")
  8455. {
  8456. if (entiy.img.Length <= 0)
  8457. {
  8458. returnErrorMsg("查无纸质发票");
  8459. return;
  8460. }
  8461. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8462. returnSuccess(returnres);
  8463. return;
  8464. }
  8465. string[] billOrderList = entiy.billOrderId.Split(',');
  8466. int iTag = 0;
  8467. string fpUrl = "";
  8468. entiy.fplsh = "";
  8469. entiy.fpdm = "";
  8470. entiy.fphm = "";
  8471. foreach (string billOrderId in billOrderList)
  8472. {
  8473. iTag++;
  8474. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8475. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8476. {
  8477. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8478. Invoicing_get_response_Obj iObj = null;
  8479. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8480. if (iObj != null)
  8481. {
  8482. //entiy.state = 2;
  8483. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8484. entiy.fpdm += iObj.list[0].c_fpdm;
  8485. entiy.fphm += iObj.list[0].c_fphm;
  8486. if (iTag < billOrderList.Length)
  8487. {
  8488. entiy.fplsh += ",";
  8489. entiy.fpdm += ",";
  8490. entiy.fphm += ",";
  8491. }
  8492. entiy.Update();
  8493. fpUrl += iObj.list[0].c_url + ",";
  8494. }
  8495. //returnSuccess(res);
  8496. StringBuilder sql = new StringBuilder();
  8497. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8498. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8499. }
  8500. else
  8501. {
  8502. int eidx = res.IndexOf("c_resultmsg");
  8503. //int lidx = res.IndexOf("c_status");
  8504. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8505. //开票失败
  8506. entiy.state = 5;
  8507. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8508. entiy.Update();
  8509. returnErrorMsg("开票失败");
  8510. return;
  8511. }
  8512. }
  8513. var returnObj = new
  8514. {
  8515. data = fpUrl
  8516. };
  8517. string ro_json = JsonConvert.SerializeObject(returnObj);
  8518. returnSuccess(ro_json);
  8519. }
  8520. }
  8521. catch (Exception ex)
  8522. {
  8523. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8524. }
  8525. return;
  8526. }
  8527. }
  8528. public void save_erp_billimg()
  8529. {
  8530. if (UrlPostParmsCheck("id"))
  8531. {
  8532. string eid = GetPostString("id");
  8533. CeErpBill bill_entity = null;
  8534. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8535. if (bill_entity != null)
  8536. {
  8537. bill_entity.img = GetPostString("img");
  8538. bill_entity.executeTime = DateTime.Now;
  8539. bill_entity.state = 2;
  8540. bill_entity.Update();
  8541. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8542. returnSuccessMsg("保存成功");
  8543. }
  8544. return;
  8545. }
  8546. }
  8547. public void upd_erp_billreturnback()
  8548. {
  8549. if (UrlPostParmsCheck("id"))
  8550. {
  8551. int eid = GetPostInt("id");
  8552. CeErpBill bill_entity = null;
  8553. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8554. if (bill_entity != null)
  8555. {
  8556. bill_entity.state = 3;
  8557. bill_entity.returnReason = GetPostString("reason");
  8558. bill_entity.Update();
  8559. returnSuccessMsg("驳回成功!");
  8560. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8561. }
  8562. return;
  8563. }
  8564. }
  8565. public void cancel_erp_bill()
  8566. {
  8567. if (UrlPostParmsCheck("id"))
  8568. {
  8569. int eid = GetPostInt("id");
  8570. int detailValue = GetPostInt("detailvalue");
  8571. CeErpBill bill_entity = null;
  8572. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8573. string cres = "";
  8574. string gres = "";
  8575. if (bill_entity != null)
  8576. {
  8577. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8578. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8579. {
  8580. int iTag = 0;
  8581. bill_entity.fplsh = "";
  8582. bill_entity.fpdm = "";
  8583. bill_entity.fphm = "";
  8584. foreach (string billOrderId in billOrderList)
  8585. {
  8586. iTag++;
  8587. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8588. if (gres.IndexOf("success") != -1)
  8589. {
  8590. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8591. Invoicing_get_response_Obj iObj = null;
  8592. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8593. if (iObj != null)
  8594. {
  8595. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8596. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8597. bill_entity.fphm += iObj.list[0].c_fphm;
  8598. if (iTag < billOrderList.Length)
  8599. {
  8600. bill_entity.fplsh += ",";
  8601. bill_entity.fpdm += ",";
  8602. bill_entity.fphm += ",";
  8603. }
  8604. bill_entity.Update();
  8605. }
  8606. }
  8607. else
  8608. {
  8609. returnErrorMsg(gres);
  8610. return;
  8611. }
  8612. }
  8613. }
  8614. if (bill_entity.sendType == "纸质发票")
  8615. {
  8616. //作废
  8617. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8618. //if (DateTime.Now.Month == extime.Month)
  8619. //{
  8620. //cres = taobaoHelper.cancel_invoicing(eid);
  8621. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8622. //{
  8623. bill_entity.state = 4;//已作废
  8624. bill_entity.Update();
  8625. returnSuccessMsg("发票已作废");
  8626. return;
  8627. //}
  8628. //else
  8629. //{
  8630. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8631. // bill_entity.Update();
  8632. // returnErrorMsg(cres);
  8633. // return;
  8634. //}
  8635. //}
  8636. //else
  8637. //{
  8638. // returnErrorMsg("纸质发票只能作废本月的发票");
  8639. // return;
  8640. //}
  8641. }
  8642. //红冲
  8643. int redTag = 0;
  8644. string[] fpdmList = bill_entity.fpdm.Split(',');
  8645. string[] fphmList = bill_entity.fphm.Split(',');
  8646. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8647. {
  8648. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8649. return;
  8650. }
  8651. foreach (string billOrderId in billOrderList)
  8652. {
  8653. redTag++;
  8654. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8655. cres += onecres;
  8656. cres += ",";
  8657. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8658. {
  8659. bill_entity.state = 4;//已作废
  8660. //bill_entity.Update();
  8661. //returnSuccessMsg("发票已红冲");
  8662. }
  8663. else if (onecres.IndexOf("重复冲红") != -1)
  8664. {
  8665. bill_entity.state = 4;//已作废
  8666. //bill_entity.Update();
  8667. //returnSuccessMsg("发票已红冲");
  8668. }
  8669. else
  8670. {
  8671. string errmsg = commonHelper.KeepChinese(onecres);
  8672. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8673. }
  8674. }
  8675. bill_entity.Update();
  8676. if (cres.IndexOf("失败") != -1)
  8677. returnErrorMsg("红冲失败");
  8678. else
  8679. returnSuccessMsg("发票已红冲");
  8680. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8681. return;
  8682. }
  8683. return;
  8684. }
  8685. }
  8686. public void del_erp_billorder()
  8687. {
  8688. if (UrlPostParmsCheck("id"))
  8689. {
  8690. string eid = GetPostString("id");
  8691. CeErpBill.Del(eid);
  8692. CeErpBill bill = CeErpBill.Get(eid);
  8693. if (bill != null)
  8694. {
  8695. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8696. }
  8697. returnSuccessMsg("删除成功");
  8698. }
  8699. }
  8700. public void finish_erp_bill()
  8701. {
  8702. if (UrlPostParmsCheck("ids"))
  8703. {
  8704. string eids = GetPostString("ids");
  8705. string[] list = eids.Split(',');
  8706. foreach (string eid in list)
  8707. {
  8708. CeErpBill bill = CeErpBill.Get(eid);
  8709. if (bill != null)
  8710. {
  8711. bill.state = 2;
  8712. bill.Update();
  8713. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8714. }
  8715. }
  8716. returnSuccessMsg("操作成功");
  8717. }
  8718. }
  8719. public void get_erp_returncash()
  8720. {
  8721. DataStruct dStruct = GetPostStruct();
  8722. List<string> lw = new List<string>();
  8723. string tid = GetPostString("tid");
  8724. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8725. string shopname = GetPostString("shopname");
  8726. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8727. string buyernick = GetPostString("buyer_nick");
  8728. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8729. string customer = GetPostString("customer");
  8730. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8731. string returndate1 = GetPostString("returndate1");
  8732. string returndate2 = GetPostString("returndate2");
  8733. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8734. if (dw.Length > 0) lw.Add(dw);
  8735. string finishDate1 = GetPostString("finishdate1");
  8736. string finishDate2 = GetPostString("finishdate2");
  8737. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8738. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8739. string returntype = GetPostString("returntype");
  8740. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8741. string returnvstate = GetPostString("returnvstate");
  8742. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8743. dStruct.Order = "created desc";
  8744. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8745. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8746. writeGridDataTableJson(dStruct.TotalCount, dt);
  8747. }
  8748. public void get_erp_staygoods()
  8749. {
  8750. DataStruct dStruct = GetPostStruct();
  8751. List<string> lw = new List<string>();
  8752. string tid = GetPostString("tid");
  8753. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8754. string shopname = GetPostString("shopname");
  8755. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8756. string wangwang = GetPostString("wangwang");
  8757. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8758. string customer = GetPostString("customer");
  8759. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8760. string returndate1 = GetPostString("returndate1");
  8761. string returndate2 = GetPostString("returndate2");
  8762. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8763. if (dw.Length > 0) lw.Add(dw);
  8764. string finishDate1 = GetPostString("finishdate1");
  8765. string finishDate2 = GetPostString("finishdate2");
  8766. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8767. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8768. string returnvstate = GetPostString("returnvstate");
  8769. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8770. string persuadetype = GetPostString("persuadetype");
  8771. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8772. string customerOrg = GetPostString("customerOrg");
  8773. if (customerOrg.Length > 0)
  8774. {
  8775. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8776. }
  8777. dStruct.Order = "creata_time desc";
  8778. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8779. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8780. writeGridDataTableJson(dStruct.TotalCount, dt);
  8781. }
  8782. public void upd_erp_staygoods()
  8783. {
  8784. if (UrlPostParmsCheck("id"))
  8785. {
  8786. int eid = GetPostInt("id");
  8787. CeErpStayGoods entity = null;
  8788. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8789. if (entity != null)
  8790. {
  8791. entity.audit_type = 1;
  8792. entity.audit_time = DateTime.Now;
  8793. entity.audit_u_id = CurrentUser.UserID;
  8794. entity.audit_u_name = CurrentUser.UserName;
  8795. entity.Update();
  8796. returnSuccessMsg("审核成功!");
  8797. return;
  8798. }
  8799. returnErrorMsg("找不到订单记录");
  8800. }
  8801. }
  8802. public void upd_erp_stayGoodsback()
  8803. {
  8804. if (UrlPostParmsCheck("id"))
  8805. {
  8806. int eid = GetPostInt("id");
  8807. CeErpStayGoods entity = null;
  8808. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8809. if (entity != null)
  8810. {
  8811. entity.audit_text = GetPostString("reason");
  8812. entity.audit_type = 2;
  8813. entity.audit_time = DateTime.Now;
  8814. entity.audit_u_id = CurrentUser.UserID;
  8815. entity.audit_u_name = CurrentUser.UserName;
  8816. entity.Update();
  8817. returnSuccessMsg("退回成功!");
  8818. return;
  8819. }
  8820. returnErrorMsg("找不到订单记录");
  8821. }
  8822. }
  8823. public void upd_erp_returncashverify()
  8824. {
  8825. if (UrlPostParmsCheck("ID"))
  8826. {
  8827. int eid = GetPostInt("ID");
  8828. CeErpReturnCash entity = null;
  8829. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8830. if (entity != null)
  8831. {
  8832. entity.cashstate = 1;
  8833. entity.verifytime = DateTime.Now;
  8834. entity.verifyuserid = CurrentUser.UserID;
  8835. entity.Update();
  8836. returnSuccessMsg("审核成功!");
  8837. return;
  8838. }
  8839. returnErrorMsg("找不到订单记录");
  8840. }
  8841. }
  8842. public void upd_all_erp_returncashverify()
  8843. {
  8844. if (UrlPostParmsCheck("ID"))
  8845. {
  8846. String[] list = GetPostString("ID").Split(',');
  8847. CeErpReturnCash entity = null;
  8848. for (int i = 0; i < list.Length; i++)
  8849. {
  8850. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8851. if (entity != null)
  8852. {
  8853. if (entity.cashstate == 1)
  8854. {
  8855. returnErrorMsg("已审核过的订单不需要在审核!");
  8856. return;
  8857. }
  8858. entity.cashstate = 1;
  8859. entity.verifytime = DateTime.Now;
  8860. entity.verifyuserid = CurrentUser.UserID;
  8861. entity.Update();
  8862. }
  8863. }
  8864. returnSuccessMsg("审核成功!");
  8865. return;
  8866. }
  8867. }
  8868. public void upd_erp_returncashback()
  8869. {
  8870. if (UrlPostParmsCheck("ID"))
  8871. {
  8872. int eid = GetPostInt("ID");
  8873. CeErpReturnCash entity = null;
  8874. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8875. if (entity != null)
  8876. {
  8877. entity.backreason = GetPostString("reason");
  8878. entity.cashstate = 2;
  8879. entity.verifytime = DateTime.Now;
  8880. entity.verifyuserid = CurrentUser.UserID;
  8881. entity.Update();
  8882. returnSuccessMsg("退回成功!");
  8883. return;
  8884. }
  8885. returnErrorMsg("找不到订单记录");
  8886. }
  8887. }
  8888. public void upd_erp_returnprice()
  8889. {
  8890. if (UrlPostParmsCheck("ID"))
  8891. {
  8892. int eid = GetPostInt("ID");
  8893. CeErpReturnCash entity = null;
  8894. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8895. if (entity != null)
  8896. {
  8897. if (entity.cashstate == 1)
  8898. {
  8899. returnErrorMsg("审核通过了不能改");
  8900. return;
  8901. }
  8902. entity.returnprice = GetPostDouble("returnprice");
  8903. entity.Update();
  8904. returnSuccessMsg("修改成功!");
  8905. return;
  8906. }
  8907. returnErrorMsg("找不到订单记录");
  8908. }
  8909. }
  8910. public void del_erp_returncash()
  8911. {
  8912. if (UrlPostParmsCheck("ID"))
  8913. {
  8914. int eid = GetPostInt("ID");
  8915. CeErpReturnCash.Del(eid);
  8916. returnSuccessMsg("操作成功");
  8917. return;
  8918. }
  8919. }
  8920. public void test_for_do_sql()
  8921. {
  8922. string sql = GetPostString("sqlstr");
  8923. if (sql.Length > 0)
  8924. {
  8925. try
  8926. {
  8927. DbHelper.DbConn.ExecuteNonQuery(sql);
  8928. var res_obj = new
  8929. {
  8930. data = "成功",
  8931. };
  8932. string ro_json = JsonConvert.SerializeObject(res_obj);
  8933. returnSuccess(ro_json);
  8934. }
  8935. catch (Exception ex)
  8936. {
  8937. var res_obj = new
  8938. {
  8939. data = ex.Message,
  8940. };
  8941. string ro_json = JsonConvert.SerializeObject(res_obj);
  8942. returnSuccess(ro_json);
  8943. }
  8944. }
  8945. }
  8946. public void get_user_info()
  8947. {
  8948. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8949. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8950. }
  8951. public void get_total_data()
  8952. {
  8953. int userId = CurrentUser.UserID;
  8954. string sql = "";
  8955. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8956. {
  8957. 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);
  8958. }
  8959. else
  8960. {
  8961. 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 " +
  8962. "(select ID from CE_ErpUser where ID = {0}) d " +
  8963. "left join " +
  8964. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8965. ") a on d.ID = a.id left join " +
  8966. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8967. ") b on a.id = b.id1 left join" +
  8968. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8969. ") c on a.id = c.id2;", userId);
  8970. }
  8971. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8972. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8973. }
  8974. public void get_date_area_total_data2()
  8975. {
  8976. int userId = CurrentUser.UserID;
  8977. string date_type = GetPostString("timetype");
  8978. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8979. string sql = "";
  8980. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8981. {
  8982. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8983. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8984. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8985. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8986. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8987. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8988. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8989. ") a on e.ID = a.id left join " +
  8990. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8991. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8992. ") b on a.id = b.id1 " +
  8993. "left join " +
  8994. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8995. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8996. ") c on a.id = c.id2 " +
  8997. "left join " +
  8998. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8999. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9000. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9001. }
  9002. else
  9003. {
  9004. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9005. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9006. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9007. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9008. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9009. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9010. ") a on e.ID = a.id left join " +
  9011. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9012. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9013. ") c on a.id = c.id2 " +
  9014. "left join " +
  9015. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9016. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9017. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9018. }
  9019. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9020. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9021. }
  9022. public void get_date_area_total_data()
  9023. {
  9024. int userId = CurrentUser.UserID;
  9025. string date_type = GetPostString("timetype");
  9026. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9027. string date1 = searchDT[0].ToString();
  9028. string date2 = searchDT[1].ToString();
  9029. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9030. {
  9031. SqlParameter[] sqlParameter ={
  9032. new SqlParameter("@userId", SqlDbType.Int,4),
  9033. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9034. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9035. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9036. };
  9037. sqlParameter[0].Value = userId;
  9038. sqlParameter[1].Value = date1;
  9039. sqlParameter[2].Value = date2;
  9040. sqlParameter[3].Direction = ParameterDirection.Output;
  9041. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9042. string res = sqlParameter[3].Value.ToString();
  9043. var res_obj = new
  9044. {
  9045. data = res
  9046. };
  9047. string ro_json = JsonConvert.SerializeObject(res_obj);
  9048. returnSuccess(ro_json);
  9049. }
  9050. else
  9051. {
  9052. SqlParameter[] sqlParameter ={
  9053. new SqlParameter("@userId", SqlDbType.Int,4),
  9054. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9055. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9056. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9057. };
  9058. sqlParameter[0].Value = userId;
  9059. sqlParameter[1].Value = date1;
  9060. sqlParameter[2].Value = date2;
  9061. sqlParameter[3].Direction = ParameterDirection.Output;
  9062. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9063. string res = sqlParameter[3].Value.ToString();
  9064. var res_obj = new
  9065. {
  9066. data = res
  9067. };
  9068. string ro_json = JsonConvert.SerializeObject(res_obj);
  9069. returnSuccess(ro_json);
  9070. }
  9071. //writeGridDataViewJson(dt.Rows.Count, dv);
  9072. }
  9073. public void get_order_list()
  9074. {
  9075. string strFields = GetPostString("paraFields");
  9076. string strOrder = GetPostString("paraOrder");
  9077. string strWhere = GetPostString("paraWhere");
  9078. string strPageSize = GetPostString("paraPageSize");
  9079. DataStruct dStruct = GetPostStruct();
  9080. dStruct.PageSize = int.Parse(strPageSize);
  9081. dStruct.Fileds = strFields;
  9082. dStruct.Order = strOrder;
  9083. dStruct.MainWhere = strWhere;
  9084. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9085. writeGridDataTableJson(dStruct.TotalCount, dt);
  9086. }
  9087. ////获取待开始订单列表
  9088. //public void get_wait_design_order_list()
  9089. //{
  9090. // string date_type = GetPostString("date_type");
  9091. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9092. // DataStruct dStruct = GetPostStruct();
  9093. // dStruct.PageSize = 1000;
  9094. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9095. // List<string> lw = new List<string>();
  9096. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9097. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9098. // dStruct.Order = "WaitDesignTime asc";
  9099. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9100. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9101. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9102. //}
  9103. //获取完成单量排名
  9104. public void get_finish_order_count_ranking()
  9105. {
  9106. /* string date_type = GetPostString("date_type");
  9107. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9108. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9109. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9110. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9111. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9112. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9113. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9114. writeGridDataTableJson(0, new DataTable());
  9115. }
  9116. public void get_finish_order_amount_ranking()
  9117. {
  9118. /*string date_type = GetPostString("date_type");
  9119. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9120. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9121. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9122. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9123. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9124. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9125. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9126. writeGridDataTableJson(0, new DataTable());
  9127. }
  9128. public void get_finish_refund_count_ranking()
  9129. {
  9130. string date_type = GetPostString("date_type");
  9131. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9132. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9133. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9134. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9135. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9136. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9137. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9138. writeGridDataTableJson(dt.Rows.Count, dt);
  9139. }
  9140. public void get_finish_refund_amount_ranking()
  9141. {
  9142. string date_type = GetPostString("date_type");
  9143. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9144. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9145. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9146. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9147. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9148. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9149. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9150. writeGridDataTableJson(dt.Rows.Count, dt);
  9151. }
  9152. public void set_erp_finishorder_director()
  9153. {
  9154. if (UrlPostParmsCheck("ctid"))
  9155. {
  9156. string eid = GetPostString("ctid");
  9157. CeErpTradeCell entity = null;
  9158. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9159. if (entity != null)
  9160. {
  9161. entity.OrderState = 8;
  9162. entity.Update();
  9163. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9164. returnSuccessMsg("操作成功!");
  9165. return;
  9166. }
  9167. returnErrorMsg("找不到记录");
  9168. }
  9169. }
  9170. public void get_erp_placeregistlist()
  9171. {
  9172. DataStruct dStruct = GetPostStruct();
  9173. List<string> lw = new List<string>();
  9174. string outsid = GetPostString("outsid");
  9175. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9176. string memo = GetPostString("memo");
  9177. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9178. string filename = GetPostString("filename");
  9179. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9180. string islate = GetPostString("islate");
  9181. if (islate.Length > 0)
  9182. {
  9183. if (islate == "1")
  9184. lw.Add(string.Format("OutLate>0"));
  9185. else
  9186. lw.Add(string.Format("OutLate=0"));
  9187. }
  9188. string placedate1 = GetPostString("placedate1");
  9189. string placedate2 = GetPostString("placedate2");
  9190. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9191. if (dw.Length > 0) lw.Add(dw);
  9192. string deliveryDate1 = GetPostString("deliverydate1");
  9193. string deliveryDate2 = GetPostString("deliverydate2");
  9194. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9195. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9196. dStruct.Order = "ID desc";
  9197. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9198. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9199. writeGridDataTableJson(dStruct.TotalCount, dt);
  9200. }
  9201. public void ins_erp_placeregist()
  9202. {
  9203. if (UrlPostParmsCheck("id"))
  9204. {
  9205. string eid = GetPostString("id");
  9206. CeErpPlaceRegister entity = null;
  9207. if (eid == "0")//新增
  9208. {
  9209. entity = new CeErpPlaceRegister();
  9210. string xdTime = GetPostString("placeTime");
  9211. if (xdTime.Length > 0)
  9212. {
  9213. entity.PlactTime = Convert.ToDateTime(xdTime);
  9214. }
  9215. string fhTime = GetPostString("deliveryTime");
  9216. if (fhTime.Length > 0)
  9217. {
  9218. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9219. }
  9220. string preTime = GetPostString("preOutTime");
  9221. if (preTime.Length > 0)
  9222. {
  9223. entity.PreOutTime = Convert.ToDateTime(preTime);
  9224. }
  9225. entity.DeliveryCount = GetPostInt("deliveryCount");
  9226. entity.ReceiveCount = GetPostInt("receiveCount");
  9227. entity.OutSid = GetPostString("outSid");
  9228. entity.FileName = GetPostString("fileName");
  9229. entity.Memo = GetPostString("memo");
  9230. entity.AddUserId = CurrentUser.UserID;
  9231. entity.CreateTime = DateTime.Now;
  9232. entity.Img = GetPostString("img");
  9233. entity.Supplier = GetPostInt("supplier");
  9234. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9235. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9236. {
  9237. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9238. DateTime dt2 = (DateTime)entity.PreOutTime;
  9239. TimeSpan span = dt1.Subtract(dt2);
  9240. if (span.Days > 0)
  9241. {
  9242. entity.OutLate = span.Days;
  9243. }
  9244. }
  9245. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9246. entity.Create();
  9247. returnSuccessMsg("添加成功!");
  9248. return;
  9249. }
  9250. else //修改
  9251. {
  9252. entity = CeErpPlaceRegister.Get(eid);
  9253. if (entity != null)
  9254. {
  9255. string xdTime = GetPostString("placeTime");
  9256. if (xdTime.Length > 0)
  9257. {
  9258. entity.PlactTime = Convert.ToDateTime(xdTime);
  9259. }
  9260. string fhTime = GetPostString("deliveryTime");
  9261. if (fhTime.Length > 0)
  9262. {
  9263. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9264. }
  9265. string preTime = GetPostString("preOutTime");
  9266. if (preTime.Length > 0)
  9267. {
  9268. entity.PreOutTime = Convert.ToDateTime(preTime);
  9269. }
  9270. entity.DeliveryCount = GetPostInt("deliveryCount");
  9271. entity.ReceiveCount = GetPostInt("receiveCount");
  9272. if (entity.DeliveryCount == entity.ReceiveCount)
  9273. {
  9274. entity.CurState = "已完成";
  9275. }
  9276. else
  9277. {
  9278. entity.CurState = "未完成";
  9279. }
  9280. entity.OutSid = GetPostString("outSid");
  9281. entity.FileName = GetPostString("fileName");
  9282. entity.Memo = GetPostString("memo");
  9283. entity.Img = GetPostString("img");
  9284. entity.Supplier = GetPostInt("supplier");
  9285. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9286. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9287. {
  9288. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9289. DateTime dt2 = (DateTime)entity.PreOutTime;
  9290. TimeSpan span = dt1.Subtract(dt2);
  9291. if (span.Days > 0)
  9292. {
  9293. entity.OutLate = span.Days;
  9294. }
  9295. }
  9296. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9297. entity.Update();
  9298. returnSuccessMsg("修改成功");
  9299. return;
  9300. }
  9301. returnErrorMsg("找不到对应的记录");
  9302. return;
  9303. }
  9304. }
  9305. returnErrorMsg("缺少必要参数");
  9306. }
  9307. public void del_erp_placeregist()
  9308. {
  9309. string eid = GetPostString("id");
  9310. CeErpPlaceRegister.Del(eid);
  9311. returnSuccessMsg("删除成功!");
  9312. return;
  9313. }
  9314. public void ins_erp_placeregistbyorder()
  9315. {
  9316. string ctid = GetPostString("ctid");
  9317. if (ctid.Length > 0)
  9318. {
  9319. StringBuilder sql = new StringBuilder();
  9320. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9321. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9322. if (dt.Rows.Count > 0)
  9323. {
  9324. foreach (DataRow dr in dt.Rows)
  9325. {
  9326. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9327. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9328. entity.AddUserId = CurrentUser.UserID;
  9329. entity.tid = dr["tid"].ToString();
  9330. entity.Did = Convert.ToString(dr["ctid"]);
  9331. entity.splitTag = dr["SplitTag"].ToString();
  9332. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9333. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9334. if (pre_ctid.Length > 0)
  9335. {
  9336. sellmemo = sellmemo.Replace(pre_ctid, "");
  9337. }
  9338. sellmemo = sellmemo.Replace("[", "");
  9339. sellmemo = sellmemo.Replace("]", "");
  9340. entity.FileName = sellmemo;
  9341. string count = dr["ProductCount"].ToString();
  9342. int usecount = commonHelper.getIntCountFromString(count);
  9343. entity.DeliveryCount = usecount;
  9344. entity.CurState = "未完成";
  9345. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9346. {
  9347. entity.Supplier = 24;//dl手提袋定制
  9348. }
  9349. else
  9350. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9351. entity.CreateTime = DateTime.Now;
  9352. entity.Create();
  9353. }
  9354. returnSuccessMsg("操作成功");
  9355. return;
  9356. }
  9357. returnErrorMsg("没有找到对应订单");
  9358. return;
  9359. }
  9360. returnErrorMsg("缺少订单编号");
  9361. return;
  9362. }
  9363. public void get_erp_persuadelist()
  9364. {
  9365. DataStruct dStruct = GetPostStruct();
  9366. List<string> lw = new List<string>();
  9367. string ctid = GetPostString("ctid");
  9368. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9369. string shopname = GetPostString("shopname");
  9370. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9371. string buyernick = GetPostString("buyer_nick");
  9372. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9373. string customer = GetPostString("customer");
  9374. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9375. string returndate1 = GetPostString("returndate1");
  9376. string returndate2 = GetPostString("returndate2");
  9377. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9378. if (dw.Length > 0) lw.Add(dw);
  9379. string finishDate1 = GetPostString("finishdate1");
  9380. string finishDate2 = GetPostString("finishdate2");
  9381. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9382. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9383. string persuadetype = GetPostString("persuadetype");
  9384. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9385. string returnvstate = GetPostString("returnvstate");
  9386. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9387. dStruct.Order = "created desc";
  9388. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9389. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9390. writeGridDataTableJson(dStruct.TotalCount, dt);
  9391. }
  9392. public void upd_erp_returnpersuadeback()
  9393. {
  9394. if (UrlPostParmsCheck("ID"))
  9395. {
  9396. int eid = GetPostInt("ID");
  9397. CeErpPersuade entity = null;
  9398. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9399. if (entity != null)
  9400. {
  9401. entity.backreason = GetPostString("reason");
  9402. entity.pstate = 2;
  9403. entity.verifytime = DateTime.Now;
  9404. entity.verifyuserid = CurrentUser.UserID;
  9405. entity.Update();
  9406. returnSuccessMsg("退回成功!");
  9407. return;
  9408. }
  9409. returnErrorMsg("找不到订单记录");
  9410. }
  9411. }
  9412. public void upd_erp_returnpersuadeverify()
  9413. {
  9414. if (UrlPostParmsCheck("ID"))
  9415. {
  9416. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9417. {
  9418. returnErrorMsg("暂无权限审核");
  9419. return;
  9420. }
  9421. int eid = GetPostInt("ID");
  9422. CeErpPersuade entity = null;
  9423. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9424. if (entity != null)
  9425. {
  9426. entity.pstate = 1;
  9427. entity.verifytime = DateTime.Now;
  9428. entity.verifyuserid = CurrentUser.UserID;
  9429. entity.Update();
  9430. returnSuccessMsg("审核成功!");
  9431. return;
  9432. }
  9433. returnErrorMsg("找不到订单记录");
  9434. }
  9435. }
  9436. public void del_erp_persuade()
  9437. {
  9438. if (UrlPostParmsCheck("ID"))
  9439. {
  9440. int eid = GetPostInt("ID");
  9441. CeErpPersuade.Del(eid);
  9442. returnSuccessMsg("操作成功");
  9443. return;
  9444. }
  9445. }
  9446. public void get_erp_oldcustoupload()
  9447. {
  9448. DataStruct dStruct = GetPostStruct();
  9449. List<string> lw = new List<string>();
  9450. string buyernick = GetPostString("buyer_nick");
  9451. if (buyernick.Length > 0)
  9452. {
  9453. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9454. }
  9455. else
  9456. return;
  9457. dStruct.Order = "pay_time desc";
  9458. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9459. DataTable dt = null;
  9460. dt = WebCache.GetData("view_erptradecell", dStruct);
  9461. writeGridDataTableJson(dStruct.TotalCount, dt);
  9462. }
  9463. public void get_erp_checkorderlist()
  9464. {
  9465. DataStruct dStruct = GetPostStruct();
  9466. List<string> lw = new List<string>();
  9467. string tid = GetPostString("ctid");
  9468. if (tid.Length > 0)
  9469. {
  9470. string select_tid = getTidByCtid(tid);
  9471. lw.Add(string.Format("tid='{0}'", select_tid));
  9472. }
  9473. string shopname = GetPostString("shopname");
  9474. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9475. string buyernick = GetPostString("buyer_nick");
  9476. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9477. string customer = GetPostString("customer");
  9478. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9479. string design = GetPostString("design");
  9480. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9481. string orderState = GetPostString("orderState");
  9482. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9483. string address = GetPostString("address");
  9484. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9485. string sellermemo = GetPostString("seller_memo");
  9486. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9487. string supplier = GetPostString("supplier");
  9488. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9489. {
  9490. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9491. }
  9492. else
  9493. {
  9494. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9495. }
  9496. string date1 = GetPostString("date1");
  9497. string date2 = GetPostString("date2");
  9498. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9499. if (dw.Length > 0) lw.Add(dw);
  9500. string placedate1 = GetPostString("placedate1");
  9501. string placedate2 = GetPostString("placedate2");
  9502. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9503. if (fdw.Length > 0) lw.Add(fdw);
  9504. string price1 = GetPostString("price1");
  9505. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9506. string price2 = GetPostString("price2");
  9507. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9508. string checkst = GetPostString("checkstate");
  9509. if (checkst.Length > 0 && "10".Equals(checkst))
  9510. {
  9511. lw.Add(string.Format("CheckOut>0"));
  9512. }
  9513. else
  9514. {
  9515. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9516. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9517. }
  9518. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9519. {
  9520. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9521. }
  9522. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9523. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9524. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9525. writeGridDataTableJson(dStruct.TotalCount, dt);
  9526. }
  9527. public void ins_erp_startCheck()
  9528. {
  9529. if (UrlPostParmsCheck("ctid"))
  9530. {
  9531. string eid = GetPostString("ctid");
  9532. CeErpTradeCell entity = null;
  9533. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9534. if (entity != null)
  9535. {
  9536. entity.MemoOpt = 4;
  9537. entity.UpdateTime = DateTime.Now;
  9538. entity.Update();
  9539. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9540. CeErpSukuraData.createInfo(entity.ctid, 6);
  9541. returnSuccessMsg("操作成功!");
  9542. return;
  9543. }
  9544. returnErrorMsg("找不到记录");
  9545. }
  9546. }
  9547. public void upd_erp_sendXlw()
  9548. {
  9549. if (UrlPostParmsCheck("ctid"))
  9550. {
  9551. string eid = GetPostString("ctid");
  9552. CeErpTradeCell entity = null;
  9553. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9554. if (entity != null)
  9555. {
  9556. if (entity.IsSendGift == 1)
  9557. {
  9558. returnErrorMsg("请勿重复标记");
  9559. return;
  9560. }
  9561. entity.IsSendGift = 1;
  9562. entity.Update();
  9563. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9564. returnSuccessMsg("操作成功!");
  9565. return;
  9566. }
  9567. returnErrorMsg("找不到记录");
  9568. }
  9569. }
  9570. public void cancel_sendXlw()
  9571. {
  9572. if (UrlPostParmsCheck("ctid"))
  9573. {
  9574. string eid = GetPostString("ctid");
  9575. CeErpTradeCell entity = null;
  9576. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9577. if (entity != null)
  9578. {
  9579. if (entity.IsSendGift == 0)
  9580. {
  9581. returnErrorMsg("未标记小礼物");
  9582. return;
  9583. }
  9584. entity.IsSendGift = 0;
  9585. entity.Update();
  9586. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9587. returnSuccessMsg("操作成功!");
  9588. return;
  9589. }
  9590. returnErrorMsg("找不到记录");
  9591. }
  9592. }
  9593. public void get_erp_designbill()
  9594. {
  9595. DataStruct dStruct = GetPostStruct();
  9596. List<string> lw = new List<string>();
  9597. int isMy = GetInt("my");
  9598. if (isMy == 1)
  9599. {
  9600. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9601. }
  9602. string tid = GetPostString("tid");
  9603. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9604. string userName = GetPostString("design");
  9605. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9606. string price1 = GetPostString("price1");
  9607. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9608. string price2 = GetPostString("price2");
  9609. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9610. string rePrice1 = GetPostString("rePrice1");
  9611. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9612. string rePrice2 = GetPostString("rePrice2");
  9613. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9614. string designerType = GetPostString("designerType");
  9615. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9616. string orderState = GetPostString("orderState");
  9617. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9618. string endTime1 = GetPostString("endTime1");
  9619. string endTime2 = GetPostString("endTime2");
  9620. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9621. if (dw.Length > 0) lw.Add(dw);
  9622. string isDk = GetPostString("isDk");
  9623. if (isDk == "1")
  9624. {
  9625. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9626. }
  9627. else if (isDk == "0")
  9628. {
  9629. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9630. }
  9631. dStruct.Order = "oid, create_time desc";
  9632. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9633. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9634. writeGridDataTableJson(dStruct.TotalCount, dt);
  9635. }
  9636. public void upd_erp_designerbill()
  9637. {
  9638. if (UrlPostParmsCheck("ID"))
  9639. {
  9640. string eid = GetPostString("ID");
  9641. CeErpDesignerBill entity = null;
  9642. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9643. if (entity != null)
  9644. {
  9645. if (GetPostDouble("designerpirce") > 0)
  9646. {
  9647. entity.realPrice = GetPostDouble("designerpirce");
  9648. entity.update_time = DateTime.Now;
  9649. entity.update_u_id = CurrentUser.UserID;
  9650. entity.update_u_name = CurrentUser.UserName;
  9651. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9652. entity.Update();
  9653. returnSuccessMsg("操作成功!");
  9654. return;
  9655. }
  9656. else
  9657. {
  9658. entity.price = GetPostDouble("price");
  9659. entity.update_time = DateTime.Now;
  9660. entity.update_u_id = CurrentUser.UserID;
  9661. entity.update_u_name = CurrentUser.UserName;
  9662. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9663. entity.Update();
  9664. returnSuccessMsg("操作成功!");
  9665. return;
  9666. }
  9667. }
  9668. returnErrorMsg("找不到记录");
  9669. }
  9670. }
  9671. public void audit_erp_designerbill()
  9672. {
  9673. if (UrlPostParmsCheck("ID"))
  9674. {
  9675. string eid = GetPostString("ID");
  9676. CeErpDesignerBill entity = null;
  9677. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9678. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9679. if (entity != null)
  9680. {
  9681. entity.realPrice = GetPostDouble("designerpirce");
  9682. entity.update_time = DateTime.Now;
  9683. entity.update_u_id = CurrentUser.UserID;
  9684. entity.update_u_name = CurrentUser.UserName;
  9685. entity.isAudit = 1;
  9686. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9687. entity.Update();
  9688. if (orderEntity != null)
  9689. {
  9690. orderEntity.IsReadTag = 3;
  9691. orderEntity.Update();
  9692. }
  9693. returnSuccessMsg("操作成功!");
  9694. return;
  9695. }
  9696. returnErrorMsg("找不到记录");
  9697. }
  9698. }
  9699. public void all_audit_erp_designerbill()
  9700. {
  9701. if (UrlPostParmsCheck("idList"))
  9702. {
  9703. string[] list = GetPostString("idList").Split(',');
  9704. CeErpDesignerBill entity = null;
  9705. for (int i = 0; i < list.Length; i++)
  9706. {
  9707. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9708. if (entity == null) return;
  9709. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9710. if (orderEntity == null) return;
  9711. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9712. entity.update_time = DateTime.Now;
  9713. entity.update_u_id = CurrentUser.UserID;
  9714. entity.update_u_name = CurrentUser.UserName;
  9715. entity.isAudit = 1;
  9716. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9717. entity.Update();
  9718. orderEntity.IsReadTag = 3;
  9719. orderEntity.Update();
  9720. }
  9721. returnSuccessMsg("操作成功!");
  9722. return;
  9723. }
  9724. }
  9725. public void get_erp_sameorders()
  9726. {
  9727. if (UrlPostParmsCheck("ctid"))
  9728. {
  9729. string eid = GetPostString("ctid");
  9730. CeErpTradeCell entity = null;
  9731. entity = CeErpTradeCell.GetByCtid(eid);
  9732. if (entity != null)
  9733. {
  9734. StringBuilder sql = new StringBuilder();
  9735. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9736. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9737. var res = new
  9738. {
  9739. data = dt.Rows.Count
  9740. };
  9741. string ro_jsond = JsonConvert.SerializeObject(res);
  9742. returnSuccess(ro_jsond);
  9743. return;
  9744. }
  9745. returnErrorMsg("未找到订单");
  9746. return;
  9747. }
  9748. returnErrorMsg("缺少必要的参数");
  9749. }
  9750. public void get_erp_islasthavesameorder()
  9751. {
  9752. if (UrlPostParmsCheck("ctid"))
  9753. {
  9754. string eid = GetPostString("ctid");
  9755. string[] ctidList = eid.Split(',');
  9756. StringBuilder sql = new StringBuilder();
  9757. string tisCtid = "";
  9758. foreach (string ctid in ctidList)
  9759. {
  9760. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9761. if (entity != null)
  9762. {
  9763. sql = new StringBuilder();
  9764. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9765. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9766. if (dth.Rows.Count > 0)
  9767. {
  9768. tisCtid += entity.ctid;
  9769. tisCtid += ",";
  9770. }
  9771. }
  9772. }
  9773. if (tisCtid.Length > 0)
  9774. {
  9775. var res = new
  9776. {
  9777. data = tisCtid
  9778. };
  9779. string ro_jsond = JsonConvert.SerializeObject(res);
  9780. returnSuccess(ro_jsond);
  9781. }
  9782. else
  9783. {
  9784. var res = new
  9785. {
  9786. data = ""
  9787. };
  9788. string ro_jsond = JsonConvert.SerializeObject(res);
  9789. returnSuccess(ro_jsond);
  9790. }
  9791. return;
  9792. }
  9793. returnErrorMsg("缺少必要的参数");
  9794. }
  9795. public void file_client_down_url()
  9796. {
  9797. if (!UrlPostParmsCheck("userId"))
  9798. {
  9799. returnErrorMsg("缺少必要的参数");
  9800. }
  9801. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9802. }
  9803. public void checkout_form_data()
  9804. {
  9805. if (!UrlPostParmsCheck("tid"))
  9806. {
  9807. returnErrorMsg("缺少必要的参数");
  9808. }
  9809. string tid = GetPostString("tid");
  9810. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9811. if (ceErpOrderFormData != null)
  9812. {
  9813. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9814. returnSuccess(ro_jsond);
  9815. return;
  9816. }
  9817. returnErrorMsg("尚未有文件!");
  9818. }
  9819. public void back_supplier_audit()
  9820. {
  9821. int userId = CurrentUser.UserID;
  9822. StringBuilder sql = new StringBuilder();
  9823. 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);
  9824. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9825. if (dt.Rows.Count > 0)
  9826. {
  9827. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9828. }
  9829. else
  9830. {
  9831. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9832. }
  9833. }
  9834. public void back_supplier_query()
  9835. {
  9836. string eid = GetPostString("ctid");
  9837. if (eid != "")
  9838. {
  9839. StringBuilder sql = new StringBuilder();
  9840. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9841. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9842. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9843. }
  9844. else
  9845. {
  9846. returnErrorMsg("找不到订单记录");
  9847. return;
  9848. }
  9849. }
  9850. public void verified_to_order()
  9851. {
  9852. int userId = CurrentUser.UserID;
  9853. StringBuilder sql = new StringBuilder();
  9854. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9855. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9856. if (dt.Rows.Count > 0)
  9857. {
  9858. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9859. }
  9860. else
  9861. {
  9862. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9863. }
  9864. }
  9865. public void upd_supplier_audit()
  9866. {
  9867. if (UrlPostParmsCheck("ctid"))
  9868. {
  9869. string eid = GetPostString("ctid");
  9870. string reason = GetPostString("returnreason");
  9871. CeErpTradeCell entity = null;
  9872. CeWithdraw withdraw = null;
  9873. withdraw = CeWithdraw.GetByTid(eid);
  9874. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9875. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9876. {
  9877. if (withdraw != null)
  9878. {
  9879. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9880. {
  9881. returnSuccessMsg("您没有权限操作!");
  9882. return;
  9883. }
  9884. else
  9885. {
  9886. if (reason.Equals("1"))
  9887. {
  9888. if (entity.OrderState == -1)
  9889. {
  9890. if (entity.FinishPlaceTime == null)
  9891. {
  9892. entity.OrderState = 2;
  9893. }
  9894. else
  9895. {
  9896. entity.OrderState = 6;
  9897. }
  9898. }
  9899. entity.Update();
  9900. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9901. if (withdraw != null)
  9902. {
  9903. withdraw.status = int.Parse(reason);
  9904. withdraw.Update();
  9905. }
  9906. returnSuccessMsg("操作成功!");
  9907. return;
  9908. }
  9909. else
  9910. {
  9911. withdraw.status = int.Parse(reason);
  9912. withdraw.acknowledgingtime = DateTime.Now;
  9913. withdraw.Update();
  9914. returnSuccessMsg("查看详细请点击线下订单查询");
  9915. return;
  9916. }
  9917. }
  9918. }
  9919. // 第一个字符是 'N'
  9920. }
  9921. if (eid[0] != 'N')
  9922. {
  9923. }
  9924. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9925. {
  9926. entity.IsVerifyToSupplier = false;
  9927. entity.IsReturn = 1;
  9928. entity.ReturnTime = DateTime.Now;
  9929. entity.ReturnReason = reason;
  9930. if (entity.OrderState == 6)
  9931. {
  9932. entity.OrderState = 5;
  9933. }
  9934. entity.Update();
  9935. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9936. if (withdraw != null)
  9937. {
  9938. withdraw.status = int.Parse(reason);
  9939. withdraw.Update();
  9940. }
  9941. returnSuccessMsg("操作成功!");
  9942. return;
  9943. }
  9944. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9945. {
  9946. ;
  9947. if (withdraw != null)
  9948. {
  9949. withdraw.status = int.Parse(reason);
  9950. withdraw.acknowledgingtime = DateTime.Now;
  9951. withdraw.Update();
  9952. returnSuccessMsg("供应商取消撤回!");
  9953. return;
  9954. }
  9955. }
  9956. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9957. {
  9958. if (entity.OrderState == -1)
  9959. {
  9960. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9961. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9962. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9963. {
  9964. returnErrorMsg("台湾客户需填写身份证!");
  9965. return;
  9966. }
  9967. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9968. {
  9969. returnErrorMsg("订单spu没有确认无法通过审核!");
  9970. return;
  9971. }
  9972. if (entity.FinishPlaceTime == null)
  9973. {
  9974. entity.OrderState = 2;
  9975. }
  9976. else
  9977. {
  9978. entity.OrderState = 3;
  9979. }
  9980. commonHelper.getCytPrice(entity);
  9981. }
  9982. entity.Update();
  9983. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9984. if (withdraw != null)
  9985. {
  9986. withdraw.status = int.Parse(reason);
  9987. withdraw.Update();
  9988. }
  9989. returnSuccessMsg("操作成功!");
  9990. return;
  9991. }
  9992. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9993. {
  9994. if (withdraw == null)
  9995. {
  9996. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9997. return;
  9998. }
  9999. }
  10000. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10001. {
  10002. if (withdraw != null)
  10003. {
  10004. withdraw.status = int.Parse(reason);
  10005. withdraw.acknowledgingtime = DateTime.Now;
  10006. withdraw.Update();
  10007. returnSuccessMsg("查看详细请点击线下订单查询");
  10008. return;
  10009. }
  10010. }
  10011. return;
  10012. }
  10013. }
  10014. //校验报价
  10015. public void refund_order_tip()
  10016. {
  10017. int userid = CurrentUser.UserID;
  10018. int sectionId = CurrentUser.UserPost.OrgID;
  10019. StringBuilder sql = new StringBuilder();
  10020. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10021. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10022. List<string> ids = new List<string>();
  10023. if (dth.Rows.Count > 0)
  10024. {
  10025. foreach (DataRow dr in dth.Rows)
  10026. {
  10027. ids.Add(dr["ID"].ToString());
  10028. }
  10029. try
  10030. {
  10031. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10032. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10033. }
  10034. catch (Exception ex)
  10035. {
  10036. }
  10037. }
  10038. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10039. }
  10040. public void refund_order_Design()
  10041. {
  10042. int userid = CurrentUser.UserID;
  10043. int sectionId = CurrentUser.UserPost.OrgID;
  10044. StringBuilder sql = new StringBuilder();
  10045. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10046. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10047. List<string> ids = new List<string>();
  10048. if (dth.Rows.Count > 0)
  10049. {
  10050. foreach (DataRow dr in dth.Rows)
  10051. {
  10052. ids.Add(dr["ID"].ToString());
  10053. }
  10054. try
  10055. {
  10056. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10057. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10058. }
  10059. catch (Exception ex)
  10060. {
  10061. }
  10062. }
  10063. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10064. }
  10065. public void change_order_info()
  10066. {
  10067. int userid = CurrentUser.UserID;
  10068. StringBuilder sql = new StringBuilder();
  10069. 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);
  10070. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10071. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10072. }
  10073. public void change_win_mome()
  10074. {
  10075. if (UrlPostParmsCheck("id,ctid"))
  10076. {
  10077. string id = GetPostString("id");
  10078. string ctid = GetPostString("ctid");
  10079. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10080. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10081. if (ce == null || ceErpMessageTip == null)
  10082. {
  10083. returnSuccessMsg("未找到对应的订单!");
  10084. return;
  10085. }
  10086. if (ce.OrderState >= 5)
  10087. {
  10088. ceErpMessageTip.isVisit = true;
  10089. ceErpMessageTip.Update();
  10090. returnSuccessMsg("已上传文件无法修改!");
  10091. return;
  10092. }
  10093. int type = GetPostInt("type");
  10094. string content = GetPostString("content");
  10095. if (type == 0)
  10096. {
  10097. content = content.Replace("(", "(");
  10098. content = content.Replace(")", ")");
  10099. string check = MidStrEx(content, "(", ")").Trim();
  10100. if (string.IsNullOrEmpty(check))
  10101. {
  10102. returnSuccessMsg("文件名格式不正确");
  10103. return;
  10104. }
  10105. }
  10106. ce.seller_memo = content;
  10107. ce.Update();
  10108. ceErpMessageTip.isVisit = true;
  10109. ceErpMessageTip.Update();
  10110. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10111. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10112. ApiVo apiVo = new ApiVo();
  10113. apiVo.orderNumber = ce.ctid;
  10114. apiVo.actionName = "demandDesign";
  10115. apiVo.orderRemarks = content;
  10116. apiVo.demandExamine = type + 1;
  10117. designHelper.API_WorkCore(apiVo);//demandDesign
  10118. returnSuccessMsg("修改成功!");
  10119. }
  10120. }
  10121. public static string MidStrEx(string sourse, string startstr, string endstr)
  10122. {
  10123. string result = string.Empty;
  10124. int startindex, endindex;
  10125. try
  10126. {
  10127. startindex = sourse.IndexOf(startstr);
  10128. if (startindex == -1)
  10129. return result;
  10130. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10131. endindex = tmpstr.IndexOf(endstr);
  10132. if (endindex == -1)
  10133. return result;
  10134. result = tmpstr.Remove(endindex);
  10135. }
  10136. catch (Exception ex)
  10137. {
  10138. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10139. }
  10140. return result;
  10141. }
  10142. public void refund_order_list()
  10143. {
  10144. int userid = CurrentUser.UserID;
  10145. int sectionId = CurrentUser.UserPost.OrgID;
  10146. StringBuilder sql = new StringBuilder();
  10147. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10148. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10149. DataStruct dStruct = GetPostStruct();
  10150. DataTable dt = null;
  10151. List<string> ids = new List<string>();
  10152. List<string> tids = new List<string>();
  10153. if (dth.Rows.Count > 0)
  10154. {
  10155. foreach (DataRow dr in dth.Rows)
  10156. {
  10157. tids.Add("'" + dr["tid"].ToString() + "'");
  10158. ids.Add(dr["id"].ToString());
  10159. }
  10160. try
  10161. {
  10162. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10163. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10164. List<string> lw = new List<string>();
  10165. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10166. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10167. dt = WebCache.GetData("view_orderlist", dStruct);
  10168. }
  10169. catch (Exception ex)
  10170. {
  10171. }
  10172. }
  10173. writeGridDataTableJson(dStruct.TotalCount, dt);
  10174. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10175. }
  10176. //新增
  10177. public void order_batch_downloads()
  10178. {
  10179. string ceid = GetPostString("tid");
  10180. String[] tid = ceid.Split(',');
  10181. order_batch_caiyingtong(tid);
  10182. /* (string success, string errors) = UploadFiles(tid);
  10183. returnSuccessMsg(success + errors);*/
  10184. return;
  10185. }
  10186. //报价接口
  10187. public void Get_To_Quote()
  10188. {
  10189. string ceid = GetPostString("ctid");
  10190. if (ceid != null)
  10191. {
  10192. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10193. if (entity != null)
  10194. {
  10195. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10196. {
  10197. return;
  10198. }
  10199. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10200. double price = 0;
  10201. if (cp == null)
  10202. {
  10203. JObject jsonObject12 = new JObject
  10204. {
  10205. { "UserId", "77886" },
  10206. { "Pwd", "lt666888" },
  10207. { "Filename", entity.seller_memo }
  10208. };
  10209. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10210. JObject jsonObjects1 = JObject.Parse(response1);
  10211. string ms1g = (string)jsonObjects1["msg"];
  10212. if (ms1g == "报价成功")
  10213. {
  10214. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10215. string data = (string)jsonObject1["price"];
  10216. 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 + "');";
  10217. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10218. returnSuccessMsg("获取报价成功:" + data);
  10219. price = Convert.ToDouble(data);
  10220. }
  10221. else
  10222. {
  10223. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10224. return;
  10225. }
  10226. }
  10227. String[] beizhu = entity.seller_memo.Split('-');
  10228. String chanp = "";
  10229. if (beizhu.Length > 0)
  10230. {
  10231. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10232. }
  10233. else
  10234. {
  10235. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10236. }
  10237. JObject jsonObject = new JObject
  10238. {
  10239. { "UserId", "77886" },
  10240. { "Pwd", "lt666888" },
  10241. { "Filename", chanp }
  10242. };
  10243. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10244. JObject jsonObjects = JObject.Parse(response);
  10245. string msg = (string)jsonObjects["msg"];
  10246. if (msg == "报价成功")
  10247. {
  10248. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10249. string data = (string)jsonObject1["price"];
  10250. 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 + "');";
  10251. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10252. returnSuccessMsg("获取报价成功:" + data);
  10253. price = Convert.ToDouble(data);
  10254. }
  10255. else
  10256. {
  10257. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10258. return;
  10259. }
  10260. if (price > 0)
  10261. {
  10262. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10263. if (ceErpTradeCellExtend == null)
  10264. {
  10265. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10266. ceErpTradeCellExtend.ctid = entity.ctid;
  10267. ceErpTradeCellExtend.payment_cyt = price;
  10268. ceErpTradeCellExtend.Create();
  10269. }
  10270. else
  10271. {
  10272. ceErpTradeCellExtend.payment_cyt = price;
  10273. ceErpTradeCellExtend.Update();
  10274. }
  10275. }
  10276. return;
  10277. }
  10278. }
  10279. else
  10280. {
  10281. returnErrorMsg("请至少选择一条数据");
  10282. return;
  10283. }
  10284. }
  10285. //新增
  10286. public void order_To_Supplier()
  10287. {
  10288. string ceid = GetPostString("tid");
  10289. String[] tid = ceid.Split(',');
  10290. if (tid.Length > 0)
  10291. {
  10292. try
  10293. {
  10294. for (int i = 0; i < tid.Length; i++)
  10295. {
  10296. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10297. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10298. entity.SupplierId = suid;
  10299. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10300. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10301. entity.Update();
  10302. }
  10303. }
  10304. catch (Exception ex)
  10305. {
  10306. returnErrorMsg("自动匹配供应商失败");
  10307. return;
  10308. }
  10309. }
  10310. else
  10311. {
  10312. returnErrorMsg("请至少选择一条数据");
  10313. return;
  10314. }
  10315. returnSuccessMsg("自动匹配供应商成功");
  10316. return;
  10317. }
  10318. public (string, string) UploadFiles(string[] urls)
  10319. {
  10320. string success = "";
  10321. string errors = "";
  10322. int userid = CurrentUser.UserID;
  10323. foreach (string url in urls)
  10324. {
  10325. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10326. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10327. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10328. {
  10329. JObject jsonObject = new JObject
  10330. {
  10331. { "Userid", "77886" },
  10332. { "pwd", "cyt86435015" },
  10333. { "content", base64FileContent },
  10334. { "ext", Path.GetExtension(fileName) }
  10335. };
  10336. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10337. JObject jsonObjects = JObject.Parse(response);
  10338. string msg = (string)jsonObjects["msg"];
  10339. if (msg.Equals("上传成功"))
  10340. {
  10341. success += url + " 上传成功";
  10342. }
  10343. else
  10344. {
  10345. errors += url + " 上传失败";
  10346. }
  10347. }
  10348. else
  10349. {
  10350. errors += url + " 格式出现问题";
  10351. }
  10352. }
  10353. if (urls.Length == 0)
  10354. {
  10355. return (success, errors);
  10356. }
  10357. return (success, errors);
  10358. }
  10359. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10360. {
  10361. return true; //总是接受
  10362. }
  10363. public static string HttpPost(string url, string param = null)
  10364. {
  10365. HttpWebRequest request;
  10366. //如果是发送HTTPS请求
  10367. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10368. {
  10369. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10370. request = WebRequest.Create(url) as HttpWebRequest;
  10371. request.ProtocolVersion = HttpVersion.Version10;
  10372. }
  10373. else
  10374. {
  10375. request = WebRequest.Create(url) as HttpWebRequest;
  10376. }
  10377. request.Method = "POST";
  10378. request.ContentType = "application/json";
  10379. request.Accept = "*/*";
  10380. request.Timeout = 120000;
  10381. request.AllowAutoRedirect = false;
  10382. StreamWriter requestStream = null;
  10383. WebResponse response = null;
  10384. string responseStr = null;
  10385. try
  10386. {
  10387. requestStream = new StreamWriter(request.GetRequestStream());
  10388. requestStream.Write(param);
  10389. requestStream.Close();
  10390. response = request.GetResponse();
  10391. if (response != null)
  10392. {
  10393. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10394. responseStr = reader.ReadToEnd();
  10395. reader.Close();
  10396. }
  10397. }
  10398. catch (Exception ex)
  10399. {
  10400. return ex.Message;
  10401. }
  10402. finally
  10403. {
  10404. request = null;
  10405. requestStream = null;
  10406. response = null;
  10407. }
  10408. return responseStr;
  10409. }
  10410. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10411. {
  10412. string base64FileContent;
  10413. string fileName;
  10414. using (WebClient webClient = new WebClient())
  10415. {
  10416. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10417. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10418. {
  10419. using (Stream stream = response.GetResponseStream())
  10420. {
  10421. using (MemoryStream memoryStream = new MemoryStream())
  10422. {
  10423. stream.CopyTo(memoryStream);
  10424. byte[] fileBytes = memoryStream.ToArray();
  10425. base64FileContent = Convert.ToBase64String(fileBytes);
  10426. fileName = response.Headers["Content-Disposition"];
  10427. if (!string.IsNullOrEmpty(fileName))
  10428. {
  10429. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10430. if (index >= 0)
  10431. {
  10432. fileName = fileName.Substring(index + 9).Trim('\"');
  10433. }
  10434. }
  10435. else
  10436. {
  10437. fileName = Path.GetFileName(downloadUrl);
  10438. }
  10439. }
  10440. }
  10441. }
  10442. }
  10443. return (fileName, base64FileContent);
  10444. }
  10445. //新增
  10446. public void order_batch_caiyingtong(string[] downloadUrls)
  10447. {
  10448. try
  10449. {
  10450. //遍历文件
  10451. DataStruct dStruct = GetPostStruct();
  10452. DataTable dt = null;
  10453. int userid = CurrentUser.UserID;
  10454. List<string> ids = new List<string>();//失败组
  10455. List<string> tids = new List<string>();
  10456. using (WebClient webClient = new WebClient())
  10457. {
  10458. foreach (var url in downloadUrls)
  10459. {
  10460. try
  10461. {
  10462. tids.Add("'" + url + "'");
  10463. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10464. if (entity != null)
  10465. {
  10466. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10467. if (cp == null)
  10468. {
  10469. JObject jsonObject = new JObject
  10470. {
  10471. { "Userid", "77886" },
  10472. { "pwd", "lt666888" },
  10473. { "Filename",entity.seller_memo }
  10474. };
  10475. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10476. JObject jsonObjects = JObject.Parse(response);
  10477. string msg = (string)jsonObjects["msg"];
  10478. if (msg == "报价成功")
  10479. {
  10480. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10481. DownloadAndConvertToBase64(url1);
  10482. }
  10483. else
  10484. {
  10485. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10486. }
  10487. }
  10488. else
  10489. {
  10490. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10491. JObject jsonObject = new JObject
  10492. {
  10493. { "Userid", "77886" },
  10494. { "pwd", "lt666888" },
  10495. { "Filename",chanp }
  10496. };
  10497. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10498. JObject jsonObjects = JObject.Parse(response);
  10499. string msg = (string)jsonObjects["msg"];
  10500. if (msg == "报价成功")
  10501. {
  10502. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10503. DownloadAndConvertToBase64(url1);
  10504. }
  10505. else
  10506. {
  10507. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10508. }
  10509. }
  10510. }
  10511. // 上传文件到FTP
  10512. }
  10513. catch (Exception ex)
  10514. {
  10515. Console.WriteLine($"An error occurred: {ex.Message}");
  10516. }
  10517. }
  10518. List<string> lw = new List<string>();
  10519. lw.Add(string.Format("( OrderState < 6 )"));
  10520. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10521. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10522. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10523. if (dt.Rows.Count > 0)
  10524. {
  10525. foreach (DataRow dr in dt.Rows)
  10526. {
  10527. ids.Add(dr["ctid"].ToString());
  10528. }
  10529. }
  10530. String ErrorMsgs = "";
  10531. foreach (String id in ids)
  10532. {
  10533. ErrorMsgs += id + ",";
  10534. }
  10535. if (ErrorMsgs.Length > 1)
  10536. {
  10537. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10538. }
  10539. if (ErrorMsgs.Length < 1)
  10540. {
  10541. ErrorMsgs = "上传成功";
  10542. returnSuccessMsg(ErrorMsgs);
  10543. }
  10544. else
  10545. {
  10546. returnErrorMsg("以下订单" + ErrorMsgs);
  10547. }
  10548. }
  10549. // 删除文件夹及其内容
  10550. /* Directory.Delete(localDirectory, true);*/
  10551. }
  10552. catch { }
  10553. }
  10554. public void get_center_data()
  10555. {
  10556. int userId = CurrentUser.UserID;
  10557. string postCode = CurrentUser.UserPost.Post.Code;
  10558. List<string> lw = new List<string>();
  10559. List<string> ww = new List<string>();
  10560. DateTime currentTime = DateTime.Now;
  10561. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10562. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10563. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10564. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10565. string sql = " SELECT ";
  10566. string startTime = "2023-10-01 11:22:31";
  10567. //设计
  10568. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10569. {
  10570. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10571. 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));
  10572. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10573. 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));
  10574. }
  10575. //客服
  10576. else if (postCode == "CustomerService" || postCode == "Director")
  10577. {
  10578. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10579. 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));
  10580. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10581. 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));
  10582. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10583. 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));
  10584. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10585. 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));
  10586. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10587. 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));
  10588. }
  10589. //售后
  10590. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10591. {
  10592. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10593. 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));
  10594. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10595. 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));
  10596. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10597. 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));
  10598. }
  10599. //下单部
  10600. else if (postCode == "Place" || postCode == "PlaceMr")
  10601. {
  10602. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10603. 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));
  10604. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10605. 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));
  10606. }
  10607. //车间
  10608. else if (postCode == "Supplier")
  10609. {
  10610. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10611. 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));
  10612. }
  10613. DataTable dt = new DataTable();
  10614. if (lw.Count > 0)
  10615. {
  10616. sql += string.Join(" , ", lw);
  10617. sql += " FROM ";
  10618. sql += string.Join(" , ", ww);
  10619. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10620. }
  10621. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10622. }
  10623. public void get_center_data_list()
  10624. {
  10625. int userId = CurrentUser.UserID;
  10626. string postCode = CurrentUser.UserPost.Post.Code;
  10627. string shopIds = CurrentUser.User.pemShop;
  10628. DataStruct dStruct = GetPostStruct();
  10629. List<string> lw = new List<string>();
  10630. DateTime currentTime = DateTime.Now;
  10631. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10632. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10633. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10634. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10635. string startTime = "2023-10-01 11:22:31";
  10636. int order_type = GetPostInt("order_type");
  10637. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10638. {
  10639. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10640. if (order_type == 0)
  10641. {
  10642. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10643. }
  10644. else if (order_type == 3)
  10645. {
  10646. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10647. }
  10648. else
  10649. {
  10650. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10651. }
  10652. }
  10653. //客服
  10654. if (postCode == "CustomerService" || postCode == "Director")
  10655. {
  10656. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10657. if (order_type == 0)
  10658. {
  10659. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10660. }
  10661. else if (order_type == 1)
  10662. {
  10663. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10664. }
  10665. else if (order_type == 2)
  10666. {
  10667. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10668. }
  10669. else if (order_type == 3)
  10670. {
  10671. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10672. }
  10673. else if (order_type == 4)
  10674. {
  10675. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10676. }
  10677. else
  10678. {
  10679. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10680. }
  10681. }
  10682. //售后
  10683. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10684. {
  10685. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10686. if (shopIds != "")
  10687. {
  10688. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10689. }
  10690. if (order_type == 2)
  10691. {
  10692. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10693. }
  10694. else if (order_type == 4)
  10695. {
  10696. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10697. }
  10698. else if (order_type == 5)
  10699. {
  10700. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10701. }
  10702. else
  10703. {
  10704. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10705. }
  10706. }
  10707. //下单部
  10708. if (postCode == "Place" || postCode == "PlaceMr")
  10709. {
  10710. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10711. if (shopIds != "")
  10712. {
  10713. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10714. }
  10715. else if (order_type == 1)
  10716. {
  10717. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10718. }
  10719. else if (order_type == 2)
  10720. {
  10721. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10722. }
  10723. else
  10724. {
  10725. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10726. }
  10727. }
  10728. //车间
  10729. if (postCode == "Supplier")
  10730. {
  10731. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10732. if (order_type == 5)
  10733. {
  10734. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10735. }
  10736. else
  10737. {
  10738. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10739. }
  10740. }
  10741. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10742. dStruct.Fileds = "tid,ctid";
  10743. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10744. writeGridDataTableJson(dStruct.TotalCount, dt);
  10745. }
  10746. public void aftersale_audit_master()
  10747. {
  10748. if (UrlPostParmsCheck("ctid"))
  10749. {
  10750. string ctid = GetPostString("ctid");
  10751. if (ctid.Length > 0)
  10752. {
  10753. bool result = aftersale_data_change(ctid);
  10754. if (result)
  10755. {
  10756. returnSuccessMsg("修改成功!");
  10757. return;
  10758. }
  10759. }
  10760. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10761. }
  10762. }
  10763. public void aftersale_batch_audit_master()
  10764. {
  10765. if (UrlPostParmsCheck("ctids"))
  10766. {
  10767. string ctids = GetPostString("ctids");
  10768. if (ctids.Length > 0)
  10769. {
  10770. List<string> list = new List<string>();
  10771. string[] ctid_list = ctids.Split(',');
  10772. foreach (var item in ctid_list)
  10773. {
  10774. bool result = aftersale_data_change(item);
  10775. if (!result)
  10776. {
  10777. list.Add(item);
  10778. }
  10779. }
  10780. if (list.Count > 0)
  10781. {
  10782. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10783. return;
  10784. }
  10785. returnSuccessMsg("修改成功!");
  10786. return;
  10787. }
  10788. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10789. }
  10790. }
  10791. public bool aftersale_data_change(string ctid)
  10792. {
  10793. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10794. if (ceErpTradeCell != null)
  10795. {
  10796. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10797. ceErpTradeCell.AfterSaleSupplierState = 0;
  10798. StringBuilder sql = new StringBuilder();
  10799. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10800. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10801. CeErpTradeResponsible.DelByTid(ctid, 0);
  10802. 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 == "不理赔")
  10803. {
  10804. CeErpTradeResponsible.DelByTid(ctid, 1);
  10805. ceErpTradeCell.AfterSaleSupplierState = 1;
  10806. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10807. ceErpTradeCell.AfterSaleState = 4;
  10808. }
  10809. else
  10810. {
  10811. ceErpTradeCell.AfterSaleState = 3;
  10812. }
  10813. bool needCyt = false;
  10814. if (dt != null)
  10815. {
  10816. if (dt.Rows.Count == 1)
  10817. {
  10818. bool isEnd = false;
  10819. foreach (DataRow dr in dt.Rows)
  10820. {
  10821. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10822. {
  10823. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10824. isEnd = true;
  10825. }
  10826. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10827. {
  10828. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10829. isEnd = true;
  10830. }
  10831. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10832. {
  10833. needCyt = true;
  10834. }
  10835. }
  10836. if (isEnd)
  10837. {
  10838. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10839. ceErpTradeCell.AfterSaleState = 4;
  10840. ceErpTradeCell.AfterSaleSupplierState = 1;
  10841. }
  10842. }
  10843. else
  10844. {
  10845. bool isAll = true;
  10846. foreach (DataRow dr in dt.Rows)
  10847. {
  10848. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10849. {
  10850. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10851. continue;
  10852. }
  10853. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10854. {
  10855. string path = "";
  10856. int OrgID = 0;
  10857. if (!Convert.IsDBNull(dr["OrgPath"]))
  10858. {
  10859. path = dr["OrgPath"].ToString();
  10860. }
  10861. if (!Convert.IsDBNull(dr["OrgID"]))
  10862. {
  10863. OrgID = Convert.ToInt32(dr["OrgID"]);
  10864. }
  10865. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10866. {
  10867. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10868. continue;
  10869. }
  10870. }
  10871. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10872. {
  10873. needCyt = true;
  10874. }
  10875. isAll = false;
  10876. }
  10877. if (isAll)
  10878. {
  10879. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10880. ceErpTradeCell.AfterSaleState = 4;
  10881. ceErpTradeCell.AfterSaleSupplierState = 1;
  10882. }
  10883. }
  10884. }
  10885. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10886. {
  10887. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10888. }
  10889. if (ceErpTradeCell.AfterSaleState == 4)
  10890. {
  10891. ApiVo apiVo = new ApiVo();
  10892. apiVo.orderNumber = ceErpTradeCell.ctid;
  10893. apiVo.actionName = "afterOver";
  10894. designHelper.API_WorkCore(apiVo); //afterOver
  10895. }
  10896. ceErpTradeCell.Update();
  10897. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10898. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10899. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10900. return true;
  10901. }
  10902. return false;
  10903. }
  10904. public void get_erp_wechatorder()
  10905. {
  10906. DataStruct dStruct = GetPostStruct();
  10907. List<string> lw = new List<string>();
  10908. string tid = GetPostString("tid");
  10909. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10910. string shopname = GetPostString("shopname");
  10911. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10912. string buyernick = GetPostString("buyer_nick");
  10913. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10914. string customer = GetPostString("customer");
  10915. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10916. string returndate1 = GetPostString("returndate1");
  10917. string returndate2 = GetPostString("returndate2");
  10918. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10919. if (dw.Length > 0) lw.Add(dw);
  10920. string finishDate1 = GetPostString("finishdate1");
  10921. string finishDate2 = GetPostString("finishdate2");
  10922. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10923. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10924. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10925. dStruct.Order = "created desc";
  10926. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10927. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10928. writeGridDataTableJson(dStruct.TotalCount, dt);
  10929. }
  10930. public void get_erp_wechatlist_sumprice()
  10931. {
  10932. DataStruct dStruct = GetPostStruct();
  10933. List<string> lw = new List<string>();
  10934. string tid = GetPostString("tid");
  10935. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10936. string shopname = GetPostString("shopname");
  10937. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10938. string buyernick = GetPostString("buyer_nick");
  10939. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10940. string customer = GetPostString("customer");
  10941. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10942. string returndate1 = GetPostString("returndate1");
  10943. string returndate2 = GetPostString("returndate2");
  10944. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10945. if (dw.Length > 0) lw.Add(dw);
  10946. string finishDate1 = GetPostString("finishdate1");
  10947. string finishDate2 = GetPostString("finishdate2");
  10948. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10949. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10950. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10951. string mainWhere = string.Join(" and ", lw.ToArray());
  10952. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10953. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10954. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10955. decimal total = 0;
  10956. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10957. {
  10958. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10959. }
  10960. var res = new
  10961. {
  10962. data = total
  10963. };
  10964. string ro_jsond = JsonConvert.SerializeObject(res);
  10965. returnSuccess(ro_jsond);
  10966. return;
  10967. }
  10968. public void get_erp_qr_waitdeliverylist()
  10969. {
  10970. DataStruct dStruct = GetPostStruct();
  10971. List<string> lw = new List<string>();
  10972. string tid = GetPostString("ctid");
  10973. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10974. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10975. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10976. var res_objz = new
  10977. {
  10978. restype = 1,
  10979. data = dt
  10980. };
  10981. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10982. returnSuccess(ro_jsonz);
  10983. }
  10984. public void get_erp_yield_list()
  10985. {
  10986. DataStruct dStruct = GetPostStruct();
  10987. List<string> lw = new List<string>();
  10988. string tid = GetPostString("ctid");
  10989. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10990. string shopname = GetPostString("shopname");
  10991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10992. string buyernick = GetPostString("buyer_nick");
  10993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10994. //if (tid.Length == 0 && buyernick.Length == 0)
  10995. //{
  10996. // lw.Add(string.Format("IsRefund<={0}", 1));
  10997. //}
  10998. string customer = GetPostString("customer");
  10999. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11000. string design = GetPostString("design");
  11001. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11002. string orderState = GetPostString("orderState");
  11003. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11004. string address = GetPostString("address");
  11005. 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));
  11006. string sellermemo = GetPostString("seller_memo");
  11007. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11008. string supplier = GetPostString("supplier");
  11009. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11010. string OrderArea = GetPostString("order_area");
  11011. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11012. string placedate1 = GetPostString("placedate1");
  11013. string placedate2 = GetPostString("placedate2");
  11014. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11015. if (fdw.Length > 0) lw.Add(fdw);
  11016. string price1 = GetPostString("price1");
  11017. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11018. string price2 = GetPostString("price2");
  11019. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11020. string unusualCon = GetPostString("unusualcon");
  11021. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11022. string posTag = CurrentUser.UserPost.Post.Code;
  11023. if (posTag == "Supplier")
  11024. {
  11025. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11026. }
  11027. lw.Add(string.Format("OrderState = 6 "));
  11028. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11029. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11030. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11031. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11032. writeGridDataTableJson(dStruct.TotalCount, dt);
  11033. }
  11034. public void change_erp_sup_state()
  11035. {
  11036. if (UrlPostParmsCheck("ctid"))
  11037. {
  11038. string ctid = GetPostString("ctid");
  11039. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11040. if (ceErpTradeCell != null)
  11041. {
  11042. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11043. if (ceErpTradeCellExtend == null)
  11044. {
  11045. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11046. ceErpTradeCellExtend.ctid = ctid;
  11047. ceErpTradeCellExtend.SupState = 1;
  11048. ceErpTradeCellExtend.Create();
  11049. }
  11050. else
  11051. {
  11052. ceErpTradeCellExtend.SupState = 1;
  11053. ceErpTradeCellExtend.Update();
  11054. }
  11055. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11056. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11057. return;
  11058. }
  11059. returnErrorMsg("找不到订单");
  11060. }
  11061. }
  11062. public void supplier_all_downs()
  11063. {
  11064. if (UrlPostParmsCheck("tids"))
  11065. {
  11066. string tids = GetPostString("tids");
  11067. if (tids != null && tids.Length > 0)
  11068. {
  11069. StringBuilder sql = new StringBuilder();
  11070. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11071. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11072. sql = new StringBuilder();
  11073. 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, "下载设计文件");
  11074. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11075. string[] list = tids.Split(',');
  11076. foreach (string ctid in list)
  11077. {
  11078. CeErpSukuraData.createInfo(ctid, 3);
  11079. }
  11080. designHelper.api_approveDesign(tids); //approveDesign
  11081. returnSuccessMsg("下载成功!");
  11082. return;
  11083. }
  11084. returnErrorMsg("下载订单更新失败");
  11085. }
  11086. }
  11087. public void uploaderFileSuccess()
  11088. {
  11089. if (UrlPostParmsCheck("fileName"))
  11090. {
  11091. string fileName = GetPostString("fileName");
  11092. ApiVo apiVo = new ApiVo();
  11093. apiVo.orderNumber = fileName;
  11094. apiVo.actionName = "finishDesign";
  11095. designHelper.API_WorkCore(apiVo);//finishDesign
  11096. returnSuccessMsg("");
  11097. }
  11098. }
  11099. public void get_sample2_order()
  11100. {
  11101. if (UrlPostParmsCheck("ctid"))
  11102. {
  11103. string ctid = GetPostString("ctid");
  11104. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11105. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11106. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11107. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11108. double total = 0.0;
  11109. double order_price = 0.0;
  11110. if (dt_bu.Rows.Count > 0)
  11111. {
  11112. foreach (DataRow dr in dt_bu.Rows)
  11113. {
  11114. total += Convert.ToDouble(dr["payment"]);
  11115. }
  11116. }
  11117. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11118. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11119. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11120. string tid = ctid.Replace("S_", "");
  11121. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11122. double paymant = 0.0;
  11123. if (entity != null)
  11124. {
  11125. paymant = entity.payment;
  11126. }
  11127. string return_reason = "";
  11128. if (dt_after != null && dt_after.Rows.Count > 0)
  11129. {
  11130. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11131. }
  11132. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11133. }
  11134. }
  11135. public void get_erp_design_status()
  11136. {
  11137. string designName = GetPostString("designName");
  11138. DataStruct dStruct = GetPostStruct();
  11139. if (designName.Length > 0)
  11140. {
  11141. 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";
  11142. sql_user += " and Name like '%" + designName + "%'";
  11143. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11144. List<string> ids_list = new List<string>();
  11145. if (user_table.Rows.Count > 0)
  11146. {
  11147. foreach (DataRow item in user_table.Rows)
  11148. {
  11149. ids_list.Add(item["id"].ToString());
  11150. string ids_s = item["TeamIds"].ToString();
  11151. if (ids_s.Length > 0)
  11152. {
  11153. ids_list.AddRange(ids_s.Split(','));
  11154. }
  11155. }
  11156. }
  11157. HashSet<string> set = new HashSet<string>(ids_list);
  11158. ids_list = set.ToList();
  11159. if (ids_list.Count > 0)
  11160. {
  11161. 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));
  11162. dStruct.MainWhere = sql;
  11163. DataTable dt = null;
  11164. dt = WebCache.GetData("view_ErpUser", dStruct);
  11165. writeGridDataTableJson(dStruct.TotalCount, dt);
  11166. }
  11167. }
  11168. }
  11169. public void change_erp_order_price()
  11170. {
  11171. string ctid = GetPostString("ctid");
  11172. double price = GetPostDouble("price");
  11173. if (ctid.Length > 0)
  11174. {
  11175. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11176. if (ceErpTradeCellExtend == null)
  11177. {
  11178. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11179. ceErpTradeCellExtend.ctid = ctid;
  11180. ceErpTradeCellExtend.payment_cyt = price;
  11181. ceErpTradeCellExtend.Create();
  11182. }
  11183. else
  11184. {
  11185. ceErpTradeCellExtend.payment_cyt = price;
  11186. ceErpTradeCellExtend.Update();
  11187. }
  11188. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11189. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11190. {
  11191. ceErpDataSendOrderInfo.isSync = false;
  11192. ceErpDataSendOrderInfo.Update();
  11193. }
  11194. if (ceErpDataSendOrderInfo == null)
  11195. {
  11196. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11197. ceErpDataSendOrderInfo.isSync = false;
  11198. ceErpDataSendOrderInfo.ctid = ctid;
  11199. ceErpDataSendOrderInfo.Create();
  11200. }
  11201. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11202. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11203. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11204. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11205. {
  11206. dataSendOrderBean dataSendOrderBean = null;
  11207. foreach (DataRow item in dth.Rows)
  11208. {
  11209. try
  11210. {
  11211. dataSendOrderBean = new dataSendOrderBean();
  11212. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11213. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11214. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11215. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11216. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11217. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11218. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11219. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11220. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11221. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11222. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11223. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11224. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11225. if (result != null)
  11226. {
  11227. if ("0".Equals(result.errcode))
  11228. {
  11229. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11230. }
  11231. else
  11232. {
  11233. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11234. }
  11235. }
  11236. }
  11237. catch (Exception ex)
  11238. {
  11239. }
  11240. }
  11241. }
  11242. returnSuccessMsg("修改成功!");
  11243. return;
  11244. }
  11245. returnErrorMsg("找不到订单");
  11246. }
  11247. public void find_he_together()
  11248. {
  11249. string ctid = GetPostString("ctid");
  11250. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11251. List<string> list = new List<string>();
  11252. if (ceErpTradeCell != null)
  11253. {
  11254. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11255. {
  11256. 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);
  11257. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11258. if (table != null && table.Rows.Count > 0)
  11259. {
  11260. foreach (TableRow row in table.Rows)
  11261. {
  11262. }
  11263. }
  11264. }
  11265. }
  11266. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11267. }
  11268. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11269. {
  11270. //chy----19
  11271. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11272. //GD-CYT-----64
  11273. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11274. //ZHX----3
  11275. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11276. //JK----97
  11277. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11278. //ZT----70
  11279. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11280. //LHCY-----98
  11281. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11282. //XD-----90
  11283. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11284. //CYCY-----14
  11285. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11286. };
  11287. //其他改名
  11288. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11289. {
  11290. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11291. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11292. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11293. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11294. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11295. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11296. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11297. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11298. };
  11299. //不统计
  11300. List<int> no_suppliers = new List<int>()
  11301. {
  11302. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11303. };
  11304. //配件单
  11305. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11306. {
  11307. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11308. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11309. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11310. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11311. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11312. {"旗杆",new List<string>(){ "班旗" } },
  11313. {"牙签",new List<string>(){ "不干胶" } }
  11314. };
  11315. public void get_place_order_data()
  11316. {
  11317. string date1 = GetPostString("date1");
  11318. string date2 = GetPostString("date2");
  11319. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11320. DateTime start = DateTime.Parse(starttime);
  11321. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11322. DateTime end = DateTime.Parse(endtime);
  11323. if (date1 != null && date1.Length > 0)
  11324. {
  11325. DateTime dateTime = DateTime.Parse(date1);
  11326. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11327. start = DateTime.Parse(starttime);
  11328. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11329. end = DateTime.Parse(endtime);
  11330. }
  11331. if (date2 != null && date2.Length > 0)
  11332. {
  11333. DateTime dateTime = DateTime.Parse(date2);
  11334. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11335. end = DateTime.Parse(endtime);
  11336. }
  11337. 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);
  11338. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11339. //不干胶-----1,卡片-----29
  11340. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11341. foreach (DataRow row in data.Rows)
  11342. {
  11343. int productId = Convert.ToInt32(row["ProductId"]);
  11344. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11345. if (no_suppliers.Contains(supplierId))
  11346. {
  11347. continue;
  11348. }
  11349. string seller_memo = row["seller_memo"].ToString();
  11350. bool ispj = false;//是否配件单
  11351. bool isfirst = true;//第一个配
  11352. maps.Keys.ForEach(key =>
  11353. {
  11354. //备注包含配件
  11355. if (seller_memo.Contains(key) && isfirst)
  11356. {
  11357. List<string> list = maps[key];
  11358. ispj = true;
  11359. isfirst = false;
  11360. for (int i = 0; i < list.Count; i++)
  11361. {
  11362. if (seller_memo.Contains(list[i]))
  11363. {
  11364. ispj = false;
  11365. break;
  11366. }
  11367. }
  11368. }
  11369. });
  11370. if (ispj)
  11371. {
  11372. continue;
  11373. }
  11374. seller_memo = seller_memo.Replace("UV", "uv");
  11375. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11376. //吊牌归到卡片
  11377. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11378. seller_memo = seller_memo.Replace("卡套", "卡片");
  11379. seller_memo = seller_memo.Replace("封套", "卡片");
  11380. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11381. seller_memo = seller_memo.Replace("腰封", "卡片");
  11382. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11383. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11384. seller_memo = seller_memo.Replace("横幅", "条幅");
  11385. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11386. string map_key = "";
  11387. string type = "";
  11388. if (supplierMap.ContainsKey(supplierId))
  11389. {
  11390. foreach (var kvp in supplierMap[supplierId])
  11391. {
  11392. if (seller_memo.Contains(kvp.Key))
  11393. {
  11394. map_key = kvp.Value;
  11395. type = kvp.Value;
  11396. break;
  11397. }
  11398. }
  11399. }
  11400. if (map_key == "")
  11401. {
  11402. type = "其他";
  11403. map_key = "其他";
  11404. }
  11405. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11406. {
  11407. map_key = suppliers[supplierId];
  11408. }
  11409. if (supplierId == 70)
  11410. {
  11411. supplierId = 70;
  11412. }
  11413. map_key += "_" + row["SupplierName"].ToString();
  11414. Dictionary<string, int> map = null;
  11415. if (other_map.ContainsKey(map_key))
  11416. {
  11417. other_map.TryGetValue(map_key, out map);
  11418. }
  11419. else
  11420. {
  11421. map = new Dictionary<string, int>();
  11422. map.Add("dayDev", 0);//当天出货
  11423. map.Add("dayTotal", 0);//下单总数
  11424. map.Add("payTotal", 0);//500以上
  11425. map.Add("today", 0);//当天出货数量
  11426. map.Add("unusua", 0);//异常数
  11427. other_map.Add(map_key, map);
  11428. other_map.TryGetValue(map_key, out map);
  11429. }
  11430. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11431. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11432. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11433. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11434. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11435. {
  11436. map["dayTotal"]++;
  11437. if (supplierId == 97)
  11438. {
  11439. supplierId = 97;
  11440. }
  11441. }
  11442. if (Convert.ToDecimal(row["payment"]) >= 500)
  11443. {
  11444. map["payTotal"]++;
  11445. }
  11446. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11447. {
  11448. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11449. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11450. {
  11451. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11452. {
  11453. map["today"]++;
  11454. }
  11455. }
  11456. else
  11457. {
  11458. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11459. {
  11460. map["today"]++;
  11461. }
  11462. else
  11463. {
  11464. if (supplierId == 119)
  11465. {
  11466. Debug.WriteLine(row["seller_memo"].ToString());
  11467. }
  11468. }
  11469. }
  11470. }
  11471. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11472. {
  11473. map["unusua"]++;
  11474. }
  11475. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11476. //GD-CYT-----64
  11477. DateTime two = palceTimeStart.AddHours(14);
  11478. DateTime three = palceTimeStart.AddHours(15);
  11479. DateTime four = palceTimeStart.AddHours(16);
  11480. DateTime six = palceTimeStart.AddHours(18);
  11481. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11482. {
  11483. //下午四点前 500-1000
  11484. string count = row["ProductCount"].ToString();
  11485. if (count != null && count.Length > 0)
  11486. {
  11487. int productCount = commonHelper.getPlaceProductCount(count);
  11488. if (productCount >= 500 && productCount <= 1000)
  11489. {
  11490. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11491. {
  11492. map["dayDev"]++;
  11493. }
  11494. }
  11495. }
  11496. }
  11497. //UV
  11498. else if ("uv".Equals(type))
  11499. {
  11500. //ZT----70
  11501. //ZHX----3
  11502. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11503. {
  11504. map["dayDev"]++;
  11505. }
  11506. //JK----97
  11507. //HZX----105
  11508. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11509. {
  11510. map["dayDev"]++;
  11511. }
  11512. }
  11513. //帆布---52|条幅---27
  11514. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11515. {
  11516. //LHCY-----98
  11517. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11518. {
  11519. map["dayDev"]++;
  11520. }
  11521. }
  11522. //条幅
  11523. else if ("条幅".Equals(type))
  11524. {
  11525. //XD-----90
  11526. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11527. {
  11528. map["dayDev"]++;
  11529. }
  11530. }
  11531. //桌布
  11532. else if ("桌布".Equals(type))
  11533. {
  11534. //XD-----90
  11535. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11536. {
  11537. map["dayDev"]++;
  11538. }
  11539. }
  11540. //DL---10
  11541. //AYTW---119
  11542. //FS-CYT-DY ----80
  11543. //JK----97
  11544. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11545. {
  11546. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11547. {
  11548. map["dayDev"]++;
  11549. }
  11550. }
  11551. // QC---121
  11552. else if (supplierId == 121)
  11553. {
  11554. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11555. {
  11556. map["dayDev"]++;
  11557. }
  11558. }
  11559. }
  11560. DataTable dt = new DataTable();
  11561. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11562. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11563. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11564. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11565. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11566. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11567. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11568. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11569. other_map.Keys.ForEach(key =>
  11570. {
  11571. DataRow dr = dt.NewRow();
  11572. Dictionary<string, int> map = other_map[key];
  11573. string[] key_list = key.Split('_');
  11574. dr[0] = key_list[0];
  11575. dr[1] = key_list[1];
  11576. if (key_list.Length > 2)
  11577. {
  11578. dr[1] += "(" + key_list[2] + ")";
  11579. }
  11580. dr[2] = map["dayTotal"];
  11581. dr[3] = map["payTotal"];
  11582. dr[4] = map["today"];
  11583. dr[5] = map["unusua"];
  11584. dr[6] = map["dayDev"];
  11585. double rate = 0.00;
  11586. if (map["dayDev"] > 0)
  11587. {
  11588. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11589. }
  11590. dr[7] = rate.ToString();
  11591. dt.Rows.Add(dr);
  11592. });
  11593. DataView dv = new DataView(dt);
  11594. dv.Sort = "SupplierName";
  11595. //dv.Sort = "AllOrder desc";
  11596. DataTable dtNew = dv.ToTable();
  11597. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11598. }
  11599. public void check_order_desing_info()
  11600. {
  11601. string ctid = GetPostString("ctid");
  11602. if (!string.IsNullOrEmpty(ctid))
  11603. {
  11604. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11605. if (ceErpTradeCell != null)
  11606. {
  11607. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11608. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11609. return;
  11610. }
  11611. returnErrorMsg("找不到订单");
  11612. return;
  11613. }
  11614. returnErrorMsg("找不到订单");
  11615. }
  11616. public void get_timeout_detail()
  11617. {
  11618. string poscode = CurrentUser.UserPost.Post.Code;
  11619. DataStruct dStruct = GetPostStruct();
  11620. List<string> lw = new List<string>();
  11621. string id = GetPostString("id");
  11622. string pay_date1 = GetPostString("pay_date1");
  11623. string pay_date2 = GetPostString("pay_date2");
  11624. int type = GetPostInt("type");
  11625. if (type == 0)
  11626. {
  11627. if (pay_date1.Length > 0)
  11628. {
  11629. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11630. }
  11631. if (pay_date2.Length > 0)
  11632. {
  11633. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11634. }
  11635. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11636. }
  11637. if (type == 1)
  11638. {
  11639. if (pay_date1.Length > 0)
  11640. {
  11641. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11642. }
  11643. if (pay_date2.Length > 0)
  11644. {
  11645. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11646. }
  11647. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11648. }
  11649. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11650. DataTable dt = null;
  11651. dt = WebCache.GetData("view_orderlist", dStruct);
  11652. writeGridDataTableJson(dStruct.TotalCount, dt);
  11653. }
  11654. public void saveUrgentChargePrice()
  11655. {
  11656. string ctid = GetPostString("ctid");
  11657. if (!string.IsNullOrEmpty(ctid))
  11658. {
  11659. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11660. if (ceErpTradeCell != null)
  11661. {
  11662. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11663. if (prices <= 100)
  11664. {
  11665. returnErrorMsg("此订单金额不足100元,无法加急。");
  11666. return;
  11667. }
  11668. double price = GetPostDouble("price");
  11669. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11670. if (ceErpTradeCellExtend == null)
  11671. {
  11672. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11673. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11674. }
  11675. ceErpTradeCellExtend.urgentCharge = price;
  11676. if (ceErpTradeCellExtend.ID > 0)
  11677. {
  11678. ceErpTradeCellExtend.Update();
  11679. }
  11680. else
  11681. {
  11682. ceErpTradeCellExtend.Save();
  11683. }
  11684. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11685. returnSuccessMsg("修改成功!");
  11686. return;
  11687. }
  11688. returnErrorMsg("找不到订单");
  11689. return;
  11690. }
  11691. returnErrorMsg("找不到订单");
  11692. }
  11693. public void finish_erp_order()
  11694. {
  11695. string ctid = GetPostString("ctid");
  11696. if (!string.IsNullOrEmpty(ctid))
  11697. {
  11698. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11699. {
  11700. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11701. if (ceErpTradeCell != null)
  11702. {
  11703. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11704. ceErpTradeCell.Update();
  11705. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11706. returnSuccessMsg("修改成功!");
  11707. return;
  11708. }
  11709. }
  11710. }
  11711. returnErrorMsg("找不到订单");
  11712. }
  11713. public void get_trade_order_list()
  11714. {
  11715. string tid = GetPostString("tid");
  11716. if (!string.IsNullOrEmpty(tid))
  11717. {
  11718. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11719. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11720. writeGridDataTableJson(data.Rows.Count, data);
  11721. return;
  11722. }
  11723. returnErrorMsg("找不到订单");
  11724. }
  11725. public void save_cell_spu()
  11726. {
  11727. string ctid = GetPostString("ctid");
  11728. string spu_id = GetPostString("spu_id");
  11729. if (!string.IsNullOrEmpty(ctid))
  11730. {
  11731. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11732. if (ceErpTradeCellExtend == null)
  11733. {
  11734. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11735. ceErpTradeCellExtend.ctid = ctid;
  11736. }
  11737. ceErpTradeCellExtend.spu_id = spu_id;
  11738. if (!string.IsNullOrEmpty(spu_id))
  11739. {
  11740. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11741. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11742. }
  11743. if (ceErpTradeCellExtend.ID == 0)
  11744. {
  11745. ceErpTradeCellExtend.Create();
  11746. }
  11747. else
  11748. {
  11749. ceErpTradeCellExtend.Update();
  11750. }
  11751. returnSuccessMsg("修改成功!");
  11752. return;
  11753. }
  11754. returnErrorMsg("找不到订单");
  11755. }
  11756. public void change_express_info()
  11757. {
  11758. string ctid = GetPostString("ctid");
  11759. string transNo = GetPostString("transNo");
  11760. string transCom = GetPostString("transCom");
  11761. if (!string.IsNullOrEmpty(ctid))
  11762. {
  11763. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11764. if (ceErpTradeCellExtend == null)
  11765. {
  11766. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11767. ceErpTradeCellExtend.ctid = ctid;
  11768. }
  11769. ceErpTradeCellExtend.modExpressNo = transNo;
  11770. ceErpTradeCellExtend.modExpressCom = transCom;
  11771. ceErpTradeCellExtend.readMod = 2;
  11772. if (ceErpTradeCellExtend.ID == 0)
  11773. {
  11774. ceErpTradeCellExtend.Create();
  11775. }
  11776. else
  11777. {
  11778. ceErpTradeCellExtend.Update();
  11779. }
  11780. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11781. returnSuccessMsg("修改成功!");
  11782. return;
  11783. }
  11784. returnErrorMsg("找不到订单");
  11785. }
  11786. public void get_change_express_list()
  11787. {
  11788. DataStruct dStruct = GetPostStruct();
  11789. List<string> lw = new List<string>();
  11790. int st = 2;
  11791. string tid = GetPostString("ctid");
  11792. if (tid.Length > 0)
  11793. {
  11794. string select_tid = getTidByCtid(tid);
  11795. lw.Add(string.Format("tid='{0}'", select_tid));
  11796. }
  11797. string shopname = GetPostString("shopname");
  11798. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11799. string buyernick = GetPostString("buyer_nick");
  11800. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11801. string sellermemo = GetPostString("seller_memo");
  11802. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11803. string supplier = GetPostString("supplier");
  11804. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11805. string customer = GetPostString("customer");
  11806. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11807. string design = GetPostString("design");
  11808. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11809. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11810. string poscode = CurrentUser.UserPost.Post.Code;
  11811. if (poscode != "SysAdmin")
  11812. {
  11813. string shopid = CurrentUser.User.pemShop;
  11814. lw.Add(string.Format("shopId in ({0})", shopid));
  11815. }
  11816. lw.Add("readMod = 2");
  11817. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11818. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11819. writeGridDataTableJson(dStruct.TotalCount, dt);
  11820. }
  11821. public void deal_express_complete()
  11822. {
  11823. string ctid = GetPostString("ctid");
  11824. if (!string.IsNullOrEmpty(ctid))
  11825. {
  11826. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11827. if (ceErpTradeCellExtend == null)
  11828. {
  11829. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11830. ceErpTradeCellExtend.ctid = ctid;
  11831. }
  11832. ceErpTradeCellExtend.readMod = 1;
  11833. if (ceErpTradeCellExtend.ID == 0)
  11834. {
  11835. ceErpTradeCellExtend.Create();
  11836. }
  11837. else
  11838. {
  11839. ceErpTradeCellExtend.Update();
  11840. }
  11841. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11842. returnSuccessMsg("修改成功!");
  11843. return;
  11844. }
  11845. returnErrorMsg("找不到订单");
  11846. }
  11847. public void aftersale_return_visit()
  11848. {
  11849. string ctid = GetPostString("ctid");
  11850. if (!string.IsNullOrEmpty(ctid))
  11851. {
  11852. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11853. if (ceErpTradeCellExtend == null)
  11854. {
  11855. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11856. ceErpTradeCellExtend.ctid = ctid;
  11857. }
  11858. ceErpTradeCellExtend.returnVisit = 1;
  11859. if (ceErpTradeCellExtend.ID == 0)
  11860. {
  11861. ceErpTradeCellExtend.Create();
  11862. }
  11863. else
  11864. {
  11865. ceErpTradeCellExtend.Update();
  11866. }
  11867. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11868. if (ceErpTradeAfterSaleExtend != null)
  11869. {
  11870. ceErpTradeAfterSaleExtend.TextResult = "";
  11871. ceErpTradeAfterSaleExtend.Update();
  11872. }
  11873. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11874. returnSuccessMsg("修改成功!");
  11875. return;
  11876. }
  11877. returnErrorMsg("找不到订单");
  11878. }
  11879. public void orderPlaceInfo()
  11880. {
  11881. string ctids = GetPostString("ctids");
  11882. string[] list = ctids.Split(',');
  11883. foreach (string ctid in list)
  11884. {
  11885. CeErpSukuraData.createInfo(ctid, 3);
  11886. }
  11887. StringBuilder sql = new StringBuilder();
  11888. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11889. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11890. designHelper.api_approveDesign(ctids); //approveDesign
  11891. returnSuccessMsg("");
  11892. }
  11893. public void get_issue_list()
  11894. {
  11895. DataStruct dStruct = GetPostStruct();
  11896. List<string> lw = new List<string>();
  11897. int st = 2;
  11898. string tid = GetPostString("ctid");
  11899. if (tid.Length > 0)
  11900. {
  11901. string select_tid = getTidByCtid(tid);
  11902. lw.Add(string.Format("tid='{0}'", select_tid));
  11903. }
  11904. string shopname = GetPostString("shopname");
  11905. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11906. string buyernick = GetPostString("buyer_nick");
  11907. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11908. string sellermemo = GetPostString("seller_memo");
  11909. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11910. string supplier = GetPostString("supplier");
  11911. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11912. string customer = GetPostString("customer");
  11913. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11914. string design = GetPostString("design");
  11915. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11916. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11917. string poscode = CurrentUser.UserPost.Post.Code;
  11918. if (poscode != "SysAdmin")
  11919. {
  11920. string shopid = CurrentUser.User.pemShop;
  11921. lw.Add(string.Format("shopId in ({0})", shopid));
  11922. }
  11923. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11924. {
  11925. lw.Add("IssueState = 1");
  11926. }
  11927. lw.Add("IssueState > 0");
  11928. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11929. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11930. writeGridDataTableJson(dStruct.TotalCount, dt);
  11931. }
  11932. public void saveIssueContent()
  11933. {
  11934. string ctid = GetPostString("ctid");
  11935. if (!string.IsNullOrEmpty(ctid))
  11936. {
  11937. string content = GetPostString("content");
  11938. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11939. if (ceErpTradeAfterSaleExtend == null)
  11940. {
  11941. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11942. ceErpTradeAfterSaleExtend.tid = ctid;
  11943. }
  11944. ceErpTradeAfterSaleExtend.IssueContent = content;
  11945. ceErpTradeAfterSaleExtend.IssueState = 1;
  11946. if (ceErpTradeAfterSaleExtend.ID > 0)
  11947. {
  11948. ceErpTradeAfterSaleExtend.Update();
  11949. }
  11950. else
  11951. {
  11952. ceErpTradeAfterSaleExtend.Create();
  11953. }
  11954. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11955. returnSuccessMsg("添加成功!");
  11956. return;
  11957. }
  11958. returnErrorMsg("找不到订单");
  11959. }
  11960. public void dealIssueContent()
  11961. {
  11962. string ctid = GetPostString("ctid");
  11963. if (!string.IsNullOrEmpty(ctid))
  11964. {
  11965. string content = GetPostString("content");
  11966. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11967. if (ceErpTradeAfterSaleExtend != null)
  11968. {
  11969. ceErpTradeAfterSaleExtend.IssueState = 2;
  11970. ceErpTradeAfterSaleExtend.Update();
  11971. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11972. returnSuccessMsg("修改完成!");
  11973. return;
  11974. }
  11975. }
  11976. returnErrorMsg("找不到订单");
  11977. }
  11978. public void set_tid_attachments()
  11979. {
  11980. string tid = GetPostString("tid");
  11981. string atta = GetPostString("atta");
  11982. if (!string.IsNullOrEmpty(tid))
  11983. {
  11984. if (string.IsNullOrEmpty(atta))
  11985. {
  11986. returnErrorMsg("文件地址为空");
  11987. return;
  11988. }
  11989. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11990. if (ceErpTradeCell != null)
  11991. {
  11992. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11993. if (ceErpTrade == null)
  11994. {
  11995. returnErrorMsg("找不到订单");
  11996. return;
  11997. }
  11998. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11999. bool isSend = false;
  12000. if (dt != null && dt.Rows.Count > 0)
  12001. {
  12002. foreach (DataRow row in dt.Rows)
  12003. {
  12004. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12005. {
  12006. isSend = true;
  12007. }
  12008. }
  12009. if (isSend)
  12010. {
  12011. returnErrorMsg("已发货无法修改");
  12012. return;
  12013. }
  12014. ceErpTrade.Attachments = atta;
  12015. ceErpTrade.Update();
  12016. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12017. returnSuccessMsg("上传成功!");
  12018. return;
  12019. }
  12020. }
  12021. }
  12022. returnErrorMsg("找不到订单");
  12023. }
  12024. public void get_tid_attachments()
  12025. {
  12026. string tid = GetPostString("tid");
  12027. if (!string.IsNullOrEmpty(tid))
  12028. {
  12029. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12030. if (ceErpTradeCell != null)
  12031. {
  12032. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12033. if (ceErpTrade == null)
  12034. {
  12035. returnErrorMsg("找不到订单");
  12036. return;
  12037. }
  12038. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12039. return;
  12040. }
  12041. }
  12042. returnErrorMsg("找不到订单");
  12043. }
  12044. public void check_erp_sameorders()
  12045. {
  12046. if (UrlPostParmsCheck("ctid"))
  12047. {
  12048. string eid = GetPostString("ctid");
  12049. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12050. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12051. if (entity != null && ceErpTrade != null)
  12052. {
  12053. if (entity.OrderState > 6)
  12054. {
  12055. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12056. return;
  12057. }
  12058. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12059. List<string> ids = new List<string>();
  12060. if (dt != null && dt.Rows.Count > 1)
  12061. {
  12062. bool needhe = true;
  12063. foreach (DataRow dr in dt.Rows)
  12064. {
  12065. ids.Add("'" + dr["ctid"] + "'");
  12066. /* //备注有合包
  12067. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12068. {
  12069. needhe = true;
  12070. }
  12071. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12072. {
  12073. needhe = true;
  12074. }
  12075. //顺丰快递
  12076. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12077. {
  12078. needhe = true;
  12079. }*/
  12080. }
  12081. if (!needhe)
  12082. {
  12083. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12084. return;
  12085. }
  12086. StringBuilder sql = new StringBuilder();
  12087. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12088. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12089. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12090. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12091. foreach (DataRow dr in dt.Rows)
  12092. {
  12093. dr["dstate"] = 0;
  12094. dr["dnumber"] = 0;
  12095. foreach (DataRow row in dt1.Rows)
  12096. {
  12097. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12098. {
  12099. dr["dstate"] = 2;
  12100. dr["default"] = 1;
  12101. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12102. }
  12103. }
  12104. if (eid.Equals(dr["ctid"].ToString()))
  12105. {
  12106. dr["dstate"] = 1;
  12107. dr["default"] = 1;
  12108. }
  12109. }
  12110. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12111. return;
  12112. }
  12113. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12114. return;
  12115. }
  12116. returnErrorMsg("未找到订单");
  12117. return;
  12118. }
  12119. returnErrorMsg("缺少必要的参数");
  12120. }
  12121. public void get_mark_number()
  12122. {
  12123. string eid = GetPostString("ctid");
  12124. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12125. if (entity != null)
  12126. {
  12127. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12128. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12129. int current = 1;
  12130. if (ceErpDeliverMark == null)
  12131. {
  12132. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12133. List<string> ids = new List<string>();
  12134. if (dt != null && dt.Rows.Count > 1)
  12135. {
  12136. foreach (DataRow dr in dt.Rows)
  12137. {
  12138. ids.Add("'" + dr["ctid"] + "'");
  12139. }
  12140. //查询已有的编号
  12141. StringBuilder sql = new StringBuilder();
  12142. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12143. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12144. if (dt1 == null || dt1.Rows.Count == 0)
  12145. {
  12146. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12147. List<int> list_number = new List<int>();
  12148. foreach (DataRow row in numbers.Rows)
  12149. {
  12150. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12151. }
  12152. //查询空余编号
  12153. for (int i = 0; i < list_number.Count + 2; i++)
  12154. {
  12155. if (!list_number.Contains(current))
  12156. {
  12157. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12158. //防止查询过程中有新数据生成
  12159. if (ceErpDeliverMark1 == null)
  12160. {
  12161. break;
  12162. }
  12163. }
  12164. current++;
  12165. }
  12166. }
  12167. else
  12168. {
  12169. foreach (DataRow row in dt1.Rows)
  12170. {
  12171. current = Convert.ToInt32(row["markNumber"]);
  12172. }
  12173. }
  12174. ceErpDeliverMark = new CeErpDeliverMark();
  12175. ceErpDeliverMark.ctid = eid;
  12176. ceErpDeliverMark.createtime = DateTime.Now;
  12177. if (ceErpTrade != null)
  12178. {
  12179. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12180. }
  12181. ceErpDeliverMark.markNumber = current;
  12182. ceErpDeliverMark.Create();
  12183. }
  12184. }
  12185. else
  12186. {
  12187. current = ceErpDeliverMark.markNumber;
  12188. }
  12189. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12190. return;
  12191. }
  12192. }
  12193. public void aftersaleCytSend()
  12194. {
  12195. string ctid = GetPostString("ctid");
  12196. if (!string.IsNullOrEmpty(ctid))
  12197. {
  12198. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12199. if (ceErpTradeCell != null)
  12200. {
  12201. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12202. }
  12203. returnSuccessMsg("推送成功");
  12204. return;
  12205. }
  12206. returnErrorMsg("缺少必要的参数");
  12207. }
  12208. public void packOrderInfo()
  12209. {
  12210. string ctids = GetPostString("ctids");
  12211. if (!string.IsNullOrEmpty(ctids))
  12212. {
  12213. string[] ctid_list = ctids.Split(',');
  12214. if (ctid_list.Length > 20)
  12215. {
  12216. returnErrorMsg("单次下载次数不能超过20个");
  12217. return;
  12218. }
  12219. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12220. StringBuilder sql = new StringBuilder();
  12221. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12222. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12223. int supplierId = 0;
  12224. StringBuilder insterSql = new StringBuilder();
  12225. for (int i = 0; i < dt.Rows.Count; i++)
  12226. {
  12227. DataRow row = dt.Rows[i];
  12228. if (i == 0)
  12229. {
  12230. supplierId = Convert.ToInt32(row["SupplierId"]);
  12231. }
  12232. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12233. {
  12234. returnErrorMsg("同车间的订单才能一起打包");
  12235. return;
  12236. }
  12237. int orderState = Convert.ToInt32(row["OrderState"]);
  12238. if (orderState != 5)
  12239. {
  12240. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12241. return;
  12242. }
  12243. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12244. }
  12245. CeErpPackData ceErpPackData = new CeErpPackData();
  12246. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12247. ceErpPackData.supplierId = supplierId;
  12248. ceErpPackData.createtime = DateTime.Now;
  12249. ceErpPackData.createBy = CurrentUser.UserID;
  12250. ceErpPackData.createName = CurrentUser.UserName;
  12251. ceErpPackData.Create();
  12252. if (ceErpPackData.ID > 0)
  12253. {
  12254. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12255. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12256. }
  12257. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12258. returnSuccessMsg("打包成功");
  12259. return;
  12260. }
  12261. returnErrorMsg("缺少必要的参数");
  12262. }
  12263. public void rePackOrderInfo()
  12264. {
  12265. string id = GetPostString("id");
  12266. if (!string.IsNullOrEmpty(id))
  12267. {
  12268. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12269. if (ceErpPackData == null)
  12270. {
  12271. returnSuccessMsg("查无数据");
  12272. return;
  12273. }
  12274. ceErpPackData.upStatus = 0;
  12275. ceErpPackData.message = "";
  12276. ceErpPackData.Update();
  12277. returnSuccessMsg("打包成功");
  12278. return;
  12279. }
  12280. returnErrorMsg("缺少必要的参数");
  12281. }
  12282. public void backPackOrderInfo()
  12283. {
  12284. string id = GetPostString("id");
  12285. if (!string.IsNullOrEmpty(id))
  12286. {
  12287. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12288. if (ceErpPackData == null)
  12289. {
  12290. returnSuccessMsg("查无数据");
  12291. return;
  12292. }
  12293. ceErpPackData.upStatus = 4;
  12294. ceErpPackData.Update();
  12295. List<string> list = new List<string>();
  12296. StringBuilder sql = new StringBuilder();
  12297. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12298. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12299. for (int i = 0; i < dt.Rows.Count; i++)
  12300. {
  12301. DataRow row = dt.Rows[i];
  12302. list.Add("'" + row["ctid"].ToString() + "'");
  12303. }
  12304. string textCtids = string.Join(",", list);
  12305. 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));
  12306. 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, "无法打包退回"));
  12307. returnSuccessMsg("退回成功");
  12308. return;
  12309. }
  12310. returnErrorMsg("缺少必要的参数");
  12311. }
  12312. public void addPackDownNum()
  12313. {
  12314. string id = GetPostString("id");
  12315. if (!string.IsNullOrEmpty(id))
  12316. {
  12317. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12318. returnSuccessMsg("下载成功");
  12319. return;
  12320. }
  12321. returnErrorMsg("缺少必要的参数");
  12322. }
  12323. public void get_pack_list()
  12324. {
  12325. DataStruct dStruct = GetPostStruct();
  12326. List<string> lw = new List<string>();
  12327. string supplier = GetPostString("supplier");
  12328. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12329. string posTag = CurrentUser.UserPost.Post.Code;
  12330. if (posTag == "Supplier")
  12331. {
  12332. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12333. }
  12334. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12335. dStruct.Order = "createtime desc";
  12336. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12337. writeGridDataTableJson(dStruct.TotalCount, dt);
  12338. }
  12339. public void get_pack_order_list()
  12340. {
  12341. string packId = GetPostString("packId");
  12342. if (string.IsNullOrEmpty(packId))
  12343. {
  12344. returnErrorMsg("缺少必要的参数");
  12345. return;
  12346. }
  12347. StringBuilder sql = new StringBuilder();
  12348. 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);
  12349. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12350. if (dt == null || dt.Rows.Count == 0)
  12351. {
  12352. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12353. return;
  12354. }
  12355. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12356. return;
  12357. }
  12358. public void get_supplier_product_time_list()
  12359. {
  12360. DataStruct dStruct = GetPostStruct();
  12361. List<string> lw = new List<string>();
  12362. string supplier = GetPostString("supplier");
  12363. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12364. string posTag = CurrentUser.UserPost.Post.Code;
  12365. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12366. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12367. writeGridDataTableJson(dStruct.TotalCount, dt);
  12368. }
  12369. public void saveSupplierProductTime()
  12370. {
  12371. string productId = GetPostString("productId");
  12372. if (string.IsNullOrEmpty(productId))
  12373. {
  12374. returnErrorMsg("缺少必要的参数");
  12375. return;
  12376. }
  12377. string productName = GetPostString("productName");
  12378. int supplierId = GetPostInt("supplierId");
  12379. if (supplierId == 0)
  12380. {
  12381. returnErrorMsg("缺少必要的参数");
  12382. return;
  12383. }
  12384. int quantity = GetPostInt("quantity");
  12385. int sendDay = GetPostInt("sendTime");
  12386. string supplierName = GetPostString("supplierName");
  12387. string craft = GetPostString("craft");
  12388. string deadLine = GetPostString("deadLine");
  12389. string dayDeadLine = GetPostString("dayDeadLine");
  12390. try
  12391. {
  12392. int eid = GetPostInt("eid");
  12393. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12394. if (ceErpSupplierProductTime == null)
  12395. {
  12396. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12397. }
  12398. ceErpSupplierProductTime.productId = productId;
  12399. ceErpSupplierProductTime.productName = productName;
  12400. ceErpSupplierProductTime.supplierId = supplierId;
  12401. ceErpSupplierProductTime.supplierName = supplierName;
  12402. ceErpSupplierProductTime.craft = craft;
  12403. ceErpSupplierProductTime.sendDay = sendDay;
  12404. ceErpSupplierProductTime.quantity = quantity;
  12405. if (!string.IsNullOrEmpty(deadLine))
  12406. {
  12407. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12408. }
  12409. if (!string.IsNullOrEmpty(dayDeadLine))
  12410. {
  12411. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12412. }
  12413. if (ceErpSupplierProductTime.ID == 0)
  12414. {
  12415. ceErpSupplierProductTime.Save();
  12416. }
  12417. else
  12418. {
  12419. ceErpSupplierProductTime.Update();
  12420. }
  12421. }
  12422. catch (Exception e)
  12423. {
  12424. }
  12425. returnSuccessMsg("保存成功");
  12426. return;
  12427. }
  12428. public void delSupplierProductTime()
  12429. {
  12430. int eid = GetPostInt("eid");
  12431. if (eid > 0)
  12432. {
  12433. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12434. if (ceErpSupplierProductTime == null)
  12435. {
  12436. returnErrorMsg("查无数据");
  12437. return;
  12438. }
  12439. ceErpSupplierProductTime.Delete();
  12440. returnSuccessMsg("保存成功");
  12441. return;
  12442. }
  12443. returnErrorMsg("缺少必要的参数");
  12444. }
  12445. public void getExpressInfo()
  12446. {
  12447. string ctid = GetPostString("ctid");
  12448. if (!string.IsNullOrEmpty(ctid))
  12449. {
  12450. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12451. if (ceErpTradeCell != null)
  12452. {
  12453. string outSid = ceErpTradeCell.OutSid;
  12454. if (outSid.Length > 0)
  12455. {
  12456. 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);
  12457. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12458. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12459. return;
  12460. }
  12461. }
  12462. returnErrorMsg("查无记录");
  12463. return;
  12464. }
  12465. returnErrorMsg("缺少必要的参数");
  12466. }
  12467. public void getExpressPostData()
  12468. {
  12469. string express = GetPostString("express");
  12470. if (!string.IsNullOrEmpty(express))
  12471. {
  12472. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12473. if (ceErpExpressInfo != null)
  12474. {
  12475. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12476. return;
  12477. }
  12478. }
  12479. returnErrorMsg("缺少必要的参数");
  12480. }
  12481. public void checkSupplierOrder()
  12482. {
  12483. string ctids = GetPostString("ctids");
  12484. if (ctids != null)
  12485. {
  12486. List<string> list = new List<string>();
  12487. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12488. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12489. for (int i = 0; i < dt.Rows.Count; i++)
  12490. {
  12491. DataRow row = dt.Rows[i];
  12492. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12493. {
  12494. continue;
  12495. }
  12496. list.Add(row["seller_memo"].ToString());
  12497. }
  12498. if (list.Count > 0)
  12499. {
  12500. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12501. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12502. return;
  12503. }
  12504. }
  12505. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12506. return;
  12507. }
  12508. public void addPersonId()
  12509. {
  12510. string tid = GetPostString("tid");
  12511. string personId = GetPostString("personId");
  12512. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12513. if (ceErpTrade != null)
  12514. {
  12515. ceErpTrade.receiver_zip = personId;
  12516. ceErpTrade.Update();
  12517. returnSuccessMsg("保存成功");
  12518. return;
  12519. }
  12520. returnErrorMsg("缺少必要的参数");
  12521. }
  12522. }
  12523. }