sync.order.cs 638 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. namespace SiteCore.Handler
  49. {
  50. public partial class sync
  51. {
  52. public void get_erp_orderlist()
  53. {
  54. string poscode = CurrentUser.UserPost.Post.Code;
  55. DataStruct dStruct = GetPostStruct();
  56. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\透卡澜达海报售价(1).xls");
  57. //apiHelper.Api_SyncOrderByTime("598825");
  58. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  59. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  60. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  61. //banniuApiHelper.sendLogisticsInfo(null);
  62. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  63. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  64. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  65. //int sid = commonHelper.autoDistributeToSupplier(entity);
  66. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  67. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1747793700000,\"deliveryType\":\"OFFLINE\",\"discountFee\":15.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1748015999000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":85.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2200806677467/O1CN01aEDI6s251wFlRwWHL_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4348532702415998633\",\"refSkuId\":\"0\",\"refSpuId\":\"620901028368\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":42.5,\"singleFee\":42.5,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【狂欢价】水晶标贴金属标签LOGO贴纸定制车热uv转印贴透明商标打印设备移丝印广告自粘刻字烫金定做公司防水不干胶印刷\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1747794079000,\"openBuyerId\":\"AAEmRHraABkUZRPgSx1NTPcZ\",\"openBuyerNick\":\"排**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1747793522000,\"payTime\":1747793695000,\"payment\":85.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"梅州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"梅江区\",\"receiverId\":\"c01bdfe140ea76155b427e6b00424547$\",\"receiverState\":\"广东省\",\"receiverTown\":\"三角镇\",\"refOid\":\"4348532702415998633\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"34.5x25.5mm-210个-UV转印贴-彩色-模切-排排坐唱山歌歌-小钰-()-老客户改稿\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0,\"type\":\"SALE\"}}");
  68. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  69. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  70. //commonHelper.loginGetOrder(2152);
  71. List<string> lw = new List<string>();
  72. string tid = GetPostString("ctid");
  73. string date1 = GetPostString("date1");
  74. //12-1 修改
  75. string urgent = GetPostString("urgent");
  76. string back = GetPostString("back");
  77. string offlineSearch = GetPostString("offlineSearch");
  78. int paramsCount = 0;
  79. if (!string.IsNullOrWhiteSpace(urgent))
  80. {
  81. if (urgent.Equals("true"))
  82. {
  83. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  84. }
  85. }
  86. if (!string.IsNullOrWhiteSpace(back))
  87. {
  88. if (back.Equals("true"))
  89. {
  90. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  91. }
  92. }
  93. if (!string.IsNullOrWhiteSpace(offlineSearch))
  94. {
  95. if (offlineSearch.Equals("true"))
  96. {
  97. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  98. }
  99. }
  100. //end
  101. string date2 = GetPostString("date2");
  102. string buyernick = GetPostString("buyer_nick");
  103. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  104. {
  105. if (tid.Length <= 0 && buyernick.Length <= 0)
  106. {
  107. return;
  108. }
  109. }
  110. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  111. {
  112. if (tid.Length > 0)
  113. {
  114. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  115. if (ceErpTradeCell != null)
  116. {
  117. tid = ceErpTradeCell.tid;
  118. }
  119. List<string> select_tid = getTidByCtidMore(tid);
  120. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  121. }
  122. if (buyernick.Length > 0)
  123. {
  124. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  125. }
  126. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  127. if (dw.Length > 0)
  128. {
  129. lw.Add(dw);
  130. }
  131. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  132. {
  133. string usershop = CurrentUser.User.pemShop;
  134. lw.Add(string.Format("ShopId in ({0})", usershop));
  135. }
  136. }
  137. else
  138. {
  139. if (ex_psize == 0)
  140. {
  141. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  142. }
  143. if (PKey != "admin")
  144. {
  145. string usershop = CurrentUser.User.pemShop;
  146. lw.Add(string.Format("ShopId in ({0})", usershop));
  147. paramsCount++;
  148. }
  149. }
  150. string uploaddate1 = GetPostString("uploaddate1");
  151. string uploaddate2 = GetPostString("uploaddate2");
  152. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  153. if (update.Length > 0) lw.Add(update);
  154. string deliverydate1 = GetPostString("deliverydate1");
  155. string deliverydate2 = GetPostString("deliverydate2");
  156. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  157. if (deliverydate.Length > 0)
  158. {
  159. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  160. };
  161. string shopname = GetPostString("shopname");
  162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  163. string addwechat = GetPostString("addwechat");
  164. if (addwechat.Length > 0)
  165. {
  166. int addWt = Convert.ToInt32(addwechat);
  167. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  168. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  169. }
  170. string customer = GetPostString("customer");
  171. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  172. string design = GetPostString("design");
  173. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  174. string orderState = GetPostString("orderState");
  175. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  176. string address = GetPostString("address");
  177. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  178. string sellermemo = GetPostString("seller_memo");
  179. if (sellermemo.Length > 0)
  180. {
  181. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  182. }
  183. string backReason = GetPostString("backReason");
  184. if (backReason.Length > 0)
  185. {
  186. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  187. }
  188. string apdate1 = GetPostString("apdate1");
  189. string apdate2 = GetPostString("apdate2");
  190. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  191. if (dwap.Length > 0) lw.Add(dwap);
  192. string price1 = GetPostString("price1");
  193. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  194. string price2 = GetPostString("price2");
  195. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  196. string isoldcustomer = GetPostString("isoldcus");
  197. string spudata = GetPostString("spudata");
  198. if ("0".Equals(spudata))
  199. {
  200. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  201. }
  202. if ("1".Equals(spudata))
  203. {
  204. lw.Add(string.Format("spu_id <> ''"));
  205. }
  206. string finishdate1 = GetPostString("finishdate1");
  207. string finishdate2 = GetPostString("finishdate2");
  208. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  209. bool isFinish = false;
  210. if (finishdate.Length > 0)
  211. {
  212. lw.Add(finishdate);
  213. isFinish = true;
  214. paramsCount++;
  215. }
  216. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  217. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  218. if (ex_psize > 0)
  219. {
  220. int UserID = CurrentUser.UserID;
  221. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  222. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  223. {
  224. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  225. }
  226. dStruct.Order = "pay_time desc";
  227. }
  228. string isNew = GetPostString("isNew");
  229. if (isNew == "true")
  230. {
  231. lw.Add(string.Format("IsNew = {0}", 1));
  232. }
  233. string overtime = GetPostString("overtime");
  234. if (overtime == "1")
  235. {
  236. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  237. }
  238. String usePost = CurrentUser.UserPost.Post.Code;
  239. if (usePost.Equals("Operation") == true)
  240. {
  241. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  242. }
  243. else
  244. {
  245. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  246. }
  247. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  248. if (dStruct.PageSize == 100000)
  249. {
  250. dStruct.Order = "";
  251. }
  252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  253. DataTable dt = null;
  254. string tablename = "view_orderlist";
  255. if (isFinish)
  256. {
  257. tablename = "view_orderlist_end";
  258. }
  259. dt = WebCache.GetData(tablename, dStruct);
  260. if (dt != null && dt.Rows.Count > 0)
  261. {
  262. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  263. foreach (DataRow dr in dt.Rows)
  264. {
  265. try
  266. {
  267. if (dr["refund_fees"] != null)
  268. {
  269. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  270. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  271. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  272. if (payment == refund_fees)
  273. {
  274. dr["refund_fees"] = Math.Round(refund_fees, 2);
  275. }
  276. else if (refund_fees == total_fee)
  277. {
  278. dr["refund_fees"] = payment;
  279. }
  280. else
  281. {
  282. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  283. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  284. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  285. }
  286. }
  287. // 对象操作
  288. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  289. ceErpTradeCell.ctid = dr["ctid"].ToString();
  290. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  291. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  292. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  293. if (dStruct.PageSize != 100000)
  294. {
  295. if (dr["DispatchSort"].ToString() == "2")
  296. {
  297. dr["gongchuang"] = 200;
  298. }
  299. else if ("外协".Equals(dr["ToType"].ToString()))
  300. {
  301. dr["gongchuang"] = 200;
  302. }
  303. else if ("内部".Equals(dr["ToType"].ToString()))
  304. {
  305. dr["gongchuang"] = -1;
  306. }
  307. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  308. {
  309. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  310. dr["gongchuang"] = response.code;
  311. }
  312. }
  313. }
  314. catch (NullReferenceException ex)
  315. {
  316. // 处理空引用异常
  317. dr["refund_fees"] = "0.00";
  318. }
  319. }
  320. }
  321. writeGridDataTableJson(dStruct.TotalCount, dt);
  322. }
  323. public void get_erp_orderlist_sumprice()
  324. {
  325. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  326. return;
  327. List<string> lw = new List<string>();
  328. string tid = GetPostString("ctid");
  329. string date1 = GetPostString("date1");
  330. string date2 = GetPostString("date2");
  331. if (tid.Length > 0 || date1.Length > 0)
  332. {
  333. lw.Add(string.Format("ctid like '%{0}%'", tid));
  334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  335. if (dw.Length > 0) lw.Add(dw);
  336. }
  337. else
  338. {
  339. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  340. }
  341. string shopname = GetPostString("shopname");
  342. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  343. string buyernick = GetPostString("buyer_nick");
  344. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  345. string customer = GetPostString("customer");
  346. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  347. string design = GetPostString("design");
  348. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  349. string orderState = GetPostString("orderState");
  350. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  351. string address = GetPostString("address");
  352. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  353. string sellermemo = GetPostString("seller_memo");
  354. if (sellermemo.Length > 0)
  355. {
  356. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  357. }
  358. string apdate1 = GetPostString("apdate1");
  359. string apdate2 = GetPostString("apdate2");
  360. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  361. if (dwap.Length > 0) lw.Add(dwap);
  362. string price1 = GetPostString("price1");
  363. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  364. string price2 = GetPostString("price2");
  365. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  366. string isoldcustomer = GetPostString("isoldcus");
  367. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  368. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  369. if (PKey != "admin")
  370. {
  371. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  372. lw.Add(string.Format("shopId in ({0})", usershop));
  373. }
  374. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  375. string mainWhere = string.Join(" and ", lw.ToArray());
  376. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  377. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  378. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  379. decimal total = 0;
  380. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  381. {
  382. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  383. }
  384. var res = new
  385. {
  386. data = total
  387. };
  388. string ro_jsond = JsonConvert.SerializeObject(res);
  389. returnSuccess(ro_jsond);
  390. return;
  391. }
  392. public void get_erp_CustomerServiceGather()
  393. {
  394. string userWhere = "", orderWhere = "";
  395. List<string> lw = new List<string>();
  396. string customer = GetPostString("customer");
  397. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  398. string shopname = GetPostString("shopname");
  399. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  400. string date1 = GetPostString("date1");
  401. string date2 = GetPostString("date2");
  402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  403. if (dw.Length > 0) lw.Add(dw);
  404. orderWhere = string.Join(" and ", lw.ToArray());
  405. string sql = string.Format("select a.Name CusName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitRelease,0) WaitRelease, isnull(e.WaitRob,0) WaitRob, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  406. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  407. "left join " +
  408. "( " +
  409. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  410. ") as b on a.ID = b.CustomerUserId " +
  411. "left join " +
  412. "( " +
  413. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  414. ") as d on a.ID = d.CustomerUserId " +
  415. "left join " +
  416. "( " +
  417. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  418. ") as e on a.ID = e.CustomerUserId " +
  419. "left join " +
  420. "( " +
  421. " select CustomerUserId, RefundCount, RefundSum from " +
  422. " ( " +
  423. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  424. " from CE_ErpTradeRefund a " +
  425. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  426. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  427. " group by CustomerUserId " +
  428. " ) as a " +
  429. ") as f on a.ID = f.CustomerUserId " +
  430. "where a.PostCode = 'CustomerService'",
  431. userWhere, orderWhere);
  432. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  433. writeGridDataTableJson(dt.Rows.Count, dt);
  434. //writeGridDataTableJson(dt.Rows.Count, dt);
  435. }
  436. //设计汇总
  437. public void get_erp_DesignerGather()
  438. {
  439. string userWhere = "", orderWhere = "";
  440. List<string> lw = new List<string>();
  441. string Designer = GetPostString("designer");
  442. int org = GetPostInt("org");
  443. if (Designer.Length > 0)
  444. {
  445. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  446. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  447. }
  448. else if (org > 0)
  449. {
  450. userWhere = string.Format(" where OrgID ={0}", org);
  451. }
  452. string shopname = GetPostString("shopname");
  453. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  454. string state = GetPostString("state");
  455. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  456. string OrderArea = GetPostString("order_area");
  457. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  458. string date1 = GetPostString("date1");
  459. string date2 = GetPostString("date2");
  460. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  461. if (dw.Length > 0) lw.Add(dw);
  462. string UpDate1 = GetPostString("UpDate1");
  463. string UpDate2 = GetPostString("UpDate2");
  464. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  465. if (dw.Length > 0) lw.Add(dw);
  466. orderWhere = string.Join(" and ", lw.ToArray());
  467. string sql = string.Format("select *,cast(cast(z.DesignFinish as float) / (case z.AllOrder when 0 then 1 else z.AllOrder end) * 100 as numeric(18,2)) as FinalizationRate from (" +
  468. "select a.Name DesignerName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitDesign,0) WaitDesign, isnull(e.Designing,0) Designing, isnull(g.DesignFinish,0) DesignFinish, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  469. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  470. "left join " +
  471. "( " +
  472. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  473. ") as b on a.ID = b.DesignUserId " +
  474. "left join " +
  475. "( " +
  476. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  477. ") as d on a.ID = d.DesignUserId " +
  478. "left join " +
  479. "( " +
  480. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  481. ") as e on a.ID = e.DesignUserId " +
  482. "left join " +
  483. "( " +
  484. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  485. ") as g on a.ID = g.DesignUserId " +
  486. "left join " +
  487. "( " +
  488. " select CustomerUserId, RefundCount, RefundSum from " +
  489. " ( " +
  490. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  491. " from CE_ErpTradeRefund a " +
  492. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  493. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  494. " group by CustomerUserId " +
  495. " ) as a " +
  496. ") as f on a.ID = f.CustomerUserId " +
  497. "where a.PostCode = 'Designer') as z",
  498. userWhere, orderWhere);
  499. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  500. writeGridDataTableJson(dt.Rows.Count, dt);
  501. }
  502. //删除tradecell的订单
  503. public void del_erp_cellorder()
  504. {
  505. if (UrlPostParmsCheck("ctid"))
  506. {
  507. string eid = GetPostString("ctid");
  508. CeErpTradeCell.DelByCtid(eid);
  509. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  510. returnSuccessMsg("删除成功");
  511. }
  512. }
  513. public void clear_erp_refundstate()
  514. {
  515. if (UrlPostParmsCheck("ids"))
  516. {
  517. string eids = GetPostString("ids");
  518. string[] ctidList = eids.Split(',');
  519. foreach (string ctid in ctidList)
  520. {
  521. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  522. if (entity != null)
  523. {
  524. entity.IsRefund = 0;
  525. entity.Update();
  526. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  527. }
  528. else
  529. continue;
  530. }
  531. returnSuccessMsg("操作成功");
  532. return;
  533. }
  534. returnErrorMsg("缺少必要参数");
  535. }
  536. public void set_erp_urgency()
  537. {
  538. if (UrlPostParmsCheck("ctid"))
  539. {
  540. string eid = GetPostString("ctid");
  541. CeErpTradeCell entity = null;
  542. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  543. if (entity != null)
  544. {
  545. double prices = commonHelper.calculationPrice(entity);
  546. if (prices <= 100)
  547. {
  548. returnErrorMsg("此订单金额不足100元,无法加急。");
  549. return;
  550. }
  551. string utime = GetPostString("urgencytime");
  552. if (utime.Length > 0)
  553. {
  554. entity.UrgencyTime = Convert.ToDateTime(utime);
  555. }
  556. else
  557. {
  558. returnErrorMsg("请选择加急时间");
  559. return;
  560. }
  561. if (entity.OrderState <= 4)
  562. {
  563. //entity.seller_memo = entity.seller_memo + "-加急";
  564. string smemo = entity.seller_memo;
  565. int kindex = smemo.IndexOf(")");
  566. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  567. if (lastoneStr != "-")
  568. {
  569. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  570. }
  571. string prememo = smemo.Substring(0, kindex + 2);
  572. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  573. int lastkindex = lastmemo.IndexOf("(");
  574. DateTime urgtime = Convert.ToDateTime(utime);
  575. string newlastmemo = "";
  576. if (lastkindex == 0)
  577. {
  578. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  579. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  580. }
  581. else
  582. {
  583. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  584. }
  585. entity.seller_memo = prememo + newlastmemo;
  586. }
  587. entity.IsUrgency = true;
  588. entity.UpdateTime = DateTime.Now;
  589. entity.Update();
  590. ApiVo apiVo = new ApiVo();
  591. apiVo.orderNumber = entity.ctid;
  592. apiVo.actionName = "changeDesign";
  593. apiVo.orderRemarks = entity.seller_memo;
  594. apiVo.remarkSign = 3;
  595. designHelper.API_WorkCore(apiVo); //changeDesign
  596. CeErpSukuraData.createInfo(entity.ctid, 7);
  597. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  598. returnSuccessMsg("设置成功!");
  599. return;
  600. }
  601. returnErrorMsg("找不到记录");
  602. }
  603. }
  604. public void set_erp_reset()
  605. {
  606. if (UrlPostParmsCheck("ctid"))
  607. {
  608. string eid = GetPostString("ctid");
  609. CeErpTradeCell entity = null;
  610. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  611. if (entity != null)
  612. {
  613. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  614. {
  615. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  616. {
  617. returnErrorMsg("财务要求已下单已发货无法重置");
  618. return;
  619. }
  620. }
  621. entity.IsUrgency = false;
  622. entity.seller_memo = "";
  623. entity.OtherMemo = "";
  624. entity.OrderState = 0;
  625. entity.IsReturn = 0;
  626. //entity.IsRefund = 0;
  627. entity.MemoOpt = 0;
  628. entity.AfterSaleState = 0;
  629. entity.AfterSaleResponsible = "";
  630. entity.AfterSaleUserId = 0;
  631. entity.IsNeedBill = 0;
  632. entity.CustomerUserId = 0;
  633. entity.DesignUserId = 0;
  634. entity.SupplierId = 0;
  635. entity.PlaceUserId = 0;
  636. entity.ptid = "";
  637. entity.IsSample = 0;
  638. entity.IsXianHuo = 0;
  639. entity.isDianziOrder = 0;
  640. entity.DispatchSort = 0;
  641. entity.FinishPlaceTime = null;
  642. entity.Update();
  643. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  644. if (trade != null)
  645. {
  646. trade.seller_memo = "";
  647. trade.Update();
  648. }
  649. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  650. returnSuccessMsg("重置成功!");
  651. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  652. if (desginBill != null)
  653. {
  654. desginBill.isDel = 1;
  655. desginBill.Update();
  656. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  657. }
  658. ApiVo apiVo = new ApiVo();
  659. apiVo.orderNumber = entity.ctid;
  660. apiVo.actionName = "resetDesign";
  661. designHelper.API_WorkCore(apiVo);//resetDesign
  662. return;
  663. }
  664. returnErrorMsg("找不到记录");
  665. }
  666. }
  667. public void save_erp_sellermemo()
  668. {
  669. if (UrlPostParmsCheck("ctid"))
  670. {
  671. string ctid = GetPostString("ctid");
  672. CeErpTradeCell entity = null;
  673. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  674. if (entity != null)
  675. {
  676. string memo = GetPostString("seller_memo");
  677. memo = memo.Replace(" ", "");
  678. if (memo.Contains("补差"))
  679. {
  680. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  681. return;
  682. }
  683. List<string> bitList = new List<string>
  684. {
  685. "\\","/",":","*","?", "\"","<" ,">","|"
  686. };
  687. bool isIn = false;
  688. foreach (string bit in bitList)
  689. {
  690. if (memo.Contains(bit))
  691. {
  692. isIn = true;
  693. }
  694. }
  695. if (isIn)
  696. {
  697. returnErrorMsg("不能使用 一些符合作为文件名");
  698. return;
  699. }
  700. if (entity.seller_memo != memo)
  701. {
  702. if (entity.IsSample == 2)
  703. {
  704. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  705. return;
  706. }
  707. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  708. {
  709. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  710. {
  711. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  712. return;
  713. }
  714. /*if (CurrentUser.UserPost.Post.Code != "Place")
  715. {
  716. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  717. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  718. {
  719. returnErrorMsg("售前系统订单无法再此修改!");
  720. return;
  721. }
  722. }*/
  723. }
  724. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  725. }
  726. commonHelper.getCytPrice(entity);
  727. int memoopt = GetPostInt("MemoOpt");
  728. Boolean ismemoopt = false;
  729. if (memoopt > 0)
  730. {
  731. string stropt = "";
  732. if (memoopt == 1)
  733. {
  734. stropt = "“改稿”";
  735. ismemoopt = true;
  736. }
  737. else if (memoopt == 2)
  738. {
  739. stropt = "“定稿”";
  740. }
  741. else if (memoopt == 3)
  742. {
  743. stropt = "“查货”";
  744. CeErpSukuraData.createInfo(entity.ctid, 6);
  745. }
  746. entity.MemoOpt = Convert.ToInt32(memoopt);
  747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  748. }
  749. if (entity.OrderState < 5)
  750. {
  751. memo = memo.Replace("(", "(");
  752. memo = memo.Replace(")", ")");
  753. }
  754. if (entity.OrderState < 3)
  755. {
  756. entity.DispatchSort = 0;
  757. }
  758. entity.seller_memo = memo;
  759. entity.UpdateTime = DateTime.Now;
  760. entity.Update();
  761. ApiVo apiVo = new ApiVo();
  762. apiVo.orderNumber = entity.ctid;
  763. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  764. apiVo.orderRemarks = memo;
  765. apiVo.remarkSign = memoopt;
  766. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  767. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  768. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  769. {
  770. dataHelper.api_orderBack(entity.ctid, "0", "");
  771. }
  772. if (entity.seller_memo.Contains("改稿"))
  773. {
  774. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  775. }
  776. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  777. returnSuccessMsg("保存成功!");
  778. return;
  779. }
  780. returnErrorMsg("找不到记录");
  781. }
  782. }
  783. public void ins_erp_checkorder()
  784. {
  785. if (UrlPostParmsCheck("ctid"))
  786. {
  787. string ctid = GetPostString("ctid");
  788. CeErpTradeCell entity = null;
  789. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  790. if (entity != null)
  791. {
  792. if (entity.OrderState < 6)
  793. {
  794. returnErrorMsg("下单完成后才可查货");
  795. return;
  796. }
  797. /*if (entity.OrderState > 6)
  798. {
  799. returnErrorMsg("订单已发货");
  800. return;
  801. }*/
  802. if (entity.FinishPlaceTime != null)
  803. {
  804. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  805. {
  806. returnErrorMsg("下单时间不足,无法查货");
  807. return;
  808. }
  809. }
  810. entity.MemoOpt = 3;
  811. entity.CheckOrderTime = DateTime.Now;
  812. entity.UpdateTime = DateTime.Now;
  813. entity.Update();
  814. CeErpSukuraData.createInfo(entity.ctid, 6);
  815. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  816. returnSuccessMsg("操作成功!");
  817. return;
  818. }
  819. returnErrorMsg("找不到记录");
  820. }
  821. }
  822. public void save_erp_othermemo()
  823. {
  824. if (UrlPostParmsCheck("ctid"))
  825. {
  826. string ctid = GetPostString("ctid");
  827. CeErpTradeCell entity = null;
  828. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  829. if (entity != null)
  830. {
  831. entity.OtherMemo = GetPostString("otherMemo");
  832. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  833. {
  834. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  835. StringBuilder sql = new StringBuilder();
  836. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  837. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  838. if (dt != null && dt.Rows.Count > 0)
  839. {
  840. foreach (DataRow dr in dt.Rows)
  841. {
  842. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  843. {
  844. //品类一直
  845. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  846. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  847. if (ceErpSampleCustomer == null)
  848. {
  849. ceErpSampleCustomer = new CeErpSampleCustomer();
  850. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  851. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  852. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  853. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  854. ceErpSampleCustomer.shopId = entity.ShopId;
  855. }
  856. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  857. ceErpSampleCustomer.lastTid = entity.tid;
  858. if (ceErpSampleCustomer.ID > 0)
  859. {
  860. ceErpSampleCustomer.Update();
  861. }
  862. else
  863. {
  864. ceErpSampleCustomer.Create();
  865. }
  866. }
  867. }
  868. }
  869. }
  870. //if (entity.IsOldCustomer == 1)
  871. //{
  872. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  873. //{
  874. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  875. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  876. //}
  877. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  878. //{
  879. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  880. // {
  881. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  882. // {
  883. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  884. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  885. // }
  886. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  887. // {
  888. // entity.OrderState = 2;
  889. // entity.DesignUserId = 0;
  890. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  891. // }
  892. // else
  893. // {
  894. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  895. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  896. // }
  897. // }
  898. //}
  899. //}
  900. entity.UpdateTime = DateTime.Now;
  901. entity.Update();
  902. returnSuccessMsg("保存成功!");
  903. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  904. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  905. if (entity.OtherMemo.Contains("改稿"))
  906. {
  907. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  908. }
  909. return;
  910. }
  911. returnErrorMsg("找不到记录");
  912. }
  913. }
  914. public void save_erp_customermemo()
  915. {
  916. if (UrlPostParmsCheck("ctid"))
  917. {
  918. string ctid = GetPostString("ctid");
  919. CeErpTradeCell entity = null;
  920. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  921. if (entity != null)
  922. {
  923. entity.UpdateTime = DateTime.Now;
  924. entity.CustomerMemo = GetPostString("CustomerMemo");
  925. entity.Update();
  926. ApiVo apiVo = new ApiVo();
  927. apiVo.orderNumber = entity.ctid;
  928. apiVo.actionName = "followRemarks";
  929. apiVo.orderRemarks = entity.CustomerMemo;
  930. designHelper.API_WorkCore(apiVo);//followRemarks
  931. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  932. returnSuccessMsg("保存成功!");
  933. return;
  934. }
  935. returnErrorMsg("找不到记录");
  936. }
  937. }
  938. public void upd_erp_addmemotag()
  939. {
  940. if (UrlPostParmsCheck("ctid"))
  941. {
  942. ;
  943. string eid = GetPostString("ctid");
  944. string sfTagstr = GetPostString("memotag");
  945. CeErpTradeCell entity = null;
  946. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  947. if (entity != null)
  948. {
  949. ApiVo apiVo = new ApiVo();
  950. if (entity.OrderState == 0)
  951. {
  952. returnErrorMsg("请先领单");
  953. return;
  954. }
  955. //撤销顺丰
  956. if (sfTagstr == "撤销顺丰")
  957. {
  958. entity.IsSF = 0;
  959. string reMsg = "";
  960. string oldmemo = entity.seller_memo;
  961. if (entity.OrderState < 5)
  962. {
  963. oldmemo = oldmemo.Replace("顺丰到付", "");
  964. oldmemo = oldmemo.Replace("顺丰寄付", "");
  965. entity.seller_memo = oldmemo;
  966. }
  967. else
  968. {
  969. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  970. {
  971. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  972. }
  973. }
  974. entity.Update();
  975. apiVo.orderNumber = entity.ctid;
  976. apiVo.actionName = "orderRemarks";
  977. apiVo.orderRemarks = entity.seller_memo;
  978. apiVo.isSf = entity.IsSF.ToString();
  979. designHelper.API_WorkCore(apiVo);//orderRemarks
  980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  981. returnSuccessMsg("撤销成功!" + reMsg);
  982. return;
  983. }
  984. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  985. {
  986. //string oldmemo = entity.seller_memo;
  987. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  988. string sfStr = GetPostString("memotag");
  989. string smemo = entity.seller_memo;
  990. int kindex = smemo.IndexOf(")");
  991. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  992. if (lastoneStr != "-")
  993. {
  994. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  995. }
  996. string prememo = smemo.Substring(0, kindex + 2);
  997. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  998. int lastkindex = lastmemo.IndexOf("(");
  999. string newlastmemo = "";
  1000. if (lastkindex == 0)
  1001. {
  1002. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1003. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1004. }
  1005. else
  1006. {
  1007. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1008. }
  1009. entity.seller_memo = prememo + newlastmemo;
  1010. }
  1011. string sfTagMSg = "";
  1012. if (sfTagstr == "顺丰寄付")
  1013. {
  1014. entity.IsSF = 1;
  1015. sfTagMSg = "顺丰寄付";
  1016. }
  1017. else if (sfTagstr == "顺丰到付")
  1018. {
  1019. entity.IsSF = 2;
  1020. sfTagMSg = "顺丰到付";
  1021. }
  1022. entity.Update();
  1023. apiVo = new ApiVo();
  1024. apiVo.orderNumber = entity.ctid;
  1025. apiVo.actionName = "orderRemarks";
  1026. apiVo.orderRemarks = entity.seller_memo;
  1027. apiVo.isSf = entity.IsSF.ToString();
  1028. designHelper.API_WorkCore(apiVo);//orderRemarks
  1029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1030. returnSuccessMsg("标记成功!");
  1031. return;
  1032. }
  1033. returnErrorMsg("找不到记录");
  1034. }
  1035. }
  1036. public void upd_erp_ordertag()
  1037. {
  1038. if (UrlPostParmsCheck("ctid"))
  1039. {
  1040. string eid = GetPostString("ctid");
  1041. CeErpTradeCell entity = null;
  1042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1043. if (entity != null)
  1044. {
  1045. int tag = GetPostInt("wechattag");
  1046. //if(tag==4 && entity.IsSample == 2)
  1047. //{
  1048. // returnErrorMsg("补差价单不能标记微信单");
  1049. // return;
  1050. //}
  1051. entity.wechatTag = tag;
  1052. entity.Update();
  1053. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1054. if (tag == 1)
  1055. {
  1056. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1057. if (cash == null)
  1058. {
  1059. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1060. cash = new CeErpReturnCash();
  1061. cash.tid = entity.tid;
  1062. cash.seller_nick = main.seller_nick;
  1063. cash.payment = trade.payment;
  1064. cash.buyer_nick = main.buyer_nick;
  1065. cash.cashstate = 0;
  1066. cash.rtype = "微信返现";
  1067. cash.returnprice = 0;
  1068. cash.created = DateTime.Now;
  1069. cash.con = "订单标记微信单";
  1070. cash.img = "";
  1071. cash.applyuserid = CurrentUser.UserID;
  1072. cash.Create();
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1074. }
  1075. else
  1076. {
  1077. cash.cashstate = 0;
  1078. cash.Update();
  1079. }
  1080. CeErpSukuraData.createInfo(entity.ctid, 9);
  1081. }
  1082. else if (tag == 2)
  1083. {
  1084. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1085. if (cash == null)
  1086. {
  1087. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1088. cash = new CeErpReturnCash();
  1089. cash.tid = entity.tid;
  1090. cash.seller_nick = main.seller_nick;
  1091. cash.payment = trade.payment;
  1092. cash.buyer_nick = main.buyer_nick;
  1093. cash.cashstate = 0;
  1094. cash.rtype = "推购返现";
  1095. cash.returnprice = 5;
  1096. cash.created = DateTime.Now;
  1097. cash.con = "订单标记推购单";
  1098. cash.img = "";
  1099. cash.applyuserid = CurrentUser.UserID;
  1100. cash.Create();
  1101. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1102. }
  1103. else
  1104. {
  1105. cash.cashstate = 0;
  1106. cash.Update();
  1107. }
  1108. CeErpSukuraData.createInfo(entity.ctid, 9);
  1109. }
  1110. else if (tag == 3)
  1111. {
  1112. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1113. if (pers == null)
  1114. {
  1115. pers = new CeErpPersuade();
  1116. pers.ctid = entity.ctid;
  1117. pers.pstate = 0;
  1118. pers.created = DateTime.Now;
  1119. pers.applyuserid = CurrentUser.UserID;
  1120. pers.Create();
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1122. }
  1123. else
  1124. {
  1125. pers.pstate = 0;
  1126. pers.Update();
  1127. }
  1128. }
  1129. else if (tag == 4 || tag == 5)
  1130. {
  1131. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1132. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1133. if (pers == null)
  1134. {
  1135. pers = new CeErpStayGoods();
  1136. pers.t_id = entity.tid;
  1137. pers.status = "待审核";
  1138. pers.audit_type = 0;
  1139. if (tag == 4)
  1140. {
  1141. pers.stay_type = "微信推购";
  1142. }
  1143. else
  1144. {
  1145. pers.stay_type = "旺旺推购";
  1146. }
  1147. if (entity.IsXianHuo == 0)
  1148. {
  1149. pers.product_id = entity.ProductId;
  1150. }
  1151. pers.wangwang = main.buyer_nick;
  1152. pers.shop_name = main.seller_nick;
  1153. pers.creata_time = DateTime.Now;
  1154. pers.create_u_id = CurrentUser.UserID;
  1155. pers.create_u_name = CurrentUser.UserName;
  1156. pers.Create();
  1157. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1158. }
  1159. else
  1160. {
  1161. pers.audit_type = 0;
  1162. pers.Update();
  1163. }
  1164. CeErpSukuraData.createInfo(entity.ctid, 10);
  1165. }
  1166. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1167. returnSuccessMsg("标记成功!");
  1168. return;
  1169. }
  1170. returnErrorMsg("找不到记录");
  1171. }
  1172. }
  1173. public void upd_erp_ordertag_cancel()
  1174. {
  1175. if (UrlPostParmsCheck("ctid"))
  1176. {
  1177. string eid = GetPostString("ctid");
  1178. CeErpTradeCell entity = null;
  1179. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1180. if (entity != null)
  1181. {
  1182. entity.wechatTag = 0;
  1183. entity.Update();
  1184. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1185. if (pers != null)
  1186. {
  1187. pers.status = "取消推购";
  1188. pers.audit_type = 3;
  1189. pers.Update();
  1190. }
  1191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1192. returnSuccessMsg("标记成功!");
  1193. return;
  1194. }
  1195. returnErrorMsg("找不到记录");
  1196. }
  1197. }
  1198. public void upd_erp_addweichattag()
  1199. {
  1200. if (UrlPostParmsCheck("ctid"))
  1201. {
  1202. ;
  1203. string eid = GetPostString("ctid");
  1204. CeErpTradeCell entity = null;
  1205. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1206. if (entity != null)
  1207. {
  1208. if (entity.IsAddWechat > 0)
  1209. {
  1210. returnErrorMsg("此单已经标记过了");
  1211. return;
  1212. }
  1213. string sql = string.Format("select * from view_erptradecell where IsAddWechat>0 and buyer_nick=(select buyer_nick from ce_erptrade where tid='{0}')", entity.tid);
  1214. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1215. if (dt.Rows.Count > 0)
  1216. {
  1217. entity.IsAddWechat = 2;
  1218. }
  1219. else
  1220. {
  1221. entity.IsAddWechat = 1;
  1222. }
  1223. entity.Update();
  1224. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1225. returnSuccessMsg("标记成功!");
  1226. return;
  1227. }
  1228. returnErrorMsg("找不到记录");
  1229. }
  1230. }
  1231. public void upd_erp_getmyorder()
  1232. {
  1233. if (UrlPostParmsCheck("ctid"))
  1234. {
  1235. ;
  1236. string eid = GetPostString("ctid");
  1237. CeErpTradeCell entity = null;
  1238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1239. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1240. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1241. {
  1242. returnErrorMsg("台湾客户需填写身份证号!");
  1243. return;
  1244. }
  1245. if (entity != null)
  1246. {
  1247. if (entity.ctid.IndexOf("C") != -1)
  1248. {
  1249. StringBuilder sql = new StringBuilder();
  1250. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1251. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1252. if (dt.Rows.Count > 0)
  1253. {
  1254. decimal total = 0;
  1255. foreach (DataRow dr in dt.Rows)
  1256. {
  1257. total += Convert.ToDecimal(dr["payment"]);
  1258. }
  1259. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1260. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1261. {
  1262. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1263. return;
  1264. }
  1265. }
  1266. }
  1267. if (entity.OrderState == -1)
  1268. {
  1269. returnErrorMsg("待审核订单无法领取!");
  1270. return;
  1271. }
  1272. entity.CustomerUserId = CurrentUser.UserID;
  1273. if (entity.OrderState < 2)
  1274. {
  1275. entity.OrderState = 2;
  1276. if (entity.ShopId != 0)
  1277. {
  1278. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1279. }
  1280. }
  1281. entity.UpdateTime = DateTime.Now;
  1282. entity.Update();
  1283. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1284. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1285. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1286. {
  1287. dataHelper.api_orderBack(entity.ctid, "0", "");
  1288. }
  1289. returnSuccessMsg("领单成功!");
  1290. return;
  1291. }
  1292. returnErrorMsg("找不到记录");
  1293. }
  1294. }
  1295. public void getmyorder_from_init()
  1296. {
  1297. if (UrlPostParmsCheck("ctid"))
  1298. {
  1299. string eid = GetPostString("ctid");
  1300. CeErpTradeCell entity = null;
  1301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1302. if (entity != null)
  1303. {
  1304. string sellerMemo = GetPostString("sellerMemo");
  1305. if (sellerMemo.Length > 0)
  1306. {
  1307. entity.seller_memo = sellerMemo;
  1308. }
  1309. string oterhMemo = GetPostString("otherMemo");
  1310. if (oterhMemo.Length > 0)
  1311. {
  1312. entity.OtherMemo = oterhMemo;
  1313. }
  1314. int urg = GetPostInt("urgency");
  1315. entity.IsUrgency = (urg == 1 ? true : false);
  1316. int wechat = GetPostInt("wechat");
  1317. int command = GetPostInt("command");
  1318. if (wechat == 1)
  1319. {
  1320. entity.wechatTag = 1;
  1321. }
  1322. if (command == 1)
  1323. {
  1324. entity.wechatTag = 2;
  1325. }
  1326. string pPro = GetPostString("pprofession");
  1327. if (pPro.Length > 0)
  1328. {
  1329. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1330. string spro = GetPostString("profession");
  1331. if (spro.Length > 0)
  1332. {
  1333. entity.ProfessionId = Convert.ToInt32(spro);
  1334. }
  1335. }
  1336. string proId = GetPostString("productId");
  1337. if (proId.Length > 0)
  1338. {
  1339. entity.ProductId = Convert.ToInt32(proId);
  1340. }
  1341. entity.Material = GetPostString("material");
  1342. entity.Craft = GetPostString("craft");
  1343. entity.CustomerUserId = CurrentUser.UserID;
  1344. if (entity.OrderState < 2)
  1345. {
  1346. entity.OrderState = 2;
  1347. if (entity.ShopId != 0)
  1348. {
  1349. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1350. }
  1351. }
  1352. entity.Update();
  1353. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1354. returnSuccessMsg("领单成功!");
  1355. return;
  1356. }
  1357. returnErrorMsg("找不到记录");
  1358. }
  1359. }
  1360. public void upd_erp_setrelationorder()
  1361. {
  1362. if (UrlPostParmsCheck("ctid"))
  1363. {
  1364. ;
  1365. string eid = GetPostString("ctid");
  1366. string ftid = GetPostString("ftid");
  1367. CeErpTradeCell entity = null;
  1368. CeErpTradeCell fentity = null;
  1369. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1370. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1371. if (fentity == null)
  1372. {
  1373. returnErrorMsg("找不到关联的主订单");
  1374. return;
  1375. }
  1376. if (entity != null)
  1377. {
  1378. if (entity.OrderState >= 5)
  1379. {
  1380. returnErrorMsg("本单已经设计完成无法关联");
  1381. return;
  1382. }
  1383. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1384. {
  1385. returnErrorMsg("线下单续审核后才能关联!");
  1386. return;
  1387. }
  1388. entity.ptid = ftid;
  1389. entity.OrderState = fentity.OrderState;
  1390. //entity.status = fentity.status;
  1391. entity.CustomerUserId = fentity.CustomerUserId;
  1392. entity.DesignUserId = fentity.DesignUserId;
  1393. entity.seller_memo = "补差价单:" + ftid;
  1394. entity.IsSample = 2;
  1395. entity.Update();
  1396. ApiVo apiVo = new ApiVo();
  1397. apiVo.orderNumber = ftid;
  1398. apiVo.payment = entity.payment;
  1399. apiVo.actionName = "repairDesign";
  1400. designHelper.API_WorkCore(apiVo);//repairDesign
  1401. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1402. returnSuccessMsg("关联成功!");
  1403. return;
  1404. }
  1405. else
  1406. returnErrorMsg("找不到记录");
  1407. }
  1408. }
  1409. public void download_erp_neworder()
  1410. {
  1411. string seller = GetPostString("seller_nick");
  1412. string tid = GetPostString("tid");
  1413. if (seller.Length <= 0 || tid.Length <= 0)
  1414. {
  1415. returnErrorMsg("数据错误");
  1416. }
  1417. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1418. //{
  1419. // returnErrorMsg("找不到店铺Sessionkey");
  1420. //}
  1421. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1422. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1423. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1424. if (res.IndexOf("refOid") == -1)
  1425. {
  1426. returnErrorMsg("下载订单数据失败");
  1427. return;
  1428. }
  1429. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1430. returnSuccessMsg("下载完成");
  1431. //tmcHelper.createNewOrder(res);
  1432. //CeErpTrade entr = null;
  1433. //entr = CeErpTrade.Get(tid);
  1434. //if (entr != null)
  1435. //{
  1436. // returnSuccess("下载成功");
  1437. // //下载成功之后,Cell表生成对应的订单;
  1438. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1439. //}
  1440. //else
  1441. //{
  1442. // returnErrorMsg("下载失败或者创建订单失败");
  1443. //}
  1444. }
  1445. public void set_erp_atersale()
  1446. {
  1447. if (UrlPostParmsCheck("ctid"))
  1448. {
  1449. string eid = GetPostString("ctid");
  1450. string reason = GetPostString("AfterSaleReason");
  1451. CeErpTradeCell entity = null;
  1452. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1453. if (entity != null)
  1454. {
  1455. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1456. {
  1457. returnErrorMsg("此订单已经在售后");
  1458. return;
  1459. }
  1460. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1461. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1462. entity.AfterSaleTime = DateTime.Now;
  1463. entity.Update();
  1464. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1465. returnSuccessMsg("转售后成功!");
  1466. return;
  1467. }
  1468. returnErrorMsg("找不到记录");
  1469. }
  1470. }
  1471. public void set_erp_withdraw()
  1472. {
  1473. if (UrlPostParmsCheck("ctid"))
  1474. {
  1475. try
  1476. {
  1477. string eid = GetPostString("ctid");//商品id
  1478. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1479. CeWithdraw ceWithdrawSelect = null;
  1480. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1481. if (ceWithdrawSelect != null)
  1482. {
  1483. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1484. {
  1485. ceWithdrawSelect.status = -1;
  1486. ceWithdrawSelect.Update();
  1487. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1488. returnSuccessMsg("重新发起审核成功");
  1489. return;
  1490. }
  1491. else
  1492. {
  1493. returnSuccessMsg("请勿重复申请!");
  1494. return;
  1495. }
  1496. }
  1497. else
  1498. {
  1499. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1500. if (string.IsNullOrEmpty(CustomerUserId))
  1501. {
  1502. CustomerUserId = "-1";
  1503. }
  1504. int Userid = CurrentUser.UserID;//用户id
  1505. CeWithdraw ceWithdraw = new CeWithdraw();
  1506. ceWithdraw.tid = eid;
  1507. ceWithdraw.userid = Userid;
  1508. ceWithdraw.providerid = CustomerUserId;
  1509. ceWithdraw.status = 3;
  1510. ceWithdraw.creationtime = DateTime.Now;
  1511. ceWithdraw.Create();
  1512. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1513. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1514. return;
  1515. }
  1516. }
  1517. catch
  1518. {
  1519. returnErrorMsg("申请撤回订单失败");
  1520. return;
  1521. }
  1522. }
  1523. }
  1524. public void ins_erp_billinfo()
  1525. {
  1526. if (UrlPostParmsCheck("ctid"))
  1527. {
  1528. string eid = GetPostString("ctid");
  1529. CeErpTradeCell entity = null;
  1530. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1531. if (entity != null)
  1532. {
  1533. CeErpBill bill = CeErpBill.GetByTid(eid);
  1534. bool isHave = false;
  1535. if (bill != null)
  1536. {
  1537. isHave = true;
  1538. if (bill.state != 4)
  1539. {
  1540. returnErrorMsg("此单已经申请过发票了");
  1541. return;
  1542. }
  1543. }
  1544. if (entity.IsNeedBill == 0)
  1545. {
  1546. entity.IsNeedBill = 1;
  1547. }
  1548. entity.Update();
  1549. string errjson = "";
  1550. try
  1551. {
  1552. CeErpBill bill_entity = new CeErpBill();
  1553. bill_entity.tid = entity.tid;
  1554. bill_entity.title = GetPostString("title");
  1555. string taxstr = GetPostString("tax");
  1556. taxstr = taxstr.Replace(" ", "");
  1557. bill_entity.tax = taxstr;
  1558. bill_entity.bank = GetPostString("bank");
  1559. string bankacstr = GetPostString("bankac");
  1560. bankacstr = bankacstr.Replace(" ", "");
  1561. bill_entity.bankac = bankacstr;
  1562. bill_entity.address = GetPostString("address");
  1563. bill_entity.phone = GetPostString("phone");
  1564. bill_entity.price = GetPostString("price");
  1565. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1566. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1567. {
  1568. billCount += 1;
  1569. }
  1570. string prebill = "ltb";
  1571. for (int idx = 1; idx <= billCount; idx++)
  1572. {
  1573. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1574. string billoid = prebill + idx + dtstr;
  1575. bill_entity.billOrderId += billoid;
  1576. if (idx < billCount)
  1577. {
  1578. bill_entity.billOrderId += ",";
  1579. }
  1580. }
  1581. bill_entity.productId = GetPostInt("ProductName");
  1582. bill_entity.num = GetPostInt("num");
  1583. bill_entity.unit = GetPostString("unit");
  1584. bill_entity.type = GetPostString("type");
  1585. bill_entity.sendType = GetPostString("SendType");
  1586. bill_entity.email = GetPostString("email");
  1587. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1588. bill_entity.shopName = GetPostString("ShopName");
  1589. bill_entity.applymemo = GetPostString("applyMemo");
  1590. bill_entity.createTime = DateTime.Now;
  1591. bill_entity.state = 0;
  1592. bill_entity.userId = CurrentUser.UserID;
  1593. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1594. bill_entity.Create();
  1595. }
  1596. catch (Exception ex)
  1597. {
  1598. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1599. returnErrorMsg("创建发票出错!");
  1600. return;
  1601. }
  1602. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1603. returnSuccessMsg("发票申请成功!");
  1604. return;
  1605. }
  1606. returnErrorMsg("找不到记录");
  1607. }
  1608. }
  1609. public void ins_erp_neworder()
  1610. {
  1611. if (UrlPostParmsCheck("receiver_name"))
  1612. {
  1613. CeErpTrade entity = new CeErpTrade();
  1614. string plat_form = GetPostString("platform");
  1615. string preStr = "N_";
  1616. if (plat_form == "拼多多")
  1617. {
  1618. preStr = "P_";
  1619. }
  1620. else if (plat_form == "阿里巴巴")
  1621. {
  1622. preStr = "A_";
  1623. }
  1624. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1625. entity.seller_nick = GetPostString("seller_nick");
  1626. entity.buyer_nick = GetPostString("buyer_nick");
  1627. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1628. entity.total_fee = entity.payment;
  1629. entity.pay_time = DateTime.Now;
  1630. entity.status = "NOT_SHIPPED";
  1631. entity.receiver_name = GetPostString("receiver_name");
  1632. entity.receiver_mobile = GetPostString("receiver_mobile");
  1633. entity.receiver_state = GetPostString("receiver_state");
  1634. entity.receiver_city = GetPostString("receiver_city");
  1635. entity.receiver_district = GetPostString("receiver_district");
  1636. entity.receiver_address = GetPostString("receiver_address");
  1637. if (entity.receiver_state == "" || entity.receiver_city == "")
  1638. {
  1639. returnErrorMsg("收件地址不能为空");
  1640. return;
  1641. }
  1642. int shopId = 0;
  1643. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1644. if (nShop != null)
  1645. {
  1646. shopId = nShop.ID;
  1647. }
  1648. if (shopId != 34 && entity.payment == 0)
  1649. {
  1650. returnErrorMsg("公司自用的单金额才能为0");
  1651. return;
  1652. }
  1653. entity.Create();
  1654. CeErpTradeCell entitycell = new CeErpTradeCell();
  1655. entitycell.ctid = entity.tid;
  1656. entitycell.tid = entity.tid;
  1657. entitycell.ShopId = shopId;
  1658. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1659. entitycell.OrderState = 0;
  1660. entitycell.pay_time = entity.pay_time;
  1661. entitycell.IsOffLineOrder = 1;
  1662. entitycell.Create();
  1663. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1664. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1665. return;
  1666. }
  1667. }
  1668. public void ins_erp_neworder2()
  1669. {
  1670. if (UrlPostParmsCheck("receiver_name"))
  1671. {
  1672. //string plat_form = GetPostString("platform");
  1673. string preStr = "X_";
  1674. string memo = GetPostString("memo");
  1675. string productId = GetPostString("productId");
  1676. string primg = GetPostString("proofimg");
  1677. string sellerNick = GetPostString("seller_nick");
  1678. string addFrom = GetPostString("addfrom");
  1679. if (addFrom == "1")
  1680. {
  1681. preStr = "N_";
  1682. }
  1683. int shopId = 0;
  1684. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1685. if (nShop != null)
  1686. {
  1687. shopId = nShop.ID;
  1688. }
  1689. else
  1690. {
  1691. returnErrorMsg("找不到对应店铺");
  1692. return;
  1693. }
  1694. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1695. {
  1696. returnErrorMsg("必须上传付款凭证");
  1697. return;
  1698. }
  1699. CeErpTrade entity = new CeErpTrade();
  1700. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1701. entity.seller_nick = sellerNick;
  1702. entity.buyer_nick = GetPostString("buyer_nick");
  1703. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1704. entity.total_fee = entity.payment;
  1705. entity.pay_time = DateTime.Now;
  1706. entity.status = "NOT_SHIPPED";
  1707. entity.receiver_name = GetPostString("receiver_name");
  1708. entity.receiver_mobile = GetPostString("receiver_mobile");
  1709. entity.receiver_state = GetPostString("receiver_state");
  1710. entity.receiver_city = GetPostString("receiver_city");
  1711. entity.receiver_district = GetPostString("receiver_district");
  1712. entity.receiver_address = GetPostString("receiver_address");
  1713. entity.seller_memo = memo;
  1714. entity.orderFrom = 20;
  1715. entity.orderType = 15;
  1716. if (entity.receiver_state == "" || entity.receiver_city == "")
  1717. {
  1718. returnErrorMsg("收件地址不能为空");
  1719. return;
  1720. }
  1721. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1722. {
  1723. returnErrorMsg("公司自用的单金额才能为0");
  1724. return;
  1725. }
  1726. entity.Create();
  1727. string toWhere = GetPostString("towhere");
  1728. CeErpTradeCell entitycell = new CeErpTradeCell();
  1729. entitycell.ctid = entity.tid;
  1730. //唯一标识
  1731. entitycell.OrderSn = entity.tid;
  1732. string orderSn = dataHelper.getSaleOrderSn();
  1733. if (orderSn != "")
  1734. {
  1735. entitycell.OrderSn = orderSn;
  1736. }
  1737. entitycell.tid = entity.tid;
  1738. //if (preStr == "X_")
  1739. //{
  1740. entitycell.IsOffLineOrder = 1;
  1741. //}
  1742. entitycell.CustomerUserId = CurrentUser.UserID;
  1743. entitycell.PayProofImg = primg;
  1744. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1745. entitycell.ProductId = Convert.ToInt32(productId);
  1746. entitycell.ShopId = shopId;
  1747. entitycell.UpdateTime = DateTime.Now;
  1748. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1749. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1750. {
  1751. entitycell.IsXianHuo = 1;
  1752. }
  1753. entitycell.pay_time = entity.pay_time;
  1754. if (toWhere == "1")
  1755. {
  1756. entitycell.OrderState = 2;
  1757. }
  1758. else
  1759. {
  1760. entitycell.OrderState = 6;
  1761. entitycell.FinishPlaceTime = entitycell.pay_time;
  1762. }
  1763. if (shopId == 94)
  1764. {
  1765. entitycell.OrderState = 4;
  1766. entitycell.WaitDesignTime = entitycell.pay_time;
  1767. entitycell.StartDesignTime = entitycell.pay_time;
  1768. entitycell.DesignUserId = 218;
  1769. }
  1770. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1771. {
  1772. entitycell.OrderState = -1;//修改12-5
  1773. CeWithdraw ceWithdraw = new CeWithdraw();
  1774. ceWithdraw.tid = entity.tid;
  1775. ceWithdraw.providerid = "-1";
  1776. ceWithdraw.status = -1;
  1777. ceWithdraw.creationtime = DateTime.Now;
  1778. ceWithdraw.userid = 1337;
  1779. ceWithdraw.Create();
  1780. }
  1781. entitycell.Create();
  1782. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1783. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1784. {
  1785. addPlaceRegist(entitycell, CurrentUser.UserID);
  1786. }
  1787. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1788. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1789. return;
  1790. }
  1791. }
  1792. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1793. {
  1794. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1795. entity.PlactTime = tradecell.pay_time;
  1796. entity.AddUserId = userid;
  1797. entity.FileName = tradecell.seller_memo;
  1798. entity.Supplier = 24;
  1799. entity.CreateTime = DateTime.Now;
  1800. entity.Did = tradecell.ctid;
  1801. entity.tid = tradecell.tid;
  1802. entity.splitTag = tradecell.SplitTag;
  1803. entity.CurState = "未完成";
  1804. entity.Create();
  1805. }
  1806. public void get_erp_offlinelist()
  1807. {
  1808. DataStruct dStruct = GetPostStruct();
  1809. List<string> lw = new List<string>();
  1810. string tid = GetPostString("ctid");
  1811. string date1 = GetPostString("date1");
  1812. string date2 = GetPostString("date2");
  1813. if (tid.Length > 0 || date1.Length > 0)
  1814. {
  1815. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1816. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1817. if (dw.Length > 0) lw.Add(dw);
  1818. }
  1819. else
  1820. {
  1821. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1822. }
  1823. string shopname = GetPostString("shopname");
  1824. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1825. string buyernick = GetPostString("buyer_nick");
  1826. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1827. string customer = GetPostString("customer");
  1828. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1829. string design = GetPostString("design");
  1830. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1831. string orderState = GetPostString("orderState");
  1832. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1833. string address = GetPostString("address");
  1834. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  1835. string sellermemo = GetPostString("seller_memo");
  1836. if (sellermemo.Length > 0)
  1837. {
  1838. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1839. }
  1840. string price1 = GetPostString("price1");
  1841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1842. string price2 = GetPostString("price2");
  1843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1844. //if (PKey != "admin")
  1845. //{
  1846. // string usershop = CurrentUser.User.pemShop;
  1847. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1848. //}
  1849. //if (ex_psize > 0)
  1850. //{
  1851. dStruct.Order = "pay_time desc";
  1852. //}
  1853. //else
  1854. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1855. lw.Add(string.Format("IsOffLineOrder=1"));
  1856. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1857. DataTable dt = null;
  1858. dt = WebCache.GetData("view_erptradecell", dStruct);
  1859. writeGridDataTableJson(dStruct.TotalCount, dt);
  1860. }
  1861. public void get_erp_returncashrecord()
  1862. {
  1863. DataStruct dStruct = GetPostStruct();
  1864. List<string> lw = new List<string>();
  1865. string tid = GetPostString("ctid");
  1866. if (tid.Length > 0)
  1867. {
  1868. lw.Add(string.Format("tid like '%{0}%'", tid));
  1869. dStruct.Order = "id desc";
  1870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1871. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1872. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1873. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1874. return;
  1875. }
  1876. returnErrorMsg("id数据错误!");
  1877. }
  1878. public void ins_erp_returncashrecord()
  1879. {
  1880. if (UrlPostParmsCheck("tid"))
  1881. {
  1882. string tid = GetPostString("tid");
  1883. string retype = GetPostString("type");
  1884. StringBuilder sql = new StringBuilder();
  1885. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1886. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1887. if (dt.Rows.Count > 0)
  1888. {
  1889. returnErrorMsg("相同返现类型记录已存在");
  1890. return;
  1891. }
  1892. CeErpReturnCash entity = new CeErpReturnCash();
  1893. entity.tid = tid;
  1894. entity.seller_nick = GetPostString("seller_nick");
  1895. string pment = GetPostString("payment");
  1896. if (pment.Length > 0)
  1897. {
  1898. entity.payment = Convert.ToDouble(pment);
  1899. }
  1900. entity.buyer_nick = GetPostString("buyer_nick");
  1901. entity.cashstate = 0;
  1902. entity.rtype = retype;
  1903. string rPrice = GetPostString("returnprice");
  1904. if (rPrice.Length > 0)
  1905. {
  1906. entity.returnprice = Convert.ToDouble(rPrice);
  1907. }
  1908. entity.created = DateTime.Now;
  1909. entity.con = GetPostString("con");
  1910. entity.img = GetPostString("img");
  1911. entity.applyuserid = CurrentUser.UserID;
  1912. entity.Create();
  1913. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1914. returnSuccessMsg("操作成功!");
  1915. return;
  1916. }
  1917. }
  1918. public void set_erp_predelivery()
  1919. {
  1920. if (UrlPostParmsCheck("ctid"))
  1921. {
  1922. string eid = GetPostString("ctid");
  1923. CeErpTradeCell entity = null;
  1924. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1925. if (entity != null)
  1926. {
  1927. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1928. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1929. //{
  1930. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1931. // return;
  1932. //}
  1933. entity.IsPreDelivery = 1;
  1934. entity.Update();
  1935. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1936. returnSuccessMsg("预发货成功!");
  1937. return;
  1938. //string shop = GetPostString("seller_nick");
  1939. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1940. //string comName = GetPostString("comName");
  1941. //string comCode = GetPostString("comCode");
  1942. //string outSid = GetPostString("outSid");//运单号
  1943. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1944. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1945. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1946. //string apires = "";
  1947. //if (deliveryType == "虚拟发货")
  1948. //{
  1949. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1950. //}
  1951. //else
  1952. //{
  1953. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1954. //}
  1955. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1956. ////{
  1957. //if (apires.IndexOf("发货成功") != -1)
  1958. //{
  1959. // if (deliveryType != "虚拟发货")
  1960. // {
  1961. // //还要插入快递信息到 快递信息表
  1962. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1963. // exinfo.tid = eid;
  1964. // exinfo.out_sid = outSid;
  1965. // exinfo.company_code = comCode;
  1966. // exinfo.company_name = comName;
  1967. // exinfo.delivery_memo = deliveryMemo;
  1968. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1969. // exinfo.deliveryType = deliveryType;
  1970. // exinfo.Create();
  1971. // }
  1972. // returnSuccessMsg("发货成功!");
  1973. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1974. //}
  1975. //else
  1976. //{
  1977. // returnErrorMsg("淘宝发货失败!!");
  1978. //}
  1979. //return;
  1980. }
  1981. returnErrorMsg("找不到订单记录");
  1982. }
  1983. }
  1984. public void get_erp_unusuallist()
  1985. {
  1986. DataStruct dStruct = GetPostStruct();
  1987. List<string> lw = new List<string>();
  1988. string tid = GetPostString("ctid");
  1989. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1990. string shopname = GetPostString("shopname");
  1991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1992. string buyernick = GetPostString("buyer_nick");
  1993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1994. string ResponsibleMan = GetPostString("responsible");
  1995. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1996. string date1 = GetPostString("date1");
  1997. string date2 = GetPostString("date2");
  1998. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1999. if (dw.Length > 0) lw.Add(dw);
  2000. string price1 = GetPostString("price1");
  2001. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2002. string price2 = GetPostString("price2");
  2003. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2004. string orderState = GetPostString("orderState");
  2005. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2006. string sellermemo = GetPostString("seller_memo");
  2007. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2008. lw.Add(string.Format("UnusualTag > 0"));
  2009. lw.Add(string.Format("IsRefund<={0}", 1));
  2010. dStruct.Order = "pay_time desc";
  2011. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2012. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2013. writeGridDataTableJson(dStruct.TotalCount, dt);
  2014. }
  2015. public void set_erp_unusualtonomal()
  2016. {
  2017. if (UrlPostParmsCheck("ctid"))
  2018. {
  2019. string eid = GetPostString("ctid");
  2020. CeErpTradeCell entity = null;
  2021. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2022. if (entity != null)
  2023. {
  2024. entity.UnusualTag = -1;
  2025. entity.Update();
  2026. returnSuccessMsg("忽略成功!");
  2027. return;
  2028. }
  2029. returnErrorMsg("找不到记录");
  2030. }
  2031. }
  2032. public void ins_erp_unusualreason()
  2033. {
  2034. if (UrlPostParmsCheck("ctid"))
  2035. {
  2036. string eid = GetPostString("ctid");
  2037. CeErpTradeCell entity = null;
  2038. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2039. if (entity != null)
  2040. {
  2041. entity.MemoOpt = 4;
  2042. entity.UnusualCon = GetPostString("con");
  2043. entity.Update();
  2044. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2045. if (trade != null)
  2046. {
  2047. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2048. }
  2049. //查货是否超时
  2050. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2051. if (ceErpTradeCellExtend == null)
  2052. {
  2053. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2054. ceErpTradeCellExtend.ctid = entity.ctid;
  2055. }
  2056. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2057. {
  2058. ceErpTradeCellExtend.CheckOut += 1;
  2059. }
  2060. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2061. if (ceErpTradeCellExtend.ID > 0)
  2062. {
  2063. ceErpTradeCellExtend.Update();
  2064. }
  2065. else
  2066. {
  2067. ceErpTradeCellExtend.Create();
  2068. }
  2069. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2070. returnSuccessMsg("操作成功!");
  2071. return;
  2072. }
  2073. returnErrorMsg("找不到记录");
  2074. }
  2075. }
  2076. public void upd_erp_sampleorder()
  2077. {
  2078. if (UrlPostParmsCheck("ctid"))
  2079. {
  2080. string eid = GetPostString("ctid");
  2081. string[] eArr = eid.Split(',');
  2082. if (eArr.Length > 1)
  2083. {
  2084. List<string> eLst = new List<string>();
  2085. for (int i = 0; i < eArr.Length; i++)
  2086. {
  2087. eLst.Add("'" + eArr[i] + "'");
  2088. }
  2089. eid = string.Join(",", eLst.ToArray());
  2090. }
  2091. else
  2092. {
  2093. eid = "'" + eid + "'";
  2094. }
  2095. StringBuilder sql = new StringBuilder();
  2096. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2097. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2098. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2099. if (dt.Rows.Count > 0)
  2100. {
  2101. string errmsg = "";
  2102. foreach (DataRow dr in dt.Rows)
  2103. {
  2104. StringBuilder sqlsb = new StringBuilder();
  2105. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2106. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2107. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2108. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2109. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2110. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2111. {
  2112. continue;
  2113. }
  2114. else
  2115. {
  2116. string emsg = commonHelper.KeepChinese(apires);
  2117. errmsg += emsg;
  2118. }
  2119. }
  2120. if (errmsg.Length > 0)
  2121. {
  2122. returnErrorMsg(errmsg);
  2123. return;
  2124. }
  2125. returnSuccessMsg("操作成功");
  2126. return;
  2127. }
  2128. returnErrorMsg("找不到记录");
  2129. }
  2130. }
  2131. public void upd_erp_transcustomer()
  2132. {
  2133. if (UrlPostParmsCheck("ctid"))
  2134. {
  2135. string eid = GetPostString("ctid");
  2136. int userid = GetPostInt("CustomerUserId");
  2137. CeErpTradeCell entity = null;
  2138. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2139. if (entity != null)
  2140. {
  2141. //string[] mlist = entity.seller_memo.Split('-');
  2142. //string sql = "select * from view_erpuser where id=" + userid;
  2143. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2144. //if (dt != null && dt.Rows.Count > 0)
  2145. //{
  2146. // string nmemo = "";
  2147. // for(int i = 0; i < mlist.Length - 1; i++)
  2148. // {
  2149. // nmemo += mlist[i];
  2150. // nmemo += "-";
  2151. // }
  2152. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2153. // entity.seller_memo = nmemo;
  2154. //}
  2155. entity.CustomerUserId = userid;
  2156. entity.Update();
  2157. returnSuccessMsg("操作成功!");
  2158. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2159. return;
  2160. }
  2161. returnErrorMsg("找不到记录");
  2162. }
  2163. }
  2164. public void upd_erp_transdesigner()
  2165. {
  2166. if (UrlPostParmsCheck("ctid"))
  2167. {
  2168. string eids = GetPostString("ctid");
  2169. string[] ctidList = eids.Split(',');
  2170. int userid = GetPostInt("DesignUserId");
  2171. foreach (string ctid in ctidList)
  2172. {
  2173. CeErpTradeCell entity = null;
  2174. CeErpDesignerBill entitys = null;
  2175. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2176. entitys = CeErpDesignerBill.GetByTid(ctid);
  2177. if (entity != null)
  2178. {
  2179. if (entity.OrderState > 4)
  2180. {
  2181. continue;
  2182. }
  2183. //存在退款不能流转
  2184. if (entity.IsRefund > 0)
  2185. {
  2186. continue;
  2187. }
  2188. entity.DesignUserId = userid;
  2189. entity.WaitDesignTime = DateTime.Now;
  2190. entity.Update();
  2191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2192. }
  2193. }
  2194. returnSuccessMsg("操作成功!");
  2195. }
  2196. }
  2197. public void upd_erp_distributedesigner()
  2198. {
  2199. if (UrlPostParmsCheck("ctid"))
  2200. {
  2201. string eid = GetPostString("ctid");
  2202. int userid = GetPostInt("DesignUserId");
  2203. string[] idlist = eid.Split(',');
  2204. if (idlist.Length <= 0)
  2205. {
  2206. returnErrorMsg("订单不能为空");
  2207. return;
  2208. }
  2209. foreach (string ctid in idlist)
  2210. {
  2211. CeErpTradeCell entity = null;
  2212. CeErpDesignerBill entitys = null;
  2213. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2214. else continue;
  2215. if (entity != null)
  2216. {
  2217. if (userid == 2125 || userid == 3542)
  2218. { }
  2219. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2220. {
  2221. returnErrorMsg("金额错误的订单无法指派");
  2222. return;
  2223. }
  2224. if (entity.OrderState >= 5)
  2225. {
  2226. returnErrorMsg("已经设计完成无法指派");
  2227. return;
  2228. }
  2229. if (entity.OrderState == -1)
  2230. {
  2231. returnErrorMsg("审核中的订单无法指派");
  2232. return;
  2233. }
  2234. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2235. {
  2236. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2237. return;
  2238. }
  2239. //157赖橙帆 159林晨 73 静之颖
  2240. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2241. {
  2242. returnErrorMsg("指派设计共创无法再次指派!");
  2243. return;
  2244. }
  2245. entity.OrderState = 3;
  2246. if (entity.SupplierId == 0)
  2247. {
  2248. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2249. entity.SupplierId = suid;
  2250. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2251. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2252. }
  2253. if (userid == 2125 && entity.seller_memo != "")
  2254. {
  2255. apiDesign.API_GetPrintData_CreateOrder(entity);
  2256. }
  2257. if (userid == 3542 && entity.seller_memo != "")
  2258. {
  2259. string userPost = CurrentUser.UserPost.Post.Code;
  2260. if (CurrentUser.UserID == 73)
  2261. {
  2262. userPost = "SysAdmin";
  2263. }
  2264. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2265. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2266. if (response.msg != "设计共创:成功")
  2267. {
  2268. returnErrorMsg(response.msg);
  2269. return;
  2270. }
  2271. entity.DispatchSort = 2;
  2272. }
  2273. else
  2274. {
  2275. if (entity.DispatchSort == 2)
  2276. {
  2277. ApiVo apiVo = new ApiVo();
  2278. apiVo.actionName = "closeDesign";
  2279. apiVo.orderNumber = entity.ctid;
  2280. designHelper.API_WorkCore(apiVo);//closeDesign
  2281. }
  2282. entity.DispatchSort = 0;
  2283. }
  2284. entity.DesignUserId = userid;
  2285. entity.WaitDesignTime = DateTime.Now;
  2286. entity.UpdateTime = DateTime.Now;
  2287. entity.Update();
  2288. string name = commonHelper.getUserNameById(userid);
  2289. commonHelper.UpdateRelationOrder(entity.ctid);
  2290. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2291. }
  2292. }
  2293. returnSuccessMsg("操作成功!");
  2294. return;
  2295. }
  2296. }
  2297. public string getTidByCtid(string ctid)
  2298. {
  2299. string tid = "";
  2300. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2301. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2302. if (dataTable != null && dataTable.Rows.Count > 0)
  2303. {
  2304. tid = dataTable.Rows[0]["tid"].ToString();
  2305. }
  2306. return tid;
  2307. }
  2308. public List<string> getTidByCtidMore(string ctid)
  2309. {
  2310. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2311. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2312. List<string> list = new List<string>();
  2313. if (dataTable != null && dataTable.Rows.Count > 0)
  2314. {
  2315. foreach (DataRow item in dataTable.Rows)
  2316. {
  2317. list.Add("'" + item["tid"].ToString() + "'");
  2318. }
  2319. }
  2320. return list;
  2321. }
  2322. public List<string> getTidByCtidLike(string ctid)
  2323. {
  2324. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2325. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2326. List<string> list = new List<string>();
  2327. if (dataTable != null && dataTable.Rows.Count > 0)
  2328. {
  2329. foreach (DataRow item in dataTable.Rows)
  2330. {
  2331. list.Add("'" + item["tid"].ToString() + "'");
  2332. }
  2333. }
  2334. return list;
  2335. }
  2336. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2337. {
  2338. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2339. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2340. List<string> list = new List<string>();
  2341. if (dataTable != null && dataTable.Rows.Count > 0)
  2342. {
  2343. foreach (DataRow item in dataTable.Rows)
  2344. {
  2345. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2346. {
  2347. continue;
  2348. }
  2349. list.Add("'" + item["receiverId"].ToString() + "'");
  2350. }
  2351. }
  2352. return list;
  2353. }
  2354. public void get_erp_myorderlist()
  2355. {
  2356. DataStruct dStruct = GetPostStruct();
  2357. List<string> lw = new List<string>();
  2358. string tid = GetPostString("ctid");
  2359. if (tid.Length > 0)
  2360. {
  2361. string select_tid = getTidByCtid(tid);
  2362. lw.Add(string.Format("tid='{0}'", select_tid));
  2363. }
  2364. else
  2365. {
  2366. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2367. }
  2368. //12-1 修改
  2369. string urgent = GetPostString("urgent");
  2370. string back = GetPostString("back");
  2371. string offlineSearch = GetPostString("offlineSearch");
  2372. if (!string.IsNullOrWhiteSpace(urgent))
  2373. {
  2374. if (urgent.Equals("true"))
  2375. {
  2376. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2377. }
  2378. }
  2379. if (!string.IsNullOrWhiteSpace(back))
  2380. {
  2381. if (back.Equals("true"))
  2382. {
  2383. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2384. }
  2385. }
  2386. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2387. {
  2388. if (offlineSearch.Equals("true"))
  2389. {
  2390. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2391. }
  2392. }
  2393. //end
  2394. string shopname = GetPostString("shopname");
  2395. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2396. string buyernick = GetPostString("buyer_nick");
  2397. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2398. string design = GetPostString("design");
  2399. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2400. string orderState = GetPostString("orderState");
  2401. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2402. string sellermemo = GetPostString("seller_memo");
  2403. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2404. string date1 = GetPostString("date1");
  2405. string date2 = GetPostString("date2");
  2406. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2407. if (dw.Length > 0) lw.Add(dw);
  2408. string price1 = GetPostString("price1");
  2409. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2410. string price2 = GetPostString("price2");
  2411. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2412. string urgency = GetPostString("urgency");
  2413. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2414. string after = GetPostString("after");
  2415. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2416. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2417. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2418. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2420. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2421. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2422. if (dt != null && dt.Rows.Count > 0)
  2423. {
  2424. foreach (DataRow dr in dt.Rows)
  2425. {
  2426. try
  2427. {
  2428. // 对象操作
  2429. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2430. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2431. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2432. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2433. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2434. if (dStruct.PageSize != 100000)
  2435. {
  2436. if (dr["DispatchSort"].ToString() == "2")
  2437. {
  2438. dr["gongchuang"] = 200;
  2439. }
  2440. else if ("外协".Equals(dr["ToType"].ToString()))
  2441. {
  2442. dr["gongchuang"] = 200;
  2443. }
  2444. else if ("内部".Equals(dr["ToType"].ToString()))
  2445. {
  2446. dr["gongchuang"] = -1;
  2447. }
  2448. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2449. {
  2450. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2451. dr["gongchuang"] = response.code;
  2452. }
  2453. }
  2454. }
  2455. catch (NullReferenceException ex)
  2456. {
  2457. }
  2458. }
  2459. }
  2460. writeGridDataTableJson(dStruct.TotalCount, dt);
  2461. }
  2462. public void get_erp_myreturnorderlist()
  2463. {
  2464. DataStruct dStruct = GetPostStruct();
  2465. List<string> lw = new List<string>();
  2466. string tid = GetPostString("ctid");
  2467. if (tid.Length > 0)
  2468. {
  2469. string select_tid = getTidByCtid(tid);
  2470. lw.Add(string.Format("tid='{0}'", select_tid));
  2471. }
  2472. else
  2473. {
  2474. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2475. }
  2476. string shopname = GetPostString("shopname");
  2477. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2478. string buyernick = GetPostString("buyer_nick");
  2479. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2480. string design = GetPostString("design");
  2481. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2482. string orderState = GetPostString("orderState");
  2483. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2484. string sellermemo = GetPostString("seller_memo");
  2485. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2486. string date1 = GetPostString("date1");
  2487. string date2 = GetPostString("date2");
  2488. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2489. if (dw.Length > 0) lw.Add(dw);
  2490. string price1 = GetPostString("price1");
  2491. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2492. string price2 = GetPostString("price2");
  2493. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2494. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2495. {
  2496. lw.Add(string.Format("CusOrgID = 94"));
  2497. }
  2498. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2499. {
  2500. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2501. }
  2502. else
  2503. {
  2504. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2505. }
  2506. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2507. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2508. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2509. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2510. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2511. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2512. if (dt != null && dt.Rows.Count > 0)
  2513. {
  2514. foreach (DataRow dr in dt.Rows)
  2515. {
  2516. try
  2517. {
  2518. // 对象操作
  2519. if (dStruct.PageSize != 100000)
  2520. {
  2521. if (dr["DispatchSort"].ToString() == "2")
  2522. {
  2523. dr["gongchuang"] = 200;
  2524. }
  2525. else if ("外协".Equals(dr["ToType"].ToString()))
  2526. {
  2527. dr["gongchuang"] = 200;
  2528. }
  2529. else if ("内部".Equals(dr["ToType"].ToString()))
  2530. {
  2531. dr["gongchuang"] = -1;
  2532. }
  2533. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2534. {
  2535. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2536. dr["gongchuang"] = response.code;
  2537. }
  2538. }
  2539. }
  2540. catch (NullReferenceException ex)
  2541. {
  2542. // 处理空引用异常
  2543. }
  2544. }
  2545. }
  2546. writeGridDataTableJson(dStruct.TotalCount, dt);
  2547. }
  2548. public void get_erp_myorderlist_pregather()
  2549. {
  2550. string date1 = GetPostString("date1");
  2551. string date2 = GetPostString("date2");
  2552. int userId = CurrentUser.UserID; //客服id
  2553. string orderWhere = "";
  2554. List<string> lw = new List<string>();
  2555. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2556. if (dw.Length > 0) lw.Add(dw);
  2557. lw.Add(string.Format("CustomerUserId={0}", userId));
  2558. lw.Add(string.Format("OrderState<9"));
  2559. orderWhere = string.Join(" and ", lw.ToArray());
  2560. string orderWhere2 = "";
  2561. List<string> lw2 = new List<string>();
  2562. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2563. if (dw2.Length > 0) lw2.Add(dw2);
  2564. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2565. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2566. string sql = string.Format("select *" +
  2567. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2568. "left join(select CustomerUserId, count(ctid) as dCount from View_ErpTradeCell where OrderState = 6 and " + orderWhere2 + " group by CustomerUserId) b on a.CustomerUserId = b.CustomerUserId " +
  2569. "left join(select CustomerUserId, count(ctid) as jCount from View_ErpTradeCell where IsUrgency = 1 and " + orderWhere + " group by CustomerUserId) c on a.CustomerUserId = c.CustomerUserId " +
  2570. "left join(select CustomerUserId, count(ctid) as sCount from View_ErpTradeCell where AfterSaleState > 0 and CHARINDEX(','+CONVERT(varchar," + userId + ")+'_k,',','+ResponsibleUserId+',')>0 and " + orderWhere + " group by CustomerUserId) d on a.CustomerUserId = d.CustomerUserId");
  2571. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2572. //writeGridDataTableJson(dt.Rows.Count, dt);
  2573. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2574. }
  2575. public void upd_erp_publishorder()
  2576. {
  2577. if (UrlPostParmsCheck("ctid"))
  2578. {
  2579. string eid = GetPostString("ctid");
  2580. CeErpTradeCell entity = null;
  2581. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2582. if (entity != null)
  2583. {
  2584. entity.OrderState = 0; //发布后,变为待抢单
  2585. entity.Update();
  2586. commonHelper.UpdateRelationOrder(entity.ctid);
  2587. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2588. returnSuccessMsg("发布成功!");
  2589. return;
  2590. }
  2591. returnErrorMsg("找不到记录");
  2592. }
  2593. }
  2594. public void get_erp_my_tiporder()
  2595. {
  2596. StringBuilder sql = new StringBuilder();
  2597. int userId = 0;
  2598. if (CurrentUser != null) userId = CurrentUser.UserID;
  2599. string posCode = CurrentUser.UserPost.Post.Code;
  2600. string isTipedAfterSaleVerify = GetPostString("af");
  2601. DataTable dt = new DataTable();
  2602. if (posCode != "Supplier")
  2603. {
  2604. if (posCode == "CustomerService" || posCode == "Director")
  2605. {
  2606. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2607. }
  2608. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2609. {
  2610. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2611. }
  2612. else
  2613. {
  2614. string teamIds = CurrentUser.User.TeamIds;
  2615. if (teamIds == "")
  2616. {
  2617. teamIds = "0";
  2618. }
  2619. sql.AppendFormat("select * from ce_erptradecell where (DesignUserId={0} or DesignUserId in (select ID from view_erpuser where OnDuty=0 and ID in ({1}))) and OrderState in (3,4) and IsReadTag>0 ", userId, teamIds);
  2620. }
  2621. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2622. }
  2623. if (dt.Rows.Count <= 0)
  2624. {
  2625. string key = "aftersale_order_" + userId;
  2626. if (RedisHelper.HasKey(key))
  2627. {
  2628. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2629. dt.Columns.Add("ctid", typeof(string));
  2630. dt.Columns.Add("IsReadTag", typeof(int));
  2631. foreach (var i in list)
  2632. {
  2633. DataRow data = dt.NewRow();
  2634. data["ctid"] = i;
  2635. data["IsReadTag"] = 4;
  2636. dt.Rows.Add(data);
  2637. }
  2638. RedisHelper.StringDelete(key);
  2639. }
  2640. }
  2641. if (dt.Rows.Count <= 0)
  2642. {
  2643. sql = new StringBuilder();
  2644. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2645. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2646. }
  2647. if (posCode == "Supplier")
  2648. {
  2649. string ids = CurrentUser.User.pemVend;
  2650. if (ids != null && ids.Length > 0)
  2651. {
  2652. string[] ids_list = ids.Split(',');
  2653. foreach (var item in ids_list)
  2654. {
  2655. string key = "return_order_" + item;
  2656. if (RedisHelper.HasKey(key))
  2657. {
  2658. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2659. dt.Columns.Add("ctid", typeof(string));
  2660. dt.Columns.Add("IsReadTag", typeof(int));
  2661. foreach (var i in list)
  2662. {
  2663. DataRow data = dt.NewRow();
  2664. data["ctid"] = i;
  2665. data["IsReadTag"] = 1;
  2666. dt.Rows.Add(data);
  2667. }
  2668. RedisHelper.StringDelete(key);
  2669. }
  2670. }
  2671. }
  2672. if (dt.Rows.Count <= 0)
  2673. {
  2674. sql = new StringBuilder();
  2675. sql.AppendFormat("select MemoOpt,SupplierId,ctid from ce_erptradecell where SupplierId in ({0}) and MemoOpt=3 and DATEDIFF(MINUTE,CheckOrderTime,GETDATE())<=3", CurrentUser.User.pemVend);
  2676. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2677. }
  2678. }
  2679. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2680. }
  2681. public void reset_erp_tiporder()
  2682. {
  2683. string ids = GetPostString("ids");
  2684. string[] ctidList = ids.Split(',');
  2685. foreach (string ctid in ctidList)
  2686. {
  2687. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2688. if (enty != null)
  2689. {
  2690. enty.IsReadTag = 0;
  2691. enty.Update();
  2692. }
  2693. }
  2694. returnSuccessMsg("成功!");
  2695. return;
  2696. }
  2697. public void get_erp_designlist()
  2698. {
  2699. DataStruct dStruct = GetPostStruct();
  2700. List<string> lw = new List<string>();
  2701. string tid = GetPostString("ctid");
  2702. if (tid.Length > 0)
  2703. {
  2704. string select_tid = getTidByCtid(tid);
  2705. lw.Add(string.Format("tid='{0}'", select_tid));
  2706. }
  2707. string shopname = GetPostString("shopname");
  2708. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2709. string buyernick = GetPostString("buyer_nick");
  2710. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2711. string customer = GetPostString("customer");
  2712. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2713. string design = GetPostString("design");
  2714. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2715. string orderState = GetPostString("orderState");
  2716. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2717. lw.Add(string.Format("OrderState<6"));
  2718. string address = GetPostString("address");
  2719. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2720. string sellermemo = GetPostString("seller_memo");
  2721. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2722. string date1 = GetPostString("date1");
  2723. string date2 = GetPostString("date2");
  2724. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2725. if (dw.Length > 0) lw.Add(dw);
  2726. string apdate1 = GetPostString("apdate1");
  2727. string apdate2 = GetPostString("apdate2");
  2728. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2729. if (dwap.Length > 0) lw.Add(dwap);
  2730. string price1 = GetPostString("price1");
  2731. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2732. string price2 = GetPostString("price2");
  2733. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2734. string designTime = GetPostString("designtime");
  2735. if (designTime.Length > 0)
  2736. {
  2737. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2738. }
  2739. string usershop = CurrentUser.User.pemShop;
  2740. if (usershop.Length > 0)
  2741. {
  2742. lw.Add(string.Format("shopId in ({0})", usershop));
  2743. }
  2744. int myOrgid = CurrentUser.UserPost.OrgID;
  2745. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2746. if (myOrgCode.IndexOf("Designer") != -1)
  2747. {
  2748. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2749. {
  2750. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2751. }
  2752. else
  2753. {
  2754. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2755. }
  2756. }
  2757. else
  2758. {
  2759. string orgId = GetPostString("designerhd");
  2760. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2761. }
  2762. if (tid.Length > 0 || buyernick.Length > 0)
  2763. {
  2764. lw.Add(string.Format("OrderState >= 3"));
  2765. }
  2766. else
  2767. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2768. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2769. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2771. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2772. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2773. if (dt != null && dt.Rows.Count > 0)
  2774. {
  2775. foreach (DataRow dr in dt.Rows)
  2776. {
  2777. try
  2778. {
  2779. // 对象操作
  2780. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2781. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2782. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2783. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2784. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2785. if (dStruct.PageSize != 100000)
  2786. {
  2787. if (dr["DispatchSort"].ToString() == "2")
  2788. {
  2789. dr["gongchuang"] = 200;
  2790. }
  2791. else if ("外协".Equals(dr["ToType"].ToString()))
  2792. {
  2793. dr["gongchuang"] = 200;
  2794. }
  2795. else if ("内部".Equals(dr["ToType"].ToString()))
  2796. {
  2797. dr["gongchuang"] = -1;
  2798. }
  2799. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2800. {
  2801. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2802. dr["gongchuang"] = response.code;
  2803. }
  2804. }
  2805. }
  2806. catch (NullReferenceException ex)
  2807. {
  2808. }
  2809. }
  2810. }
  2811. writeGridDataTableJson(dStruct.TotalCount, dt);
  2812. }
  2813. public void get_erp_mydesignlist()
  2814. {
  2815. DataStruct dStruct = GetPostStruct();
  2816. List<string> lw = new List<string>();
  2817. string tid = GetPostString("ctid");
  2818. if (tid.Length > 0)
  2819. {
  2820. string select_tid = getTidByCtid(tid);
  2821. lw.Add(string.Format("tid='{0}'", select_tid));
  2822. }
  2823. string shopname = GetPostString("shopname");
  2824. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2825. string buyernick = GetPostString("buyer_nick");
  2826. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2827. string customer = GetPostString("customer");
  2828. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2829. string orderState = GetPostString("orderState");
  2830. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2831. //lw.Add(string.Format("OrderState<6"));
  2832. string date1 = GetPostString("date1");
  2833. string date2 = GetPostString("date2");
  2834. string dw = GetDateWhere("pay_time", date1, date2);
  2835. if (dw.Length > 0) lw.Add(dw);
  2836. string apdate1 = GetPostString("apdate1");
  2837. string apdate2 = GetPostString("apdate2");
  2838. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2839. if (dwap.Length > 0) lw.Add(dwap);
  2840. string price1 = GetPostString("price1");
  2841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2842. string price2 = GetPostString("price2");
  2843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2844. string olddownload = GetPostString("olddown");
  2845. if (olddownload == "1")
  2846. {
  2847. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2848. }
  2849. else if (olddownload == "2")
  2850. {
  2851. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2852. }
  2853. string sellermemo = GetPostString("seller_memo");
  2854. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2855. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2856. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2857. {
  2858. if (CurrentUser.User.TeamIds.Length > 0)
  2859. {
  2860. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2861. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2862. else
  2863. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2864. }
  2865. else
  2866. {
  2867. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2868. }
  2869. }
  2870. if (tid.Length <= 0)
  2871. {
  2872. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2873. }
  2874. lw.Add(string.Format("IsReturn!=3"));
  2875. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2876. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2877. string teamids = CurrentUser.User.TeamIds.ToString();
  2878. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2879. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2880. if (dt != null && dt.Rows.Count > 0)
  2881. {
  2882. foreach (DataRow dr in dt.Rows)
  2883. {
  2884. try
  2885. {
  2886. // 对象操作
  2887. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2888. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2889. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2890. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2891. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2892. if (dStruct.PageSize != 100000)
  2893. {
  2894. if (dr["DispatchSort"].ToString() == "2")
  2895. {
  2896. dr["gongchuang"] = 200;
  2897. }
  2898. else if ("外协".Equals(dr["ToType"].ToString()))
  2899. {
  2900. dr["gongchuang"] = 200;
  2901. }
  2902. else if ("内部".Equals(dr["ToType"].ToString()))
  2903. {
  2904. dr["gongchuang"] = -1;
  2905. }
  2906. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2907. {
  2908. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2909. dr["gongchuang"] = response.code;
  2910. }
  2911. }
  2912. }
  2913. catch (NullReferenceException ex)
  2914. {
  2915. }
  2916. }
  2917. }
  2918. writeGridDataTableJson(dStruct.TotalCount, dt);
  2919. }
  2920. public void set_erp_startdesign()
  2921. {
  2922. if (UrlPostParmsCheck("ctid"))
  2923. {
  2924. string eid = GetPostString("ctid");
  2925. CeErpTradeCell entity = null;
  2926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2927. if (entity != null)
  2928. {
  2929. if (entity.OrderState != 3)
  2930. {
  2931. returnErrorMsg("请刷新,订单已经设计了");
  2932. return;
  2933. }
  2934. entity.StartDesignTime = DateTime.Now;
  2935. entity.OrderState = 4;
  2936. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2937. {
  2938. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2939. entity.SupplierId = suid;
  2940. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2941. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2942. }
  2943. entity.UpdateTime = DateTime.Now;
  2944. //entity.MakeSupplier = suname;
  2945. entity.Update();
  2946. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2948. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2949. commonHelper.getCytPrice(entity);
  2950. returnSuccessMsg("操作成功!");
  2951. return;
  2952. }
  2953. returnErrorMsg("找不到记录");
  2954. }
  2955. }
  2956. public void ins_erp_designselfmemo()
  2957. {
  2958. if (UrlPostParmsCheck("ctid"))
  2959. {
  2960. string eid = GetPostString("ctid");
  2961. string con = GetPostString("con");
  2962. CeErpTradeCell entity = null;
  2963. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2964. if (entity != null)
  2965. {
  2966. entity.DesignSelfMemo = con;
  2967. entity.Update();
  2968. returnSuccessMsg("操作成功!");
  2969. return;
  2970. }
  2971. returnErrorMsg("找不到记录");
  2972. }
  2973. }
  2974. public void ins_erp_designprice()
  2975. {
  2976. if (UrlPostParmsCheck("ctid"))
  2977. {
  2978. string eid = GetPostString("ctid");
  2979. int uid = CurrentUser.UserID;
  2980. string userName = CurrentUser.UserName;
  2981. CeErpTradeCell entity = null;
  2982. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2983. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2984. if (entitys == null)
  2985. {
  2986. entitys = new CeErpDesignerBill();
  2987. }
  2988. if (entity != null)
  2989. {
  2990. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2991. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2992. entity.StartDesignTime = DateTime.Now;
  2993. entity.OrderState = 4;
  2994. string suname = "";
  2995. if (entity.SupplierId == 0)
  2996. {
  2997. int sid = commonHelper.autoDistributeToSupplier(entity);
  2998. entity.SupplierId = sid;
  2999. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3000. }
  3001. entity.Update();
  3002. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3003. if (ceErpUserPost != null)
  3004. {
  3005. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3006. if (ceErpPost != null)
  3007. {
  3008. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3009. {
  3010. entitys.tid = entity.ctid;
  3011. entitys.oid = entity.tid;
  3012. entitys.uid = uid;
  3013. entitys.userName = userName;
  3014. entitys.designerType = 1;
  3015. entitys.designerTypeText = "内部设计师";
  3016. entitys.price = Convert.ToDouble(GetPostString("price"));
  3017. entitys.designNum = GetPostInt("designNum");
  3018. entitys.modifyNum = GetPostInt("modifyNum");
  3019. entitys.designSize = GetPostString("designSize");
  3020. entitys.modifySize = GetPostString("modifySize");
  3021. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3022. {
  3023. entitys.create_time = DateTime.Now;
  3024. entitys.create_u_id = uid;
  3025. entitys.create_u_name = userName;
  3026. entitys.Save();
  3027. }
  3028. else
  3029. {
  3030. entitys.update_time = DateTime.Now;
  3031. entitys.update_u_id = uid;
  3032. entitys.update_u_name = userName;
  3033. entitys.Update();
  3034. }
  3035. }
  3036. }
  3037. }
  3038. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3040. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3041. if (suname != "")
  3042. {
  3043. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3044. }
  3045. commonHelper.getCytPrice(entity);
  3046. returnSuccessMsg("操作成功!");
  3047. return;
  3048. }
  3049. returnErrorMsg("找不到记录");
  3050. }
  3051. }
  3052. public void upload_erp_filecomplete()
  3053. {
  3054. if (UrlPostParmsCheck("ctid"))
  3055. {
  3056. string eid = GetPostString("ctid");
  3057. CeErpTradeCell entity = null;
  3058. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3059. if (entity != null)
  3060. {
  3061. entity.OrderState = 5; //设计完成
  3062. entity.Update();
  3063. returnSuccessMsg(eid + "上传成功,设计完成!");
  3064. return;
  3065. }
  3066. returnErrorMsg("找不到订单记录");
  3067. }
  3068. }
  3069. public void get_erp_designovertimelist()
  3070. {
  3071. DataStruct dStruct = GetPostStruct();
  3072. List<string> lw = new List<string>();
  3073. string tid = GetPostString("ctid");
  3074. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3075. string shopname = GetPostString("shopname");
  3076. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3077. string buyernick = GetPostString("buyer_nick");
  3078. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3079. string ResponsibleMan = GetPostString("responsible");
  3080. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3081. string date1 = GetPostString("date1");
  3082. string date2 = GetPostString("date2");
  3083. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3084. if (dw.Length > 0) lw.Add(dw);
  3085. string price1 = GetPostString("price1");
  3086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3087. string price2 = GetPostString("price2");
  3088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3089. string orderState = GetPostString("orderState");
  3090. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3091. string sellermemo = GetPostString("seller_memo");
  3092. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3093. lw.Add(string.Format("UnusualTag=3"));
  3094. lw.Add(string.Format("IsRefund<={0}", 1));
  3095. dStruct.Order = "WaitDesignTime desc";
  3096. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3097. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3098. writeGridDataTableJson(dStruct.TotalCount, dt);
  3099. }
  3100. //设计管理 获取抢单大厅列表
  3101. public void get_erp_grabinglist()
  3102. {
  3103. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3104. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3105. bool oldOrder = false;
  3106. if (org != null)
  3107. {
  3108. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3109. }
  3110. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3111. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3112. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3113. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3114. //先处理订单数据
  3115. if (dt.Rows.Count > 0)
  3116. {
  3117. Dictionary<string, int> design = null;
  3118. int count = 0;
  3119. foreach (DataRow row in dt.Rows)
  3120. {
  3121. if (map.ContainsKey(row["ShopId"].ToString()))
  3122. {
  3123. map.TryGetValue(row["ShopId"].ToString(), out design);
  3124. }
  3125. else
  3126. {
  3127. design = new Dictionary<string, int>();
  3128. }
  3129. if (design.ContainsKey(row["ProductId"].ToString()))
  3130. {
  3131. design.TryGetValue(row["ProductId"].ToString(), out count);
  3132. }
  3133. count++;
  3134. design[row["ProductId"].ToString()] = count;
  3135. map[row["ShopId"].ToString()] = design;
  3136. }
  3137. }
  3138. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3139. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3140. //把店铺排序和技能排序分类
  3141. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3142. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3143. if (design_dt.Rows.Count > 0)
  3144. {
  3145. Dictionary<string, string> design = null;
  3146. List<string> shopIds = null;
  3147. foreach (DataRow row in design_dt.Rows)
  3148. {
  3149. if ("0".Equals(row["designId"].ToString()))
  3150. {
  3151. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3152. {
  3153. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3154. }
  3155. else
  3156. {
  3157. shopIds = new List<string>();
  3158. }
  3159. shopIds.Add(row["shopId"].ToString());
  3160. shop_orders[row["orders"].ToString()] = shopIds;
  3161. }
  3162. else
  3163. {
  3164. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3165. {
  3166. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3167. }
  3168. else
  3169. {
  3170. design = new Dictionary<string, string>();
  3171. }
  3172. design[row["orders"].ToString()] = row["designId"].ToString();
  3173. design_orders[row["shopId"].ToString()] = design;
  3174. }
  3175. }
  3176. //处理成key value后根据key排序
  3177. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3178. foreach (List<string> val in shop_orders.Values)
  3179. {
  3180. if (val != null)
  3181. {
  3182. foreach (string key in val)
  3183. {
  3184. if (design_orders.ContainsKey(key.ToString()))
  3185. {
  3186. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3187. }
  3188. }
  3189. }
  3190. }
  3191. }
  3192. //校验哪个优先级有订单
  3193. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3194. foreach (string key in shop_orders.Keys)
  3195. {
  3196. List<string> ids = null;
  3197. shop_orders.TryGetValue(key, out ids);
  3198. //id为shopid
  3199. foreach (string id in ids)
  3200. {
  3201. Dictionary<string, int> list = null;
  3202. Dictionary<string, string> desing = null;
  3203. map.TryGetValue(id, out list);
  3204. design_orders.TryGetValue(id, out desing);
  3205. if (list != null && desing != null)
  3206. {
  3207. foreach (var item in desing)
  3208. {
  3209. int count = 0;
  3210. if (list.ContainsKey(item.Value))
  3211. {
  3212. list.TryGetValue(item.Value, out count);
  3213. if (count > 0)
  3214. {
  3215. designIds[id] = item.Value;
  3216. break;
  3217. }
  3218. }
  3219. }
  3220. }
  3221. }
  3222. if (designIds.Count > 0)
  3223. {
  3224. break;
  3225. }
  3226. }
  3227. DataTable table = new DataTable();
  3228. table.Columns.Add("tid", typeof(string));
  3229. table.Columns.Add("ctid", typeof(string));
  3230. table.Columns.Add("seller_nick", typeof(string));
  3231. table.Columns.Add("productName", typeof(string));
  3232. table.Columns.Add("pay_time", typeof(string));
  3233. table.Columns.Add("seller_memo", typeof(string));
  3234. if (designIds.Count > 0)
  3235. {
  3236. string shopId = "";
  3237. string productId = "";
  3238. foreach (var designInfo in designIds)
  3239. {
  3240. shopId = designInfo.Key;
  3241. productId = designInfo.Value;
  3242. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3243. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3244. if (dt.Rows.Count > 0)
  3245. {
  3246. foreach (DataRow row in dt.Rows)
  3247. {
  3248. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3249. {
  3250. DataRow data = table.NewRow();
  3251. data["ctid"] = row["ctid"].ToString();
  3252. data["tid"] = row["tid"].ToString();
  3253. data["seller_nick"] = ceErpShop.ShopName;
  3254. data["pay_time"] = row["pay_time"].ToString();
  3255. data["seller_memo"] = row["seller_memo"].ToString();
  3256. data["productName"] = ceErpProduct.PType;
  3257. table.Rows.Add(data);
  3258. }
  3259. }
  3260. }
  3261. }
  3262. }
  3263. writeGridDataTableJson(table.Rows.Count, table);
  3264. }
  3265. private object rushLockObject = new object();
  3266. public void set_erp_grabingorder()
  3267. {
  3268. if (UrlPostParmsCheck("ctid"))
  3269. {
  3270. int total = CurrentUser.User.Person.Total;
  3271. int userId = CurrentUser.User.ID;
  3272. int noFinish = CurrentUser.User.Person.NoFinish;
  3273. int finalization = CurrentUser.User.Person.Finalization;
  3274. string eids = GetPostString("ctid");
  3275. string key = "RushKey_" + userId;
  3276. int count = 0;
  3277. if (erpRedis.RedisHelper.KeyExists(key))
  3278. {
  3279. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3280. if (redisCount != null)
  3281. {
  3282. count = Convert.ToInt32(redisCount);
  3283. }
  3284. }
  3285. if (count >= total)
  3286. {
  3287. returnErrorMsg("半小时内已经抢" + total + "单");
  3288. return;
  3289. }
  3290. string[] ctidlist = eids.Split(',');
  3291. if (count + ctidlist.Length > total)
  3292. {
  3293. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3294. return;
  3295. }
  3296. int itag = 0;
  3297. lock (rushLockObject)
  3298. {
  3299. if (ctidlist.Length > 0)
  3300. {
  3301. string[] dtList = new string[ctidlist.Length];
  3302. for (int i = 0; i < ctidlist.Length; i++)
  3303. {
  3304. dtList[i] = "'" + ctidlist[i] + "'";
  3305. }
  3306. string sql_user = string.Format("select OrderState from CE_ErpTradeCell where DesignUserId = {0} and WaitDesignTime BETWEEN '{1}' and '{2}'", userId, DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  3307. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3308. if (dt_user.Rows.Count > 0)
  3309. {
  3310. int doing = 0;//未定稿
  3311. int finish = 0;//已完成
  3312. foreach (DataRow dr in dt_user.Rows)
  3313. {
  3314. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3315. {
  3316. doing++;
  3317. }
  3318. else
  3319. {
  3320. finish++;
  3321. }
  3322. }
  3323. if (doing >= noFinish)
  3324. {
  3325. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3326. return;
  3327. }
  3328. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3329. {
  3330. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3331. return;
  3332. }
  3333. }
  3334. //校验选择单子状态
  3335. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3337. if (dt.Rows.Count > 0)
  3338. {
  3339. List<string> list = new List<string>();
  3340. foreach (DataRow dr in dt.Rows)
  3341. {
  3342. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3343. {
  3344. list.Add(dr["ctid"].ToString());
  3345. }
  3346. }
  3347. if (list.Count > 0)
  3348. {
  3349. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3350. return;
  3351. }
  3352. }
  3353. foreach (string ctid in ctidlist)
  3354. {
  3355. CeErpTradeCell entity = null;
  3356. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3357. if (entity != null)
  3358. {
  3359. entity.OrderState = 3;
  3360. entity.DesignUserId = CurrentUser.UserID;
  3361. entity.WaitDesignTime = DateTime.Now;
  3362. entity.StartDesignTime = DateTime.Now;
  3363. entity.Update();
  3364. commonHelper.UpdateRelationOrder(entity.ctid);
  3365. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3366. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3367. itag++;
  3368. }
  3369. }
  3370. }
  3371. }
  3372. count += ctidlist.Length;
  3373. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3374. if (itag == 0)
  3375. returnErrorMsg("没有找到相关订单");
  3376. else
  3377. returnSuccessMsg("抢单成功!");
  3378. return;
  3379. }
  3380. }
  3381. public void get_erp_waitorderlist()
  3382. {
  3383. DataStruct dStruct = GetPostStruct();
  3384. List<string> lw = new List<string>();
  3385. string tid = GetPostString("ctid");
  3386. if (tid.Length > 0)
  3387. {
  3388. string select_tid = getTidByCtid(tid);
  3389. lw.Add(string.Format("tid='{0}'", select_tid));
  3390. }
  3391. string shopname = GetPostString("shopname");
  3392. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3393. string buyernick = GetPostString("buyer_nick");
  3394. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3395. string customer = GetPostString("customer");
  3396. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3397. string design = GetPostString("design");
  3398. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3399. string orderState = GetPostString("orderState");
  3400. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3401. string supplier = GetPostString("supplier");
  3402. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3403. string sellermemo = GetPostString("seller_memo");
  3404. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3405. string otherMemo = GetPostString("otherMemo");
  3406. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3407. string address = GetPostString("address");
  3408. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  3409. string date1 = GetPostString("date1");
  3410. string date2 = GetPostString("date2");
  3411. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3412. if (dw.Length > 0) lw.Add(dw);
  3413. string price1 = GetPostString("price1");
  3414. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3415. string price2 = GetPostString("price2");
  3416. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3417. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3418. lw.Add(string.Format("IsSample != 2 "));
  3419. lw.Add(string.Format("OrderState = 5 "));
  3420. lw.Add(string.Format("IsRefund<={0}", 1));
  3421. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3422. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3423. string pagesize = GetPostString("pagesize");
  3424. if (pagesize != null)
  3425. {
  3426. dStruct.PageSize = 200;
  3427. }
  3428. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3429. List<string> tids = new List<string>();
  3430. if (dt != null)
  3431. {
  3432. dt.Columns.Add("compenPrice", typeof(double));
  3433. foreach (DataRow dr in dt.Rows)
  3434. {
  3435. if (Convert.IsDBNull(dr["compenPrice"]))
  3436. {
  3437. dr["compenPrice"] = 0;
  3438. }
  3439. tids.Add("'" + dr["tid"].ToString() + "'");
  3440. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  3441. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3442. {
  3443. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3444. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3445. entity.SupplierId = suid;
  3446. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3447. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3448. entity.Update();
  3449. }
  3450. }
  3451. }
  3452. if (tids.Count > 0)
  3453. {
  3454. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3455. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3456. if (dt_price != null && dt_price.Rows.Count > 0)
  3457. {
  3458. foreach (DataRow dr in dt_price.Rows)
  3459. {
  3460. foreach (DataRow row in dt.Rows)
  3461. {
  3462. if (row["tid"].Equals(dr["ptid"]))
  3463. {
  3464. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3465. break;
  3466. }
  3467. }
  3468. }
  3469. }
  3470. }
  3471. writeGridDataTableJson(dStruct.TotalCount, dt);
  3472. }
  3473. public void get_erp_supplierwaitorderlist()
  3474. {
  3475. DataStruct dStruct = GetPostStruct();
  3476. List<string> lw = new List<string>();
  3477. string tid = GetPostString("ctid");
  3478. if (tid.Length > 0)
  3479. {
  3480. string select_tid = getTidByCtid(tid);
  3481. lw.Add(string.Format("tid='{0}'", select_tid));
  3482. }
  3483. string shopname = GetPostString("shopname");
  3484. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3485. string sellermemo = GetPostString("seller_memo");
  3486. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3487. string date1 = GetPostString("date1");
  3488. string date2 = GetPostString("date2");
  3489. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3490. if (dw.Length > 0) lw.Add(dw);
  3491. lw.Add(string.Format("OrderState = 5 "));
  3492. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3493. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3494. {
  3495. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3496. }
  3497. string supplier = GetPostString("supplier");
  3498. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3499. {
  3500. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3501. }
  3502. lw.Add(string.Format("IsRefund<={0}", 1));
  3503. dStruct.Order = "FinishDesignTime desc";
  3504. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3505. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3506. if (dt != null)
  3507. {
  3508. foreach (DataRow dr in dt.Rows)
  3509. {
  3510. 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();
  3511. }
  3512. }
  3513. writeGridDataTableJson(dStruct.TotalCount, dt);
  3514. }
  3515. public void upd_erp_verifytosupplier()
  3516. {
  3517. if (UrlPostParmsCheck("ctid"))
  3518. {
  3519. string eids = GetPostString("ctid");
  3520. CeErpTradeCell entity = null;
  3521. string[] eidsList = eids.Split(',');
  3522. if (eidsList.Length <= 0)
  3523. {
  3524. returnErrorMsg("订单号不能空");
  3525. return;
  3526. }
  3527. List<string> tLst = new List<string>();
  3528. foreach (string ctidstr in eidsList)
  3529. {
  3530. tLst.Add("'" + ctidstr + "'");
  3531. CeErpDataSendOrderInfo.createObject(ctidstr);
  3532. }
  3533. string needtids = string.Join(",", tLst.ToArray());
  3534. StringBuilder sql = new StringBuilder();
  3535. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3536. 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);
  3537. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3538. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3539. returnSuccessMsg("操作成功!");
  3540. return;
  3541. /**foreach (string ctidstr in eidsList)
  3542. {
  3543. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3544. if (entity != null)
  3545. {
  3546. if (entity.SupplierId == 0)
  3547. {
  3548. continue;
  3549. }
  3550. entity.IsVerifyToSupplier = true;
  3551. if (entity.IsReturn == 1) //1是供应商打回
  3552. {
  3553. entity.IsReturn = 0;
  3554. }
  3555. entity.FinishPlaceTime = DateTime.Now;
  3556. entity.PlaceUserId = CurrentUser.UserID;
  3557. entity.Update();
  3558. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3559. }
  3560. }
  3561. returnSuccessMsg("操作成功!");
  3562. return;**/
  3563. }
  3564. }
  3565. public void upd_erp_supplierback()
  3566. {
  3567. if (UrlPostParmsCheck("ctid"))
  3568. {
  3569. string eid = GetPostString("ctid");
  3570. string reason = GetPostString("returnreason");
  3571. CeErpTradeCell entity = null;
  3572. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3573. if (entity != null)
  3574. {
  3575. string message = "操作成功!";
  3576. string isDown = "";
  3577. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3578. {
  3579. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3580. isDown = "被点击下载";
  3581. }
  3582. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3583. {
  3584. string key = "return_order_" + entity.SupplierId;
  3585. List<string> list = new List<string>();
  3586. if (RedisHelper.HasKey(key))
  3587. {
  3588. object data = RedisHelper.StringGet(key);
  3589. list = Convert.ToString(data).Split(',').ToList();
  3590. }
  3591. list.Add(eid);
  3592. RedisHelper.StringSet(key, string.Join(",", list));
  3593. }
  3594. entity.IsVerifyToSupplier = false;
  3595. entity.IsReturn = 1;
  3596. entity.IsHaveNewOrder = 0;
  3597. entity.ReturnTime = DateTime.Now;
  3598. entity.ReturnReason = reason;
  3599. if (entity.OrderState == 6)
  3600. {
  3601. entity.OrderState = 5;
  3602. }
  3603. entity.Update();
  3604. CeErpSukuraData.createInfo(entity.ctid, 5);
  3605. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3606. returnSuccessMsg(message);
  3607. return;
  3608. }
  3609. returnErrorMsg("找不到订单记录");
  3610. }
  3611. }
  3612. public void upd_erp_toaftersaleorder()
  3613. {
  3614. if (UrlPostParmsCheck("ctid"))
  3615. {
  3616. string eid = GetPostString("ctid");
  3617. string reason = GetPostString("returnreason");
  3618. CeErpTradeCell entity = null;
  3619. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3620. if (entity != null)
  3621. {
  3622. if (entity.isAfterSaleOrder != 1)
  3623. {
  3624. returnErrorMsg("带S的售后单才能打回给售后");
  3625. return;
  3626. }
  3627. if (entity.OrderState >= 5)
  3628. {
  3629. returnErrorMsg("已经设计完成了不能打回给售后");
  3630. return;
  3631. }
  3632. entity.OrderState = 0;
  3633. entity.IsReturn = 3;
  3634. entity.ReturnTime = DateTime.Now;
  3635. entity.UpdateTime = DateTime.Now;
  3636. entity.ReturnReason = reason;
  3637. entity.Update();
  3638. CeErpSukuraData.createInfo(entity.ctid, 5);
  3639. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3640. returnSuccessMsg("操作成功!");
  3641. return;
  3642. }
  3643. returnErrorMsg("找不到订单记录");
  3644. }
  3645. }
  3646. public void upd_erp_aftersaletodesign()
  3647. {
  3648. if (UrlPostParmsCheck("ctid"))
  3649. {
  3650. string eid = GetPostString("ctid");
  3651. CeErpTradeCell entity = null;
  3652. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3653. if (entity != null)
  3654. {
  3655. entity.OrderState = 3;
  3656. entity.IsReturn = 0;
  3657. entity.UpdateTime = DateTime.Now;
  3658. entity.Update();
  3659. CeErpSukuraData.createInfo(entity.ctid, 5);
  3660. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3661. returnSuccessMsg("操作成功!");
  3662. return;
  3663. }
  3664. returnErrorMsg("找不到订单记录");
  3665. }
  3666. }
  3667. public void assign_erp_supplier()
  3668. {
  3669. if (UrlPostParmsCheck("ctid"))
  3670. {
  3671. string eids = GetPostString("ctid");
  3672. int sid = GetPostInt("SupplierName");
  3673. string fromTag = GetPostString("tag");
  3674. string[] eidList = eids.Split(',');
  3675. if (eidList.Length <= 0)
  3676. {
  3677. returnErrorMsg("指派不能为空");
  3678. return;
  3679. }
  3680. string errMsg = "";
  3681. string suname = commonHelper.getSupplierNameById(sid);
  3682. foreach (string ctid in eidList)
  3683. {
  3684. CeErpTradeCell entity = null;
  3685. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3686. if (entity != null)
  3687. {
  3688. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3689. {
  3690. errMsg += (ctid + "指派失败!!!");
  3691. continue;
  3692. }
  3693. entity.SupplierId = sid;
  3694. entity.Update();
  3695. commonHelper.UpdateRelationOrder(entity.ctid);
  3696. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3697. if (entity.OrderState >= 6)
  3698. {
  3699. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3700. //{
  3701. // string msl = entity.MakeSupplier;
  3702. // string[] mslist = msl.Split(',');
  3703. // 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);
  3704. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3705. //}
  3706. //else
  3707. //{
  3708. StringBuilder sql = new StringBuilder();
  3709. 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);
  3710. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3711. //}
  3712. }
  3713. }
  3714. else
  3715. {
  3716. continue;
  3717. }
  3718. }
  3719. if (errMsg.Length > 0)
  3720. {
  3721. returnErrorMsg(errMsg);
  3722. return;
  3723. }
  3724. returnSuccessMsg("操作成功!");
  3725. return;
  3726. }
  3727. }
  3728. public void assign_erp_makesupplier()
  3729. {
  3730. if (UrlPostParmsCheck("ctid"))
  3731. {
  3732. string eids = GetPostString("ctid");
  3733. string sname = GetPostString("SupplierName");
  3734. string[] eidList = eids.Split(',');
  3735. if (eidList.Length <= 0)
  3736. {
  3737. returnErrorMsg("指派不能为空");
  3738. return;
  3739. }
  3740. List<string> tLst = new List<string>();
  3741. foreach (string ctid in eidList)
  3742. {
  3743. CeErpTradeCell entity = null;
  3744. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3745. if (entity != null)
  3746. {
  3747. entity.MakeSupplier = sname;
  3748. entity.Update();
  3749. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3750. tLst.Add("'" + ctid + "'");
  3751. }
  3752. else
  3753. {
  3754. continue;
  3755. }
  3756. }
  3757. string ctids = string.Join(",", tLst.ToArray());
  3758. StringBuilder sql2 = new StringBuilder();
  3759. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3760. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3761. returnSuccessMsg("操作成功!");
  3762. return;
  3763. }
  3764. }
  3765. public void ins_erp_returnreason()
  3766. {
  3767. if (UrlPostParmsCheck("ctid"))
  3768. {
  3769. string eid = GetPostString("ctid");
  3770. CeErpTradeCell entity = null;
  3771. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3772. string userpost = CurrentUser.UserPost.Post.Code;
  3773. if (entity != null)
  3774. {
  3775. bool isPlace = false;
  3776. if (entity.OrderState > 6)
  3777. {
  3778. returnErrorMsg("已发货无法打回!");
  3779. return;
  3780. }
  3781. if (entity.OrderState == 6)
  3782. {
  3783. isPlace = true;
  3784. }
  3785. bool isNeedUpdateCell2 = false;
  3786. if (entity.OrderState >= 6)
  3787. {
  3788. isNeedUpdateCell2 = true;
  3789. }
  3790. int returnTag = 2;
  3791. if (userpost == "Supplier")
  3792. {
  3793. returnTag = 1;
  3794. }
  3795. int toType = GetPostInt("totype");
  3796. string fromType = "3";
  3797. if (entity.OrderState < 5)
  3798. {
  3799. fromType = "3";
  3800. }
  3801. else
  3802. {
  3803. fromType = "4";
  3804. }
  3805. if (entity.IsXianHuo == 0)
  3806. {
  3807. if (returnTag == 2)
  3808. {
  3809. if (toType == 1)
  3810. {
  3811. entity.OrderState = 0;
  3812. entity.ReturnUserType = 1;
  3813. string clearman = GetPostString("clearman");
  3814. if (!string.IsNullOrEmpty(clearman))
  3815. {
  3816. entity.DesignUserId = 0;
  3817. }
  3818. }
  3819. else
  3820. {
  3821. entity.OrderState = 3;
  3822. entity.ReturnUserType = 2;
  3823. }
  3824. entity.IsReadTag = 1;
  3825. }
  3826. else if (returnTag == 1)
  3827. {
  3828. entity.OrderState = 5;
  3829. }
  3830. entity.IsVerifyToSupplier = false;
  3831. }
  3832. if (entity.IsXianHuo == 1)
  3833. {
  3834. entity.OrderState = 5;
  3835. }
  3836. entity.UnusualTag = 0;
  3837. entity.UnusualTime = null;
  3838. entity.UnusualCon = "";
  3839. entity.IsReturn = returnTag;
  3840. entity.ReturnTime = DateTime.Now;
  3841. entity.UpdateTime = DateTime.Now;
  3842. entity.ReturnReason = GetPostString("returnreason");
  3843. entity.Update();
  3844. if (entity.OrderState == 3)
  3845. {
  3846. ApiVo apiVo = new ApiVo();
  3847. apiVo.orderNumber = entity.ctid;
  3848. apiVo.actionName = "rebutDesign";
  3849. apiVo.orderRemarks = entity.ReturnReason;
  3850. designHelper.API_WorkCore(apiVo);//rebutDesign
  3851. }
  3852. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3853. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3854. {
  3855. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3856. }
  3857. CeErpSukuraData.createInfo(entity.ctid, 5);
  3858. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3859. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3860. if (isPlace)
  3861. {
  3862. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3863. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3864. if (dth != null && dth.Rows.Count > 0)
  3865. {
  3866. dataSendOrderBean dataSendOrderBean = null;
  3867. foreach (DataRow item in dth.Rows)
  3868. {
  3869. try
  3870. {
  3871. dataSendOrderBean = new dataSendOrderBean();
  3872. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3873. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3874. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3875. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3876. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3877. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3878. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3879. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3880. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3881. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3882. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3883. dataSendOrderBean.Radio1723534706288 = "打回";
  3884. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3885. if (result != null)
  3886. {
  3887. if ("0".Equals(result.errcode))
  3888. {
  3889. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3890. }
  3891. else
  3892. {
  3893. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3894. }
  3895. }
  3896. }
  3897. catch (Exception ex)
  3898. {
  3899. }
  3900. }
  3901. }
  3902. }
  3903. if (isNeedUpdateCell2)
  3904. {
  3905. if (entity.MakeSupplier.IndexOf(",") != -1)
  3906. {
  3907. StringBuilder sql2 = new StringBuilder();
  3908. 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);
  3909. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3910. }
  3911. else
  3912. {
  3913. StringBuilder sql2 = new StringBuilder();
  3914. 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);
  3915. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3916. }
  3917. }
  3918. returnSuccessMsg("操作成功!");
  3919. return;
  3920. }
  3921. returnErrorMsg("找不到订单记录");
  3922. }
  3923. }
  3924. public void cyt_erp_returnreason()
  3925. {
  3926. if (UrlPostParmsCheck("ctid"))
  3927. {
  3928. string eid = GetPostString("ctid");
  3929. CeErpTradeCell entity = null;
  3930. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3931. string userpost = CurrentUser.UserPost.Post.Code;
  3932. if (entity != null)
  3933. {
  3934. if (entity.OrderState > 6)
  3935. {
  3936. returnErrorMsg("已发货无法打回!");
  3937. return;
  3938. }
  3939. JObject jsonObject = new JObject
  3940. {
  3941. { "Userid", "77886" },
  3942. { "Pwd", "lt666888" },
  3943. { "LTOrderId",eid }
  3944. };
  3945. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3946. JObject jsonObjects = JObject.Parse(response);
  3947. string msg = (string)jsonObjects["msg"];
  3948. if (msg != "取消成功")
  3949. {
  3950. returnErrorMsg(msg);
  3951. return;
  3952. }
  3953. bool isNeedUpdateCell2 = false;
  3954. if (entity.OrderState >= 6)
  3955. {
  3956. isNeedUpdateCell2 = true;
  3957. }
  3958. int returnTag = 2;
  3959. if (userpost == "Supplier")
  3960. {
  3961. returnTag = 1;
  3962. }
  3963. if (entity.IsXianHuo == 0)
  3964. {
  3965. if (returnTag == 2)
  3966. {
  3967. int toType = GetPostInt("totype");
  3968. if (toType == 1)
  3969. {
  3970. entity.OrderState = 0;
  3971. entity.ReturnUserType = 1;
  3972. }
  3973. else
  3974. {
  3975. entity.OrderState = 4;
  3976. entity.ReturnUserType = 2;
  3977. }
  3978. entity.IsReadTag = 1;
  3979. }
  3980. else if (returnTag == 1)
  3981. {
  3982. entity.OrderState = 5;
  3983. }
  3984. entity.IsVerifyToSupplier = false;
  3985. }
  3986. entity.UnusualTag = 0;
  3987. entity.UnusualTime = null;
  3988. entity.UnusualCon = "";
  3989. entity.IsReturn = returnTag;
  3990. entity.ReturnTime = DateTime.Now;
  3991. entity.ReturnReason = GetPostString("returnreason");
  3992. entity.Update();
  3993. if (entity.OrderState == 4)
  3994. {
  3995. ApiVo apiVo = new ApiVo();
  3996. apiVo.orderNumber = entity.ctid;
  3997. apiVo.actionName = "rebutDesign";
  3998. apiVo.orderRemarks = entity.ReturnReason;
  3999. designHelper.API_WorkCore(apiVo);//rebutDesign
  4000. }
  4001. CeErpSukuraData.createInfo(entity.ctid, 5);
  4002. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4004. if (isNeedUpdateCell2)
  4005. {
  4006. if (entity.MakeSupplier.IndexOf(",") != -1)
  4007. {
  4008. StringBuilder sql2 = new StringBuilder();
  4009. 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);
  4010. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4011. }
  4012. else
  4013. {
  4014. StringBuilder sql2 = new StringBuilder();
  4015. 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);
  4016. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4017. }
  4018. }
  4019. returnSuccessMsg("操作成功!");
  4020. return;
  4021. }
  4022. returnErrorMsg("找不到订单记录");
  4023. }
  4024. }
  4025. public void upd_erp_xianhuoreturntag()
  4026. {
  4027. if (UrlPostParmsCheck("ctid"))
  4028. {
  4029. string eids = GetPostString("ctid");
  4030. string[] ctids = eids.Split(',');
  4031. foreach (string ctid in ctids)
  4032. {
  4033. CeErpTradeCell entity = null;
  4034. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4035. if (entity != null)
  4036. {
  4037. entity.IsReturn = 0;
  4038. entity.Update();
  4039. CeErpSukuraData.createInfo(entity.ctid, 5);
  4040. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4041. }
  4042. }
  4043. returnSuccessMsg("操作成功!");
  4044. return;
  4045. }
  4046. }
  4047. public void get_erp_waitdeliverylist()
  4048. {
  4049. DataStruct dStruct = GetPostStruct();
  4050. List<string> lw = new List<string>();
  4051. string tid = GetPostString("ctid");
  4052. if (tid.Length > 0)
  4053. {
  4054. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4055. if (tid.Length > 5)
  4056. {
  4057. List<string> tids = getTidByCtidLike(tid);
  4058. if (tids.Count > 0 && tids.Count < 10)
  4059. {
  4060. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4061. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4062. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4063. {
  4064. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4065. }*/
  4066. }
  4067. }
  4068. lw.Add(tid_sql);
  4069. }
  4070. string shopname = GetPostString("shopname");
  4071. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4072. string buyernick = GetPostString("buyer_nick");
  4073. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4074. //if (tid.Length == 0 && buyernick.Length == 0)
  4075. //{
  4076. // lw.Add(string.Format("IsRefund<={0}", 1));
  4077. //}
  4078. string customer = GetPostString("customer");
  4079. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4080. string design = GetPostString("design");
  4081. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4082. string orderState = GetPostString("orderState");
  4083. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4084. string address = GetPostString("address");
  4085. 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));
  4086. string sellermemo = GetPostString("seller_memo");
  4087. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4088. string supplier = GetPostString("supplier");
  4089. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4090. string OrderArea = GetPostString("order_area");
  4091. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4092. string placedate1 = GetPostString("placedate1");
  4093. string placedate2 = GetPostString("placedate2");
  4094. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4095. if (fdw.Length > 0) lw.Add(fdw);
  4096. string price1 = GetPostString("price1");
  4097. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4098. string price2 = GetPostString("price2");
  4099. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4100. string unusualCon = GetPostString("unusualcon");
  4101. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4102. string otherMemo = GetPostString("otherMemo");
  4103. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4104. string posTag = CurrentUser.UserPost.Post.Code;
  4105. if (posTag == "Supplier")
  4106. {
  4107. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4108. }
  4109. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4110. lw.Add(string.Format("type != 'PDD' "));
  4111. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4112. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4113. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4114. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4115. writeGridDataTableJson(dStruct.TotalCount, dt);
  4116. }
  4117. public void get_erp_changedeliverylist()
  4118. {
  4119. DataStruct dStruct = GetPostStruct();
  4120. List<string> lw = new List<string>();
  4121. string tid = GetPostString("ctid");
  4122. if (tid.Length > 0)
  4123. {
  4124. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4125. if (tid.Length > 5)
  4126. {
  4127. List<string> tids = getTidByCtidLike(tid);
  4128. if (tids.Count > 0 && tids.Count < 10)
  4129. {
  4130. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4131. }
  4132. }
  4133. lw.Add(tid_sql);
  4134. }
  4135. string shopname = GetPostString("shopname");
  4136. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4137. string buyernick = GetPostString("buyer_nick");
  4138. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4139. //if (tid.Length == 0 && buyernick.Length == 0)
  4140. //{
  4141. // lw.Add(string.Format("IsRefund<={0}", 1));
  4142. //}
  4143. string customer = GetPostString("customer");
  4144. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4145. string design = GetPostString("design");
  4146. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4147. string orderState = GetPostString("orderState");
  4148. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4149. string address = GetPostString("address");
  4150. 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));
  4151. string sellermemo = GetPostString("seller_memo");
  4152. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4153. string supplier = GetPostString("supplier");
  4154. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4155. string OrderArea = GetPostString("order_area");
  4156. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4157. string placedate1 = GetPostString("placedate1");
  4158. string placedate2 = GetPostString("placedate2");
  4159. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4160. if (fdw.Length > 0) lw.Add(fdw);
  4161. string price1 = GetPostString("price1");
  4162. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4163. string price2 = GetPostString("price2");
  4164. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4165. string unusualCon = GetPostString("unusualcon");
  4166. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4167. string otherMemo = GetPostString("otherMemo");
  4168. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4169. string posTag = CurrentUser.UserPost.Post.Code;
  4170. if (posTag == "Supplier")
  4171. {
  4172. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4173. }
  4174. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4175. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4176. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4177. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4178. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4179. /*if (tid.Length > 0)
  4180. {
  4181. List<string> tids = new List<string>();
  4182. if (dt != null && dt.Rows.Count > 0)
  4183. {
  4184. foreach (DataRow item in dt.Rows)
  4185. {
  4186. tids.Add("'" + item["tid"] + "'");
  4187. }
  4188. }
  4189. if (tids.Count > 0)
  4190. {
  4191. lw.RemoveAt(0);
  4192. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4193. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4194. dt = WebCache.GetData("view_erptradecell", dStruct);
  4195. }
  4196. }*/
  4197. writeGridDataTableJson(dStruct.TotalCount, dt);
  4198. }
  4199. public void get_erp_pddderiving()
  4200. {
  4201. DataStruct dStruct = GetPostStruct();
  4202. List<string> lw = new List<string>();
  4203. string tid = GetPostString("ctid");
  4204. if (tid.Length > 0)
  4205. {
  4206. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4207. if (tid.Length > 5)
  4208. {
  4209. List<string> tids = getTidByCtidLike(tid);
  4210. if (tids.Count > 0 && tids.Count < 10)
  4211. {
  4212. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4213. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4214. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4215. {
  4216. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4217. }*/
  4218. }
  4219. }
  4220. lw.Add(tid_sql);
  4221. }
  4222. string shopname = GetPostString("shopname");
  4223. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4224. string buyernick = GetPostString("buyer_nick");
  4225. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4226. //if (tid.Length == 0 && buyernick.Length == 0)
  4227. //{
  4228. // lw.Add(string.Format("IsRefund<={0}", 1));
  4229. //}
  4230. string customer = GetPostString("customer");
  4231. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4232. string design = GetPostString("design");
  4233. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4234. string orderState = GetPostString("orderState");
  4235. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4236. string address = GetPostString("address");
  4237. 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));
  4238. string sellermemo = GetPostString("seller_memo");
  4239. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4240. string supplier = GetPostString("supplier");
  4241. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4242. string OrderArea = GetPostString("order_area");
  4243. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4244. string placedate1 = GetPostString("placedate1");
  4245. string placedate2 = GetPostString("placedate2");
  4246. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4247. if (fdw.Length > 0) lw.Add(fdw);
  4248. string price1 = GetPostString("price1");
  4249. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4250. string price2 = GetPostString("price2");
  4251. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4252. string unusualCon = GetPostString("unusualcon");
  4253. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4254. string posTag = CurrentUser.UserPost.Post.Code;
  4255. if (posTag == "Supplier")
  4256. {
  4257. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4258. }
  4259. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4260. lw.Add(string.Format("type = 'PDD' "));
  4261. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4262. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4263. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4264. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4265. /*if (tid.Length > 0)
  4266. {
  4267. List<string> tids = new List<string>();
  4268. if (dt != null && dt.Rows.Count > 0)
  4269. {
  4270. foreach (DataRow item in dt.Rows)
  4271. {
  4272. tids.Add("'" + item["tid"] + "'");
  4273. }
  4274. }
  4275. if (tids.Count > 0)
  4276. {
  4277. lw.RemoveAt(0);
  4278. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4279. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4280. dt = WebCache.GetData("view_erptradecell", dStruct);
  4281. }
  4282. }*/
  4283. writeGridDataTableJson(dStruct.TotalCount, dt);
  4284. }
  4285. public void get_erp_jdderiving()
  4286. {
  4287. DataStruct dStruct = GetPostStruct();
  4288. List<string> lw = new List<string>();
  4289. string tid = GetPostString("ctid");
  4290. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4291. string shopname = GetPostString("shopname");
  4292. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4293. string buyernick = GetPostString("buyer_nick");
  4294. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4295. //if (tid.Length == 0 && buyernick.Length == 0)
  4296. //{
  4297. // lw.Add(string.Format("IsRefund<={0}", 1));
  4298. //}
  4299. string customer = GetPostString("customer");
  4300. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4301. string design = GetPostString("design");
  4302. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4303. string orderState = GetPostString("orderState");
  4304. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4305. string address = GetPostString("address");
  4306. 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));
  4307. string sellermemo = GetPostString("seller_memo");
  4308. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4309. string supplier = GetPostString("supplier");
  4310. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4311. string OrderArea = GetPostString("order_area");
  4312. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4313. string placedate1 = GetPostString("placedate1");
  4314. string placedate2 = GetPostString("placedate2");
  4315. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4316. if (fdw.Length > 0) lw.Add(fdw);
  4317. string price1 = GetPostString("price1");
  4318. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4319. string price2 = GetPostString("price2");
  4320. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4321. string unusualCon = GetPostString("unusualcon");
  4322. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4323. string posTag = CurrentUser.UserPost.Post.Code;
  4324. if (posTag == "Supplier")
  4325. {
  4326. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4327. }
  4328. lw.Add(string.Format("OrderState = 6 "));
  4329. lw.Add(string.Format("type = 'JD' "));
  4330. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4331. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4332. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4333. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4334. writeGridDataTableJson(dStruct.TotalCount, dt);
  4335. }
  4336. public void get_erp_demoorderlist()
  4337. {
  4338. DataStruct dStruct = GetPostStruct();
  4339. List<string> lw = new List<string>();
  4340. string tid = GetPostString("ctid");
  4341. if (tid.Length > 0)
  4342. {
  4343. string select_tid = getTidByCtid(tid);
  4344. lw.Add(string.Format("tid='{0}'", select_tid));
  4345. }
  4346. string shopname = GetPostString("shopname");
  4347. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4348. string buyernick = GetPostString("buyer_nick");
  4349. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4350. string customer = GetPostString("customer");
  4351. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4352. string design = GetPostString("design");
  4353. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4354. string orderState = GetPostString("orderState");
  4355. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4356. string address = GetPostString("address");
  4357. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4358. string sellermemo = GetPostString("seller_memo");
  4359. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4360. string supplier = GetPostString("supplier");
  4361. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4362. string OrderArea = GetPostString("order_area");
  4363. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4364. string date1 = GetPostString("date1");
  4365. string date2 = GetPostString("date2");
  4366. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4367. if (dw.Length > 0) lw.Add(dw);
  4368. string price1 = GetPostString("price1");
  4369. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4370. string price2 = GetPostString("price2");
  4371. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4372. string posTag = CurrentUser.UserPost.Post.Code;
  4373. if (posTag == "Supplier")
  4374. {
  4375. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4376. }
  4377. //lw.Add(string.Format("OrderState = 6 "));
  4378. lw.Add(string.Format("IsSample={0}", 3));
  4379. lw.Add(string.Format("IsRefund<={0}", 1));
  4380. dStruct.Order = "pay_time desc";
  4381. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4382. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4383. writeGridDataTableJson(dStruct.TotalCount, dt);
  4384. }
  4385. public void save_erp_checkmemo()
  4386. {
  4387. if (UrlPostParmsCheck("ctid"))
  4388. {
  4389. string ctid = GetPostString("ctid");
  4390. CeErpTradeCell entity = null;
  4391. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4392. if (entity != null)
  4393. {
  4394. entity.CheckMemo = GetPostString("CheckMemo");
  4395. entity.Update();
  4396. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4397. if (trade != null)
  4398. {
  4399. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4400. }
  4401. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4402. returnSuccessMsg("保存成功!");
  4403. return;
  4404. }
  4405. returnErrorMsg("找不到记录");
  4406. }
  4407. }
  4408. public void get_erp_returnlist()
  4409. {
  4410. DataStruct dStruct = GetPostStruct();
  4411. List<string> lw = new List<string>();
  4412. string tid = GetPostString("ctid");
  4413. if (tid.Length > 0)
  4414. {
  4415. string select_tid = getTidByCtid(tid);
  4416. lw.Add(string.Format("tid='{0}'", select_tid));
  4417. }
  4418. string shopname = GetPostString("shopname");
  4419. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4420. string buyernick = GetPostString("buyer_nick");
  4421. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4422. string customer = GetPostString("customer");
  4423. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4424. string design = GetPostString("design");
  4425. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4426. string orderState = GetPostString("orderState");
  4427. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4428. string address = GetPostString("address");
  4429. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4430. string sellermemo = GetPostString("seller_memo");
  4431. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4432. string supplier = GetPostString("supplier");
  4433. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4434. string date1 = GetPostString("date1");
  4435. string date2 = GetPostString("date2");
  4436. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4437. if (dw.Length > 0) lw.Add(dw);
  4438. string bdate1 = GetPostString("backdate1");
  4439. string bdate2 = GetPostString("backdate2");
  4440. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4441. if (dw_back.Length > 0) lw.Add(dw_back);
  4442. string price1 = GetPostString("price1");
  4443. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4444. string price2 = GetPostString("price2");
  4445. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4446. lw.Add(string.Format("IsReturn>0"));
  4447. lw.Add(string.Format("IsXianHuo=0"));
  4448. lw.Add(string.Format("IsReturn!=3"));
  4449. string backtype = GetPostString("backtype");
  4450. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4451. dStruct.Order = "FinishDesignTime desc";
  4452. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4453. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4454. writeGridDataTableJson(dStruct.TotalCount, dt);
  4455. }
  4456. public void get_erp_today_sumreturn()
  4457. {
  4458. DataStruct dStruct = GetPostStruct();
  4459. List<string> lw = new List<string>();
  4460. string bdate1 = GetPostString("returnTimeS");
  4461. string bdate2 = GetPostString("returnTimeE");
  4462. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4463. if (dw_back.Length > 0) lw.Add(dw_back);
  4464. lw.Add(string.Format("IsReturn=0"));
  4465. lw.Add(string.Format("IsXianHuo=0"));
  4466. string mainWhere = string.Join(" and ", lw.ToArray());
  4467. string sql = "";
  4468. if (dw_back.Length > 0)
  4469. {
  4470. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4471. }
  4472. else
  4473. {
  4474. 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 + "'";
  4475. }
  4476. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4477. decimal total = 0, today_finish = 0;
  4478. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4479. {
  4480. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4481. }
  4482. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4483. {
  4484. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4485. }
  4486. var res = new
  4487. {
  4488. data = total,
  4489. data1 = today_finish,
  4490. };
  4491. string ro_jsond = JsonConvert.SerializeObject(res);
  4492. returnSuccess(ro_jsond);
  4493. return;
  4494. }
  4495. public void get_erp_allreturnlist()
  4496. {
  4497. DataStruct dStruct = GetPostStruct();
  4498. List<string> lw = new List<string>();
  4499. string tid = GetPostString("ctid");
  4500. if (tid.Length > 0)
  4501. {
  4502. string select_tid = getTidByCtid(tid);
  4503. lw.Add(string.Format("tid='{0}'", select_tid));
  4504. }
  4505. string shopname = GetPostString("shopname");
  4506. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4507. string buyernick = GetPostString("buyer_nick");
  4508. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4509. string customer = GetPostString("customer");
  4510. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4511. string design = GetPostString("design");
  4512. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4513. string orderState = GetPostString("orderState");
  4514. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4515. string address = GetPostString("address");
  4516. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4517. string sellermemo = GetPostString("seller_memo");
  4518. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4519. string supplier = GetPostString("supplier");
  4520. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4521. string date1 = GetPostString("date1");
  4522. string date2 = GetPostString("date2");
  4523. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4524. if (dw.Length > 0) lw.Add(dw);
  4525. string bdate1 = GetPostString("backdate1");
  4526. string bdate2 = GetPostString("backdate2");
  4527. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4528. if (dw_back.Length > 0) lw.Add(dw_back);
  4529. string price1 = GetPostString("price1");
  4530. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4531. string price2 = GetPostString("price2");
  4532. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4533. string backreason = GetPostString("backreason");
  4534. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4535. lw.Add(string.Format("IsXianHuo=0"));
  4536. lw.Add(string.Format("ReturnTime != ''"));
  4537. string backtype = GetPostString("backtype");
  4538. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4539. dStruct.Order = "FinishDesignTime desc";
  4540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4541. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4542. writeGridDataTableJson(dStruct.TotalCount, dt);
  4543. }
  4544. public void get_erp_aftersalereturnlist()
  4545. {
  4546. DataStruct dStruct = GetPostStruct();
  4547. List<string> lw = new List<string>();
  4548. string tid = GetPostString("ctid");
  4549. if (tid.Length > 0)
  4550. {
  4551. string select_tid = getTidByCtid(tid);
  4552. lw.Add(string.Format("tid='{0}'", select_tid));
  4553. }
  4554. string shopname = GetPostString("shopname");
  4555. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4556. string buyernick = GetPostString("buyer_nick");
  4557. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4558. string customer = GetPostString("customer");
  4559. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4560. string design = GetPostString("design");
  4561. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4562. string orderState = GetPostString("orderState");
  4563. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4564. string address = GetPostString("address");
  4565. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4566. string sellermemo = GetPostString("seller_memo");
  4567. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4568. string supplier = GetPostString("supplier");
  4569. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4570. string date1 = GetPostString("date1");
  4571. string date2 = GetPostString("date2");
  4572. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4573. if (dw.Length > 0) lw.Add(dw);
  4574. string bdate1 = GetPostString("backdate1");
  4575. string bdate2 = GetPostString("backdate2");
  4576. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4577. if (dw_back.Length > 0) lw.Add(dw_back);
  4578. string price1 = GetPostString("price1");
  4579. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4580. string price2 = GetPostString("price2");
  4581. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4582. lw.Add(string.Format("IsReturn=3"));
  4583. string backtype = GetPostString("backtype");
  4584. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4585. string backreason = GetPostString("backreason");
  4586. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4587. dStruct.Order = "ReturnTime desc";
  4588. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4589. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4590. writeGridDataTableJson(dStruct.TotalCount, dt);
  4591. }
  4592. public void get_erp_xianhuoreturnlist()
  4593. {
  4594. DataStruct dStruct = GetPostStruct();
  4595. List<string> lw = new List<string>();
  4596. string tid = GetPostString("ctid");
  4597. if (tid.Length > 0)
  4598. {
  4599. string select_tid = getTidByCtid(tid);
  4600. lw.Add(string.Format("tid='{0}'", select_tid));
  4601. }
  4602. string shopname = GetPostString("shopname");
  4603. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4604. string buyernick = GetPostString("buyer_nick");
  4605. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4606. string customer = GetPostString("customer");
  4607. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4608. string design = GetPostString("design");
  4609. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4610. string orderState = GetPostString("orderState");
  4611. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4612. string address = GetPostString("address");
  4613. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4614. string sellermemo = GetPostString("seller_memo");
  4615. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4616. string supplier = GetPostString("supplier");
  4617. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4618. string OrderArea = GetPostString("order_area");
  4619. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4620. string date1 = GetPostString("date1");
  4621. string date2 = GetPostString("date2");
  4622. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4623. if (dw.Length > 0) lw.Add(dw);
  4624. string price1 = GetPostString("price1");
  4625. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4626. string price2 = GetPostString("price2");
  4627. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4628. string posTag = CurrentUser.UserPost.Post.Code;
  4629. if (posTag == "Supplier")
  4630. {
  4631. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4632. }
  4633. lw.Add(string.Format("OrderState=6 "));
  4634. lw.Add(string.Format("IsXianHuo=1 "));
  4635. lw.Add(string.Format("IsReturn>0 "));
  4636. lw.Add(string.Format("IsReturn!=3"));
  4637. lw.Add(string.Format("IsRefund<={0}", 1));
  4638. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4639. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4640. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4641. writeGridDataTableJson(dStruct.TotalCount, dt);
  4642. }
  4643. public void set_erp_orderdelivery()
  4644. {
  4645. if (UrlPostParmsCheck("ctid"))
  4646. {
  4647. string eid = GetPostString("ctid");
  4648. CeErpTradeCell entity = null;
  4649. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4650. if (entity != null)
  4651. {
  4652. if (entity.OrderState >= 7)
  4653. {
  4654. returnErrorMsg("此单已发货,无需重复发货");
  4655. return;
  4656. }
  4657. if (entity.OrderState != 6)
  4658. {
  4659. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4660. return;
  4661. }
  4662. string shop = GetPostString("seller_nick");
  4663. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4664. string comName = GetPostString("comName");
  4665. string comCode = GetPostString("comCode");
  4666. string outSid = GetPostString("outSid");
  4667. string deliveryType = GetPostString("deliveryType");
  4668. string deliveryMemo = GetPostString("deliveryMemo");
  4669. outSid = outSid.Trim();
  4670. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4671. if (mainEn == null)
  4672. {
  4673. returnErrorMsg("找不到原始订单记录");
  4674. return;
  4675. }
  4676. bool isInitOrderDeliv = false;
  4677. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4678. {
  4679. isInitOrderDeliv = true;
  4680. }
  4681. string apires = "";
  4682. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4683. 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)
  4684. {
  4685. apires = "发货成功true";
  4686. }
  4687. else
  4688. {
  4689. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4690. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4691. }
  4692. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4693. {
  4694. entity.OrderState = 7;//发货后订单已发货
  4695. entity.OutSid = outSid;
  4696. entity.MemoOpt = 0;
  4697. entity.UpdateTime = DateTime.Now;
  4698. entity.FinishDeliveryTime = DateTime.Now;
  4699. entity.Update();
  4700. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4701. commonHelper.UpdateRelationOrder(entity.ctid);
  4702. //还要插入快递信息到 快递信息表
  4703. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4704. exinfo.tid = eid;
  4705. exinfo.out_sid = outSid;
  4706. exinfo.company_code = comCode;
  4707. exinfo.company_name = comName;
  4708. exinfo.delivery_memo = deliveryMemo;
  4709. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4710. exinfo.deliveryType = deliveryType;
  4711. exinfo.Create();
  4712. returnSuccessMsg("发货操作成功!");
  4713. commonHelper.UpdateRelationOrder(entity.ctid);
  4714. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4715. CeErpSukuraData.createInfo(entity.ctid, 4);
  4716. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4717. {
  4718. commonHelper.sendCytExpress(exinfo);
  4719. }
  4720. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4721. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4722. }
  4723. else
  4724. {
  4725. string errmsg = commonHelper.KeepChinese(apires);
  4726. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4727. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4728. }
  4729. return;
  4730. }
  4731. returnErrorMsg("找不到订单记录");
  4732. }
  4733. }
  4734. public void set_erp_multidelivery()
  4735. {
  4736. string eids = GetPostString("tids");
  4737. string[] eidList = eids.Split(',');
  4738. if (eidList.Length <= 0)
  4739. {
  4740. returnErrorMsg("发货不能为空");
  4741. return;
  4742. }
  4743. foreach (string ctid in eidList)
  4744. {
  4745. if (ctid.Length <= 0) continue;
  4746. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4747. if (expInfo != null)
  4748. {
  4749. StringBuilder sql = new StringBuilder();
  4750. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4751. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4752. if (dt.Rows.Count > 0)
  4753. {
  4754. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4755. {
  4756. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4757. expInfo.state = "异常";
  4758. expInfo.isMultiDelivery = 1;
  4759. expInfo.Update();
  4760. continue;
  4761. }
  4762. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4763. {
  4764. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4765. expInfo.state = "异常";
  4766. expInfo.Update();
  4767. continue;
  4768. }
  4769. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4770. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4771. bool isInitOrderDeliv = false;
  4772. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4773. {
  4774. isInitOrderDeliv = true;
  4775. expInfo.isMultiDelivery = 1;
  4776. }
  4777. if (ctid.IndexOf("N") != -1)
  4778. {
  4779. StringBuilder sqlbucha = new StringBuilder();
  4780. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4781. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4782. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4783. commonHelper.UpdateRelationOrder(ctid);
  4784. expInfo.delivery_memo = "发货成功";
  4785. expInfo.state = "发货成功";
  4786. expInfo.isMultiDelivery = 1;
  4787. expInfo.Update();
  4788. }
  4789. else
  4790. {
  4791. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4792. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4793. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4794. {
  4795. expInfo.delivery_memo = "发货成功";
  4796. expInfo.state = "发货成功";
  4797. expInfo.isMultiDelivery = 1;
  4798. expInfo.Update();
  4799. commonHelper.UpdateRelationOrder(ctid);
  4800. CeErpSukuraData.createInfo(ctid, 4);
  4801. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4802. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4803. }
  4804. else
  4805. {
  4806. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4807. expInfo.state = "异常";
  4808. expInfo.Update();
  4809. }
  4810. }
  4811. }
  4812. }
  4813. }
  4814. returnSuccessMsg("操作完成");
  4815. }
  4816. public void reset_erp_memoopt()
  4817. {
  4818. if (UrlPostParmsCheck("ctid"))
  4819. {
  4820. string eid = GetPostString("ctid");
  4821. CeErpTradeCell entity = null;
  4822. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4823. if (entity != null)
  4824. {
  4825. string stropt = "";
  4826. if (entity.MemoOpt == 1)
  4827. {
  4828. stropt = "“改稿”";
  4829. }
  4830. else if (entity.MemoOpt == 2)
  4831. {
  4832. stropt = "“定稿”";
  4833. }
  4834. else if (entity.MemoOpt == 3)
  4835. {
  4836. stropt = "“完成查货”";
  4837. CeErpSukuraData.createInfo(entity.ctid, 6);
  4838. }
  4839. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4840. entity.UpdateTime = DateTime.Now;
  4841. entity.MemoOpt = 0;
  4842. entity.Update();
  4843. returnSuccessMsg("操作成功!");
  4844. return;
  4845. }
  4846. returnErrorMsg("找不到记录");
  4847. }
  4848. }
  4849. public void get_erp_deliveryunusual()
  4850. {
  4851. DataStruct dStruct = GetPostStruct();
  4852. List<string> lw = new List<string>();
  4853. string tid = GetPostString("ctid");
  4854. if (tid.Length > 0)
  4855. {
  4856. string select_tid = getTidByCtid(tid);
  4857. lw.Add(string.Format("tid='{0}'", select_tid));
  4858. }
  4859. string shopname = GetPostString("shopname");
  4860. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4861. string buyernick = GetPostString("buyer_nick");
  4862. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4863. string customer = GetPostString("customer");
  4864. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4865. string design = GetPostString("design");
  4866. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4867. string sellermemo = GetPostString("seller_memo");
  4868. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4869. string supplier = GetPostString("supplier");
  4870. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4871. string date1 = GetPostString("date1");
  4872. string date2 = GetPostString("date2");
  4873. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4874. if (dw.Length > 0) lw.Add(dw);
  4875. string placedate1 = GetPostString("placedate1");
  4876. string placedate2 = GetPostString("placedate2");
  4877. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4878. if (dw_place.Length > 0) lw.Add(dw_place);
  4879. string price1 = GetPostString("price1");
  4880. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4881. string price2 = GetPostString("price2");
  4882. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4883. string unusualCon = GetPostString("unusualcon");
  4884. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4885. string posTag = CurrentUser.UserPost.Post.Code;
  4886. if (posTag == "Supplier")
  4887. {
  4888. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4889. }
  4890. lw.Add(string.Format("OrderState = 6"));
  4891. lw.Add(string.Format("UnusualTag = 5"));
  4892. lw.Add(string.Format("IsRefund<={0}", 1));
  4893. dStruct.Order = "FinishPlaceTime desc";
  4894. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4895. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4896. writeGridDataTableJson(dStruct.TotalCount, dt);
  4897. }
  4898. public void get_erp_deliveryedlist()
  4899. {
  4900. DataStruct dStruct = GetPostStruct();
  4901. List<string> lw = new List<string>();
  4902. string tid = GetPostString("ctid");
  4903. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4904. string shopname = GetPostString("shopname");
  4905. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4906. string buyernick = GetPostString("buyer_nick");
  4907. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4908. string customer = GetPostString("customer");
  4909. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4910. string design = GetPostString("design");
  4911. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4912. string sellermemo = GetPostString("seller_memo");
  4913. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4914. string logistics = GetPostString("logistics");
  4915. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4916. string date1 = GetPostString("date1");
  4917. string date2 = GetPostString("date2");
  4918. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4919. //if (dw.Length > 0) lw.Add(dw);
  4920. string placedate1 = GetPostString("placedate1");
  4921. string placedate2 = GetPostString("placedate2");
  4922. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4923. if (fdw.Length > 0) lw.Add(fdw);
  4924. string devdate1 = GetPostString("deliverydate1");
  4925. string devdate2 = GetPostString("deliverydate2");
  4926. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4927. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4928. string price1 = GetPostString("price1");
  4929. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4930. string price2 = GetPostString("price2");
  4931. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4932. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4933. {
  4934. if (tid.Length > 0)
  4935. {
  4936. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4937. if (tid.Length > 5)
  4938. {
  4939. List<string> tids = getTidByCtidLike(tid);
  4940. if (tids.Count > 0 && tids.Count < 10)
  4941. {
  4942. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4943. }
  4944. }
  4945. lw.Add(tid_sql);
  4946. }
  4947. if (buyernick.Length > 0)
  4948. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4949. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4950. if (dw.Length > 0) lw.Add(dw);
  4951. }
  4952. else
  4953. {
  4954. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4955. }
  4956. string posTag = CurrentUser.UserPost.Post.Code;
  4957. if (posTag == "Supplier")
  4958. {
  4959. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4960. }
  4961. else
  4962. {
  4963. string supplier = GetPostString("supplier");
  4964. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4965. }
  4966. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4967. lw.Add(string.Format("type != 'PDD' "));
  4968. lw.Add(string.Format("IsRefund!={0}", 2));
  4969. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4970. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4971. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4972. /*if (tid.Length > 0)
  4973. {
  4974. List<string> tids = new List<string>();
  4975. if (dt != null && dt.Rows.Count > 0)
  4976. {
  4977. foreach (DataRow item in dt.Rows)
  4978. {
  4979. tids.Add("'" + item["tid"] + "'");
  4980. }
  4981. }
  4982. if (tids.Count > 0)
  4983. {
  4984. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4985. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4986. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4987. dt = WebCache.GetData("view_erptradecell", dStruct);
  4988. }
  4989. }*/
  4990. if (dt != null)
  4991. {
  4992. foreach (DataRow dr in dt.Rows)
  4993. {
  4994. 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();
  4995. }
  4996. }
  4997. writeGridDataTableJson(dStruct.TotalCount, dt);
  4998. }
  4999. public void get_erp_pdddeliveryed()
  5000. {
  5001. DataStruct dStruct = GetPostStruct();
  5002. List<string> lw = new List<string>();
  5003. string tid = GetPostString("ctid");
  5004. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5005. string shopname = GetPostString("shopname");
  5006. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5007. string buyernick = GetPostString("buyer_nick");
  5008. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5009. string customer = GetPostString("customer");
  5010. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5011. string design = GetPostString("design");
  5012. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5013. string sellermemo = GetPostString("seller_memo");
  5014. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5015. string logistics = GetPostString("logistics");
  5016. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5017. string date1 = GetPostString("date1");
  5018. string date2 = GetPostString("date2");
  5019. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5020. //if (dw.Length > 0) lw.Add(dw);
  5021. string placedate1 = GetPostString("placedate1");
  5022. string placedate2 = GetPostString("placedate2");
  5023. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5024. if (fdw.Length > 0) lw.Add(fdw);
  5025. string devdate1 = GetPostString("deliverydate1");
  5026. string devdate2 = GetPostString("deliverydate2");
  5027. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5028. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5029. string price1 = GetPostString("price1");
  5030. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5031. string price2 = GetPostString("price2");
  5032. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5033. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5034. {
  5035. if (tid.Length > 0)
  5036. {
  5037. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5038. if (tid.Length > 5)
  5039. {
  5040. List<string> tids = getTidByCtidLike(tid);
  5041. if (tids.Count > 0 && tids.Count < 10)
  5042. {
  5043. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5044. }
  5045. }
  5046. lw.Add(tid_sql);
  5047. }
  5048. if (buyernick.Length > 0)
  5049. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5050. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5051. if (dw.Length > 0) lw.Add(dw);
  5052. }
  5053. else
  5054. {
  5055. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5056. }
  5057. string posTag = CurrentUser.UserPost.Post.Code;
  5058. if (posTag == "Supplier")
  5059. {
  5060. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5061. }
  5062. else
  5063. {
  5064. string supplier = GetPostString("supplier");
  5065. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5066. }
  5067. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5068. lw.Add(string.Format("type = 'PDD' "));
  5069. lw.Add(string.Format("IsRefund!={0}", 2));
  5070. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5071. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5072. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5073. /* if (tid.Length > 0)
  5074. {
  5075. List<string> tids = new List<string>();
  5076. if (dt != null && dt.Rows.Count > 0)
  5077. {
  5078. foreach (DataRow item in dt.Rows)
  5079. {
  5080. tids.Add("'" + item["tid"] + "'");
  5081. }
  5082. }
  5083. if (tids.Count > 0)
  5084. {
  5085. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5086. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5087. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5088. dt = WebCache.GetData("view_erptradecell", dStruct);
  5089. }
  5090. }*/
  5091. foreach (DataRow dr in dt.Rows)
  5092. {
  5093. 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();
  5094. }
  5095. writeGridDataTableJson(dStruct.TotalCount, dt);
  5096. }
  5097. public void get_erp_jddeliveryed()
  5098. {
  5099. DataStruct dStruct = GetPostStruct();
  5100. List<string> lw = new List<string>();
  5101. string tid = GetPostString("ctid");
  5102. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5103. string shopname = GetPostString("shopname");
  5104. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5105. string buyernick = GetPostString("buyer_nick");
  5106. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5107. string customer = GetPostString("customer");
  5108. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5109. string design = GetPostString("design");
  5110. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5111. string sellermemo = GetPostString("seller_memo");
  5112. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5113. string date1 = GetPostString("date1");
  5114. string date2 = GetPostString("date2");
  5115. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5116. //if (dw.Length > 0) lw.Add(dw);
  5117. string placedate1 = GetPostString("placedate1");
  5118. string placedate2 = GetPostString("placedate2");
  5119. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5120. if (fdw.Length > 0) lw.Add(fdw);
  5121. string devdate1 = GetPostString("deliverydate1");
  5122. string devdate2 = GetPostString("deliverydate2");
  5123. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5124. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5125. string price1 = GetPostString("price1");
  5126. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5127. string price2 = GetPostString("price2");
  5128. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5129. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5130. {
  5131. if (tid.Length > 0)
  5132. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5133. if (buyernick.Length > 0)
  5134. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5135. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5136. if (dw.Length > 0) lw.Add(dw);
  5137. }
  5138. else
  5139. {
  5140. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5141. }
  5142. string posTag = CurrentUser.UserPost.Post.Code;
  5143. if (posTag == "Supplier")
  5144. {
  5145. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5146. }
  5147. else
  5148. {
  5149. string supplier = GetPostString("supplier");
  5150. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5151. }
  5152. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5153. lw.Add(string.Format("type = 'JD' "));
  5154. lw.Add(string.Format("IsRefund!={0}", 2));
  5155. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5156. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5157. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5158. foreach (DataRow dr in dt.Rows)
  5159. {
  5160. 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();
  5161. }
  5162. writeGridDataTableJson(dStruct.TotalCount, dt);
  5163. }
  5164. public void get_erp_allplacelist()
  5165. {
  5166. DataStruct dStruct = GetPostStruct();
  5167. List<string> lw = new List<string>();
  5168. string tid = GetPostString("ctid");
  5169. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5170. string shopname = GetPostString("shopname");
  5171. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5172. string buyernick = GetPostString("buyer_nick");
  5173. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5174. string customer = GetPostString("customer");
  5175. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5176. string design = GetPostString("design");
  5177. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5178. string sellermemo = GetPostString("seller_memo");
  5179. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5180. string supplier = GetPostString("supplier");
  5181. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5182. string date1 = GetPostString("date1");
  5183. string date2 = GetPostString("date2");
  5184. string pldate1 = GetPostString("placedate1");
  5185. string pldate2 = GetPostString("placedate2");
  5186. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5187. //if (dw.Length > 0) lw.Add(dw);
  5188. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5189. {
  5190. if (tid.Length > 0)
  5191. {
  5192. string select_tid = getTidByCtid(tid);
  5193. lw.Add(string.Format("tid='{0}'", select_tid));
  5194. }
  5195. if (buyernick.Length > 0)
  5196. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5197. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5198. if (dw.Length > 0) lw.Add(dw);
  5199. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5200. if (dw_place.Length > 0) lw.Add(dw_place);
  5201. }
  5202. else
  5203. {
  5204. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5205. {
  5206. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5207. }
  5208. }
  5209. string price1 = GetPostString("price1");
  5210. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5211. string price2 = GetPostString("price2");
  5212. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5213. string posTag = CurrentUser.UserPost.Post.Code;
  5214. if (posTag == "Supplier")
  5215. {
  5216. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5217. }
  5218. lw.Add(string.Format("OrderState >= 6"));
  5219. lw.Add(string.Format("IsSample != 2 "));
  5220. //lw.Add(string.Format("isDianziOrder = 0 "));
  5221. lw.Add(string.Format("SupplierId > 0 "));
  5222. //lw.Add(string.Format("IsRefund<={0}", 1));
  5223. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5224. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5225. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5226. foreach (DataRow dr in dt.Rows)
  5227. {
  5228. 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();
  5229. }
  5230. writeGridDataTableJson(dStruct.TotalCount, dt);
  5231. }
  5232. public void get_erp_financeallplacelist()
  5233. {
  5234. DataStruct dStruct = GetPostStruct();
  5235. List<string> lw = new List<string>();
  5236. string tid = GetPostString("ctid");
  5237. string shopname = GetPostString("shopname");
  5238. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5239. string buyernick = GetPostString("buyer_nick");
  5240. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5241. string customer = GetPostString("customer");
  5242. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5243. string design = GetPostString("design");
  5244. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5245. string sellermemo = GetPostString("seller_memo");
  5246. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5247. string supplier = GetPostString("supplier");
  5248. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5249. string date1 = GetPostString("date1");
  5250. string date2 = GetPostString("date2");
  5251. string pldate1 = GetPostString("placedate1");
  5252. string pldate2 = GetPostString("placedate2");
  5253. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5254. {
  5255. if (tid.Length > 0)
  5256. {
  5257. string select_tid = getTidByCtid(tid);
  5258. lw.Add(string.Format("tid='{0}'", select_tid));
  5259. }
  5260. if (buyernick.Length > 0)
  5261. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5262. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5263. if (dw.Length > 0) lw.Add(dw);
  5264. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5265. if (dw_place.Length > 0) lw.Add(dw_place);
  5266. }
  5267. else
  5268. {
  5269. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5270. {
  5271. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5272. }
  5273. }
  5274. string price1 = GetPostString("price1");
  5275. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5276. string price2 = GetPostString("price2");
  5277. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5278. string posTag = CurrentUser.UserPost.Post.Code;
  5279. if (posTag == "Supplier")
  5280. {
  5281. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5282. }
  5283. //lw.Add(string.Format("OrderState >= 6"));
  5284. lw.Add(string.Format("IsSample != 2 "));
  5285. lw.Add(string.Format("isDianziOrder = 0 "));
  5286. //lw.Add(string.Format("IsRefund<={0}", 1));
  5287. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5289. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5290. foreach (DataRow dr in dt.Rows)
  5291. {
  5292. 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();
  5293. }
  5294. writeGridDataTableJson(dStruct.TotalCount, dt);
  5295. }
  5296. public void get_erp_expresslist()
  5297. {
  5298. int listtype = GetInt("ltype");
  5299. DataStruct dStruct = GetPostStruct();
  5300. List<string> lw = new List<string>();
  5301. string tid = GetPostString("tid");
  5302. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5303. string outsid = GetPostString("out_sid");
  5304. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5305. string importer = GetPostString("ImportUserName");
  5306. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5307. string file = GetPostString("import_file");
  5308. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5309. string printman = GetPostString("printman");
  5310. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5311. string date1 = GetPostString("date1");
  5312. string date2 = GetPostString("date2");
  5313. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5314. if (dw.Length > 0) lw.Add(dw);
  5315. string fdate1 = GetPostString("finishdate1");
  5316. string fdate2 = GetPostString("finishdate2");
  5317. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5318. if (fdw.Length > 0) lw.Add(fdw);
  5319. string supplierId = GetPostString("supplierId");
  5320. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5321. if (listtype == 1)
  5322. {
  5323. lw.Add(string.Format("importUserId !=0"));
  5324. }
  5325. string posTag = CurrentUser.UserPost.Post.Code;
  5326. if (posTag == "Supplier")
  5327. {
  5328. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5329. }
  5330. if (dStruct.PageSize != 100000)
  5331. {
  5332. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5333. }
  5334. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5335. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5336. writeGridDataTableJson(dStruct.TotalCount, dt);
  5337. }
  5338. public void set_erp_buchaorderdelivery()
  5339. {
  5340. if (UrlPostParmsCheck("ctid"))
  5341. {
  5342. string eid = GetPostString("ctid");
  5343. CeErpTradeCell entity = null;
  5344. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5345. if (entity != null)
  5346. {
  5347. if (entity.IsSample != 2)
  5348. {
  5349. returnErrorMsg("补差价单才能标记为已发货");
  5350. return;
  5351. }
  5352. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5353. entity.OrderState = 7;
  5354. entity.Update();
  5355. returnSuccessMsg("操作成功!");
  5356. return;
  5357. }
  5358. returnErrorMsg("找不到记录");
  5359. }
  5360. }
  5361. public void get_stdtemplates()
  5362. {
  5363. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5364. //string res = taobaoHelper.test();
  5365. string res = apiHelper.API_PrintTemplate();
  5366. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5367. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5368. {
  5369. int sidx = res.IndexOf("error_code");
  5370. int eidx = res.IndexOf("success");
  5371. string msg = res.Substring(sidx, eidx - sidx);
  5372. returnErrorMsg(msg);
  5373. return;
  5374. }
  5375. if (res.Length <= 0)
  5376. {
  5377. returnErrorMsg("模板数据为空!");
  5378. return;
  5379. }
  5380. ReturnSuccess(res);
  5381. }
  5382. public void cancel_print_order()
  5383. {
  5384. if (UrlPostParmsCheck("ctid"))
  5385. {
  5386. string ctid = GetPostString("ctid");
  5387. CeErpTradeCell entity = null;
  5388. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5389. if (entity != null)
  5390. {
  5391. string res = "";
  5392. string code = entity.LastBillWaybillCode;
  5393. if (code == "")
  5394. {
  5395. code = entity.OutSid;
  5396. }
  5397. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5398. XLog.SaveLog(0, "取消面单" + res);
  5399. }
  5400. }
  5401. }
  5402. public void set_erp_printwaybill()
  5403. {
  5404. if (UrlPostParmsCheck("ctid"))
  5405. {
  5406. string ctid = GetPostString("ctid");
  5407. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5408. string cpName = GetPostString("cpname");
  5409. string isTogether = GetPostString("together");
  5410. string printType = GetPostString("printType");
  5411. //var res_obj = new
  5412. //{
  5413. // restype = 1,
  5414. // 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\"}"
  5415. //};
  5416. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5417. //ReturnSuccess(ro_json);
  5418. //return;
  5419. bool isUseLastWayBillCode = false;
  5420. CeErpTradeCell entity = null;
  5421. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5422. if (entity != null)
  5423. {
  5424. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5425. {
  5426. isUseLastWayBillCode = true;
  5427. }
  5428. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5429. {
  5430. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5431. return;
  5432. }
  5433. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5434. {
  5435. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5436. return;
  5437. }
  5438. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5439. {
  5440. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5441. return;
  5442. }
  5443. }
  5444. string res = "";
  5445. Api_waybill_code_response_Obj fullObj = null;
  5446. string pData_str = "";
  5447. string curUseWayBillCode = "";
  5448. if (isUseLastWayBillCode == false)
  5449. {
  5450. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5451. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5452. if (res.IndexOf("failure") != -1)
  5453. {
  5454. //int idx = res.IndexOf("sub_message");
  5455. //int idx2 = res.IndexOf("flag");
  5456. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5457. string errMsgNeed = commonHelper.KeepChinese(res);
  5458. var res_objd = new
  5459. {
  5460. restype = 0,
  5461. data = "获取面单失败" + errMsgNeed
  5462. };
  5463. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5464. returnSuccess(ro_jsond);
  5465. if (res.IndexOf("停发") != -1)
  5466. {
  5467. entity.UnusualCon = "物流停发";
  5468. entity.Update();
  5469. }
  5470. //returnErrorMsg("获取面单失败,"+emsg);
  5471. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5472. return;
  5473. }
  5474. else if (res.IndexOf("errorMsg") != -1)
  5475. {
  5476. //int idx = res.IndexOf("errorMsg");
  5477. //int idx2 = res.IndexOf("}]}");
  5478. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5479. string errMsgNeed = commonHelper.KeepChinese(res);
  5480. var res_objf = new
  5481. {
  5482. restype = 0,
  5483. data = "获取面单失败2" + errMsgNeed
  5484. };
  5485. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5486. if (res.IndexOf("停发") != -1)
  5487. {
  5488. entity.UnusualCon = "物流停发";
  5489. entity.Update();
  5490. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5491. if (trade != null)
  5492. {
  5493. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5494. }
  5495. }
  5496. returnSuccess(ro_jsonf);
  5497. //returnErrorMsg("获取面单失败," + emsg);
  5498. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5499. return;
  5500. }
  5501. try
  5502. {
  5503. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5504. //res = res.Replace(" ", "");
  5505. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5506. }
  5507. catch (Exception ex)
  5508. {
  5509. XLog.SaveLog(0, "生成fullObj" + res);
  5510. var res_objf = new
  5511. {
  5512. restype = 0,
  5513. data = "生成fullObj发生错误" + ex.Message
  5514. };
  5515. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5516. returnSuccess(ro_jsonf);
  5517. return;
  5518. }
  5519. if (fullObj.response.data.content.Count > 0)
  5520. {
  5521. ContentItem codeObj = fullObj.response.data.content[0];
  5522. if (cpCode.IndexOf("SFFQ-") != -1)
  5523. {
  5524. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5525. }
  5526. else
  5527. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5528. curUseWayBillCode = codeObj.waybillCode;
  5529. }
  5530. else
  5531. {
  5532. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5533. var res_objf = new
  5534. {
  5535. restype = 0,
  5536. data = "生成fullObj找不到快递单号waybillCode"
  5537. };
  5538. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5539. returnSuccess(ro_jsonf);
  5540. return;
  5541. }
  5542. }
  5543. else
  5544. {
  5545. //使用上次打印的快递单号
  5546. if (cpCode == "SFFQ-LY")
  5547. {
  5548. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5549. }
  5550. else
  5551. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5552. curUseWayBillCode = entity.LastBillWaybillCode;
  5553. }
  5554. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5555. {
  5556. var res_obje = new
  5557. {
  5558. restype = 0,
  5559. data = "获取加密打印数据失败"
  5560. };
  5561. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5562. returnSuccess(ro_jsone);
  5563. entity.LastBillCpCode = cpCode;
  5564. entity.LastBillWaybillCode = curUseWayBillCode;
  5565. entity.Update();
  5566. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5567. //returnErrorMsg("获取加密打印数据失败");
  5568. return;
  5569. }
  5570. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5571. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5572. string btnType = "";
  5573. string errorMsg = "";
  5574. if (entity != null)
  5575. {
  5576. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5577. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5578. //cpcode是 YTO-CAINIAO
  5579. //string comCode = cpCode.Split('-')[0].ToString();
  5580. string apires = "";
  5581. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5582. //isTogether=2是新的合包弹窗
  5583. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5584. {
  5585. if (ctid.IndexOf("N") != -1)
  5586. {
  5587. apires = "发货成功";
  5588. }
  5589. else
  5590. {
  5591. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5592. }
  5593. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5594. //打单后发货
  5595. StringBuilder sql = new StringBuilder();
  5596. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5597. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5598. {
  5599. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5600. }
  5601. else
  5602. {
  5603. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5604. }
  5605. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5606. foreach (DataRow row in dt.Rows)
  5607. {
  5608. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5609. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5610. {
  5611. try
  5612. {
  5613. btnType = "待发货";
  5614. entity.OutSid = curUseWayBillCode;
  5615. entity.OrderState = 7;
  5616. entity.IsUrgency = false;
  5617. entity.LastBillCpCode = "";
  5618. entity.LastBillWaybillCode = "";
  5619. entity.FinishDeliveryTime = DateTime.Now;
  5620. entity.IsReturn = 0;
  5621. entity.MemoOpt = 0;
  5622. entity.UpdateTime = DateTime.Now;
  5623. entity.Update();
  5624. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5625. //还要插入快递信息到 快递信息表
  5626. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5627. exinfo.tid = entity.ctid;
  5628. exinfo.out_sid = curUseWayBillCode;
  5629. exinfo.company_code = cpCode;
  5630. exinfo.company_name = cpName;
  5631. exinfo.supplierUserName = supplierName;
  5632. exinfo.deliveryType = "发货成功";
  5633. exinfo.print_time = DateTime.Now;
  5634. exinfo.printUser = CurrentUser.UserName;
  5635. exinfo.postData = pData_str;
  5636. exinfo.Create();
  5637. commonHelper.UpdateRelationOrder(entity.ctid);
  5638. CeErpSukuraData.createInfo(ctid, 4);
  5639. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5640. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5641. {
  5642. commonHelper.sendCytExpress(exinfo);
  5643. }
  5644. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5645. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5646. }
  5647. catch (Exception ex)
  5648. {
  5649. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5650. }
  5651. }
  5652. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5653. {
  5654. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5655. if (entity.OrderState == 6)
  5656. {
  5657. entity.OrderState = 7;
  5658. }
  5659. entity.UpdateTime = DateTime.Now;
  5660. entity.FinishDeliveryTime = DateTime.Now;
  5661. btnType = "已发货";
  5662. entity.Update();
  5663. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5664. exinfo.tid = entity.ctid;
  5665. exinfo.out_sid = curUseWayBillCode;
  5666. exinfo.company_code = cpCode;
  5667. exinfo.company_name = cpName;
  5668. exinfo.supplierUserName = supplierName;
  5669. exinfo.deliveryType = "发货成功";
  5670. exinfo.print_time = DateTime.Now;
  5671. exinfo.printUser = CurrentUser.UserName;
  5672. exinfo.postData = pData_str;
  5673. exinfo.Create();
  5674. commonHelper.UpdateRelationOrder(entity.ctid);
  5675. CeErpSukuraData.createInfo(entity.ctid, 4);
  5676. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5677. {
  5678. commonHelper.sendCytExpress(exinfo);
  5679. }
  5680. //不处理
  5681. }
  5682. else
  5683. {
  5684. entity.UpdateTime = DateTime.Now;
  5685. entity.LastBillCpCode = cpCode;
  5686. entity.LastBillWaybillCode = curUseWayBillCode;
  5687. entity.Update();
  5688. string errmsg = commonHelper.KeepChinese(apires);
  5689. var res_objz = new
  5690. {
  5691. restype = 0,
  5692. data = "打单后发货失败"
  5693. };
  5694. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5695. returnSuccess(ro_jsonz);
  5696. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5697. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5698. return;
  5699. }
  5700. }
  5701. }
  5702. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5703. {
  5704. string ctids = GetPostString("ctids");
  5705. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5706. List<string> list = new List<string>();
  5707. List<string> send_list = new List<string>();
  5708. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5709. CeErpTrade ceErpTrade = new CeErpTrade();
  5710. //可合包的合并一起发货
  5711. if (dt == null && string.IsNullOrEmpty(ctids))
  5712. {
  5713. var res_objz = new
  5714. {
  5715. restype = 0,
  5716. data = "打单后发货失败"
  5717. };
  5718. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5719. returnSuccess(ro_jsonz);
  5720. return;
  5721. }
  5722. if (!string.IsNullOrEmpty(ctids))
  5723. {
  5724. StringBuilder sql = new StringBuilder();
  5725. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5726. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5727. }
  5728. foreach (DataRow row in dt.Rows)
  5729. {
  5730. list.Add("'" + row["ctid"] + "'");
  5731. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5732. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5733. if (ctid.IndexOf("N") != -1)
  5734. {
  5735. apires = "发货成功";
  5736. }
  5737. else
  5738. {
  5739. if (!send_list.Contains(ceErpTrade.tid))
  5740. {
  5741. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5742. }
  5743. else
  5744. {
  5745. apires = "发货成功";
  5746. }
  5747. }
  5748. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5749. {
  5750. send_list.Add(ceErpTrade.tid);
  5751. try
  5752. {
  5753. btnType = "待发货";
  5754. ceErpTradeCell.OutSid = curUseWayBillCode;
  5755. ceErpTradeCell.OrderState = 7;
  5756. ceErpTradeCell.IsUrgency = false;
  5757. ceErpTradeCell.LastBillCpCode = "";
  5758. ceErpTradeCell.LastBillWaybillCode = "";
  5759. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5760. ceErpTradeCell.IsReturn = 0;
  5761. ceErpTradeCell.MemoOpt = 0;
  5762. ceErpTradeCell.UpdateTime = DateTime.Now;
  5763. ceErpTradeCell.Update();
  5764. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5765. //还要插入快递信息到 快递信息表
  5766. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5767. exinfo.tid = ceErpTradeCell.ctid;
  5768. exinfo.out_sid = curUseWayBillCode;
  5769. exinfo.company_code = cpCode;
  5770. exinfo.company_name = cpName;
  5771. exinfo.supplierUserName = supplierName;
  5772. exinfo.deliveryType = "发货成功";
  5773. exinfo.print_time = DateTime.Now;
  5774. exinfo.printUser = CurrentUser.UserName;
  5775. exinfo.postData = pData_str;
  5776. exinfo.Create();
  5777. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5778. CeErpSukuraData.createInfo(ctid, 4);
  5779. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5780. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5781. {
  5782. commonHelper.sendCytExpress(exinfo);
  5783. }
  5784. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5785. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5786. }
  5787. catch (Exception ex)
  5788. {
  5789. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5790. }
  5791. }
  5792. else
  5793. {
  5794. ceErpTradeCell.UpdateTime = DateTime.Now;
  5795. ceErpTradeCell.LastBillCpCode = cpCode;
  5796. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5797. ceErpTradeCell.Update();
  5798. string errmsg = commonHelper.KeepChinese(apires);
  5799. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5800. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5801. }
  5802. }
  5803. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5804. }
  5805. }
  5806. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5807. var res_obj = new
  5808. {
  5809. restype = 1,
  5810. data = pData_str,
  5811. errorMsg
  5812. };
  5813. string ro_json = JsonConvert.SerializeObject(res_obj);
  5814. ReturnSuccess(ro_json);
  5815. return;
  5816. }
  5817. }
  5818. private string GetUTF8String(byte[] vs)
  5819. {
  5820. throw new NotImplementedException();
  5821. }
  5822. public void set_erp_printwaybill_cn()
  5823. {
  5824. if (UrlPostParmsCheck("ctid"))
  5825. {
  5826. string ctid = GetPostString("ctid");
  5827. string cpCode = GetPostString("cpcode");
  5828. string cpName = GetPostString("cpname");
  5829. string tempUrl = GetPostString("tempurl");
  5830. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5831. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5832. //string res = taobaoHelper.test();
  5833. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5834. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5835. {
  5836. int sidx = res.IndexOf("errorMsg");
  5837. int eidx = res.IndexOf("}");
  5838. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5839. var res_objzxx = new
  5840. {
  5841. restype = 0,
  5842. data = msg
  5843. };
  5844. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5845. returnSuccess(ro_jsonzxx);
  5846. //returnErrorMsg(msg);
  5847. return;
  5848. }
  5849. int idx = res.IndexOf("waybillCode");
  5850. int idx2 = res.IndexOf("printData");
  5851. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5852. string eid = GetPostString("ctid");
  5853. CeErpTradeCell entity = null;
  5854. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5855. if (entity != null)
  5856. {
  5857. string osid = entity.OutSid;
  5858. entity.OutSid = osid + "," + outsid;
  5859. entity.FinishDeliveryTime = DateTime.Now;
  5860. entity.OrderState = 7;
  5861. entity.UpdateTime = DateTime.Now;
  5862. entity.IsReturn = 0;
  5863. entity.Update();
  5864. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5865. exinfo.tid = entity.ctid;
  5866. exinfo.out_sid = outsid;
  5867. exinfo.company_code = cpCode;
  5868. exinfo.company_name = cpName;
  5869. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5870. exinfo.deliveryType = "发货成功";
  5871. exinfo.print_time = DateTime.Now;
  5872. exinfo.printUser = CurrentUser.UserName;
  5873. exinfo.Create();
  5874. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5875. {
  5876. commonHelper.sendCytExpress(exinfo);
  5877. }
  5878. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5879. }
  5880. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5881. var res_objz = new
  5882. {
  5883. restype = 1,
  5884. data = res
  5885. };
  5886. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5887. returnSuccess(ro_jsonz);
  5888. //ReturnSuccess(res);
  5889. }
  5890. }
  5891. ////打单,打印面单 获取面单号
  5892. //public void set_erp_printwaybill()
  5893. //{
  5894. // if (UrlPostParmsCheck("ctid"))
  5895. // {
  5896. // string ctid = GetPostString("ctid");
  5897. // string cpCode = GetPostString("cpcode");
  5898. // string tempUrl = GetPostString("tempurl");
  5899. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5900. // //string res = taobaoHelper.test();
  5901. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5902. // if (res.IndexOf("error_response") != -1)
  5903. // {
  5904. // int sidx = res.IndexOf("sub_msg");
  5905. // int eidx = res.IndexOf("request_id");
  5906. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5907. // returnErrorMsg(msg);
  5908. // return;
  5909. // }
  5910. // int idx = res.IndexOf("waybill_code");
  5911. // int idx2 = res.IndexOf("}]}");
  5912. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5913. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5914. // ReturnSuccess(res);
  5915. // }
  5916. //}
  5917. public void cancel_erp_aftersale()
  5918. {
  5919. if (UrlPostParmsCheck("ctid"))
  5920. {
  5921. string eid = GetPostString("ctid");
  5922. CeErpTradeCell entity = null;
  5923. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5924. if (entity != null)
  5925. {
  5926. //有过处理的售后,取消也不能删除 售 字,保留
  5927. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5928. {
  5929. entity.AfterSaleState = 4;
  5930. }
  5931. else
  5932. entity.AfterSaleState = 0;
  5933. entity.UpdateTime = DateTime.Now;
  5934. entity.Update();
  5935. returnSuccessMsg("操作成功!");
  5936. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5937. return;
  5938. }
  5939. returnErrorMsg("找不到订单记录");
  5940. }
  5941. }
  5942. public void get_erp_aftersalelist()
  5943. {
  5944. DataStruct dStruct = GetPostStruct();
  5945. List<string> lw = new List<string>();
  5946. int st = GetInt("st");
  5947. string tid = GetPostString("ctid");
  5948. if (st == 3)
  5949. {
  5950. if (tid.Length > 0)
  5951. {
  5952. string select_tid = getTidByCtid(tid);
  5953. lw.Add(string.Format("tid='{0}'", select_tid));
  5954. }
  5955. }
  5956. else
  5957. {
  5958. if (tid.Length > 0)
  5959. {
  5960. string select_tid = getTidByCtid(tid);
  5961. lw.Add(string.Format("tid='{0}'", select_tid));
  5962. }
  5963. }
  5964. string shopname = GetPostString("shopname");
  5965. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5966. string buyernick = GetPostString("buyer_nick");
  5967. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5968. string sellermemo = GetPostString("seller_memo");
  5969. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5970. string orderState = GetPostString("orderState");
  5971. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5972. string afterState = GetPostString("afterstate");
  5973. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5974. string date1 = GetPostString("date1");
  5975. string date2 = GetPostString("date2");
  5976. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5977. if (dw.Length > 0) lw.Add(dw);
  5978. string price1 = GetPostString("price1");
  5979. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5980. string price2 = GetPostString("price2");
  5981. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5982. //lw.Add(string.Format("IsRefund!={0}", 1));
  5983. string reason = GetPostString("reason");
  5984. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5985. string method = GetPostString("method");
  5986. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5987. string handler = GetPostString("handler");
  5988. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5989. string handledate1 = GetPostString("handledate1");
  5990. string handledate2 = GetPostString("handledate2");
  5991. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5992. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5993. string finish1 = GetPostString("finishdate1");
  5994. string finish2 = GetPostString("finishdate2");
  5995. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5996. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5997. string afterdate1 = GetPostString("afterdate1");
  5998. string afterdate2 = GetPostString("afterdate2");
  5999. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6000. if (afterDate.Length > 0) lw.Add(afterDate);
  6001. string supplier = GetPostString("supplier");
  6002. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6003. string responsible = GetPostString("responsibleman");
  6004. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6005. string customer = GetPostString("customer");
  6006. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6007. string design = GetPostString("design");
  6008. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6009. string afterMemoType = GetPostString("aftermemotype");
  6010. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6011. string posCode = CurrentUser.UserPost.Post.Code;
  6012. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6013. //{
  6014. // string vstate = GetPostString("vstate");
  6015. // if (vstate.Length > 0)
  6016. // {
  6017. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6018. // }
  6019. // if (posCode == "Supplier")
  6020. // {
  6021. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6022. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6023. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6024. // }
  6025. // else
  6026. // {
  6027. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6028. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6029. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6030. // {
  6031. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6032. // }
  6033. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6034. // {
  6035. // int orgid = CurrentUser.UserPost.OrgID;
  6036. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6037. // }
  6038. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6039. // {
  6040. // string shopid = CurrentUser.User.pemShop;
  6041. // lw.Add(string.Format("shopId in ({0})", shopid));
  6042. // }
  6043. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6044. // //{
  6045. // // int org_id = CurrentUser.UserPost.OrgID;
  6046. // // lw.Add(string.Format("OrgID={0}", org_id));
  6047. // //}
  6048. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6049. // }
  6050. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6051. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6052. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6053. //}
  6054. if (st == 5)
  6055. {
  6056. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6057. {
  6058. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6059. {
  6060. string shopid = CurrentUser.User.pemShop;
  6061. lw.Add(string.Format("shopId in ({0})", shopid));
  6062. }
  6063. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6064. {
  6065. int mrOrgid = CurrentUser.UserPost.OrgID;
  6066. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6067. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6068. }
  6069. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6070. //{
  6071. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6072. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6073. //}
  6074. else
  6075. {
  6076. string userIdStr = "";
  6077. if (posCode == "CustomerService")
  6078. {
  6079. userIdStr = CurrentUser.UserID + "_k";
  6080. }
  6081. else if (posCode == "Designer" || posCode == "wxDesigner")
  6082. {
  6083. userIdStr = CurrentUser.UserID + "_s";
  6084. }
  6085. else if (posCode == "Place")
  6086. {
  6087. userIdStr = CurrentUser.UserID + "_x";
  6088. }
  6089. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6090. }
  6091. }
  6092. string placedate1 = GetPostString("placedate1");
  6093. string placedate2 = GetPostString("placedate2");
  6094. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6095. if (dwplace.Length > 0) lw.Add(dwplace);
  6096. string supState = GetPostString("supState");
  6097. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6098. string searchType = GetPostString("searchType");
  6099. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6100. {
  6101. lw.Add(string.Format("BackNum>1"));
  6102. }
  6103. lw.Add(string.Format("AfterSaleState>0"));
  6104. if (ex_psize > 0)
  6105. {
  6106. if (CurrentUser.UserPost.Post.Code == "Finance")
  6107. dStruct.Order = "pay_time desc";
  6108. else
  6109. dStruct.Order = "HandleTime desc";
  6110. }
  6111. else
  6112. dStruct.Order = "HandleTime desc";
  6113. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6114. DataTable dt = WebCache.GetData("view_test", dStruct);
  6115. writeGridDataTableJson(dStruct.TotalCount, dt);
  6116. }
  6117. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6118. //{
  6119. // lw.Add(string.Format("AfterSaleState=4"));
  6120. // string code = CurrentUser.UserPost.Post.Code;
  6121. // if (code == "CustomerService")
  6122. // {
  6123. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6124. // }
  6125. // else if (code == "Designer" || code == "DesignerMr")
  6126. // {
  6127. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6128. // }
  6129. // else if (code == "Place" || code == "PlaceMr")
  6130. // {
  6131. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6132. // }
  6133. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6134. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6135. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6136. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6137. //}
  6138. //else //处理中的售后,待处理和处理中合并
  6139. //{
  6140. // if (afterState.Length <= 0)
  6141. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6142. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6143. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6144. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6145. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6146. //}
  6147. }
  6148. public void get_erp_disagreeftersalelist()
  6149. {
  6150. DataStruct dStruct = GetPostStruct();
  6151. List<string> lw = new List<string>();
  6152. int st = 2;
  6153. string tid = GetPostString("ctid");
  6154. if (tid.Length > 0)
  6155. {
  6156. string select_tid = getTidByCtid(tid);
  6157. lw.Add(string.Format("tid='{0}'", select_tid));
  6158. }
  6159. string shopname = GetPostString("shopname");
  6160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6161. string buyernick = GetPostString("buyer_nick");
  6162. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6163. string sellermemo = GetPostString("seller_memo");
  6164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6165. string orderState = GetPostString("orderState");
  6166. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6167. string afterState = GetPostString("afterstate");
  6168. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6169. string date1 = GetPostString("date1");
  6170. string date2 = GetPostString("date2");
  6171. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6172. if (dw.Length > 0) lw.Add(dw);
  6173. string price1 = GetPostString("price1");
  6174. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6175. string price2 = GetPostString("price2");
  6176. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6177. //lw.Add(string.Format("IsRefund!={0}", 1));
  6178. string reason = GetPostString("reason");
  6179. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6180. string method = GetPostString("method");
  6181. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6182. string handler = GetPostString("handler");
  6183. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6184. string handledate1 = GetPostString("handledate1");
  6185. string handledate2 = GetPostString("handledate2");
  6186. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6187. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6188. string afterdate1 = GetPostString("afterdate1");
  6189. string afterdate2 = GetPostString("afterdate2");
  6190. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6191. if (afterDate.Length > 0) lw.Add(afterDate);
  6192. string backdate1 = GetPostString("backdate1");
  6193. string backdate2 = GetPostString("backdate2");
  6194. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6195. if (backDate.Length > 0) lw.Add(backDate);
  6196. string supplier = GetPostString("supplier");
  6197. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6198. string responsible = GetPostString("responsibleman");
  6199. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6200. string customer = GetPostString("customer");
  6201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6202. string design = GetPostString("design");
  6203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6204. string afterSaleMemo = GetPostString("afterSaleMemo");
  6205. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6206. string afterMemoType = GetPostString("aftermemotype");
  6207. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6208. string aftersakereason = GetPostString("aftersakereason");
  6209. if (aftersakereason.Length > 0)
  6210. {
  6211. if (aftersakereason == "1")
  6212. {
  6213. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6214. }
  6215. if (aftersakereason == "2")
  6216. {
  6217. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6218. }
  6219. }
  6220. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6221. string poscode = CurrentUser.UserPost.Post.Code;
  6222. if (poscode != "SysAdmin")
  6223. {
  6224. string shopid = CurrentUser.User.pemShop;
  6225. lw.Add(string.Format("shopId in ({0})", shopid));
  6226. }
  6227. string searchType = GetPostString("searchType");
  6228. if (searchType == "wait")
  6229. {
  6230. lw.Add(string.Format("HandleTime is null"));
  6231. }
  6232. if (searchType == "handling")
  6233. {
  6234. lw.Add(string.Format("HandleTime is not null "));
  6235. }
  6236. if (searchType == "back" || searchType == "puBack")
  6237. {
  6238. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6239. }
  6240. if (searchType == "reBack")
  6241. {
  6242. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6243. }
  6244. if (searchType == "moreBack")
  6245. {
  6246. lw.Add(string.Format("backNum > 1"));
  6247. }
  6248. lw.Add(string.Format("(AfterSaleState=5)"));
  6249. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6250. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6251. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6252. writeGridDataTableJson(dStruct.TotalCount, dt);
  6253. }
  6254. public void get_erp_handlingaftersalelist()
  6255. {
  6256. DataStruct dStruct = GetPostStruct();
  6257. List<string> lw = new List<string>();
  6258. int st = 2;
  6259. string tid = GetPostString("ctid");
  6260. if (tid.Length > 0)
  6261. {
  6262. string select_tid = getTidByCtid(tid);
  6263. lw.Add(string.Format("tid='{0}'", select_tid));
  6264. }
  6265. string shopname = GetPostString("shopname");
  6266. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6267. string buyernick = GetPostString("buyer_nick");
  6268. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6269. string sellermemo = GetPostString("seller_memo");
  6270. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6271. string orderState = GetPostString("orderState");
  6272. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6273. string afterState = GetPostString("afterstate");
  6274. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6275. string date1 = GetPostString("date1");
  6276. string date2 = GetPostString("date2");
  6277. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6278. if (dw.Length > 0) lw.Add(dw);
  6279. string price1 = GetPostString("price1");
  6280. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6281. string price2 = GetPostString("price2");
  6282. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6283. //lw.Add(string.Format("IsRefund!={0}", 1));
  6284. string reason = GetPostString("reason");
  6285. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6286. string method = GetPostString("method");
  6287. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6288. string handler = GetPostString("handler");
  6289. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6290. string handledate1 = GetPostString("handledate1");
  6291. string handledate2 = GetPostString("handledate2");
  6292. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6293. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6294. string afterdate1 = GetPostString("afterdate1");
  6295. string afterdate2 = GetPostString("afterdate2");
  6296. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6297. if (afterDate.Length > 0) lw.Add(afterDate);
  6298. string supplier = GetPostString("supplier");
  6299. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6300. string responsible = GetPostString("responsibleman");
  6301. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6302. string customer = GetPostString("customer");
  6303. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6304. string design = GetPostString("design");
  6305. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6306. string afterSaleMemo = GetPostString("afterSaleMemo");
  6307. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6308. string afterMemoType = GetPostString("aftermemotype");
  6309. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6310. string afterresult = GetPostString("afterresult");
  6311. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6312. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6313. string poscode = CurrentUser.UserPost.Post.Code;
  6314. if (poscode != "SysAdmin")
  6315. {
  6316. string shopid = CurrentUser.User.pemShop;
  6317. lw.Add(string.Format("shopId in ({0})", shopid));
  6318. }
  6319. string searchType = GetPostString("searchType");
  6320. if (searchType == "wait")
  6321. {
  6322. lw.Add(string.Format("HandleTime is null"));
  6323. }
  6324. if (searchType == "documentary")
  6325. {
  6326. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6327. }
  6328. if (searchType == "handling")
  6329. {
  6330. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6331. }
  6332. if (searchType == "back" || searchType == "puBack")
  6333. {
  6334. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6335. }
  6336. if (searchType == "reBack")
  6337. {
  6338. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6339. }
  6340. if (afterState.Length <= 0)
  6341. {
  6342. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6343. }
  6344. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6345. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6346. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6347. writeGridDataTableJson(dStruct.TotalCount, dt);
  6348. }
  6349. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6350. //public void get_erp_back_handlingaftersalelist()
  6351. //{
  6352. // DataStruct dStruct = GetPostStruct();
  6353. // List<string> lw = new List<string>();
  6354. // string tid = GetPostString("ctid");
  6355. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6356. // string shopname = GetPostString("shopname");
  6357. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6358. // string buyernick = GetPostString("buyer_nick");
  6359. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6360. // string sellermemo = GetPostString("seller_memo");
  6361. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6362. // string orderState = GetPostString("orderState");
  6363. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6364. // string afterState = GetPostString("afterstate");
  6365. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6366. // string date1 = GetPostString("date1");
  6367. // string date2 = GetPostString("date2");
  6368. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6369. // if (dw.Length > 0) lw.Add(dw);
  6370. // string price1 = GetPostString("price1");
  6371. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6372. // string price2 = GetPostString("price2");
  6373. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6374. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6375. // string reason = GetPostString("reason");
  6376. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6377. // string method = GetPostString("method");
  6378. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6379. // string handler = GetPostString("handler");
  6380. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6381. // string handledate1 = GetPostString("handledate1");
  6382. // string handledate2 = GetPostString("handledate2");
  6383. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6384. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6385. // string afterdate1 = GetPostString("afterdate1");
  6386. // string afterdate2 = GetPostString("afterdate2");
  6387. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6388. // if (afterDate.Length > 0) lw.Add(afterDate);
  6389. // string supplier = GetPostString("supplier");
  6390. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6391. // string responsible = GetPostString("responsibleman");
  6392. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6393. // string customer = GetPostString("customer");
  6394. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6395. // string design = GetPostString("design");
  6396. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6397. // string afterMemoType = GetPostString("aftermemotype");
  6398. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6399. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6400. // if (afterState.Length <= 0)
  6401. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6402. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6403. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6404. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6405. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6406. //}
  6407. public void get_erp_aftersaleverifylist()
  6408. {
  6409. DataStruct dStruct = GetPostStruct();
  6410. List<string> lw = new List<string>();
  6411. string tid = GetPostString("ctid");
  6412. if (tid.Length > 0)
  6413. {
  6414. string select_tid = getTidByCtid(tid);
  6415. lw.Add(string.Format("otid='{0}'", select_tid));
  6416. }
  6417. string shopname = GetPostString("shopname");
  6418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6419. string buyernick = GetPostString("buyer_nick");
  6420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6421. string sellermemo = GetPostString("seller_memo");
  6422. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6423. string orderState = GetPostString("orderState");
  6424. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6425. //lw.Add(string.Format("IsRefund!={0}", 1));
  6426. string reason = GetPostString("reason");
  6427. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6428. string method = GetPostString("method");
  6429. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6430. string handler = GetPostString("handler");
  6431. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6432. string handledate1 = GetPostString("handledate1");
  6433. string handledate2 = GetPostString("handledate2");
  6434. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6435. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6436. string finish1 = GetPostString("finishdate1");
  6437. string finish2 = GetPostString("finishdate2");
  6438. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6439. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6440. string supplier = GetPostString("supplier");
  6441. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6442. string responsible = GetPostString("responsibleman");
  6443. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6444. string posCode = CurrentUser.UserPost.Post.Code;
  6445. string vstate = GetPostString("vstate");
  6446. if (vstate.Length > 0)
  6447. {
  6448. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6449. }
  6450. if (posCode == "Supplier")
  6451. {
  6452. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6453. lw.Add(string.Format("VerifyState = 0"));
  6454. lw.Add("type = 1");
  6455. lw.Add(string.Format("AfterSaleState={0}", 3));
  6456. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6457. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6458. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6459. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6460. writeGridDataTableJson(dStruct.TotalCount, dt);
  6461. }
  6462. else if (posCode == "logistics")
  6463. {
  6464. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6465. lw.Add(string.Format("VerifyState = 0"));
  6466. lw.Add("type = 2");
  6467. lw.Add(string.Format("AfterSaleState={0}", 3));
  6468. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6469. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6470. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6471. writeGridDataTableJson(dStruct.TotalCount, dt);
  6472. }
  6473. else
  6474. {
  6475. lw.Add(string.Format("(AfterSaleState = 3)"));
  6476. string reasonState = GetPostString("reasonState");
  6477. lw.Add("type = 0");
  6478. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6479. || posCode == "Summarize" || posCode == "Finance")
  6480. {
  6481. if (reasonState == "2")
  6482. {
  6483. lw.Add("VerifyState = 3");
  6484. }
  6485. else if (reasonState == "1")
  6486. {
  6487. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6488. }
  6489. else
  6490. {
  6491. lw.Add("VerifyState in (0,3)");
  6492. }
  6493. //不加条件,可以看全部
  6494. }
  6495. 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")
  6496. {
  6497. int orgid = CurrentUser.UserPost.OrgID;
  6498. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6499. if (string.IsNullOrEmpty(manageOrgId))
  6500. {
  6501. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6502. }
  6503. else
  6504. {
  6505. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6506. }
  6507. if (reasonState == "1")
  6508. {
  6509. lw.Add("VerifyState = 3");
  6510. }
  6511. else if (reasonState == "2")
  6512. {
  6513. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6514. }
  6515. else
  6516. {
  6517. }
  6518. }
  6519. else
  6520. {
  6521. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6522. }
  6523. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6524. //{
  6525. // int org_id = CurrentUser.UserPost.OrgID;
  6526. // lw.Add(string.Format("OrgID={0}", org_id));
  6527. //}
  6528. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6529. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6530. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6531. writeGridDataTableJson(dStruct.TotalCount, dt);
  6532. }
  6533. }
  6534. public void get_erp_finishaftersalelist()
  6535. {
  6536. DataStruct dStruct = GetPostStruct();
  6537. List<string> lw = new List<string>();
  6538. int st = 4;
  6539. string tid = GetPostString("ctid");
  6540. if (tid.Length > 0)
  6541. {
  6542. string select_tid = getTidByCtid(tid);
  6543. lw.Add(string.Format("otid='{0}'", select_tid));
  6544. }
  6545. string shopname = GetPostString("shopname");
  6546. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6547. //lw.Add(string.Format("IsRefund!={0}", 1));
  6548. string reason = GetPostString("reason");
  6549. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6550. string method = GetPostString("method");
  6551. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6552. string buyernick = GetPostString("buyer_nick");
  6553. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6554. string handler = GetPostString("handler");
  6555. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6556. string handledate1 = GetPostString("handledate1");
  6557. string handledate2 = GetPostString("handledate2");
  6558. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6559. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6560. string finish1 = GetPostString("finishdate1");
  6561. string finish2 = GetPostString("finishdate2");
  6562. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6563. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6564. string supplier = GetPostString("supplier");
  6565. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6566. string responsible = GetPostString("responsibleman");
  6567. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6568. string vstate = GetPostString("vstate");
  6569. if (vstate.Length > 0)
  6570. {
  6571. if ("3".Equals(vstate))
  6572. {
  6573. lw.Add(string.Format("IsTem=1"));
  6574. }
  6575. else
  6576. {
  6577. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6578. }
  6579. }
  6580. lw.Add(string.Format("AfterSaleState=4"));
  6581. string code = CurrentUser.UserPost.Post.Code;
  6582. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6583. {
  6584. //不加条件,可以看全部
  6585. }
  6586. else if (code == "Supplier")
  6587. {
  6588. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6589. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6590. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6591. }
  6592. else if (code == "logistics")
  6593. {
  6594. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6595. lw.Add("type = 2");
  6596. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6597. }
  6598. 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")
  6599. {
  6600. int orgid = CurrentUser.UserPost.OrgID;
  6601. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6602. if (string.IsNullOrEmpty(manageOrgIds))
  6603. {
  6604. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6605. }
  6606. else
  6607. {
  6608. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6609. }
  6610. }
  6611. else
  6612. {
  6613. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6614. }
  6615. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6616. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6617. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6618. writeGridDataTableJson(dStruct.TotalCount, dt);
  6619. }
  6620. public void handle_erp_aftersale()
  6621. {
  6622. if (UrlPostParmsCheck("ctid"))
  6623. {
  6624. string eid = GetPostString("ctid");
  6625. string responStr = GetPostString("AfterSaleResponsible");
  6626. if (responStr.Length <= 0)
  6627. {
  6628. returnErrorMsg("售后责任人不能为空");
  6629. return;
  6630. }
  6631. bool isDesign = false;
  6632. double designFree = 0.00;
  6633. int responsibleId = 0;
  6634. CeErpTradeCell entity = null;
  6635. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6636. if (entity != null)
  6637. {
  6638. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6639. string afterMethod = GetPostString("AfterSaleMethod");
  6640. if (isNeedNewOrder == 1)
  6641. {
  6642. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6643. bool ishav = true;
  6644. if (newentity == null)
  6645. {
  6646. newentity = entity.Clone() as CeErpTradeCell;
  6647. ishav = false;
  6648. newentity.ctid = "S_" + entity.ctid;
  6649. newentity.OrderState = 0;
  6650. //唯一标识
  6651. newentity.OrderSn = newentity.ctid;
  6652. string orderSn = dataHelper.getSaleOrderSn();
  6653. if (orderSn != "")
  6654. {
  6655. newentity.OrderSn = orderSn;
  6656. }
  6657. }
  6658. newentity.UpdateTime = DateTime.Now;
  6659. newentity.AfterSaleState = 0;
  6660. newentity.AfterSaleMethod = afterMethod;
  6661. if (!ishav)
  6662. {
  6663. string memo_str = newentity.seller_memo;
  6664. memo_str = memo_str.Replace("(", "(");
  6665. memo_str = memo_str.Replace(")", ")");
  6666. int sIndex = memo_str.IndexOf("(");
  6667. int eIndex = memo_str.IndexOf(")");
  6668. if (sIndex == -1 || eIndex == -1)
  6669. {
  6670. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6671. return;
  6672. }
  6673. string first = memo_str.Substring(0, sIndex + 1);
  6674. string memoCtid = newentity.OrderSn;
  6675. //if (memoCtid.IndexOf("C") != -1)
  6676. //{
  6677. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6678. //if (CIdx.IndexOf("+") != -1)
  6679. //{
  6680. //CIdx = "C" + CIdx.Split('+')[1];
  6681. //}
  6682. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6683. //}
  6684. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6685. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6686. string newMemo = first + memoCtid + last;
  6687. newentity.seller_memo = newMemo;
  6688. newentity.FinishPlaceTime = null;
  6689. newentity.UnusualTag = 0;
  6690. newentity.UnusualCon = "";
  6691. newentity.UnusualTime = null;
  6692. newentity.AfterSaleMemo = "";
  6693. newentity.AfterSaleMethod = afterMethod;
  6694. newentity.AfterSalePreTime = null;
  6695. newentity.AfterSaleReason = "";
  6696. newentity.AfterSaleResponsible = "";
  6697. newentity.AfterSaleState = 0;
  6698. newentity.AfterSaleTime = null;
  6699. newentity.AfterSaleUserId = 0;
  6700. newentity.AfterSaleSupplierState = 0;
  6701. newentity.LastBillWaybillCode = "";
  6702. newentity.LastBillCpCode = "";
  6703. newentity.FinishAfterSaleTime = null;
  6704. newentity.HandleTime = null;
  6705. newentity.IsSF = 0;
  6706. newentity.IsOldCustomer = 0;
  6707. newentity.UrgencyTime = null;
  6708. newentity.ResponsibleUserId = "";
  6709. newentity.IsVerifyToSupplier = false;
  6710. newentity.payment = 0;
  6711. newentity.CheckMemo = "";
  6712. newentity.OutSid = "";
  6713. newentity.CheckOrderTime = null;
  6714. newentity.MemoOpt = 0;
  6715. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6716. }
  6717. newentity.isAfterSaleOrder = 1;
  6718. newentity.IsRefund = 0;
  6719. string receiveMobile = GetPostString("receiver_mobile");
  6720. if (receiveMobile.Length > 0)
  6721. {
  6722. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6723. if (trade != null)
  6724. {
  6725. trade.receiver_name = GetPostString("receiver_name");
  6726. trade.receiver_mobile = receiveMobile;
  6727. trade.receiver_state = GetPostString("receiver_state");
  6728. trade.receiver_city = GetPostString("receiver_city");
  6729. trade.receiver_district = GetPostString("receiver_district");
  6730. trade.receiver_address = GetPostString("receiver_address");
  6731. newentity.IsOffLineOrder = 1;
  6732. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6733. }
  6734. }
  6735. string st = GetPostString("ToState");
  6736. if (st.Length > 0)
  6737. {
  6738. if (newentity.OrderState <= 3)
  6739. {
  6740. newentity.WaitDesignTime = DateTime.Now;
  6741. newentity.StartDesignTime = null;
  6742. newentity.FinishDesignTime = null;
  6743. newentity.OrderState = 3;
  6744. if (st == "下单员")
  6745. {
  6746. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6747. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6748. {
  6749. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6750. }
  6751. }
  6752. else
  6753. {
  6754. newentity.WaitDesignTime = DateTime.Now;
  6755. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6756. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6757. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6758. {
  6759. DataRow user = dt1.Rows[0];
  6760. //找主管
  6761. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6762. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6763. if (dt != null && dt.Rows.Count > 0)
  6764. {
  6765. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6766. newentity.DesignUserId = designMr;
  6767. string key = "aftersale_order_" + designMr;
  6768. if (RedisHelper.HasKey(key))
  6769. {
  6770. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6771. list.Add(newentity.ctid);
  6772. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6773. }
  6774. }
  6775. //账号正常
  6776. if (user["State"].ToString() == "0")
  6777. {
  6778. newentity.DesignUserId = entity.DesignUserId;
  6779. string key = "aftersale_order_" + entity.DesignUserId;
  6780. if (RedisHelper.HasKey(key))
  6781. {
  6782. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6783. list.Add(newentity.ctid);
  6784. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6785. }
  6786. }
  6787. }
  6788. }
  6789. }
  6790. if (entity.IsXianHuo == 1)
  6791. {
  6792. newentity.OrderState = 6;
  6793. entity.FinishPlaceTime = DateTime.Now;
  6794. }
  6795. }
  6796. if (ishav)
  6797. {
  6798. newentity.Update();
  6799. }
  6800. else
  6801. {
  6802. newentity.Create();
  6803. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6804. newCellExtend.ctid = newentity.ctid;
  6805. newCellExtend.orderFrom = 20;
  6806. newCellExtend.orderType = 30;
  6807. if (st == "下单员")
  6808. {
  6809. }
  6810. else
  6811. {
  6812. newCellExtend.ReprintTime = DateTime.Now;
  6813. }
  6814. newCellExtend.Create();
  6815. }
  6816. if (st != "下单员")
  6817. {
  6818. if (entity.DispatchSort == 2)
  6819. {
  6820. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6821. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6822. }
  6823. }
  6824. }
  6825. //处理售后扩展
  6826. string resIdStr = GetPostString("ResponsibleUserId");
  6827. string refundFees = GetPostString("refundFrees");
  6828. int IsComplain = GetPostInt("isComplain");
  6829. int IsBad = GetPostInt("isBad");
  6830. string IsOriginal = GetPostString("isOriginal");
  6831. double diffResultPrice = GetPostDouble("diffResultPrice");
  6832. string textResult = GetPostString("textResult");
  6833. string supplierResponsible = GetPostString("supplierResponsible");
  6834. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6835. if (ceErpTradeAfterSaleExtend == null)
  6836. {
  6837. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6838. ceErpTradeAfterSaleExtend.tid = eid;
  6839. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6840. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6841. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6842. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6843. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6844. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6845. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6846. ceErpTradeAfterSaleExtend.Create();
  6847. }
  6848. else
  6849. {
  6850. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6851. {
  6852. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6853. }
  6854. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6855. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6856. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6857. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6858. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6859. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6860. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6861. ceErpTradeAfterSaleExtend.Update();
  6862. }
  6863. int gysid = GetPostInt("ResponsibleSupId");
  6864. if (entity.AfterSaleUserId == 0)
  6865. {
  6866. entity.AfterSaleUserId = CurrentUser.UserID;
  6867. }
  6868. entity.ResponsibleUserId = resIdStr;
  6869. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6870. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6871. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6872. {
  6873. CeErpTradeResponsible.DelByTid(eid, -1);
  6874. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6875. int backNum = 0;
  6876. if (number != null)
  6877. {
  6878. backNum = number.BackNum;
  6879. }
  6880. char[] separator = { ',' };
  6881. string[] sArray = resIdStr.Split(separator);
  6882. string[] refundFreeList = { };
  6883. if (refundFees.Length > 0)
  6884. {
  6885. refundFreeList = refundFees.Split(separator);
  6886. }
  6887. int index = -1;
  6888. foreach (string i in sArray)
  6889. {
  6890. index++;
  6891. if (i.Length <= 0) continue;
  6892. char[] separator2 = { '_' };
  6893. string idstr = i.Split(separator2)[0];
  6894. string idtype = i.Split(separator2)[1];
  6895. double refudFree = 0;
  6896. if (refundFreeList.Length > 0)
  6897. {
  6898. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6899. }
  6900. if (idtype == "s")
  6901. {
  6902. isDesign = true;
  6903. designFree = refudFree;
  6904. }
  6905. int userId = Convert.ToInt32(idstr);
  6906. int type = 0;
  6907. if (idtype == "g")
  6908. {
  6909. type = 1;
  6910. }
  6911. if (idtype == "w")
  6912. {
  6913. type = 2;
  6914. }
  6915. if (idtype == "t")
  6916. {
  6917. type = 3;
  6918. }
  6919. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6920. if (ceErpTradeResponsible == null)
  6921. {
  6922. ceErpTradeResponsible = new CeErpTradeResponsible();
  6923. ceErpTradeResponsible.tid = eid;
  6924. ceErpTradeResponsible.UserId = userId;
  6925. ceErpTradeResponsible.createdTime = DateTime.Now;
  6926. ceErpTradeResponsible.type = type;
  6927. if (type == 1)
  6928. {
  6929. ceErpTradeResponsible.IsSup = 1;
  6930. }
  6931. if (type == 2)
  6932. {
  6933. ceErpTradeResponsible.IsFlow = 1;
  6934. }
  6935. }
  6936. ceErpTradeResponsible.RefundFee = refudFree;
  6937. ceErpTradeResponsible.VerifyState = 0;
  6938. if (userId == 2125 || idtype == "w")
  6939. {
  6940. ceErpTradeResponsible.VerifyState = 1;
  6941. }
  6942. if (idtype == "w" && userId == 101)
  6943. {
  6944. ceErpTradeResponsible.VerifyState = 0;
  6945. }
  6946. if (ceErpTradeResponsible.ID > 0)
  6947. {
  6948. ceErpTradeResponsible.Update();
  6949. }
  6950. else
  6951. {
  6952. ceErpTradeResponsible.Create();
  6953. }
  6954. if (isDesign)
  6955. {
  6956. responsibleId = ceErpTradeResponsible.ID;
  6957. }
  6958. }
  6959. CeErpTradeResponsible.NumByTid(backNum, eid);
  6960. }
  6961. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6962. if (ceErpTradeCellExtend != null)
  6963. {
  6964. ceErpTradeCellExtend.returnVisit = 0;
  6965. ceErpTradeCellExtend.Update();
  6966. }
  6967. if (entity.HandleTime != null)
  6968. {
  6969. if (entity.AfterSaleState == 1)
  6970. {
  6971. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6972. }
  6973. else
  6974. {
  6975. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6976. }
  6977. }
  6978. else
  6979. {
  6980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6981. entity.HandleTime = DateTime.Now;
  6982. }
  6983. bool isCompale = false;
  6984. if (entity.AfterSaleState == 5)
  6985. {
  6986. isCompale = true;
  6987. entity.AfterSaleState = 3;
  6988. }
  6989. entity.AfterSaleSupplierState = 0;
  6990. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6991. {
  6992. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6993. }
  6994. string sImgs = GetPostString("img");
  6995. entity.AfterSaleSupplierImg = sImgs;
  6996. entity.supRefundType = GetPostString("supRefundType");
  6997. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6998. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6999. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7000. entity.AfterSaleMemoType = GetPostString("MemoType");
  7001. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7002. {
  7003. //entity.AfterSaleSupplierState = 2;
  7004. }
  7005. string df = GetPostString("DeductFee");
  7006. if (df == "")
  7007. {
  7008. df = "0";
  7009. }
  7010. string rf = GetPostString("RefundFee");
  7011. if (rf == "")
  7012. {
  7013. rf = "0";
  7014. }
  7015. string pm = GetPostString("AfterSalePayment");
  7016. if (pm == "")
  7017. {
  7018. pm = "0";
  7019. }
  7020. entity.AfterSalePayment = Convert.ToDouble(pm);
  7021. entity.DeductFee = Convert.ToDouble(df);
  7022. entity.RefundFee = Convert.ToDouble(rf);
  7023. entity.UpdateTime = DateTime.Now;
  7024. entity.Update();
  7025. string toState = GetPostString("ToState");
  7026. string original = GetPostString("isOriginal");
  7027. ApiVo apiVo = new ApiVo();
  7028. apiVo.orderNumber = entity.ctid;
  7029. apiVo.actionName = "afterDesign";
  7030. apiVo.orderRemarks = entity.AfterSaleMethod;
  7031. apiVo.reasonRemarks = entity.AfterSaleReason;
  7032. apiVo.isDesign = isDesign;
  7033. apiVo.designFree = designFree;
  7034. apiVo.responsibleId = responsibleId;
  7035. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7036. if (toState == "设计师")
  7037. {
  7038. apiVo.isOriginal = Convert.ToBoolean(original);
  7039. }
  7040. designHelper.API_WorkCore(apiVo);//afterDesign
  7041. CeErpMethod methodSql = new CeErpMethod();
  7042. methodSql.con = entity.AfterSaleMethod;
  7043. methodSql.addTime = DateTime.Now;
  7044. methodSql.Create();
  7045. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7046. CeErpMethod.ExecuteNonQuery(delsql);
  7047. if (isCompale)
  7048. {
  7049. aftersale_data_change(entity.ctid);
  7050. }
  7051. returnSuccessMsg("操作成功!");
  7052. return;
  7053. }
  7054. returnErrorMsg("找不到订单记录");
  7055. }
  7056. }
  7057. public void ins_erp_toresponsible()
  7058. {
  7059. if (UrlPostParmsCheck("ctid"))
  7060. {
  7061. string eid = GetPostString("ctid");
  7062. CeErpTradeCell entity = null;
  7063. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7064. if (entity != null)
  7065. {
  7066. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7067. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7068. {
  7069. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7070. return;
  7071. }
  7072. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7073. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7074. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7075. if (entity.AfterSalePreTime == null)
  7076. {
  7077. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7078. {
  7079. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7080. }
  7081. }
  7082. entity.AfterSalePreTime = DateTime.Now;
  7083. //预完成给售后主管审核客户问题直接完成
  7084. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7085. {
  7086. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7087. {
  7088. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7089. }
  7090. }
  7091. ceErpTradeAfterSaleExtend.Update();
  7092. entity.AfterSaleState = 2;
  7093. entity.UpdateTime = DateTime.Now;
  7094. entity.Update();
  7095. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7096. aftersale_data_change(entity.ctid);
  7097. returnSuccessMsg("操作成功!");
  7098. return;
  7099. }
  7100. returnErrorMsg("找不到订单记录");
  7101. }
  7102. }
  7103. public void cancel_erp_aftersaleanddelnew()
  7104. {
  7105. if (UrlPostParmsCheck("ctid"))
  7106. {
  7107. string eid = GetPostString("ctid");
  7108. CeErpTradeCell entity = null;
  7109. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7110. if (entity != null)
  7111. {
  7112. entity.AfterSaleState = 0;
  7113. entity.AfterSaleReason = "";
  7114. entity.AfterSaleMethod = "";
  7115. entity.AfterSaleMemo = "";
  7116. entity.AfterSaleResponsible = "";
  7117. entity.ResponsibleUserId = "";
  7118. entity.DeductFee = 0;
  7119. entity.RefundFee = 0;
  7120. entity.IsArbitrate = 0;
  7121. CeErpTradeResponsible.DelByTid(eid, -1);
  7122. entity.Update();
  7123. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7124. if (after != null)
  7125. {
  7126. if (after.OrderState < 5)
  7127. CeErpTradeCell.DelByCtid("S_" + eid);
  7128. }
  7129. returnSuccessMsg("操作成功!");
  7130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7131. return;
  7132. }
  7133. returnErrorMsg("找不到订单记录");
  7134. }
  7135. }
  7136. public void get_erp_aftersale_pregather()
  7137. {
  7138. List<string> lw = new List<string>();
  7139. int st = GetInt("st");
  7140. string tid = GetPostString("ctid");
  7141. if (tid.Length > 0)
  7142. {
  7143. string select_tid = getTidByCtid(tid);
  7144. lw.Add(string.Format("tid='{0}'", select_tid));
  7145. }
  7146. string shopname = GetPostString("shopname");
  7147. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7148. string buyernick = GetPostString("buyer_nick");
  7149. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7150. string sellermemo = GetPostString("seller_memo");
  7151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7152. string orderState = GetPostString("orderState");
  7153. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7154. string reason = GetPostString("reason");
  7155. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7156. string method = GetPostString("method");
  7157. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7158. string handler = GetPostString("handler");
  7159. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7160. string handledate1 = GetPostString("handledate1");
  7161. string handledate2 = GetPostString("handledate2");
  7162. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7163. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7164. string supplier = GetPostString("supplier");
  7165. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7166. string responsible = GetPostString("responsibleman");
  7167. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7168. string customer = GetPostString("customer");
  7169. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7170. string design = GetPostString("design");
  7171. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7172. string afterMemoType = GetPostString("aftermemotype");
  7173. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7174. string afterSaleMemo = GetPostString("afterSaleMemo");
  7175. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7176. string afterresult = GetPostString("afterresult");
  7177. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7178. string poscode = CurrentUser.UserPost.Post.Code;
  7179. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7180. {
  7181. string shopid = CurrentUser.User.pemShop;
  7182. lw.Add(string.Format("shopId in ({0})", shopid));
  7183. }
  7184. var mainwhere = string.Join(" and ", lw.ToArray());
  7185. string ro_json = "";
  7186. string type = GetPostString("gather_type");
  7187. int number = 0;
  7188. if (poscode == "AfterSale")
  7189. {
  7190. //处理中
  7191. if (type == "Handling")
  7192. {
  7193. 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) : ""));
  7194. DataTable dt = null;
  7195. try
  7196. {
  7197. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7198. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7199. }
  7200. catch (Exception e)
  7201. {
  7202. dt = new DataTable();
  7203. }
  7204. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7205. return;
  7206. }
  7207. if (type == "Wait")
  7208. {
  7209. //待处理
  7210. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7211. DataTable dt1 = null;
  7212. try
  7213. {
  7214. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7215. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7216. }
  7217. catch (Exception e)
  7218. {
  7219. dt1 = new DataTable();
  7220. }
  7221. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7222. return;
  7223. }
  7224. if (type == "back")
  7225. {
  7226. //打回
  7227. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7228. DataTable dt2 = null;
  7229. try
  7230. {
  7231. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7232. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7233. }
  7234. catch (Exception e)
  7235. {
  7236. dt2 = new DataTable();
  7237. }
  7238. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7239. return;
  7240. }
  7241. if (type == "preCompletion")
  7242. {
  7243. //预完成
  7244. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7245. DataTable dt3 = null;
  7246. try
  7247. {
  7248. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7249. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7250. }
  7251. catch (Exception e)
  7252. {
  7253. dt3 = new DataTable();
  7254. }
  7255. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7256. return;
  7257. }
  7258. if (type == "documentary")
  7259. {
  7260. //跟单中
  7261. 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) : ""));
  7262. DataTable dt4 = null;
  7263. try
  7264. {
  7265. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7266. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7267. }
  7268. catch (Exception e)
  7269. {
  7270. dt4 = new DataTable();
  7271. }
  7272. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7273. return;
  7274. }
  7275. if (type == "reBack")
  7276. {
  7277. //被打回
  7278. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7279. DataTable dt1 = null;
  7280. try
  7281. {
  7282. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7283. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7284. }
  7285. catch (Exception e)
  7286. {
  7287. dt1 = new DataTable();
  7288. }
  7289. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7290. return;
  7291. }
  7292. }
  7293. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7294. {
  7295. if (type == "puBack")
  7296. {
  7297. //退回
  7298. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7299. DataTable dt = null;
  7300. try
  7301. {
  7302. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7303. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7304. }
  7305. catch (Exception e)
  7306. {
  7307. dt = new DataTable();
  7308. }
  7309. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7310. return;
  7311. }
  7312. if (type == "reBack")
  7313. {
  7314. //打回
  7315. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7316. DataTable dt1 = null;
  7317. try
  7318. {
  7319. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7320. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7321. }
  7322. catch (Exception e)
  7323. {
  7324. dt1 = new DataTable();
  7325. }
  7326. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7327. return;
  7328. }
  7329. if (type == "examEd")
  7330. {
  7331. //已审核
  7332. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7333. DataTable dt2 = null;
  7334. try
  7335. {
  7336. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7337. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7338. }
  7339. catch (Exception e)
  7340. {
  7341. dt2 = new DataTable();
  7342. }
  7343. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7344. return;
  7345. }
  7346. if (type == "waitExam")
  7347. {
  7348. //待审核
  7349. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7350. DataTable dt3 = null;
  7351. try
  7352. {
  7353. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7354. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7355. }
  7356. catch (Exception e)
  7357. {
  7358. dt3 = new DataTable();
  7359. }
  7360. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7361. return;
  7362. }
  7363. if (type == "Handling")
  7364. {
  7365. //处理中
  7366. 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) : ""));
  7367. DataTable dt4 = null;
  7368. try
  7369. {
  7370. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7371. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7372. }
  7373. catch (Exception e)
  7374. {
  7375. dt4 = new DataTable();
  7376. }
  7377. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7378. return;
  7379. }
  7380. if (type == "Wait")
  7381. {
  7382. //待处理
  7383. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7384. DataTable dt5 = null;
  7385. try
  7386. {
  7387. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7388. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7389. }
  7390. catch (Exception e)
  7391. {
  7392. dt5 = new DataTable();
  7393. }
  7394. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7395. return;
  7396. }
  7397. if (type == "documentary")
  7398. {
  7399. //跟单中
  7400. 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) : ""));
  7401. DataTable dt6 = null;
  7402. try
  7403. {
  7404. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7405. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7406. }
  7407. catch (Exception e)
  7408. {
  7409. dt6 = new DataTable();
  7410. }
  7411. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7412. return;
  7413. }
  7414. }
  7415. returnSuccess(ro_json);
  7416. }
  7417. public void end_erp_aftersale()
  7418. {
  7419. if (UrlPostParmsCheck("ctid"))
  7420. {
  7421. string eid = GetPostString("ctid");
  7422. CeErpTradeCell entity = null;
  7423. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7424. if (entity != null)
  7425. {
  7426. string stype = GetPostString("stype");
  7427. string typeStr = stype;
  7428. entity.AfterSaleState = 4;
  7429. entity.FinishAfterSaleTime = DateTime.Now;
  7430. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7431. entity.Update();
  7432. ApiVo apiVo = new ApiVo();
  7433. apiVo.orderNumber = entity.ctid;
  7434. apiVo.actionName = "afterOver";
  7435. designHelper.API_WorkCore(apiVo); //afterOver
  7436. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7437. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7438. CeErpSukuraData.createInfo(entity.ctid, 8);
  7439. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7440. returnSuccessMsg("操作成功!");
  7441. return;
  7442. }
  7443. returnErrorMsg("找不到订单记录");
  7444. }
  7445. }
  7446. public void ins_erp_finishaftersale()
  7447. {
  7448. if (UrlPostParmsCheck("id"))
  7449. {
  7450. string eid = GetPostString("id");
  7451. CeErpTradeResponsible entity = null;
  7452. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7453. if (entity != null)
  7454. {
  7455. entity.VerifyState = 1;
  7456. entity.VerifyTime = DateTime.Now;
  7457. entity.Update();
  7458. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7459. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7460. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7461. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7462. if (dt.Rows.Count <= 0)
  7463. {
  7464. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7465. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7466. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7467. CeErpSukuraData.createInfo(entity.tid, 8);
  7468. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7469. {
  7470. CeErpDesignerBill.Del(entity.tid);
  7471. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7472. }
  7473. }
  7474. returnSuccessMsg("操作成功!");
  7475. return;
  7476. }
  7477. returnErrorMsg("找不到订单记录");
  7478. }
  7479. }
  7480. public void upd_erp_arbitrateaftersale()
  7481. {
  7482. if (UrlPostParmsCheck("id"))
  7483. {
  7484. string eid = GetPostString("id");
  7485. CeErpTradeResponsible entity = null;
  7486. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7487. if (entity != null)
  7488. {
  7489. entity.IsArbitrate = 1;
  7490. entity.ArbitradeMemo = GetPostString("reason");
  7491. entity.VerifyState = 2;
  7492. entity.Update();
  7493. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7494. if (tradecell != null)
  7495. {
  7496. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7497. tradecell.IsArbitrate = 1;
  7498. tradecell.Update();
  7499. }
  7500. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7501. returnSuccessMsg("操作成功!");
  7502. return;
  7503. }
  7504. returnErrorMsg("找不到订单记录");
  7505. }
  7506. }
  7507. public void upd_erp_backaftersale()
  7508. {
  7509. if (UrlPostParmsCheck("tid"))
  7510. {
  7511. string eid = GetPostString("tid");
  7512. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7513. int backNum = 0;
  7514. if (number != null)
  7515. {
  7516. backNum = number.BackNum;
  7517. }
  7518. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7519. CeErpTradeCell entity = null;
  7520. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7521. if (entity != null)
  7522. {
  7523. entity.AfterSaleBackReason = GetPostString("backreason");
  7524. entity.AfterSaleState = 1;
  7525. entity.AfterSaleSupplierState = 0;
  7526. entity.UpdateTime = DateTime.Now;
  7527. entity.Update();
  7528. returnSuccessMsg("操作成功!");
  7529. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7530. return;
  7531. }
  7532. returnErrorMsg("找不到订单记录");
  7533. }
  7534. }
  7535. public void get_erp_supplieraftersalelist()
  7536. {
  7537. DataStruct dStruct = GetPostStruct();
  7538. List<string> lw = new List<string>();
  7539. string tid = GetPostString("ctid");
  7540. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7541. string shopname = GetPostString("shopname");
  7542. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7543. string buyernick = GetPostString("buyer_nick");
  7544. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7545. string sellermemo = GetPostString("seller_memo");
  7546. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7547. string orderState = GetPostString("orderState");
  7548. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7549. string afterState = GetPostString("afterstate");
  7550. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7551. string date1 = GetPostString("date1");
  7552. string date2 = GetPostString("date2");
  7553. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7554. if (dw.Length > 0) lw.Add(dw);
  7555. string price1 = GetPostString("price1");
  7556. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7557. string price2 = GetPostString("price2");
  7558. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7559. string reason = GetPostString("reason");
  7560. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7561. string method = GetPostString("method");
  7562. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7563. string handledate1 = GetPostString("handledate1");
  7564. string handledate2 = GetPostString("handledate2");
  7565. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7566. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7567. string handler = GetPostString("handler");
  7568. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7569. string afterdate1 = GetPostString("afterdate1");
  7570. string afterdate2 = GetPostString("afterdate2");
  7571. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7572. if (afterDate.Length > 0) lw.Add(afterDate);
  7573. string customer = GetPostString("customer");
  7574. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7575. string design = GetPostString("design");
  7576. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7577. string afterMemoType = GetPostString("aftermemotype");
  7578. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7579. string vstate = GetPostString("vstate");
  7580. if (vstate.Length > 0)
  7581. {
  7582. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7583. }
  7584. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7585. string supplier = GetPostString("supplier");
  7586. int supid = commonHelper.getSupplierIDByName(supplier);
  7587. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7588. string posCode = CurrentUser.UserPost.Post.Code;
  7589. if (posCode == "Supplier")
  7590. {
  7591. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7592. }
  7593. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7594. {
  7595. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7596. }
  7597. else
  7598. {
  7599. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7600. }
  7601. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7602. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7603. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7604. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7605. writeGridDataTableJson(dStruct.TotalCount, dt);
  7606. }
  7607. public void upd_erp_supverifyaftersale()
  7608. {
  7609. if (UrlPostParmsCheck("id"))
  7610. {
  7611. string id = GetPostString("id");
  7612. int st = GetPostInt("afterstate");
  7613. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7614. CeErpTradeCell entity = null;
  7615. if (ceErpTradeResponsible != null)
  7616. {
  7617. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7618. }
  7619. string afmemo = GetPostString("supmemo");
  7620. string image = GetPostString("image");
  7621. if (entity != null)
  7622. {
  7623. entity.AfterSaleSupplierState = st;
  7624. entity.AfterSaleSupplierMemo = afmemo;
  7625. if (st == 1)
  7626. {
  7627. ceErpTradeResponsible.VerifyState = 1;
  7628. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7629. ceErpTradeResponsible.Update();
  7630. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7631. if (isAll)
  7632. {
  7633. entity.AfterSaleState = 4;
  7634. entity.FinishAfterSaleTime = DateTime.Now;
  7635. }
  7636. }
  7637. else
  7638. {
  7639. CeErpTradeResponsible.dateByTid(entity.ctid);
  7640. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7641. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7642. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7643. if (num <= 1)
  7644. {
  7645. entity.AfterSaleState = 1;
  7646. }
  7647. else
  7648. {
  7649. entity.AfterSaleState = 5;
  7650. }
  7651. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7652. if (ceErpTradeAfterSaleExtend != null)
  7653. {
  7654. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7655. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7656. ceErpTradeAfterSaleExtend.Update();
  7657. }
  7658. else
  7659. {
  7660. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7661. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7662. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7663. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7664. ceErpTradeAfterSaleExtend.Create();
  7665. }
  7666. }
  7667. if (entity.AfterSaleState == 4)
  7668. {
  7669. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7670. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7671. {
  7672. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7673. }
  7674. ApiVo apiVo = new ApiVo();
  7675. apiVo.orderNumber = entity.ctid;
  7676. apiVo.actionName = "afterOver";
  7677. designHelper.API_WorkCore(apiVo); //afterOver
  7678. }
  7679. entity.UpdateTime = DateTime.Now;
  7680. entity.Update();
  7681. returnSuccessMsg("操作成功!");
  7682. CeErpSukuraData.createInfo(entity.ctid, 8);
  7683. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7684. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7685. return;
  7686. }
  7687. returnErrorMsg("找不到订单记录");
  7688. }
  7689. }
  7690. public void upd_erp_masteraftersale()
  7691. {
  7692. if (UrlPostParmsCheck("id"))
  7693. {
  7694. string id = GetPostString("id");
  7695. int st = GetPostInt("afterstate");
  7696. string afmemo = GetPostString("supmemo");
  7697. string image = GetPostString("image");
  7698. string textResult = GetPostString("textResult");
  7699. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7700. if (ceErpTradeResponsible != null)
  7701. {
  7702. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7703. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7704. ceErpTradeResponsible.Update();
  7705. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7706. if (entity != null)
  7707. {
  7708. entity.AfterSaleSupplierState = st;
  7709. entity.AfterSaleSupplierMemo = afmemo;
  7710. if (st == 1)
  7711. {
  7712. }
  7713. else
  7714. {
  7715. CeErpTradeResponsible.dateByTid(entity.ctid);
  7716. //退回到售后
  7717. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7718. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7719. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7720. if (num <= 1)
  7721. {
  7722. entity.AfterSaleState = 1;
  7723. }
  7724. else
  7725. {
  7726. entity.AfterSaleState = 5;
  7727. }
  7728. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7729. if (ceErpTradeAfterSaleExtend != null)
  7730. {
  7731. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7732. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7733. ceErpTradeAfterSaleExtend.Update();
  7734. }
  7735. else
  7736. {
  7737. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7738. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7739. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7740. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7741. ceErpTradeAfterSaleExtend.Create();
  7742. }
  7743. }
  7744. entity.UpdateTime = DateTime.Now;
  7745. entity.Update();
  7746. returnSuccessMsg("操作成功!");
  7747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7748. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7749. return;
  7750. }
  7751. }
  7752. returnErrorMsg("找不到订单记录");
  7753. }
  7754. }
  7755. public void upd_erp_personaftersale()
  7756. {
  7757. if (UrlPostParmsCheck("id"))
  7758. {
  7759. //林小连
  7760. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7761. {
  7762. upd_erp_masteraftersale();
  7763. return;
  7764. }
  7765. string id = GetPostString("id");
  7766. int st = GetPostInt("afterstate");
  7767. string afmemo = GetPostString("supmemo");
  7768. string image = GetPostString("image");
  7769. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7770. if (ceErpTradeResponsible != null)
  7771. {
  7772. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7773. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7774. ceErpTradeResponsible.Update();
  7775. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7776. if (entity != null)
  7777. {
  7778. entity.AfterSaleSupplierMemo = afmemo;
  7779. entity.AfterSaleSupplierState = st;
  7780. if (st == 1)
  7781. {
  7782. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7783. if (isAll)
  7784. {
  7785. entity.AfterSaleState = 4;
  7786. entity.FinishAfterSaleTime = DateTime.Now;
  7787. }
  7788. }
  7789. else
  7790. {
  7791. CeErpTradeResponsible.dateByTid(entity.ctid);
  7792. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7793. if (ceErpTradeAfterSaleExtend != null)
  7794. {
  7795. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7796. ceErpTradeAfterSaleExtend.Update();
  7797. }
  7798. else
  7799. {
  7800. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7801. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7802. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7803. ceErpTradeAfterSaleExtend.Create();
  7804. }
  7805. //退回到主管
  7806. //entity.AfterSaleState = 2;
  7807. }
  7808. if (entity.AfterSaleState == 4)
  7809. {
  7810. ApiVo apiVo = new ApiVo();
  7811. apiVo.orderNumber = entity.ctid;
  7812. apiVo.actionName = "afterOver";
  7813. designHelper.API_WorkCore(apiVo); //afterOver
  7814. }
  7815. entity.UpdateTime = DateTime.Now;
  7816. entity.Update();
  7817. returnSuccessMsg("操作成功!");
  7818. CeErpSukuraData.createInfo(entity.ctid, 8);
  7819. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7820. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7821. return;
  7822. }
  7823. }
  7824. returnErrorMsg("找不到订单记录");
  7825. }
  7826. }
  7827. public void set_erp_supplierrefundtag()
  7828. {
  7829. if (UrlPostParmsCheck("ctid"))
  7830. {
  7831. string eid = GetPostString("ctid");
  7832. CeErpTradeCell entity = null;
  7833. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7834. if (entity != null)
  7835. {
  7836. entity.IsSupplierRefund = GetPostInt("tag");
  7837. entity.Update();
  7838. returnSuccessMsg("操作成功!");
  7839. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7840. return;
  7841. }
  7842. returnErrorMsg("找不到订单记录");
  7843. }
  7844. }
  7845. public void get_erp_refundlist()
  7846. {
  7847. DataStruct dStruct = GetPostStruct();
  7848. List<string> lw = new List<string>();
  7849. string tid = GetPostString("tid");
  7850. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7851. //string rid = GetPostString("refund_id");
  7852. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7853. string shopname = GetPostString("shopname");
  7854. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7855. string buyernick = GetPostString("buyer_nick");
  7856. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7857. string customer = GetPostString("customer");
  7858. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7859. string design = GetPostString("design");
  7860. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7861. string sellermemo = GetPostString("seller_memo");
  7862. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7863. //string date1 = GetPostString("date1");
  7864. //string date2 = GetPostString("date2");
  7865. //string dateType = GetPostString("dateType");
  7866. //if (dateType.Length > 0)
  7867. //{
  7868. // if (dateType == "1001") dateType = "0";
  7869. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7870. // if (searchDT.Count == 2)
  7871. // {
  7872. // date1 = searchDT[0].ToString();
  7873. // date2 = searchDT[1].ToString();
  7874. // }
  7875. //}
  7876. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7877. //if (dw.Length > 0) lw.Add(dw);
  7878. string redate1 = GetPostString("refunddate1");
  7879. string redate2 = GetPostString("refunddate2");
  7880. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7881. if (dwdate.Length > 0) lw.Add(dwdate);
  7882. string price1 = GetPostString("price1");
  7883. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7884. string price2 = GetPostString("price2");
  7885. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7886. string ispartrefund = GetPostString("ispartrefund");
  7887. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7888. string refundState = GetPostString("refundvstate");
  7889. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7890. int st = GetInt("st");
  7891. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7892. {
  7893. string responsible = GetPostString("responsibleman");
  7894. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7895. lw.Add(string.Format("RefundState>={0}", st));
  7896. string code = CurrentUser.UserPost.Post.Code;
  7897. if (code == "CustomerService")
  7898. {
  7899. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7900. }
  7901. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7902. {
  7903. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7904. }
  7905. else if (code == "Place" || code == "PlaceMr")
  7906. {
  7907. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7908. }
  7909. dStruct.Order = "RefundState asc,created desc";
  7910. }
  7911. else if (st == 10)
  7912. {
  7913. string responsible = GetPostString("responsibleman");
  7914. if (responsible == "空白")
  7915. {
  7916. lw.Add(string.Format("ResponsibleUserName = ''"));
  7917. }
  7918. else if (responsible.Length > 0)
  7919. {
  7920. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7921. }
  7922. lw.Add(string.Format("RefundState>=0"));
  7923. dStruct.Order = "created desc";
  7924. }
  7925. else
  7926. {
  7927. string responsible = GetPostString("responsibleman");
  7928. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7929. lw.Add(string.Format("RefundState={0}", st));
  7930. dStruct.Order = "created desc";
  7931. }
  7932. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7933. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7934. dt.Columns.Add("refund_fees");
  7935. foreach (DataRow dr in dt.Rows)
  7936. {
  7937. String status = dr["status"].ToString();
  7938. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7939. {
  7940. dr["refund_fees"] = dr["refund_fee"];
  7941. }
  7942. else
  7943. {
  7944. dr["refund_fees"] = "0.0";
  7945. }
  7946. }
  7947. writeGridDataTableJson(dStruct.TotalCount, dt);
  7948. }
  7949. public void get_erp_refunddesignlist()
  7950. {
  7951. DataStruct dStruct = GetPostStruct();
  7952. List<string> lw = new List<string>();
  7953. string tid = GetPostString("tid");
  7954. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7955. string shopname = GetPostString("shopname");
  7956. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7957. string buyernick = GetPostString("buyer_nick");
  7958. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7959. string customer = GetPostString("customer");
  7960. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7961. string design = GetPostString("design");
  7962. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7963. string sellermemo = GetPostString("seller_memo");
  7964. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7965. string redate1 = GetPostString("refunddate1");
  7966. string redate2 = GetPostString("refunddate2");
  7967. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7968. if (dwdate.Length > 0) lw.Add(dwdate);
  7969. string price1 = GetPostString("price1");
  7970. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7971. string price2 = GetPostString("price2");
  7972. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7973. string ispartrefund = GetPostString("ispartrefund");
  7974. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7975. string designerorg = GetPostString("designerorg");
  7976. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7977. string refundState = GetPostString("refundState");
  7978. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7979. int myOrgid = CurrentUser.UserPost.OrgID;
  7980. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7981. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7982. {
  7983. if (CurrentUser.User.TeamIds.Length > 0)
  7984. {
  7985. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7986. }
  7987. else
  7988. {
  7989. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7990. }
  7991. }
  7992. else if ("SysAdmin".Equals(myOrgCode))
  7993. {
  7994. }
  7995. else
  7996. {
  7997. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7998. {
  7999. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8000. }
  8001. else
  8002. {
  8003. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8004. }
  8005. }
  8006. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8007. dStruct.Order = "created desc";
  8008. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8009. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8010. dt.Columns.Add("refund_fees");
  8011. foreach (DataRow dr in dt.Rows)
  8012. {
  8013. String status = dr["status"].ToString();
  8014. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8015. {
  8016. dr["refund_fees"] = dr["refund_fee"];
  8017. }
  8018. else
  8019. {
  8020. dr["refund_fees"] = "0.0";
  8021. }
  8022. }
  8023. writeGridDataTableJson(dStruct.TotalCount, dt);
  8024. }
  8025. public void handle_erp_refundtag()
  8026. {
  8027. if (UrlPostParmsCheck("refund_id"))
  8028. {
  8029. string eid = GetPostString("refund_id");
  8030. string respMan = GetPostString("ResponsibleName");
  8031. if (respMan.Length <= 0)
  8032. {
  8033. returnErrorMsg("责任人不能为空");
  8034. return;
  8035. }
  8036. CeErpTradeRefund entity = null;
  8037. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8038. if (entity != null)
  8039. {
  8040. entity.ResponsibleUserName = respMan;
  8041. string userid = GetPostString("ResponsibleUserId");
  8042. if (userid.Length > 0)
  8043. {
  8044. entity.ResponsibleUserId = userid;
  8045. }
  8046. entity.Memo = GetPostString("Memo");
  8047. if (respMan.IndexOf("客服") != -1 ||
  8048. respMan.IndexOf("设计师") != -1 ||
  8049. respMan.IndexOf("下单员") != -1)
  8050. {
  8051. entity.RefundState = 2;
  8052. }
  8053. else
  8054. {
  8055. entity.RefundState = 3;
  8056. }
  8057. entity.modified = DateTime.Now;
  8058. entity.Update();
  8059. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8060. returnSuccessMsg("操作成功!");
  8061. return;
  8062. }
  8063. returnErrorMsg("找不到订单记录");
  8064. }
  8065. }
  8066. public void handle_erp_designrefundtag()
  8067. {
  8068. if (UrlPostParmsCheck("refund_id"))
  8069. {
  8070. string eid = GetPostString("refund_id");
  8071. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8072. if (ceErpTradeCellExtend == null)
  8073. {
  8074. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8075. ceErpTradeCellExtend.ctid = eid;
  8076. }
  8077. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8078. if (ceErpTradeCellExtend.ID > 0)
  8079. {
  8080. ceErpTradeCellExtend.Update();
  8081. }
  8082. else
  8083. {
  8084. ceErpTradeCellExtend.Create();
  8085. }
  8086. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8087. returnSuccessMsg("操作成功!");
  8088. return;
  8089. }
  8090. returnErrorMsg("找不到订单记录");
  8091. }
  8092. public void upd_erp_refundverify()
  8093. {
  8094. if (UrlPostParmsCheck("refund_id"))
  8095. {
  8096. string eid = GetPostString("refund_id");
  8097. CeErpTradeRefund entity = null;
  8098. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8099. if (entity != null)
  8100. {
  8101. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8102. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8103. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8104. {
  8105. entity.RefundState = 2;
  8106. }
  8107. else
  8108. {
  8109. entity.RefundState = 3;
  8110. }
  8111. entity.Update();
  8112. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8113. returnSuccessMsg("操作成功!");
  8114. return;
  8115. }
  8116. returnErrorMsg("找不到订单记录");
  8117. }
  8118. }
  8119. public void upd_erp_refundapprove()
  8120. {
  8121. if (UrlPostParmsCheck("refund_id"))
  8122. {
  8123. string eid = GetPostString("refund_id");
  8124. CeErpTradeRefund entity = null;
  8125. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8126. if (entity != null)
  8127. {
  8128. int apr = GetPostInt("approve");
  8129. if (apr == 0)
  8130. {
  8131. entity.RefundState = 1;
  8132. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8133. }
  8134. else if (apr == 1)
  8135. {
  8136. entity.RefundState = 3;
  8137. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8138. }
  8139. entity.modified = DateTime.Now;
  8140. entity.Update();
  8141. returnSuccessMsg("操作成功!");
  8142. return;
  8143. }
  8144. returnErrorMsg("找不到订单记录");
  8145. }
  8146. }
  8147. public void get_erp_billlist()
  8148. {
  8149. DataStruct dStruct = GetPostStruct();
  8150. List<string> lw = new List<string>();
  8151. string title = GetPostString("title");
  8152. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8153. string tid = GetPostString("tid");
  8154. string tids = GetPostString("tids");
  8155. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8156. if (tids.Length > 0)
  8157. {
  8158. tids = "'" + tids + "'";
  8159. tids = tids.Replace(",", "','");
  8160. lw.Add(string.Format("tid in ({0})", tids));
  8161. }
  8162. string shopname = GetPostString("shopname");
  8163. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8164. string buyernick = GetPostString("buyer_nick");
  8165. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8166. string customer = GetPostString("customer");
  8167. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8168. string date1 = GetPostString("date1");
  8169. string date2 = GetPostString("date2");
  8170. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8171. if (dw.Length > 0) lw.Add(dw);
  8172. string price1 = GetPostString("price1");
  8173. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8174. string price2 = GetPostString("price2");
  8175. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8176. string returndate1 = GetPostString("returndate1");
  8177. string returndate2 = GetPostString("returndate2");
  8178. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8179. if (dw1.Length > 0) lw.Add(dw1);
  8180. string billtype = GetPostString("billtype");
  8181. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8182. string billstate = GetPostString("billstate");
  8183. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8184. string usershop = CurrentUser.User.pemShop;
  8185. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8186. dStruct.Order = "createTime desc";
  8187. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8188. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8189. //foreach (DataRow dr in dt.Rows)
  8190. //{
  8191. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8192. //}
  8193. writeGridDataTableJson(dStruct.TotalCount, dt);
  8194. }
  8195. public void modify_erp_billinfo()
  8196. {
  8197. if (UrlPostParmsCheck("ID"))
  8198. {
  8199. string eid = GetPostString("ID");
  8200. CeErpBill bill_entity = null;
  8201. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8202. if (bill_entity != null)
  8203. {
  8204. bill_entity.tid = GetPostString("tid");
  8205. bill_entity.title = GetPostString("title");
  8206. bill_entity.tax = GetPostString("tax");
  8207. bill_entity.bank = GetPostString("bank");
  8208. bill_entity.bankac = GetPostString("bankac");
  8209. bill_entity.address = GetPostString("address");
  8210. bill_entity.phone = GetPostString("phone");
  8211. bill_entity.price = GetPostString("price");
  8212. bill_entity.productId = GetPostInt("ProductName");
  8213. bill_entity.num = GetPostInt("num");
  8214. bill_entity.unit = GetPostString("unit");
  8215. bill_entity.type = GetPostString("type");
  8216. bill_entity.sendType = GetPostString("SendType");
  8217. bill_entity.email = GetPostString("email");
  8218. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8219. bill_entity.shopName = GetPostString("ShopName");
  8220. bill_entity.applymemo = GetPostString("applymemo");
  8221. bill_entity.modifyTime = DateTime.Now;
  8222. bill_entity.createTime = DateTime.Now;
  8223. bill_entity.state = 0;
  8224. bill_entity.Update();
  8225. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8226. returnSuccessMsg("发票修改成功!");
  8227. return;
  8228. }
  8229. returnErrorMsg("找不到对应记录");
  8230. }
  8231. }
  8232. public void set_erp_invoicing()
  8233. {
  8234. if (UrlPostParmsCheck("id"))
  8235. {
  8236. try
  8237. {
  8238. string eid = GetPostString("id");
  8239. CeErpBill bill_entity = null;
  8240. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8241. if (bill_entity != null)
  8242. {
  8243. int ComId = GetPostInt("ComId");
  8244. //string memo = GetPostString("Memo");
  8245. int allInfo = GetPostInt("allinfo");
  8246. string clert = CurrentUser.User.Name;
  8247. //string detailValue = GetPostString("detailvalue");
  8248. string billId = bill_entity.billOrderId;
  8249. string[] billIdList = billId.Split(',');
  8250. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8251. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8252. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8253. {
  8254. billCount += 1;
  8255. }
  8256. if (billId.Length <= 0 || billIdList.Length != billCount)
  8257. {
  8258. bill_entity.billOrderId = "";
  8259. string prebill = "ltb";
  8260. for (int idx = 1; idx <= billCount; idx++)
  8261. {
  8262. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8263. string billoid = prebill + idx + dtstr;
  8264. bill_entity.billOrderId += billoid;
  8265. if (idx < billCount)
  8266. {
  8267. bill_entity.billOrderId += ",";
  8268. }
  8269. }
  8270. }
  8271. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8272. if (bill_entity.state == 5)
  8273. {
  8274. string errMsg = bill_entity.failerror;
  8275. string[] errlist = errMsg.Split('|');
  8276. string[] errTags = new string[errlist.Length];
  8277. for (int itag = 0; itag < errlist.Length; itag++)
  8278. {
  8279. if (errlist[itag].Length <= 0) continue;
  8280. errTags[itag] = errlist[itag].Split('&')[0];
  8281. }
  8282. for (int iii = 0; iii < errTags.Length; iii++)
  8283. {
  8284. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8285. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8286. if (billOrderList.Length >= erroBillOrderTag)
  8287. {
  8288. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8289. if (needModifyBillId.Length <= 19)
  8290. {
  8291. needModifyBillId = needModifyBillId + "1";
  8292. }
  8293. else
  8294. {
  8295. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8296. last = last + 1;
  8297. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8298. }
  8299. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8300. }
  8301. }
  8302. }
  8303. bool isHaveBillSucces = false;
  8304. string totalRes = "";
  8305. bill_entity.failerror = "";
  8306. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8307. {
  8308. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8309. totalRes += res;
  8310. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8311. {
  8312. isHaveBillSucces = true;
  8313. bill_entity.comId = ComId;
  8314. bill_entity.state = 1;
  8315. bill_entity.executeTime = DateTime.Now;
  8316. bill_entity.executeUser = clert;
  8317. }
  8318. else
  8319. {
  8320. bill_entity.state = 5;
  8321. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8322. }
  8323. }
  8324. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8325. bill_entity.Update();
  8326. if (isHaveBillSucces)
  8327. {
  8328. StringBuilder sql = new StringBuilder();
  8329. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8330. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8331. }
  8332. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8333. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8334. {
  8335. returnErrorMsg("开票失败");
  8336. }
  8337. else
  8338. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8339. return;
  8340. }
  8341. returnErrorMsg("找不到对应记录");
  8342. }
  8343. catch (Exception ex)
  8344. {
  8345. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8346. returnErrorMsg("操作失败");
  8347. }
  8348. }
  8349. }
  8350. public void get_erp_invoicing_back()
  8351. {
  8352. if (UrlPostParmsCheck("id"))
  8353. {
  8354. try
  8355. {
  8356. string id = GetPostString("id");
  8357. CeErpBill entiy = CeErpBill.Get(id);
  8358. if (entiy != null)
  8359. {
  8360. if (entiy.state == 0)
  8361. {
  8362. returnErrorMsg("发票还未开具");
  8363. return;
  8364. }
  8365. string[] billOrderList = entiy.billOrderId.Split(',');
  8366. int iTag = 0;
  8367. entiy.fplsh = "";
  8368. entiy.fpdm = "";
  8369. entiy.fphm = "";
  8370. foreach (string billOrderId in billOrderList)
  8371. {
  8372. iTag++;
  8373. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8374. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8375. {
  8376. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8377. try
  8378. {
  8379. Invoicing_get_response_Obj iObj = null;
  8380. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8381. if (iObj != null)
  8382. {
  8383. entiy.state = 2;
  8384. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8385. entiy.fpdm += iObj.list[0].c_fpdm;
  8386. entiy.fphm += iObj.list[0].c_fphm;
  8387. if (iTag < billOrderList.Length)
  8388. {
  8389. entiy.fplsh += ",";
  8390. entiy.fpdm += ",";
  8391. entiy.fphm += ",";
  8392. }
  8393. entiy.Update();
  8394. }
  8395. StringBuilder sql = new StringBuilder();
  8396. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8397. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8398. returnSuccessMsg("开票成功");
  8399. }
  8400. catch (Exception ex)
  8401. {
  8402. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8403. }
  8404. return;
  8405. }
  8406. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8407. {
  8408. var res_obj = new
  8409. {
  8410. data = "开票中"
  8411. };
  8412. string ro_json = JsonConvert.SerializeObject(res_obj);
  8413. returnSuccess(ro_json);
  8414. return;
  8415. }
  8416. else
  8417. {
  8418. int eidx = res.IndexOf("c_resultmsg");
  8419. int lidx = res.IndexOf("c_status");
  8420. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8421. entiy.state = 5;
  8422. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8423. entiy.Update();
  8424. returnErrorMsg("开票失败");
  8425. return;
  8426. }
  8427. }
  8428. }
  8429. }
  8430. catch (Exception ex)
  8431. {
  8432. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8433. }
  8434. return;
  8435. }
  8436. }
  8437. public void get_erp_invoicing()
  8438. {
  8439. if (UrlPostParmsCheck("id"))
  8440. {
  8441. try
  8442. {
  8443. string id = GetPostString("id");
  8444. CeErpBill entiy = CeErpBill.Get(id);
  8445. if (entiy != null)
  8446. {
  8447. if (entiy.state == 0)
  8448. {
  8449. returnErrorMsg("发票还未开具");
  8450. return;
  8451. }
  8452. if (entiy.sendType == "纸质发票")
  8453. {
  8454. if (entiy.img.Length <= 0)
  8455. {
  8456. returnErrorMsg("查无纸质发票");
  8457. return;
  8458. }
  8459. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8460. returnSuccess(returnres);
  8461. return;
  8462. }
  8463. string[] billOrderList = entiy.billOrderId.Split(',');
  8464. int iTag = 0;
  8465. string fpUrl = "";
  8466. entiy.fplsh = "";
  8467. entiy.fpdm = "";
  8468. entiy.fphm = "";
  8469. foreach (string billOrderId in billOrderList)
  8470. {
  8471. iTag++;
  8472. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8473. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8474. {
  8475. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8476. Invoicing_get_response_Obj iObj = null;
  8477. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8478. if (iObj != null)
  8479. {
  8480. //entiy.state = 2;
  8481. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8482. entiy.fpdm += iObj.list[0].c_fpdm;
  8483. entiy.fphm += iObj.list[0].c_fphm;
  8484. if (iTag < billOrderList.Length)
  8485. {
  8486. entiy.fplsh += ",";
  8487. entiy.fpdm += ",";
  8488. entiy.fphm += ",";
  8489. }
  8490. entiy.Update();
  8491. fpUrl += iObj.list[0].c_url + ",";
  8492. }
  8493. //returnSuccess(res);
  8494. StringBuilder sql = new StringBuilder();
  8495. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8496. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8497. }
  8498. else
  8499. {
  8500. int eidx = res.IndexOf("c_resultmsg");
  8501. //int lidx = res.IndexOf("c_status");
  8502. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8503. //开票失败
  8504. entiy.state = 5;
  8505. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8506. entiy.Update();
  8507. returnErrorMsg("开票失败");
  8508. return;
  8509. }
  8510. }
  8511. var returnObj = new
  8512. {
  8513. data = fpUrl
  8514. };
  8515. string ro_json = JsonConvert.SerializeObject(returnObj);
  8516. returnSuccess(ro_json);
  8517. }
  8518. }
  8519. catch (Exception ex)
  8520. {
  8521. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8522. }
  8523. return;
  8524. }
  8525. }
  8526. public void save_erp_billimg()
  8527. {
  8528. if (UrlPostParmsCheck("id"))
  8529. {
  8530. string eid = GetPostString("id");
  8531. CeErpBill bill_entity = null;
  8532. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8533. if (bill_entity != null)
  8534. {
  8535. bill_entity.img = GetPostString("img");
  8536. bill_entity.executeTime = DateTime.Now;
  8537. bill_entity.state = 2;
  8538. bill_entity.Update();
  8539. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8540. returnSuccessMsg("保存成功");
  8541. }
  8542. return;
  8543. }
  8544. }
  8545. public void upd_erp_billreturnback()
  8546. {
  8547. if (UrlPostParmsCheck("id"))
  8548. {
  8549. int eid = GetPostInt("id");
  8550. CeErpBill bill_entity = null;
  8551. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8552. if (bill_entity != null)
  8553. {
  8554. bill_entity.state = 3;
  8555. bill_entity.returnReason = GetPostString("reason");
  8556. bill_entity.Update();
  8557. returnSuccessMsg("驳回成功!");
  8558. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8559. }
  8560. return;
  8561. }
  8562. }
  8563. public void cancel_erp_bill()
  8564. {
  8565. if (UrlPostParmsCheck("id"))
  8566. {
  8567. int eid = GetPostInt("id");
  8568. int detailValue = GetPostInt("detailvalue");
  8569. CeErpBill bill_entity = null;
  8570. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8571. string cres = "";
  8572. string gres = "";
  8573. if (bill_entity != null)
  8574. {
  8575. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8576. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8577. {
  8578. int iTag = 0;
  8579. bill_entity.fplsh = "";
  8580. bill_entity.fpdm = "";
  8581. bill_entity.fphm = "";
  8582. foreach (string billOrderId in billOrderList)
  8583. {
  8584. iTag++;
  8585. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8586. if (gres.IndexOf("success") != -1)
  8587. {
  8588. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8589. Invoicing_get_response_Obj iObj = null;
  8590. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8591. if (iObj != null)
  8592. {
  8593. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8594. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8595. bill_entity.fphm += iObj.list[0].c_fphm;
  8596. if (iTag < billOrderList.Length)
  8597. {
  8598. bill_entity.fplsh += ",";
  8599. bill_entity.fpdm += ",";
  8600. bill_entity.fphm += ",";
  8601. }
  8602. bill_entity.Update();
  8603. }
  8604. }
  8605. else
  8606. {
  8607. returnErrorMsg(gres);
  8608. return;
  8609. }
  8610. }
  8611. }
  8612. if (bill_entity.sendType == "纸质发票")
  8613. {
  8614. //作废
  8615. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8616. //if (DateTime.Now.Month == extime.Month)
  8617. //{
  8618. //cres = taobaoHelper.cancel_invoicing(eid);
  8619. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8620. //{
  8621. bill_entity.state = 4;//已作废
  8622. bill_entity.Update();
  8623. returnSuccessMsg("发票已作废");
  8624. return;
  8625. //}
  8626. //else
  8627. //{
  8628. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8629. // bill_entity.Update();
  8630. // returnErrorMsg(cres);
  8631. // return;
  8632. //}
  8633. //}
  8634. //else
  8635. //{
  8636. // returnErrorMsg("纸质发票只能作废本月的发票");
  8637. // return;
  8638. //}
  8639. }
  8640. //红冲
  8641. int redTag = 0;
  8642. string[] fpdmList = bill_entity.fpdm.Split(',');
  8643. string[] fphmList = bill_entity.fphm.Split(',');
  8644. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8645. {
  8646. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8647. return;
  8648. }
  8649. foreach (string billOrderId in billOrderList)
  8650. {
  8651. redTag++;
  8652. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8653. cres += onecres;
  8654. cres += ",";
  8655. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8656. {
  8657. bill_entity.state = 4;//已作废
  8658. //bill_entity.Update();
  8659. //returnSuccessMsg("发票已红冲");
  8660. }
  8661. else if (onecres.IndexOf("重复冲红") != -1)
  8662. {
  8663. bill_entity.state = 4;//已作废
  8664. //bill_entity.Update();
  8665. //returnSuccessMsg("发票已红冲");
  8666. }
  8667. else
  8668. {
  8669. string errmsg = commonHelper.KeepChinese(onecres);
  8670. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8671. }
  8672. }
  8673. bill_entity.Update();
  8674. if (cres.IndexOf("失败") != -1)
  8675. returnErrorMsg("红冲失败");
  8676. else
  8677. returnSuccessMsg("发票已红冲");
  8678. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8679. return;
  8680. }
  8681. return;
  8682. }
  8683. }
  8684. public void del_erp_billorder()
  8685. {
  8686. if (UrlPostParmsCheck("id"))
  8687. {
  8688. string eid = GetPostString("id");
  8689. CeErpBill.Del(eid);
  8690. CeErpBill bill = CeErpBill.Get(eid);
  8691. if (bill != null)
  8692. {
  8693. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8694. }
  8695. returnSuccessMsg("删除成功");
  8696. }
  8697. }
  8698. public void finish_erp_bill()
  8699. {
  8700. if (UrlPostParmsCheck("ids"))
  8701. {
  8702. string eids = GetPostString("ids");
  8703. string[] list = eids.Split(',');
  8704. foreach (string eid in list)
  8705. {
  8706. CeErpBill bill = CeErpBill.Get(eid);
  8707. if (bill != null)
  8708. {
  8709. bill.state = 2;
  8710. bill.Update();
  8711. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8712. }
  8713. }
  8714. returnSuccessMsg("操作成功");
  8715. }
  8716. }
  8717. public void get_erp_returncash()
  8718. {
  8719. DataStruct dStruct = GetPostStruct();
  8720. List<string> lw = new List<string>();
  8721. string tid = GetPostString("tid");
  8722. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8723. string shopname = GetPostString("shopname");
  8724. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8725. string buyernick = GetPostString("buyer_nick");
  8726. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8727. string customer = GetPostString("customer");
  8728. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8729. string returndate1 = GetPostString("returndate1");
  8730. string returndate2 = GetPostString("returndate2");
  8731. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8732. if (dw.Length > 0) lw.Add(dw);
  8733. string finishDate1 = GetPostString("finishdate1");
  8734. string finishDate2 = GetPostString("finishdate2");
  8735. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8736. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8737. string returntype = GetPostString("returntype");
  8738. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8739. string returnvstate = GetPostString("returnvstate");
  8740. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8741. dStruct.Order = "created desc";
  8742. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8743. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8744. writeGridDataTableJson(dStruct.TotalCount, dt);
  8745. }
  8746. public void get_erp_staygoods()
  8747. {
  8748. DataStruct dStruct = GetPostStruct();
  8749. List<string> lw = new List<string>();
  8750. string tid = GetPostString("tid");
  8751. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8752. string shopname = GetPostString("shopname");
  8753. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8754. string wangwang = GetPostString("wangwang");
  8755. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8756. string customer = GetPostString("customer");
  8757. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8758. string returndate1 = GetPostString("returndate1");
  8759. string returndate2 = GetPostString("returndate2");
  8760. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8761. if (dw.Length > 0) lw.Add(dw);
  8762. string finishDate1 = GetPostString("finishdate1");
  8763. string finishDate2 = GetPostString("finishdate2");
  8764. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8765. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8766. string returnvstate = GetPostString("returnvstate");
  8767. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8768. string persuadetype = GetPostString("persuadetype");
  8769. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8770. string customerOrg = GetPostString("customerOrg");
  8771. if (customerOrg.Length > 0)
  8772. {
  8773. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8774. }
  8775. dStruct.Order = "creata_time desc";
  8776. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8777. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8778. writeGridDataTableJson(dStruct.TotalCount, dt);
  8779. }
  8780. public void upd_erp_staygoods()
  8781. {
  8782. if (UrlPostParmsCheck("id"))
  8783. {
  8784. int eid = GetPostInt("id");
  8785. CeErpStayGoods entity = null;
  8786. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8787. if (entity != null)
  8788. {
  8789. entity.audit_type = 1;
  8790. entity.audit_time = DateTime.Now;
  8791. entity.audit_u_id = CurrentUser.UserID;
  8792. entity.audit_u_name = CurrentUser.UserName;
  8793. entity.Update();
  8794. returnSuccessMsg("审核成功!");
  8795. return;
  8796. }
  8797. returnErrorMsg("找不到订单记录");
  8798. }
  8799. }
  8800. public void upd_erp_stayGoodsback()
  8801. {
  8802. if (UrlPostParmsCheck("id"))
  8803. {
  8804. int eid = GetPostInt("id");
  8805. CeErpStayGoods entity = null;
  8806. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8807. if (entity != null)
  8808. {
  8809. entity.audit_text = GetPostString("reason");
  8810. entity.audit_type = 2;
  8811. entity.audit_time = DateTime.Now;
  8812. entity.audit_u_id = CurrentUser.UserID;
  8813. entity.audit_u_name = CurrentUser.UserName;
  8814. entity.Update();
  8815. returnSuccessMsg("退回成功!");
  8816. return;
  8817. }
  8818. returnErrorMsg("找不到订单记录");
  8819. }
  8820. }
  8821. public void upd_erp_returncashverify()
  8822. {
  8823. if (UrlPostParmsCheck("ID"))
  8824. {
  8825. int eid = GetPostInt("ID");
  8826. CeErpReturnCash entity = null;
  8827. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8828. if (entity != null)
  8829. {
  8830. entity.cashstate = 1;
  8831. entity.verifytime = DateTime.Now;
  8832. entity.verifyuserid = CurrentUser.UserID;
  8833. entity.Update();
  8834. returnSuccessMsg("审核成功!");
  8835. return;
  8836. }
  8837. returnErrorMsg("找不到订单记录");
  8838. }
  8839. }
  8840. public void upd_all_erp_returncashverify()
  8841. {
  8842. if (UrlPostParmsCheck("ID"))
  8843. {
  8844. String[] list = GetPostString("ID").Split(',');
  8845. CeErpReturnCash entity = null;
  8846. for (int i = 0; i < list.Length; i++)
  8847. {
  8848. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8849. if (entity != null)
  8850. {
  8851. if (entity.cashstate == 1)
  8852. {
  8853. returnErrorMsg("已审核过的订单不需要在审核!");
  8854. return;
  8855. }
  8856. entity.cashstate = 1;
  8857. entity.verifytime = DateTime.Now;
  8858. entity.verifyuserid = CurrentUser.UserID;
  8859. entity.Update();
  8860. }
  8861. }
  8862. returnSuccessMsg("审核成功!");
  8863. return;
  8864. }
  8865. }
  8866. public void upd_erp_returncashback()
  8867. {
  8868. if (UrlPostParmsCheck("ID"))
  8869. {
  8870. int eid = GetPostInt("ID");
  8871. CeErpReturnCash entity = null;
  8872. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8873. if (entity != null)
  8874. {
  8875. entity.backreason = GetPostString("reason");
  8876. entity.cashstate = 2;
  8877. entity.verifytime = DateTime.Now;
  8878. entity.verifyuserid = CurrentUser.UserID;
  8879. entity.Update();
  8880. returnSuccessMsg("退回成功!");
  8881. return;
  8882. }
  8883. returnErrorMsg("找不到订单记录");
  8884. }
  8885. }
  8886. public void upd_erp_returnprice()
  8887. {
  8888. if (UrlPostParmsCheck("ID"))
  8889. {
  8890. int eid = GetPostInt("ID");
  8891. CeErpReturnCash entity = null;
  8892. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8893. if (entity != null)
  8894. {
  8895. if (entity.cashstate == 1)
  8896. {
  8897. returnErrorMsg("审核通过了不能改");
  8898. return;
  8899. }
  8900. entity.returnprice = GetPostDouble("returnprice");
  8901. entity.Update();
  8902. returnSuccessMsg("修改成功!");
  8903. return;
  8904. }
  8905. returnErrorMsg("找不到订单记录");
  8906. }
  8907. }
  8908. public void del_erp_returncash()
  8909. {
  8910. if (UrlPostParmsCheck("ID"))
  8911. {
  8912. int eid = GetPostInt("ID");
  8913. CeErpReturnCash.Del(eid);
  8914. returnSuccessMsg("操作成功");
  8915. return;
  8916. }
  8917. }
  8918. public void test_for_do_sql()
  8919. {
  8920. string sql = GetPostString("sqlstr");
  8921. if (sql.Length > 0)
  8922. {
  8923. try
  8924. {
  8925. DbHelper.DbConn.ExecuteNonQuery(sql);
  8926. var res_obj = new
  8927. {
  8928. data = "成功",
  8929. };
  8930. string ro_json = JsonConvert.SerializeObject(res_obj);
  8931. returnSuccess(ro_json);
  8932. }
  8933. catch (Exception ex)
  8934. {
  8935. var res_obj = new
  8936. {
  8937. data = ex.Message,
  8938. };
  8939. string ro_json = JsonConvert.SerializeObject(res_obj);
  8940. returnSuccess(ro_json);
  8941. }
  8942. }
  8943. }
  8944. public void get_user_info()
  8945. {
  8946. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8947. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8948. }
  8949. public void get_total_data()
  8950. {
  8951. int userId = CurrentUser.UserID;
  8952. string sql = "";
  8953. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8954. {
  8955. 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);
  8956. }
  8957. else
  8958. {
  8959. 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 " +
  8960. "(select ID from CE_ErpUser where ID = {0}) d " +
  8961. "left join " +
  8962. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8963. ") a on d.ID = a.id left join " +
  8964. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8965. ") b on a.id = b.id1 left join" +
  8966. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8967. ") c on a.id = c.id2;", userId);
  8968. }
  8969. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8970. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8971. }
  8972. public void get_date_area_total_data2()
  8973. {
  8974. int userId = CurrentUser.UserID;
  8975. string date_type = GetPostString("timetype");
  8976. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8977. string sql = "";
  8978. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8979. {
  8980. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8981. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8982. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8983. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8984. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8985. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8986. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8987. ") a on e.ID = a.id left join " +
  8988. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8989. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8990. ") b on a.id = b.id1 " +
  8991. "left join " +
  8992. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8993. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8994. ") c on a.id = c.id2 " +
  8995. "left join " +
  8996. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8997. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8998. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8999. }
  9000. else
  9001. {
  9002. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9003. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9004. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9005. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9006. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9007. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9008. ") a on e.ID = a.id left join " +
  9009. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9010. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9011. ") c on a.id = c.id2 " +
  9012. "left join " +
  9013. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9014. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9015. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9016. }
  9017. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9018. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9019. }
  9020. public void get_date_area_total_data()
  9021. {
  9022. int userId = CurrentUser.UserID;
  9023. string date_type = GetPostString("timetype");
  9024. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9025. string date1 = searchDT[0].ToString();
  9026. string date2 = searchDT[1].ToString();
  9027. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9028. {
  9029. SqlParameter[] sqlParameter ={
  9030. new SqlParameter("@userId", SqlDbType.Int,4),
  9031. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9032. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9033. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9034. };
  9035. sqlParameter[0].Value = userId;
  9036. sqlParameter[1].Value = date1;
  9037. sqlParameter[2].Value = date2;
  9038. sqlParameter[3].Direction = ParameterDirection.Output;
  9039. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9040. string res = sqlParameter[3].Value.ToString();
  9041. var res_obj = new
  9042. {
  9043. data = res
  9044. };
  9045. string ro_json = JsonConvert.SerializeObject(res_obj);
  9046. returnSuccess(ro_json);
  9047. }
  9048. else
  9049. {
  9050. SqlParameter[] sqlParameter ={
  9051. new SqlParameter("@userId", SqlDbType.Int,4),
  9052. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9053. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9054. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9055. };
  9056. sqlParameter[0].Value = userId;
  9057. sqlParameter[1].Value = date1;
  9058. sqlParameter[2].Value = date2;
  9059. sqlParameter[3].Direction = ParameterDirection.Output;
  9060. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9061. string res = sqlParameter[3].Value.ToString();
  9062. var res_obj = new
  9063. {
  9064. data = res
  9065. };
  9066. string ro_json = JsonConvert.SerializeObject(res_obj);
  9067. returnSuccess(ro_json);
  9068. }
  9069. //writeGridDataViewJson(dt.Rows.Count, dv);
  9070. }
  9071. public void get_order_list()
  9072. {
  9073. string strFields = GetPostString("paraFields");
  9074. string strOrder = GetPostString("paraOrder");
  9075. string strWhere = GetPostString("paraWhere");
  9076. string strPageSize = GetPostString("paraPageSize");
  9077. DataStruct dStruct = GetPostStruct();
  9078. dStruct.PageSize = int.Parse(strPageSize);
  9079. dStruct.Fileds = strFields;
  9080. dStruct.Order = strOrder;
  9081. dStruct.MainWhere = strWhere;
  9082. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9083. writeGridDataTableJson(dStruct.TotalCount, dt);
  9084. }
  9085. ////获取待开始订单列表
  9086. //public void get_wait_design_order_list()
  9087. //{
  9088. // string date_type = GetPostString("date_type");
  9089. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9090. // DataStruct dStruct = GetPostStruct();
  9091. // dStruct.PageSize = 1000;
  9092. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9093. // List<string> lw = new List<string>();
  9094. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9095. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9096. // dStruct.Order = "WaitDesignTime asc";
  9097. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9098. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9099. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9100. //}
  9101. //获取完成单量排名
  9102. public void get_finish_order_count_ranking()
  9103. {
  9104. /* string date_type = GetPostString("date_type");
  9105. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9106. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9107. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9108. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9109. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9110. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9111. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9112. writeGridDataTableJson(0, new DataTable());
  9113. }
  9114. public void get_finish_order_amount_ranking()
  9115. {
  9116. /*string date_type = GetPostString("date_type");
  9117. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9118. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9119. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9120. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9121. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9122. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9123. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9124. writeGridDataTableJson(0, new DataTable());
  9125. }
  9126. public void get_finish_refund_count_ranking()
  9127. {
  9128. string date_type = GetPostString("date_type");
  9129. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9130. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9131. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9132. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9133. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9134. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9136. writeGridDataTableJson(dt.Rows.Count, dt);
  9137. }
  9138. public void get_finish_refund_amount_ranking()
  9139. {
  9140. string date_type = GetPostString("date_type");
  9141. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9142. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9143. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9144. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9145. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9146. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9147. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9148. writeGridDataTableJson(dt.Rows.Count, dt);
  9149. }
  9150. public void set_erp_finishorder_director()
  9151. {
  9152. if (UrlPostParmsCheck("ctid"))
  9153. {
  9154. string eid = GetPostString("ctid");
  9155. CeErpTradeCell entity = null;
  9156. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9157. if (entity != null)
  9158. {
  9159. entity.OrderState = 8;
  9160. entity.Update();
  9161. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9162. returnSuccessMsg("操作成功!");
  9163. return;
  9164. }
  9165. returnErrorMsg("找不到记录");
  9166. }
  9167. }
  9168. public void get_erp_placeregistlist()
  9169. {
  9170. DataStruct dStruct = GetPostStruct();
  9171. List<string> lw = new List<string>();
  9172. string outsid = GetPostString("outsid");
  9173. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9174. string memo = GetPostString("memo");
  9175. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9176. string filename = GetPostString("filename");
  9177. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9178. string islate = GetPostString("islate");
  9179. if (islate.Length > 0)
  9180. {
  9181. if (islate == "1")
  9182. lw.Add(string.Format("OutLate>0"));
  9183. else
  9184. lw.Add(string.Format("OutLate=0"));
  9185. }
  9186. string placedate1 = GetPostString("placedate1");
  9187. string placedate2 = GetPostString("placedate2");
  9188. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9189. if (dw.Length > 0) lw.Add(dw);
  9190. string deliveryDate1 = GetPostString("deliverydate1");
  9191. string deliveryDate2 = GetPostString("deliverydate2");
  9192. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9193. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9194. dStruct.Order = "ID desc";
  9195. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9196. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9197. writeGridDataTableJson(dStruct.TotalCount, dt);
  9198. }
  9199. public void ins_erp_placeregist()
  9200. {
  9201. if (UrlPostParmsCheck("id"))
  9202. {
  9203. string eid = GetPostString("id");
  9204. CeErpPlaceRegister entity = null;
  9205. if (eid == "0")//新增
  9206. {
  9207. entity = new CeErpPlaceRegister();
  9208. string xdTime = GetPostString("placeTime");
  9209. if (xdTime.Length > 0)
  9210. {
  9211. entity.PlactTime = Convert.ToDateTime(xdTime);
  9212. }
  9213. string fhTime = GetPostString("deliveryTime");
  9214. if (fhTime.Length > 0)
  9215. {
  9216. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9217. }
  9218. string preTime = GetPostString("preOutTime");
  9219. if (preTime.Length > 0)
  9220. {
  9221. entity.PreOutTime = Convert.ToDateTime(preTime);
  9222. }
  9223. entity.DeliveryCount = GetPostInt("deliveryCount");
  9224. entity.ReceiveCount = GetPostInt("receiveCount");
  9225. entity.OutSid = GetPostString("outSid");
  9226. entity.FileName = GetPostString("fileName");
  9227. entity.Memo = GetPostString("memo");
  9228. entity.AddUserId = CurrentUser.UserID;
  9229. entity.CreateTime = DateTime.Now;
  9230. entity.Img = GetPostString("img");
  9231. entity.Supplier = GetPostInt("supplier");
  9232. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9233. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9234. {
  9235. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9236. DateTime dt2 = (DateTime)entity.PreOutTime;
  9237. TimeSpan span = dt1.Subtract(dt2);
  9238. if (span.Days > 0)
  9239. {
  9240. entity.OutLate = span.Days;
  9241. }
  9242. }
  9243. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9244. entity.Create();
  9245. returnSuccessMsg("添加成功!");
  9246. return;
  9247. }
  9248. else //修改
  9249. {
  9250. entity = CeErpPlaceRegister.Get(eid);
  9251. if (entity != null)
  9252. {
  9253. string xdTime = GetPostString("placeTime");
  9254. if (xdTime.Length > 0)
  9255. {
  9256. entity.PlactTime = Convert.ToDateTime(xdTime);
  9257. }
  9258. string fhTime = GetPostString("deliveryTime");
  9259. if (fhTime.Length > 0)
  9260. {
  9261. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9262. }
  9263. string preTime = GetPostString("preOutTime");
  9264. if (preTime.Length > 0)
  9265. {
  9266. entity.PreOutTime = Convert.ToDateTime(preTime);
  9267. }
  9268. entity.DeliveryCount = GetPostInt("deliveryCount");
  9269. entity.ReceiveCount = GetPostInt("receiveCount");
  9270. if (entity.DeliveryCount == entity.ReceiveCount)
  9271. {
  9272. entity.CurState = "已完成";
  9273. }
  9274. else
  9275. {
  9276. entity.CurState = "未完成";
  9277. }
  9278. entity.OutSid = GetPostString("outSid");
  9279. entity.FileName = GetPostString("fileName");
  9280. entity.Memo = GetPostString("memo");
  9281. entity.Img = GetPostString("img");
  9282. entity.Supplier = GetPostInt("supplier");
  9283. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9284. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9285. {
  9286. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9287. DateTime dt2 = (DateTime)entity.PreOutTime;
  9288. TimeSpan span = dt1.Subtract(dt2);
  9289. if (span.Days > 0)
  9290. {
  9291. entity.OutLate = span.Days;
  9292. }
  9293. }
  9294. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9295. entity.Update();
  9296. returnSuccessMsg("修改成功");
  9297. return;
  9298. }
  9299. returnErrorMsg("找不到对应的记录");
  9300. return;
  9301. }
  9302. }
  9303. returnErrorMsg("缺少必要参数");
  9304. }
  9305. public void del_erp_placeregist()
  9306. {
  9307. string eid = GetPostString("id");
  9308. CeErpPlaceRegister.Del(eid);
  9309. returnSuccessMsg("删除成功!");
  9310. return;
  9311. }
  9312. public void ins_erp_placeregistbyorder()
  9313. {
  9314. string ctid = GetPostString("ctid");
  9315. if (ctid.Length > 0)
  9316. {
  9317. StringBuilder sql = new StringBuilder();
  9318. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9319. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9320. if (dt.Rows.Count > 0)
  9321. {
  9322. foreach (DataRow dr in dt.Rows)
  9323. {
  9324. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9325. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9326. entity.AddUserId = CurrentUser.UserID;
  9327. entity.tid = dr["tid"].ToString();
  9328. entity.Did = Convert.ToString(dr["ctid"]);
  9329. entity.splitTag = dr["SplitTag"].ToString();
  9330. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9331. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9332. if (pre_ctid.Length > 0)
  9333. {
  9334. sellmemo = sellmemo.Replace(pre_ctid, "");
  9335. }
  9336. sellmemo = sellmemo.Replace("[", "");
  9337. sellmemo = sellmemo.Replace("]", "");
  9338. entity.FileName = sellmemo;
  9339. string count = dr["ProductCount"].ToString();
  9340. int usecount = commonHelper.getIntCountFromString(count);
  9341. entity.DeliveryCount = usecount;
  9342. entity.CurState = "未完成";
  9343. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9344. {
  9345. entity.Supplier = 24;//dl手提袋定制
  9346. }
  9347. else
  9348. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9349. entity.CreateTime = DateTime.Now;
  9350. entity.Create();
  9351. }
  9352. returnSuccessMsg("操作成功");
  9353. return;
  9354. }
  9355. returnErrorMsg("没有找到对应订单");
  9356. return;
  9357. }
  9358. returnErrorMsg("缺少订单编号");
  9359. return;
  9360. }
  9361. public void get_erp_persuadelist()
  9362. {
  9363. DataStruct dStruct = GetPostStruct();
  9364. List<string> lw = new List<string>();
  9365. string ctid = GetPostString("ctid");
  9366. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9367. string shopname = GetPostString("shopname");
  9368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9369. string buyernick = GetPostString("buyer_nick");
  9370. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9371. string customer = GetPostString("customer");
  9372. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9373. string returndate1 = GetPostString("returndate1");
  9374. string returndate2 = GetPostString("returndate2");
  9375. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9376. if (dw.Length > 0) lw.Add(dw);
  9377. string finishDate1 = GetPostString("finishdate1");
  9378. string finishDate2 = GetPostString("finishdate2");
  9379. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9380. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9381. string persuadetype = GetPostString("persuadetype");
  9382. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9383. string returnvstate = GetPostString("returnvstate");
  9384. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9385. dStruct.Order = "created desc";
  9386. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9387. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9388. writeGridDataTableJson(dStruct.TotalCount, dt);
  9389. }
  9390. public void upd_erp_returnpersuadeback()
  9391. {
  9392. if (UrlPostParmsCheck("ID"))
  9393. {
  9394. int eid = GetPostInt("ID");
  9395. CeErpPersuade entity = null;
  9396. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9397. if (entity != null)
  9398. {
  9399. entity.backreason = GetPostString("reason");
  9400. entity.pstate = 2;
  9401. entity.verifytime = DateTime.Now;
  9402. entity.verifyuserid = CurrentUser.UserID;
  9403. entity.Update();
  9404. returnSuccessMsg("退回成功!");
  9405. return;
  9406. }
  9407. returnErrorMsg("找不到订单记录");
  9408. }
  9409. }
  9410. public void upd_erp_returnpersuadeverify()
  9411. {
  9412. if (UrlPostParmsCheck("ID"))
  9413. {
  9414. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9415. {
  9416. returnErrorMsg("暂无权限审核");
  9417. return;
  9418. }
  9419. int eid = GetPostInt("ID");
  9420. CeErpPersuade entity = null;
  9421. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9422. if (entity != null)
  9423. {
  9424. entity.pstate = 1;
  9425. entity.verifytime = DateTime.Now;
  9426. entity.verifyuserid = CurrentUser.UserID;
  9427. entity.Update();
  9428. returnSuccessMsg("审核成功!");
  9429. return;
  9430. }
  9431. returnErrorMsg("找不到订单记录");
  9432. }
  9433. }
  9434. public void del_erp_persuade()
  9435. {
  9436. if (UrlPostParmsCheck("ID"))
  9437. {
  9438. int eid = GetPostInt("ID");
  9439. CeErpPersuade.Del(eid);
  9440. returnSuccessMsg("操作成功");
  9441. return;
  9442. }
  9443. }
  9444. public void get_erp_oldcustoupload()
  9445. {
  9446. DataStruct dStruct = GetPostStruct();
  9447. List<string> lw = new List<string>();
  9448. string buyernick = GetPostString("buyer_nick");
  9449. if (buyernick.Length > 0)
  9450. {
  9451. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9452. }
  9453. else
  9454. return;
  9455. dStruct.Order = "pay_time desc";
  9456. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9457. DataTable dt = null;
  9458. dt = WebCache.GetData("view_erptradecell", dStruct);
  9459. writeGridDataTableJson(dStruct.TotalCount, dt);
  9460. }
  9461. public void get_erp_checkorderlist()
  9462. {
  9463. DataStruct dStruct = GetPostStruct();
  9464. List<string> lw = new List<string>();
  9465. string tid = GetPostString("ctid");
  9466. if (tid.Length > 0)
  9467. {
  9468. string select_tid = getTidByCtid(tid);
  9469. lw.Add(string.Format("tid='{0}'", select_tid));
  9470. }
  9471. string shopname = GetPostString("shopname");
  9472. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9473. string buyernick = GetPostString("buyer_nick");
  9474. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9475. string customer = GetPostString("customer");
  9476. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9477. string design = GetPostString("design");
  9478. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9479. string orderState = GetPostString("orderState");
  9480. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9481. string address = GetPostString("address");
  9482. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9483. string sellermemo = GetPostString("seller_memo");
  9484. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9485. string supplier = GetPostString("supplier");
  9486. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9487. {
  9488. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9489. }
  9490. else
  9491. {
  9492. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9493. }
  9494. string date1 = GetPostString("date1");
  9495. string date2 = GetPostString("date2");
  9496. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9497. if (dw.Length > 0) lw.Add(dw);
  9498. string placedate1 = GetPostString("placedate1");
  9499. string placedate2 = GetPostString("placedate2");
  9500. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9501. if (fdw.Length > 0) lw.Add(fdw);
  9502. string price1 = GetPostString("price1");
  9503. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9504. string price2 = GetPostString("price2");
  9505. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9506. string checkst = GetPostString("checkstate");
  9507. if (checkst.Length > 0 && "10".Equals(checkst))
  9508. {
  9509. lw.Add(string.Format("CheckOut>0"));
  9510. }
  9511. else
  9512. {
  9513. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9514. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9515. }
  9516. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9517. {
  9518. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9519. }
  9520. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9521. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9522. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9523. writeGridDataTableJson(dStruct.TotalCount, dt);
  9524. }
  9525. public void ins_erp_startCheck()
  9526. {
  9527. if (UrlPostParmsCheck("ctid"))
  9528. {
  9529. string eid = GetPostString("ctid");
  9530. CeErpTradeCell entity = null;
  9531. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9532. if (entity != null)
  9533. {
  9534. entity.MemoOpt = 4;
  9535. entity.UpdateTime = DateTime.Now;
  9536. entity.Update();
  9537. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9538. CeErpSukuraData.createInfo(entity.ctid, 6);
  9539. returnSuccessMsg("操作成功!");
  9540. return;
  9541. }
  9542. returnErrorMsg("找不到记录");
  9543. }
  9544. }
  9545. public void upd_erp_sendXlw()
  9546. {
  9547. if (UrlPostParmsCheck("ctid"))
  9548. {
  9549. string eid = GetPostString("ctid");
  9550. CeErpTradeCell entity = null;
  9551. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9552. if (entity != null)
  9553. {
  9554. if (entity.IsSendGift == 1)
  9555. {
  9556. returnErrorMsg("请勿重复标记");
  9557. return;
  9558. }
  9559. entity.IsSendGift = 1;
  9560. entity.Update();
  9561. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9562. returnSuccessMsg("操作成功!");
  9563. return;
  9564. }
  9565. returnErrorMsg("找不到记录");
  9566. }
  9567. }
  9568. public void cancel_sendXlw()
  9569. {
  9570. if (UrlPostParmsCheck("ctid"))
  9571. {
  9572. string eid = GetPostString("ctid");
  9573. CeErpTradeCell entity = null;
  9574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9575. if (entity != null)
  9576. {
  9577. if (entity.IsSendGift == 0)
  9578. {
  9579. returnErrorMsg("未标记小礼物");
  9580. return;
  9581. }
  9582. entity.IsSendGift = 0;
  9583. entity.Update();
  9584. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9585. returnSuccessMsg("操作成功!");
  9586. return;
  9587. }
  9588. returnErrorMsg("找不到记录");
  9589. }
  9590. }
  9591. public void get_erp_designbill()
  9592. {
  9593. DataStruct dStruct = GetPostStruct();
  9594. List<string> lw = new List<string>();
  9595. int isMy = GetInt("my");
  9596. if (isMy == 1)
  9597. {
  9598. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9599. }
  9600. string tid = GetPostString("tid");
  9601. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9602. string userName = GetPostString("design");
  9603. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9604. string price1 = GetPostString("price1");
  9605. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9606. string price2 = GetPostString("price2");
  9607. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9608. string rePrice1 = GetPostString("rePrice1");
  9609. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9610. string rePrice2 = GetPostString("rePrice2");
  9611. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9612. string designerType = GetPostString("designerType");
  9613. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9614. string orderState = GetPostString("orderState");
  9615. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9616. string endTime1 = GetPostString("endTime1");
  9617. string endTime2 = GetPostString("endTime2");
  9618. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9619. if (dw.Length > 0) lw.Add(dw);
  9620. string isDk = GetPostString("isDk");
  9621. if (isDk == "1")
  9622. {
  9623. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9624. }
  9625. else if (isDk == "0")
  9626. {
  9627. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9628. }
  9629. dStruct.Order = "oid, create_time desc";
  9630. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9631. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9632. writeGridDataTableJson(dStruct.TotalCount, dt);
  9633. }
  9634. public void upd_erp_designerbill()
  9635. {
  9636. if (UrlPostParmsCheck("ID"))
  9637. {
  9638. string eid = GetPostString("ID");
  9639. CeErpDesignerBill entity = null;
  9640. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9641. if (entity != null)
  9642. {
  9643. if (GetPostDouble("designerpirce") > 0)
  9644. {
  9645. entity.realPrice = GetPostDouble("designerpirce");
  9646. entity.update_time = DateTime.Now;
  9647. entity.update_u_id = CurrentUser.UserID;
  9648. entity.update_u_name = CurrentUser.UserName;
  9649. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9650. entity.Update();
  9651. returnSuccessMsg("操作成功!");
  9652. return;
  9653. }
  9654. else
  9655. {
  9656. entity.price = GetPostDouble("price");
  9657. entity.update_time = DateTime.Now;
  9658. entity.update_u_id = CurrentUser.UserID;
  9659. entity.update_u_name = CurrentUser.UserName;
  9660. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9661. entity.Update();
  9662. returnSuccessMsg("操作成功!");
  9663. return;
  9664. }
  9665. }
  9666. returnErrorMsg("找不到记录");
  9667. }
  9668. }
  9669. public void audit_erp_designerbill()
  9670. {
  9671. if (UrlPostParmsCheck("ID"))
  9672. {
  9673. string eid = GetPostString("ID");
  9674. CeErpDesignerBill entity = null;
  9675. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9676. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9677. if (entity != null)
  9678. {
  9679. entity.realPrice = GetPostDouble("designerpirce");
  9680. entity.update_time = DateTime.Now;
  9681. entity.update_u_id = CurrentUser.UserID;
  9682. entity.update_u_name = CurrentUser.UserName;
  9683. entity.isAudit = 1;
  9684. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9685. entity.Update();
  9686. if (orderEntity != null)
  9687. {
  9688. orderEntity.IsReadTag = 3;
  9689. orderEntity.Update();
  9690. }
  9691. returnSuccessMsg("操作成功!");
  9692. return;
  9693. }
  9694. returnErrorMsg("找不到记录");
  9695. }
  9696. }
  9697. public void all_audit_erp_designerbill()
  9698. {
  9699. if (UrlPostParmsCheck("idList"))
  9700. {
  9701. string[] list = GetPostString("idList").Split(',');
  9702. CeErpDesignerBill entity = null;
  9703. for (int i = 0; i < list.Length; i++)
  9704. {
  9705. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9706. if (entity == null) return;
  9707. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9708. if (orderEntity == null) return;
  9709. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9710. entity.update_time = DateTime.Now;
  9711. entity.update_u_id = CurrentUser.UserID;
  9712. entity.update_u_name = CurrentUser.UserName;
  9713. entity.isAudit = 1;
  9714. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9715. entity.Update();
  9716. orderEntity.IsReadTag = 3;
  9717. orderEntity.Update();
  9718. }
  9719. returnSuccessMsg("操作成功!");
  9720. return;
  9721. }
  9722. }
  9723. public void get_erp_sameorders()
  9724. {
  9725. if (UrlPostParmsCheck("ctid"))
  9726. {
  9727. string eid = GetPostString("ctid");
  9728. CeErpTradeCell entity = null;
  9729. entity = CeErpTradeCell.GetByCtid(eid);
  9730. if (entity != null)
  9731. {
  9732. StringBuilder sql = new StringBuilder();
  9733. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9734. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9735. var res = new
  9736. {
  9737. data = dt.Rows.Count
  9738. };
  9739. string ro_jsond = JsonConvert.SerializeObject(res);
  9740. returnSuccess(ro_jsond);
  9741. return;
  9742. }
  9743. returnErrorMsg("未找到订单");
  9744. return;
  9745. }
  9746. returnErrorMsg("缺少必要的参数");
  9747. }
  9748. public void get_erp_islasthavesameorder()
  9749. {
  9750. if (UrlPostParmsCheck("ctid"))
  9751. {
  9752. string eid = GetPostString("ctid");
  9753. string[] ctidList = eid.Split(',');
  9754. StringBuilder sql = new StringBuilder();
  9755. string tisCtid = "";
  9756. foreach (string ctid in ctidList)
  9757. {
  9758. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9759. if (entity != null)
  9760. {
  9761. sql = new StringBuilder();
  9762. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9763. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9764. if (dth.Rows.Count > 0)
  9765. {
  9766. tisCtid += entity.ctid;
  9767. tisCtid += ",";
  9768. }
  9769. }
  9770. }
  9771. if (tisCtid.Length > 0)
  9772. {
  9773. var res = new
  9774. {
  9775. data = tisCtid
  9776. };
  9777. string ro_jsond = JsonConvert.SerializeObject(res);
  9778. returnSuccess(ro_jsond);
  9779. }
  9780. else
  9781. {
  9782. var res = new
  9783. {
  9784. data = ""
  9785. };
  9786. string ro_jsond = JsonConvert.SerializeObject(res);
  9787. returnSuccess(ro_jsond);
  9788. }
  9789. return;
  9790. }
  9791. returnErrorMsg("缺少必要的参数");
  9792. }
  9793. public void file_client_down_url()
  9794. {
  9795. if (!UrlPostParmsCheck("userId"))
  9796. {
  9797. returnErrorMsg("缺少必要的参数");
  9798. }
  9799. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9800. }
  9801. public void checkout_form_data()
  9802. {
  9803. if (!UrlPostParmsCheck("tid"))
  9804. {
  9805. returnErrorMsg("缺少必要的参数");
  9806. }
  9807. string tid = GetPostString("tid");
  9808. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9809. if (ceErpOrderFormData != null)
  9810. {
  9811. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9812. returnSuccess(ro_jsond);
  9813. return;
  9814. }
  9815. returnErrorMsg("尚未有文件!");
  9816. }
  9817. public void back_supplier_audit()
  9818. {
  9819. int userId = CurrentUser.UserID;
  9820. StringBuilder sql = new StringBuilder();
  9821. 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);
  9822. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9823. if (dt.Rows.Count > 0)
  9824. {
  9825. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9826. }
  9827. else
  9828. {
  9829. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9830. }
  9831. }
  9832. public void back_supplier_query()
  9833. {
  9834. string eid = GetPostString("ctid");
  9835. if (eid != "")
  9836. {
  9837. StringBuilder sql = new StringBuilder();
  9838. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9839. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9840. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9841. }
  9842. else
  9843. {
  9844. returnErrorMsg("找不到订单记录");
  9845. return;
  9846. }
  9847. }
  9848. public void verified_to_order()
  9849. {
  9850. int userId = CurrentUser.UserID;
  9851. StringBuilder sql = new StringBuilder();
  9852. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9853. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9854. if (dt.Rows.Count > 0)
  9855. {
  9856. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9857. }
  9858. else
  9859. {
  9860. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9861. }
  9862. }
  9863. public void upd_supplier_audit()
  9864. {
  9865. if (UrlPostParmsCheck("ctid"))
  9866. {
  9867. string eid = GetPostString("ctid");
  9868. string reason = GetPostString("returnreason");
  9869. CeErpTradeCell entity = null;
  9870. CeWithdraw withdraw = null;
  9871. withdraw = CeWithdraw.GetByTid(eid);
  9872. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9873. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9874. {
  9875. if (withdraw != null)
  9876. {
  9877. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9878. {
  9879. returnSuccessMsg("您没有权限操作!");
  9880. return;
  9881. }
  9882. else
  9883. {
  9884. if (reason.Equals("1"))
  9885. {
  9886. if (entity.OrderState == -1)
  9887. {
  9888. if (entity.FinishPlaceTime == null)
  9889. {
  9890. entity.OrderState = 2;
  9891. }
  9892. else
  9893. {
  9894. entity.OrderState = 6;
  9895. }
  9896. }
  9897. entity.Update();
  9898. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9899. if (withdraw != null)
  9900. {
  9901. withdraw.status = int.Parse(reason);
  9902. withdraw.Update();
  9903. }
  9904. returnSuccessMsg("操作成功!");
  9905. return;
  9906. }
  9907. else
  9908. {
  9909. withdraw.status = int.Parse(reason);
  9910. withdraw.acknowledgingtime = DateTime.Now;
  9911. withdraw.Update();
  9912. returnSuccessMsg("查看详细请点击线下订单查询");
  9913. return;
  9914. }
  9915. }
  9916. }
  9917. // 第一个字符是 'N'
  9918. }
  9919. if (eid[0] != 'N')
  9920. {
  9921. }
  9922. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9923. {
  9924. entity.IsVerifyToSupplier = false;
  9925. entity.IsReturn = 1;
  9926. entity.ReturnTime = DateTime.Now;
  9927. entity.ReturnReason = reason;
  9928. if (entity.OrderState == 6)
  9929. {
  9930. entity.OrderState = 5;
  9931. }
  9932. entity.Update();
  9933. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9934. if (withdraw != null)
  9935. {
  9936. withdraw.status = int.Parse(reason);
  9937. withdraw.Update();
  9938. }
  9939. returnSuccessMsg("操作成功!");
  9940. return;
  9941. }
  9942. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9943. {
  9944. ;
  9945. if (withdraw != null)
  9946. {
  9947. withdraw.status = int.Parse(reason);
  9948. withdraw.acknowledgingtime = DateTime.Now;
  9949. withdraw.Update();
  9950. returnSuccessMsg("供应商取消撤回!");
  9951. return;
  9952. }
  9953. }
  9954. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9955. {
  9956. if (entity.OrderState == -1)
  9957. {
  9958. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9959. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9960. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9961. {
  9962. returnErrorMsg("台湾客户需填写身份证!");
  9963. return;
  9964. }
  9965. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9966. {
  9967. returnErrorMsg("订单spu没有确认无法通过审核!");
  9968. return;
  9969. }
  9970. if (entity.FinishPlaceTime == null)
  9971. {
  9972. entity.OrderState = 2;
  9973. }
  9974. else
  9975. {
  9976. entity.OrderState = 3;
  9977. }
  9978. commonHelper.getCytPrice(entity);
  9979. }
  9980. entity.Update();
  9981. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9982. if (withdraw != null)
  9983. {
  9984. withdraw.status = int.Parse(reason);
  9985. withdraw.Update();
  9986. }
  9987. returnSuccessMsg("操作成功!");
  9988. return;
  9989. }
  9990. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9991. {
  9992. if (withdraw == null)
  9993. {
  9994. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9995. return;
  9996. }
  9997. }
  9998. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9999. {
  10000. if (withdraw != null)
  10001. {
  10002. withdraw.status = int.Parse(reason);
  10003. withdraw.acknowledgingtime = DateTime.Now;
  10004. withdraw.Update();
  10005. returnSuccessMsg("查看详细请点击线下订单查询");
  10006. return;
  10007. }
  10008. }
  10009. return;
  10010. }
  10011. }
  10012. //校验报价
  10013. public void refund_order_tip()
  10014. {
  10015. int userid = CurrentUser.UserID;
  10016. int sectionId = CurrentUser.UserPost.OrgID;
  10017. StringBuilder sql = new StringBuilder();
  10018. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10019. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10020. List<string> ids = new List<string>();
  10021. if (dth.Rows.Count > 0)
  10022. {
  10023. foreach (DataRow dr in dth.Rows)
  10024. {
  10025. ids.Add(dr["ID"].ToString());
  10026. }
  10027. try
  10028. {
  10029. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10030. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10031. }
  10032. catch (Exception ex)
  10033. {
  10034. }
  10035. }
  10036. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10037. }
  10038. public void refund_order_Design()
  10039. {
  10040. int userid = CurrentUser.UserID;
  10041. int sectionId = CurrentUser.UserPost.OrgID;
  10042. StringBuilder sql = new StringBuilder();
  10043. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10044. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10045. List<string> ids = new List<string>();
  10046. if (dth.Rows.Count > 0)
  10047. {
  10048. foreach (DataRow dr in dth.Rows)
  10049. {
  10050. ids.Add(dr["ID"].ToString());
  10051. }
  10052. try
  10053. {
  10054. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10055. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10056. }
  10057. catch (Exception ex)
  10058. {
  10059. }
  10060. }
  10061. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10062. }
  10063. public void change_order_info()
  10064. {
  10065. int userid = CurrentUser.UserID;
  10066. StringBuilder sql = new StringBuilder();
  10067. 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);
  10068. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10069. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10070. }
  10071. public void change_win_mome()
  10072. {
  10073. if (UrlPostParmsCheck("id,ctid"))
  10074. {
  10075. string id = GetPostString("id");
  10076. string ctid = GetPostString("ctid");
  10077. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10078. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10079. if (ce == null || ceErpMessageTip == null)
  10080. {
  10081. returnSuccessMsg("未找到对应的订单!");
  10082. return;
  10083. }
  10084. if (ce.OrderState >= 5)
  10085. {
  10086. ceErpMessageTip.isVisit = true;
  10087. ceErpMessageTip.Update();
  10088. returnSuccessMsg("已上传文件无法修改!");
  10089. return;
  10090. }
  10091. int type = GetPostInt("type");
  10092. string content = GetPostString("content");
  10093. if (type == 0)
  10094. {
  10095. content = content.Replace("(", "(");
  10096. content = content.Replace(")", ")");
  10097. string check = MidStrEx(content, "(", ")").Trim();
  10098. if (string.IsNullOrEmpty(check))
  10099. {
  10100. returnSuccessMsg("文件名格式不正确");
  10101. return;
  10102. }
  10103. }
  10104. ce.seller_memo = content;
  10105. ce.Update();
  10106. ceErpMessageTip.isVisit = true;
  10107. ceErpMessageTip.Update();
  10108. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10109. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10110. ApiVo apiVo = new ApiVo();
  10111. apiVo.orderNumber = ce.ctid;
  10112. apiVo.actionName = "demandDesign";
  10113. apiVo.orderRemarks = content;
  10114. apiVo.demandExamine = type + 1;
  10115. designHelper.API_WorkCore(apiVo);//demandDesign
  10116. returnSuccessMsg("修改成功!");
  10117. }
  10118. }
  10119. public static string MidStrEx(string sourse, string startstr, string endstr)
  10120. {
  10121. string result = string.Empty;
  10122. int startindex, endindex;
  10123. try
  10124. {
  10125. startindex = sourse.IndexOf(startstr);
  10126. if (startindex == -1)
  10127. return result;
  10128. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10129. endindex = tmpstr.IndexOf(endstr);
  10130. if (endindex == -1)
  10131. return result;
  10132. result = tmpstr.Remove(endindex);
  10133. }
  10134. catch (Exception ex)
  10135. {
  10136. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10137. }
  10138. return result;
  10139. }
  10140. public void refund_order_list()
  10141. {
  10142. int userid = CurrentUser.UserID;
  10143. int sectionId = CurrentUser.UserPost.OrgID;
  10144. StringBuilder sql = new StringBuilder();
  10145. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10146. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10147. DataStruct dStruct = GetPostStruct();
  10148. DataTable dt = null;
  10149. List<string> ids = new List<string>();
  10150. List<string> tids = new List<string>();
  10151. if (dth.Rows.Count > 0)
  10152. {
  10153. foreach (DataRow dr in dth.Rows)
  10154. {
  10155. tids.Add("'" + dr["tid"].ToString() + "'");
  10156. ids.Add(dr["id"].ToString());
  10157. }
  10158. try
  10159. {
  10160. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10161. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10162. List<string> lw = new List<string>();
  10163. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10164. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10165. dt = WebCache.GetData("view_orderlist", dStruct);
  10166. }
  10167. catch (Exception ex)
  10168. {
  10169. }
  10170. }
  10171. writeGridDataTableJson(dStruct.TotalCount, dt);
  10172. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10173. }
  10174. //新增
  10175. public void order_batch_downloads()
  10176. {
  10177. string ceid = GetPostString("tid");
  10178. String[] tid = ceid.Split(',');
  10179. order_batch_caiyingtong(tid);
  10180. /* (string success, string errors) = UploadFiles(tid);
  10181. returnSuccessMsg(success + errors);*/
  10182. return;
  10183. }
  10184. //报价接口
  10185. public void Get_To_Quote()
  10186. {
  10187. string ceid = GetPostString("ctid");
  10188. if (ceid != null)
  10189. {
  10190. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10191. if (entity != null)
  10192. {
  10193. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10194. {
  10195. return;
  10196. }
  10197. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10198. double price = 0;
  10199. if (cp == null)
  10200. {
  10201. JObject jsonObject12 = new JObject
  10202. {
  10203. { "UserId", "77886" },
  10204. { "Pwd", "lt666888" },
  10205. { "Filename", entity.seller_memo }
  10206. };
  10207. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10208. JObject jsonObjects1 = JObject.Parse(response1);
  10209. string ms1g = (string)jsonObjects1["msg"];
  10210. if (ms1g == "报价成功")
  10211. {
  10212. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10213. string data = (string)jsonObject1["price"];
  10214. 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 + "');";
  10215. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10216. returnSuccessMsg("获取报价成功:" + data);
  10217. price = Convert.ToDouble(data);
  10218. }
  10219. else
  10220. {
  10221. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10222. return;
  10223. }
  10224. }
  10225. String[] beizhu = entity.seller_memo.Split('-');
  10226. String chanp = "";
  10227. if (beizhu.Length > 0)
  10228. {
  10229. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10230. }
  10231. else
  10232. {
  10233. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10234. }
  10235. JObject jsonObject = new JObject
  10236. {
  10237. { "UserId", "77886" },
  10238. { "Pwd", "lt666888" },
  10239. { "Filename", chanp }
  10240. };
  10241. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10242. JObject jsonObjects = JObject.Parse(response);
  10243. string msg = (string)jsonObjects["msg"];
  10244. if (msg == "报价成功")
  10245. {
  10246. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10247. string data = (string)jsonObject1["price"];
  10248. 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 + "');";
  10249. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10250. returnSuccessMsg("获取报价成功:" + data);
  10251. price = Convert.ToDouble(data);
  10252. }
  10253. else
  10254. {
  10255. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10256. return;
  10257. }
  10258. if (price > 0)
  10259. {
  10260. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10261. if (ceErpTradeCellExtend == null)
  10262. {
  10263. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10264. ceErpTradeCellExtend.ctid = entity.ctid;
  10265. ceErpTradeCellExtend.payment_cyt = price;
  10266. ceErpTradeCellExtend.Create();
  10267. }
  10268. else
  10269. {
  10270. ceErpTradeCellExtend.payment_cyt = price;
  10271. ceErpTradeCellExtend.Update();
  10272. }
  10273. }
  10274. return;
  10275. }
  10276. }
  10277. else
  10278. {
  10279. returnErrorMsg("请至少选择一条数据");
  10280. return;
  10281. }
  10282. }
  10283. //新增
  10284. public void order_To_Supplier()
  10285. {
  10286. string ceid = GetPostString("tid");
  10287. String[] tid = ceid.Split(',');
  10288. if (tid.Length > 0)
  10289. {
  10290. try
  10291. {
  10292. for (int i = 0; i < tid.Length; i++)
  10293. {
  10294. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10295. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10296. entity.SupplierId = suid;
  10297. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10298. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10299. entity.Update();
  10300. }
  10301. }
  10302. catch (Exception ex)
  10303. {
  10304. returnErrorMsg("自动匹配供应商失败");
  10305. return;
  10306. }
  10307. }
  10308. else
  10309. {
  10310. returnErrorMsg("请至少选择一条数据");
  10311. return;
  10312. }
  10313. returnSuccessMsg("自动匹配供应商成功");
  10314. return;
  10315. }
  10316. public (string, string) UploadFiles(string[] urls)
  10317. {
  10318. string success = "";
  10319. string errors = "";
  10320. int userid = CurrentUser.UserID;
  10321. foreach (string url in urls)
  10322. {
  10323. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10324. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10325. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10326. {
  10327. JObject jsonObject = new JObject
  10328. {
  10329. { "Userid", "77886" },
  10330. { "pwd", "cyt86435015" },
  10331. { "content", base64FileContent },
  10332. { "ext", Path.GetExtension(fileName) }
  10333. };
  10334. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10335. JObject jsonObjects = JObject.Parse(response);
  10336. string msg = (string)jsonObjects["msg"];
  10337. if (msg.Equals("上传成功"))
  10338. {
  10339. success += url + " 上传成功";
  10340. }
  10341. else
  10342. {
  10343. errors += url + " 上传失败";
  10344. }
  10345. }
  10346. else
  10347. {
  10348. errors += url + " 格式出现问题";
  10349. }
  10350. }
  10351. if (urls.Length == 0)
  10352. {
  10353. return (success, errors);
  10354. }
  10355. return (success, errors);
  10356. }
  10357. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10358. {
  10359. return true; //总是接受
  10360. }
  10361. public static string HttpPost(string url, string param = null)
  10362. {
  10363. HttpWebRequest request;
  10364. //如果是发送HTTPS请求
  10365. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10366. {
  10367. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10368. request = WebRequest.Create(url) as HttpWebRequest;
  10369. request.ProtocolVersion = HttpVersion.Version10;
  10370. }
  10371. else
  10372. {
  10373. request = WebRequest.Create(url) as HttpWebRequest;
  10374. }
  10375. request.Method = "POST";
  10376. request.ContentType = "application/json";
  10377. request.Accept = "*/*";
  10378. request.Timeout = 120000;
  10379. request.AllowAutoRedirect = false;
  10380. StreamWriter requestStream = null;
  10381. WebResponse response = null;
  10382. string responseStr = null;
  10383. try
  10384. {
  10385. requestStream = new StreamWriter(request.GetRequestStream());
  10386. requestStream.Write(param);
  10387. requestStream.Close();
  10388. response = request.GetResponse();
  10389. if (response != null)
  10390. {
  10391. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10392. responseStr = reader.ReadToEnd();
  10393. reader.Close();
  10394. }
  10395. }
  10396. catch (Exception ex)
  10397. {
  10398. return ex.Message;
  10399. }
  10400. finally
  10401. {
  10402. request = null;
  10403. requestStream = null;
  10404. response = null;
  10405. }
  10406. return responseStr;
  10407. }
  10408. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10409. {
  10410. string base64FileContent;
  10411. string fileName;
  10412. using (WebClient webClient = new WebClient())
  10413. {
  10414. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10415. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10416. {
  10417. using (Stream stream = response.GetResponseStream())
  10418. {
  10419. using (MemoryStream memoryStream = new MemoryStream())
  10420. {
  10421. stream.CopyTo(memoryStream);
  10422. byte[] fileBytes = memoryStream.ToArray();
  10423. base64FileContent = Convert.ToBase64String(fileBytes);
  10424. fileName = response.Headers["Content-Disposition"];
  10425. if (!string.IsNullOrEmpty(fileName))
  10426. {
  10427. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10428. if (index >= 0)
  10429. {
  10430. fileName = fileName.Substring(index + 9).Trim('\"');
  10431. }
  10432. }
  10433. else
  10434. {
  10435. fileName = Path.GetFileName(downloadUrl);
  10436. }
  10437. }
  10438. }
  10439. }
  10440. }
  10441. return (fileName, base64FileContent);
  10442. }
  10443. //新增
  10444. public void order_batch_caiyingtong(string[] downloadUrls)
  10445. {
  10446. try
  10447. {
  10448. //遍历文件
  10449. DataStruct dStruct = GetPostStruct();
  10450. DataTable dt = null;
  10451. int userid = CurrentUser.UserID;
  10452. List<string> ids = new List<string>();//失败组
  10453. List<string> tids = new List<string>();
  10454. using (WebClient webClient = new WebClient())
  10455. {
  10456. foreach (var url in downloadUrls)
  10457. {
  10458. try
  10459. {
  10460. tids.Add("'" + url + "'");
  10461. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10462. if (entity != null)
  10463. {
  10464. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10465. if (cp == null)
  10466. {
  10467. JObject jsonObject = new JObject
  10468. {
  10469. { "Userid", "77886" },
  10470. { "pwd", "lt666888" },
  10471. { "Filename",entity.seller_memo }
  10472. };
  10473. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10474. JObject jsonObjects = JObject.Parse(response);
  10475. string msg = (string)jsonObjects["msg"];
  10476. if (msg == "报价成功")
  10477. {
  10478. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10479. DownloadAndConvertToBase64(url1);
  10480. }
  10481. else
  10482. {
  10483. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10484. }
  10485. }
  10486. else
  10487. {
  10488. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10489. JObject jsonObject = new JObject
  10490. {
  10491. { "Userid", "77886" },
  10492. { "pwd", "lt666888" },
  10493. { "Filename",chanp }
  10494. };
  10495. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10496. JObject jsonObjects = JObject.Parse(response);
  10497. string msg = (string)jsonObjects["msg"];
  10498. if (msg == "报价成功")
  10499. {
  10500. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10501. DownloadAndConvertToBase64(url1);
  10502. }
  10503. else
  10504. {
  10505. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10506. }
  10507. }
  10508. }
  10509. // 上传文件到FTP
  10510. }
  10511. catch (Exception ex)
  10512. {
  10513. Console.WriteLine($"An error occurred: {ex.Message}");
  10514. }
  10515. }
  10516. List<string> lw = new List<string>();
  10517. lw.Add(string.Format("( OrderState < 6 )"));
  10518. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10519. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10520. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10521. if (dt.Rows.Count > 0)
  10522. {
  10523. foreach (DataRow dr in dt.Rows)
  10524. {
  10525. ids.Add(dr["ctid"].ToString());
  10526. }
  10527. }
  10528. String ErrorMsgs = "";
  10529. foreach (String id in ids)
  10530. {
  10531. ErrorMsgs += id + ",";
  10532. }
  10533. if (ErrorMsgs.Length > 1)
  10534. {
  10535. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10536. }
  10537. if (ErrorMsgs.Length < 1)
  10538. {
  10539. ErrorMsgs = "上传成功";
  10540. returnSuccessMsg(ErrorMsgs);
  10541. }
  10542. else
  10543. {
  10544. returnErrorMsg("以下订单" + ErrorMsgs);
  10545. }
  10546. }
  10547. // 删除文件夹及其内容
  10548. /* Directory.Delete(localDirectory, true);*/
  10549. }
  10550. catch { }
  10551. }
  10552. public void get_center_data()
  10553. {
  10554. int userId = CurrentUser.UserID;
  10555. string postCode = CurrentUser.UserPost.Post.Code;
  10556. List<string> lw = new List<string>();
  10557. List<string> ww = new List<string>();
  10558. DateTime currentTime = DateTime.Now;
  10559. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10560. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10561. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10562. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10563. string sql = " SELECT ";
  10564. string startTime = "2023-10-01 11:22:31";
  10565. //设计
  10566. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10567. {
  10568. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10569. 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));
  10570. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10571. 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));
  10572. }
  10573. //客服
  10574. else if (postCode == "CustomerService" || postCode == "Director")
  10575. {
  10576. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10577. 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));
  10578. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10579. 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));
  10580. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10581. 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));
  10582. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10583. 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));
  10584. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10585. 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));
  10586. }
  10587. //售后
  10588. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10589. {
  10590. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10591. 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));
  10592. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10593. 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));
  10594. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10595. 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));
  10596. }
  10597. //下单部
  10598. else if (postCode == "Place" || postCode == "PlaceMr")
  10599. {
  10600. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10601. 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));
  10602. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10603. 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));
  10604. }
  10605. //车间
  10606. else if (postCode == "Supplier")
  10607. {
  10608. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10609. 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));
  10610. }
  10611. DataTable dt = new DataTable();
  10612. if (lw.Count > 0)
  10613. {
  10614. sql += string.Join(" , ", lw);
  10615. sql += " FROM ";
  10616. sql += string.Join(" , ", ww);
  10617. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10618. }
  10619. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10620. }
  10621. public void get_center_data_list()
  10622. {
  10623. int userId = CurrentUser.UserID;
  10624. string postCode = CurrentUser.UserPost.Post.Code;
  10625. string shopIds = CurrentUser.User.pemShop;
  10626. DataStruct dStruct = GetPostStruct();
  10627. List<string> lw = new List<string>();
  10628. DateTime currentTime = DateTime.Now;
  10629. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10630. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10631. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10632. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10633. string startTime = "2023-10-01 11:22:31";
  10634. int order_type = GetPostInt("order_type");
  10635. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10636. {
  10637. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10638. if (order_type == 0)
  10639. {
  10640. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10641. }
  10642. else if (order_type == 3)
  10643. {
  10644. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10645. }
  10646. else
  10647. {
  10648. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10649. }
  10650. }
  10651. //客服
  10652. if (postCode == "CustomerService" || postCode == "Director")
  10653. {
  10654. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10655. if (order_type == 0)
  10656. {
  10657. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10658. }
  10659. else if (order_type == 1)
  10660. {
  10661. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10662. }
  10663. else if (order_type == 2)
  10664. {
  10665. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10666. }
  10667. else if (order_type == 3)
  10668. {
  10669. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10670. }
  10671. else if (order_type == 4)
  10672. {
  10673. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10674. }
  10675. else
  10676. {
  10677. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10678. }
  10679. }
  10680. //售后
  10681. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10682. {
  10683. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10684. if (shopIds != "")
  10685. {
  10686. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10687. }
  10688. if (order_type == 2)
  10689. {
  10690. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10691. }
  10692. else if (order_type == 4)
  10693. {
  10694. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10695. }
  10696. else if (order_type == 5)
  10697. {
  10698. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10699. }
  10700. else
  10701. {
  10702. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10703. }
  10704. }
  10705. //下单部
  10706. if (postCode == "Place" || postCode == "PlaceMr")
  10707. {
  10708. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10709. if (shopIds != "")
  10710. {
  10711. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10712. }
  10713. else if (order_type == 1)
  10714. {
  10715. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10716. }
  10717. else if (order_type == 2)
  10718. {
  10719. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10720. }
  10721. else
  10722. {
  10723. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10724. }
  10725. }
  10726. //车间
  10727. if (postCode == "Supplier")
  10728. {
  10729. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10730. if (order_type == 5)
  10731. {
  10732. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10733. }
  10734. else
  10735. {
  10736. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10737. }
  10738. }
  10739. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10740. dStruct.Fileds = "tid,ctid";
  10741. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10742. writeGridDataTableJson(dStruct.TotalCount, dt);
  10743. }
  10744. public void aftersale_audit_master()
  10745. {
  10746. if (UrlPostParmsCheck("ctid"))
  10747. {
  10748. string ctid = GetPostString("ctid");
  10749. if (ctid.Length > 0)
  10750. {
  10751. bool result = aftersale_data_change(ctid);
  10752. if (result)
  10753. {
  10754. returnSuccessMsg("修改成功!");
  10755. return;
  10756. }
  10757. }
  10758. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10759. }
  10760. }
  10761. public void aftersale_batch_audit_master()
  10762. {
  10763. if (UrlPostParmsCheck("ctids"))
  10764. {
  10765. string ctids = GetPostString("ctids");
  10766. if (ctids.Length > 0)
  10767. {
  10768. List<string> list = new List<string>();
  10769. string[] ctid_list = ctids.Split(',');
  10770. foreach (var item in ctid_list)
  10771. {
  10772. bool result = aftersale_data_change(item);
  10773. if (!result)
  10774. {
  10775. list.Add(item);
  10776. }
  10777. }
  10778. if (list.Count > 0)
  10779. {
  10780. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10781. return;
  10782. }
  10783. returnSuccessMsg("修改成功!");
  10784. return;
  10785. }
  10786. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10787. }
  10788. }
  10789. public bool aftersale_data_change(string ctid)
  10790. {
  10791. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10792. if (ceErpTradeCell != null)
  10793. {
  10794. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10795. ceErpTradeCell.AfterSaleSupplierState = 0;
  10796. StringBuilder sql = new StringBuilder();
  10797. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10798. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10799. CeErpTradeResponsible.DelByTid(ctid, 0);
  10800. 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 == "不理赔")
  10801. {
  10802. CeErpTradeResponsible.DelByTid(ctid, 1);
  10803. ceErpTradeCell.AfterSaleSupplierState = 1;
  10804. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10805. ceErpTradeCell.AfterSaleState = 4;
  10806. }
  10807. else
  10808. {
  10809. ceErpTradeCell.AfterSaleState = 3;
  10810. }
  10811. bool needCyt = false;
  10812. if (dt != null)
  10813. {
  10814. if (dt.Rows.Count == 1)
  10815. {
  10816. bool isEnd = false;
  10817. foreach (DataRow dr in dt.Rows)
  10818. {
  10819. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10820. {
  10821. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10822. isEnd = true;
  10823. }
  10824. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10825. {
  10826. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10827. isEnd = true;
  10828. }
  10829. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10830. {
  10831. needCyt = true;
  10832. }
  10833. }
  10834. if (isEnd)
  10835. {
  10836. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10837. ceErpTradeCell.AfterSaleState = 4;
  10838. ceErpTradeCell.AfterSaleSupplierState = 1;
  10839. }
  10840. }
  10841. else
  10842. {
  10843. bool isAll = true;
  10844. foreach (DataRow dr in dt.Rows)
  10845. {
  10846. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10847. {
  10848. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10849. continue;
  10850. }
  10851. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10852. {
  10853. string path = "";
  10854. int OrgID = 0;
  10855. if (!Convert.IsDBNull(dr["OrgPath"]))
  10856. {
  10857. path = dr["OrgPath"].ToString();
  10858. }
  10859. if (!Convert.IsDBNull(dr["OrgID"]))
  10860. {
  10861. OrgID = Convert.ToInt32(dr["OrgID"]);
  10862. }
  10863. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10864. {
  10865. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10866. continue;
  10867. }
  10868. }
  10869. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10870. {
  10871. needCyt = true;
  10872. }
  10873. isAll = false;
  10874. }
  10875. if (isAll)
  10876. {
  10877. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10878. ceErpTradeCell.AfterSaleState = 4;
  10879. ceErpTradeCell.AfterSaleSupplierState = 1;
  10880. }
  10881. }
  10882. }
  10883. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10884. {
  10885. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10886. }
  10887. if (ceErpTradeCell.AfterSaleState == 4)
  10888. {
  10889. ApiVo apiVo = new ApiVo();
  10890. apiVo.orderNumber = ceErpTradeCell.ctid;
  10891. apiVo.actionName = "afterOver";
  10892. designHelper.API_WorkCore(apiVo); //afterOver
  10893. }
  10894. ceErpTradeCell.Update();
  10895. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10896. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10897. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10898. return true;
  10899. }
  10900. return false;
  10901. }
  10902. public void get_erp_wechatorder()
  10903. {
  10904. DataStruct dStruct = GetPostStruct();
  10905. List<string> lw = new List<string>();
  10906. string tid = GetPostString("tid");
  10907. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10908. string shopname = GetPostString("shopname");
  10909. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10910. string buyernick = GetPostString("buyer_nick");
  10911. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10912. string customer = GetPostString("customer");
  10913. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10914. string returndate1 = GetPostString("returndate1");
  10915. string returndate2 = GetPostString("returndate2");
  10916. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10917. if (dw.Length > 0) lw.Add(dw);
  10918. string finishDate1 = GetPostString("finishdate1");
  10919. string finishDate2 = GetPostString("finishdate2");
  10920. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10921. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10922. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10923. dStruct.Order = "created desc";
  10924. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10925. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10926. writeGridDataTableJson(dStruct.TotalCount, dt);
  10927. }
  10928. public void get_erp_wechatlist_sumprice()
  10929. {
  10930. DataStruct dStruct = GetPostStruct();
  10931. List<string> lw = new List<string>();
  10932. string tid = GetPostString("tid");
  10933. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10934. string shopname = GetPostString("shopname");
  10935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10936. string buyernick = GetPostString("buyer_nick");
  10937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10938. string customer = GetPostString("customer");
  10939. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10940. string returndate1 = GetPostString("returndate1");
  10941. string returndate2 = GetPostString("returndate2");
  10942. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10943. if (dw.Length > 0) lw.Add(dw);
  10944. string finishDate1 = GetPostString("finishdate1");
  10945. string finishDate2 = GetPostString("finishdate2");
  10946. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10947. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10948. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10949. string mainWhere = string.Join(" and ", lw.ToArray());
  10950. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10951. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10952. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10953. decimal total = 0;
  10954. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10955. {
  10956. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10957. }
  10958. var res = new
  10959. {
  10960. data = total
  10961. };
  10962. string ro_jsond = JsonConvert.SerializeObject(res);
  10963. returnSuccess(ro_jsond);
  10964. return;
  10965. }
  10966. public void get_erp_qr_waitdeliverylist()
  10967. {
  10968. DataStruct dStruct = GetPostStruct();
  10969. List<string> lw = new List<string>();
  10970. string tid = GetPostString("ctid");
  10971. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10973. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10974. var res_objz = new
  10975. {
  10976. restype = 1,
  10977. data = dt
  10978. };
  10979. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10980. returnSuccess(ro_jsonz);
  10981. }
  10982. public void get_erp_yield_list()
  10983. {
  10984. DataStruct dStruct = GetPostStruct();
  10985. List<string> lw = new List<string>();
  10986. string tid = GetPostString("ctid");
  10987. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10988. string shopname = GetPostString("shopname");
  10989. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10990. string buyernick = GetPostString("buyer_nick");
  10991. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10992. //if (tid.Length == 0 && buyernick.Length == 0)
  10993. //{
  10994. // lw.Add(string.Format("IsRefund<={0}", 1));
  10995. //}
  10996. string customer = GetPostString("customer");
  10997. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10998. string design = GetPostString("design");
  10999. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11000. string orderState = GetPostString("orderState");
  11001. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11002. string address = GetPostString("address");
  11003. 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));
  11004. string sellermemo = GetPostString("seller_memo");
  11005. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11006. string supplier = GetPostString("supplier");
  11007. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11008. string OrderArea = GetPostString("order_area");
  11009. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11010. string placedate1 = GetPostString("placedate1");
  11011. string placedate2 = GetPostString("placedate2");
  11012. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11013. if (fdw.Length > 0) lw.Add(fdw);
  11014. string price1 = GetPostString("price1");
  11015. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11016. string price2 = GetPostString("price2");
  11017. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11018. string unusualCon = GetPostString("unusualcon");
  11019. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11020. string posTag = CurrentUser.UserPost.Post.Code;
  11021. if (posTag == "Supplier")
  11022. {
  11023. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11024. }
  11025. lw.Add(string.Format("OrderState = 6 "));
  11026. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11027. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11028. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11029. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11030. writeGridDataTableJson(dStruct.TotalCount, dt);
  11031. }
  11032. public void change_erp_sup_state()
  11033. {
  11034. if (UrlPostParmsCheck("ctid"))
  11035. {
  11036. string ctid = GetPostString("ctid");
  11037. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11038. if (ceErpTradeCell != null)
  11039. {
  11040. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11041. if (ceErpTradeCellExtend == null)
  11042. {
  11043. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11044. ceErpTradeCellExtend.ctid = ctid;
  11045. ceErpTradeCellExtend.SupState = 1;
  11046. ceErpTradeCellExtend.Create();
  11047. }
  11048. else
  11049. {
  11050. ceErpTradeCellExtend.SupState = 1;
  11051. ceErpTradeCellExtend.Update();
  11052. }
  11053. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11054. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11055. return;
  11056. }
  11057. returnErrorMsg("找不到订单");
  11058. }
  11059. }
  11060. public void supplier_all_downs()
  11061. {
  11062. if (UrlPostParmsCheck("tids"))
  11063. {
  11064. string tids = GetPostString("tids");
  11065. if (tids != null && tids.Length > 0)
  11066. {
  11067. StringBuilder sql = new StringBuilder();
  11068. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11069. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11070. sql = new StringBuilder();
  11071. 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, "下载设计文件");
  11072. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11073. string[] list = tids.Split(',');
  11074. foreach (string ctid in list)
  11075. {
  11076. CeErpSukuraData.createInfo(ctid, 3);
  11077. }
  11078. designHelper.api_approveDesign(tids); //approveDesign
  11079. returnSuccessMsg("下载成功!");
  11080. return;
  11081. }
  11082. returnErrorMsg("下载订单更新失败");
  11083. }
  11084. }
  11085. public void uploaderFileSuccess()
  11086. {
  11087. if (UrlPostParmsCheck("fileName"))
  11088. {
  11089. string fileName = GetPostString("fileName");
  11090. ApiVo apiVo = new ApiVo();
  11091. apiVo.orderNumber = fileName;
  11092. apiVo.actionName = "finishDesign";
  11093. designHelper.API_WorkCore(apiVo);//finishDesign
  11094. returnSuccessMsg("");
  11095. }
  11096. }
  11097. public void get_sample2_order()
  11098. {
  11099. if (UrlPostParmsCheck("ctid"))
  11100. {
  11101. string ctid = GetPostString("ctid");
  11102. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11103. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11104. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11105. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11106. double total = 0.0;
  11107. double order_price = 0.0;
  11108. if (dt_bu.Rows.Count > 0)
  11109. {
  11110. foreach (DataRow dr in dt_bu.Rows)
  11111. {
  11112. total += Convert.ToDouble(dr["payment"]);
  11113. }
  11114. }
  11115. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11116. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11117. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11118. string tid = ctid.Replace("S_", "");
  11119. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11120. double paymant = 0.0;
  11121. if (entity != null)
  11122. {
  11123. paymant = entity.payment;
  11124. }
  11125. string return_reason = "";
  11126. if (dt_after != null && dt_after.Rows.Count > 0)
  11127. {
  11128. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11129. }
  11130. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11131. }
  11132. }
  11133. public void get_erp_design_status()
  11134. {
  11135. string designName = GetPostString("designName");
  11136. DataStruct dStruct = GetPostStruct();
  11137. if (designName.Length > 0)
  11138. {
  11139. 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";
  11140. sql_user += " and Name like '%" + designName + "%'";
  11141. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11142. List<string> ids_list = new List<string>();
  11143. if (user_table.Rows.Count > 0)
  11144. {
  11145. foreach (DataRow item in user_table.Rows)
  11146. {
  11147. ids_list.Add(item["id"].ToString());
  11148. string ids_s = item["TeamIds"].ToString();
  11149. if (ids_s.Length > 0)
  11150. {
  11151. ids_list.AddRange(ids_s.Split(','));
  11152. }
  11153. }
  11154. }
  11155. HashSet<string> set = new HashSet<string>(ids_list);
  11156. ids_list = set.ToList();
  11157. if (ids_list.Count > 0)
  11158. {
  11159. 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));
  11160. dStruct.MainWhere = sql;
  11161. DataTable dt = null;
  11162. dt = WebCache.GetData("view_ErpUser", dStruct);
  11163. writeGridDataTableJson(dStruct.TotalCount, dt);
  11164. }
  11165. }
  11166. }
  11167. public void change_erp_order_price()
  11168. {
  11169. string ctid = GetPostString("ctid");
  11170. double price = GetPostDouble("price");
  11171. if (ctid.Length > 0)
  11172. {
  11173. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11174. if (ceErpTradeCellExtend == null)
  11175. {
  11176. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11177. ceErpTradeCellExtend.ctid = ctid;
  11178. ceErpTradeCellExtend.payment_cyt = price;
  11179. ceErpTradeCellExtend.Create();
  11180. }
  11181. else
  11182. {
  11183. ceErpTradeCellExtend.payment_cyt = price;
  11184. ceErpTradeCellExtend.Update();
  11185. }
  11186. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11187. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11188. {
  11189. ceErpDataSendOrderInfo.isSync = false;
  11190. ceErpDataSendOrderInfo.Update();
  11191. }
  11192. if (ceErpDataSendOrderInfo == null)
  11193. {
  11194. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11195. ceErpDataSendOrderInfo.isSync = false;
  11196. ceErpDataSendOrderInfo.ctid = ctid;
  11197. ceErpDataSendOrderInfo.Create();
  11198. }
  11199. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11200. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11201. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11202. if (dth != null && dth.Rows.Count > 0)
  11203. {
  11204. dataSendOrderBean dataSendOrderBean = null;
  11205. foreach (DataRow item in dth.Rows)
  11206. {
  11207. try
  11208. {
  11209. dataSendOrderBean = new dataSendOrderBean();
  11210. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11211. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11212. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11213. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11214. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11215. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11216. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11217. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11218. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11219. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11220. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11221. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11222. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11223. if (result != null)
  11224. {
  11225. if ("0".Equals(result.errcode))
  11226. {
  11227. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11228. }
  11229. else
  11230. {
  11231. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11232. }
  11233. }
  11234. }
  11235. catch (Exception ex)
  11236. {
  11237. }
  11238. }
  11239. }
  11240. returnSuccessMsg("修改成功!");
  11241. return;
  11242. }
  11243. returnErrorMsg("找不到订单");
  11244. }
  11245. public void find_he_together()
  11246. {
  11247. string ctid = GetPostString("ctid");
  11248. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11249. List<string> list = new List<string>();
  11250. if (ceErpTradeCell != null)
  11251. {
  11252. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11253. {
  11254. 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);
  11255. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11256. if (table != null && table.Rows.Count > 0)
  11257. {
  11258. foreach (TableRow row in table.Rows)
  11259. {
  11260. }
  11261. }
  11262. }
  11263. }
  11264. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11265. }
  11266. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11267. {
  11268. //chy----19
  11269. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11270. //GD-CYT-----64
  11271. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11272. //ZHX----3
  11273. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11274. //JK----97
  11275. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11276. //ZT----70
  11277. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11278. //LHCY-----98
  11279. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11280. //XD-----90
  11281. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11282. //CYCY-----14
  11283. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11284. };
  11285. //其他改名
  11286. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11287. {
  11288. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11289. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11290. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11291. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11292. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11293. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11294. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11295. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11296. };
  11297. //不统计
  11298. List<int> no_suppliers = new List<int>()
  11299. {
  11300. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11301. };
  11302. //配件单
  11303. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11304. {
  11305. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11306. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11307. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11308. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11309. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11310. {"旗杆",new List<string>(){ "班旗" } },
  11311. {"牙签",new List<string>(){ "不干胶" } }
  11312. };
  11313. public void get_place_order_data()
  11314. {
  11315. string date1 = GetPostString("date1");
  11316. string date2 = GetPostString("date2");
  11317. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11318. DateTime start = DateTime.Parse(starttime);
  11319. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11320. DateTime end = DateTime.Parse(endtime);
  11321. if (date1 != null && date1.Length > 0)
  11322. {
  11323. DateTime dateTime = DateTime.Parse(date1);
  11324. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11325. start = DateTime.Parse(starttime);
  11326. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11327. end = DateTime.Parse(endtime);
  11328. }
  11329. if (date2 != null && date2.Length > 0)
  11330. {
  11331. DateTime dateTime = DateTime.Parse(date2);
  11332. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11333. end = DateTime.Parse(endtime);
  11334. }
  11335. 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);
  11336. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11337. //不干胶-----1,卡片-----29
  11338. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11339. foreach (DataRow row in data.Rows)
  11340. {
  11341. int productId = Convert.ToInt32(row["ProductId"]);
  11342. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11343. if (no_suppliers.Contains(supplierId))
  11344. {
  11345. continue;
  11346. }
  11347. string seller_memo = row["seller_memo"].ToString();
  11348. bool ispj = false;//是否配件单
  11349. bool isfirst = true;//第一个配
  11350. maps.Keys.ForEach(key =>
  11351. {
  11352. //备注包含配件
  11353. if (seller_memo.Contains(key) && isfirst)
  11354. {
  11355. List<string> list = maps[key];
  11356. ispj = true;
  11357. isfirst = false;
  11358. for (int i = 0; i < list.Count; i++)
  11359. {
  11360. if (seller_memo.Contains(list[i]))
  11361. {
  11362. ispj = false;
  11363. break;
  11364. }
  11365. }
  11366. }
  11367. });
  11368. if (ispj)
  11369. {
  11370. continue;
  11371. }
  11372. seller_memo = seller_memo.Replace("UV", "uv");
  11373. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11374. //吊牌归到卡片
  11375. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11376. seller_memo = seller_memo.Replace("卡套", "卡片");
  11377. seller_memo = seller_memo.Replace("封套", "卡片");
  11378. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11379. 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. string map_key = "";
  11385. string type = "";
  11386. if (supplierMap.ContainsKey(supplierId))
  11387. {
  11388. foreach (var kvp in supplierMap[supplierId])
  11389. {
  11390. if (seller_memo.Contains(kvp.Key))
  11391. {
  11392. map_key = kvp.Value;
  11393. type = kvp.Value;
  11394. break;
  11395. }
  11396. }
  11397. }
  11398. if (map_key == "")
  11399. {
  11400. type = "其他";
  11401. map_key = "其他";
  11402. }
  11403. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11404. {
  11405. map_key = suppliers[supplierId];
  11406. }
  11407. if (supplierId == 70)
  11408. {
  11409. supplierId = 70;
  11410. }
  11411. map_key += "_" + row["SupplierName"].ToString();
  11412. Dictionary<string, int> map = null;
  11413. if (other_map.ContainsKey(map_key))
  11414. {
  11415. other_map.TryGetValue(map_key, out map);
  11416. }
  11417. else
  11418. {
  11419. map = new Dictionary<string, int>();
  11420. map.Add("dayDev", 0);//当天出货
  11421. map.Add("dayTotal", 0);//下单总数
  11422. map.Add("payTotal", 0);//500以上
  11423. map.Add("today", 0);//当天出货数量
  11424. map.Add("unusua", 0);//异常数
  11425. other_map.Add(map_key, map);
  11426. other_map.TryGetValue(map_key, out map);
  11427. }
  11428. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11429. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11430. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11431. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11432. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11433. {
  11434. map["dayTotal"]++;
  11435. if (supplierId == 97)
  11436. {
  11437. supplierId = 97;
  11438. }
  11439. }
  11440. if (Convert.ToDecimal(row["payment"]) >= 500)
  11441. {
  11442. map["payTotal"]++;
  11443. }
  11444. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11445. {
  11446. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11447. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11448. {
  11449. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11450. {
  11451. map["today"]++;
  11452. }
  11453. }
  11454. else
  11455. {
  11456. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11457. {
  11458. map["today"]++;
  11459. }
  11460. else
  11461. {
  11462. if (supplierId == 119)
  11463. {
  11464. Debug.WriteLine(row["seller_memo"].ToString());
  11465. }
  11466. }
  11467. }
  11468. }
  11469. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11470. {
  11471. map["unusua"]++;
  11472. }
  11473. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11474. //GD-CYT-----64
  11475. DateTime two = palceTimeStart.AddHours(14);
  11476. DateTime three = palceTimeStart.AddHours(15);
  11477. DateTime four = palceTimeStart.AddHours(16);
  11478. DateTime six = palceTimeStart.AddHours(18);
  11479. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11480. {
  11481. //下午四点前 500-1000
  11482. string count = row["ProductCount"].ToString();
  11483. if (count != null && count.Length > 0)
  11484. {
  11485. int productCount = commonHelper.getPlaceProductCount(count);
  11486. if (productCount >= 500 && productCount <= 1000)
  11487. {
  11488. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11489. {
  11490. map["dayDev"]++;
  11491. }
  11492. }
  11493. }
  11494. }
  11495. //UV
  11496. else if ("uv".Equals(type))
  11497. {
  11498. //ZT----70
  11499. //ZHX----3
  11500. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11501. {
  11502. map["dayDev"]++;
  11503. }
  11504. //JK----97
  11505. //HZX----105
  11506. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11507. {
  11508. map["dayDev"]++;
  11509. }
  11510. }
  11511. //帆布---52|条幅---27
  11512. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11513. {
  11514. //LHCY-----98
  11515. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11516. {
  11517. map["dayDev"]++;
  11518. }
  11519. }
  11520. //条幅
  11521. else if ("条幅".Equals(type))
  11522. {
  11523. //XD-----90
  11524. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11525. {
  11526. map["dayDev"]++;
  11527. }
  11528. }
  11529. //桌布
  11530. else if ("桌布".Equals(type))
  11531. {
  11532. //XD-----90
  11533. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11534. {
  11535. map["dayDev"]++;
  11536. }
  11537. }
  11538. //DL---10
  11539. //AYTW---119
  11540. //FS-CYT-DY ----80
  11541. //JK----97
  11542. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11543. {
  11544. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11545. {
  11546. map["dayDev"]++;
  11547. }
  11548. }
  11549. // QC---121
  11550. else if (supplierId == 121)
  11551. {
  11552. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11553. {
  11554. map["dayDev"]++;
  11555. }
  11556. }
  11557. }
  11558. DataTable dt = new DataTable();
  11559. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11560. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11561. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11562. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11563. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11564. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11565. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11566. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11567. other_map.Keys.ForEach(key =>
  11568. {
  11569. DataRow dr = dt.NewRow();
  11570. Dictionary<string, int> map = other_map[key];
  11571. string[] key_list = key.Split('_');
  11572. dr[0] = key_list[0];
  11573. dr[1] = key_list[1];
  11574. if (key_list.Length > 2)
  11575. {
  11576. dr[1] += "(" + key_list[2] + ")";
  11577. }
  11578. dr[2] = map["dayTotal"];
  11579. dr[3] = map["payTotal"];
  11580. dr[4] = map["today"];
  11581. dr[5] = map["unusua"];
  11582. dr[6] = map["dayDev"];
  11583. double rate = 0.00;
  11584. if (map["dayDev"] > 0)
  11585. {
  11586. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11587. }
  11588. dr[7] = rate.ToString();
  11589. dt.Rows.Add(dr);
  11590. });
  11591. DataView dv = new DataView(dt);
  11592. dv.Sort = "SupplierName";
  11593. //dv.Sort = "AllOrder desc";
  11594. DataTable dtNew = dv.ToTable();
  11595. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11596. }
  11597. public void check_order_desing_info()
  11598. {
  11599. string ctid = GetPostString("ctid");
  11600. if (!string.IsNullOrEmpty(ctid))
  11601. {
  11602. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11603. if (ceErpTradeCell != null)
  11604. {
  11605. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11606. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11607. return;
  11608. }
  11609. returnErrorMsg("找不到订单");
  11610. return;
  11611. }
  11612. returnErrorMsg("找不到订单");
  11613. }
  11614. public void get_timeout_detail()
  11615. {
  11616. string poscode = CurrentUser.UserPost.Post.Code;
  11617. DataStruct dStruct = GetPostStruct();
  11618. List<string> lw = new List<string>();
  11619. string id = GetPostString("id");
  11620. string pay_date1 = GetPostString("pay_date1");
  11621. string pay_date2 = GetPostString("pay_date2");
  11622. int type = GetPostInt("type");
  11623. if (type == 0)
  11624. {
  11625. if (pay_date1.Length > 0)
  11626. {
  11627. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11628. }
  11629. if (pay_date2.Length > 0)
  11630. {
  11631. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11632. }
  11633. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11634. }
  11635. if (type == 1)
  11636. {
  11637. if (pay_date1.Length > 0)
  11638. {
  11639. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11640. }
  11641. if (pay_date2.Length > 0)
  11642. {
  11643. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11644. }
  11645. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11646. }
  11647. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11648. DataTable dt = null;
  11649. dt = WebCache.GetData("view_orderlist", dStruct);
  11650. writeGridDataTableJson(dStruct.TotalCount, dt);
  11651. }
  11652. public void saveUrgentChargePrice()
  11653. {
  11654. string ctid = GetPostString("ctid");
  11655. if (!string.IsNullOrEmpty(ctid))
  11656. {
  11657. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11658. if (ceErpTradeCell != null)
  11659. {
  11660. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11661. if (prices <= 100)
  11662. {
  11663. returnErrorMsg("此订单金额不足100元,无法加急。");
  11664. return;
  11665. }
  11666. double price = GetPostDouble("price");
  11667. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11668. if (ceErpTradeCellExtend == null)
  11669. {
  11670. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11671. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11672. }
  11673. ceErpTradeCellExtend.urgentCharge = price;
  11674. if (ceErpTradeCellExtend.ID > 0)
  11675. {
  11676. ceErpTradeCellExtend.Update();
  11677. }
  11678. else
  11679. {
  11680. ceErpTradeCellExtend.Save();
  11681. }
  11682. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11683. returnSuccessMsg("修改成功!");
  11684. return;
  11685. }
  11686. returnErrorMsg("找不到订单");
  11687. return;
  11688. }
  11689. returnErrorMsg("找不到订单");
  11690. }
  11691. public void finish_erp_order()
  11692. {
  11693. string ctid = GetPostString("ctid");
  11694. if (!string.IsNullOrEmpty(ctid))
  11695. {
  11696. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11697. {
  11698. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11699. if (ceErpTradeCell != null)
  11700. {
  11701. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11702. ceErpTradeCell.Update();
  11703. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11704. returnSuccessMsg("修改成功!");
  11705. return;
  11706. }
  11707. }
  11708. }
  11709. returnErrorMsg("找不到订单");
  11710. }
  11711. public void get_trade_order_list()
  11712. {
  11713. string tid = GetPostString("tid");
  11714. if (!string.IsNullOrEmpty(tid))
  11715. {
  11716. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11717. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11718. writeGridDataTableJson(data.Rows.Count, data);
  11719. return;
  11720. }
  11721. returnErrorMsg("找不到订单");
  11722. }
  11723. public void save_cell_spu()
  11724. {
  11725. string ctid = GetPostString("ctid");
  11726. string spu_id = GetPostString("spu_id");
  11727. if (!string.IsNullOrEmpty(ctid))
  11728. {
  11729. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11730. if (ceErpTradeCellExtend == null)
  11731. {
  11732. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11733. ceErpTradeCellExtend.ctid = ctid;
  11734. }
  11735. ceErpTradeCellExtend.spu_id = spu_id;
  11736. if (!string.IsNullOrEmpty(spu_id))
  11737. {
  11738. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11739. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11740. }
  11741. if (ceErpTradeCellExtend.ID == 0)
  11742. {
  11743. ceErpTradeCellExtend.Create();
  11744. }
  11745. else
  11746. {
  11747. ceErpTradeCellExtend.Update();
  11748. }
  11749. returnSuccessMsg("修改成功!");
  11750. return;
  11751. }
  11752. returnErrorMsg("找不到订单");
  11753. }
  11754. public void change_express_info()
  11755. {
  11756. string ctid = GetPostString("ctid");
  11757. string transNo = GetPostString("transNo");
  11758. string transCom = GetPostString("transCom");
  11759. if (!string.IsNullOrEmpty(ctid))
  11760. {
  11761. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11762. if (ceErpTradeCellExtend == null)
  11763. {
  11764. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11765. ceErpTradeCellExtend.ctid = ctid;
  11766. }
  11767. ceErpTradeCellExtend.modExpressNo = transNo;
  11768. ceErpTradeCellExtend.modExpressCom = transCom;
  11769. ceErpTradeCellExtend.readMod = 2;
  11770. if (ceErpTradeCellExtend.ID == 0)
  11771. {
  11772. ceErpTradeCellExtend.Create();
  11773. }
  11774. else
  11775. {
  11776. ceErpTradeCellExtend.Update();
  11777. }
  11778. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11779. returnSuccessMsg("修改成功!");
  11780. return;
  11781. }
  11782. returnErrorMsg("找不到订单");
  11783. }
  11784. public void get_change_express_list()
  11785. {
  11786. DataStruct dStruct = GetPostStruct();
  11787. List<string> lw = new List<string>();
  11788. int st = 2;
  11789. string tid = GetPostString("ctid");
  11790. if (tid.Length > 0)
  11791. {
  11792. string select_tid = getTidByCtid(tid);
  11793. lw.Add(string.Format("tid='{0}'", select_tid));
  11794. }
  11795. string shopname = GetPostString("shopname");
  11796. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11797. string buyernick = GetPostString("buyer_nick");
  11798. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11799. string sellermemo = GetPostString("seller_memo");
  11800. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11801. string supplier = GetPostString("supplier");
  11802. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11803. string customer = GetPostString("customer");
  11804. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11805. string design = GetPostString("design");
  11806. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11807. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11808. string poscode = CurrentUser.UserPost.Post.Code;
  11809. if (poscode != "SysAdmin")
  11810. {
  11811. string shopid = CurrentUser.User.pemShop;
  11812. lw.Add(string.Format("shopId in ({0})", shopid));
  11813. }
  11814. lw.Add("readMod = 2");
  11815. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11816. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11817. writeGridDataTableJson(dStruct.TotalCount, dt);
  11818. }
  11819. public void deal_express_complete()
  11820. {
  11821. string ctid = GetPostString("ctid");
  11822. if (!string.IsNullOrEmpty(ctid))
  11823. {
  11824. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11825. if (ceErpTradeCellExtend == null)
  11826. {
  11827. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11828. ceErpTradeCellExtend.ctid = ctid;
  11829. }
  11830. ceErpTradeCellExtend.readMod = 1;
  11831. if (ceErpTradeCellExtend.ID == 0)
  11832. {
  11833. ceErpTradeCellExtend.Create();
  11834. }
  11835. else
  11836. {
  11837. ceErpTradeCellExtend.Update();
  11838. }
  11839. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11840. returnSuccessMsg("修改成功!");
  11841. return;
  11842. }
  11843. returnErrorMsg("找不到订单");
  11844. }
  11845. public void aftersale_return_visit()
  11846. {
  11847. string ctid = GetPostString("ctid");
  11848. if (!string.IsNullOrEmpty(ctid))
  11849. {
  11850. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11851. if (ceErpTradeCellExtend == null)
  11852. {
  11853. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11854. ceErpTradeCellExtend.ctid = ctid;
  11855. }
  11856. ceErpTradeCellExtend.returnVisit = 1;
  11857. if (ceErpTradeCellExtend.ID == 0)
  11858. {
  11859. ceErpTradeCellExtend.Create();
  11860. }
  11861. else
  11862. {
  11863. ceErpTradeCellExtend.Update();
  11864. }
  11865. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11866. if (ceErpTradeAfterSaleExtend != null)
  11867. {
  11868. ceErpTradeAfterSaleExtend.TextResult = "";
  11869. ceErpTradeAfterSaleExtend.Update();
  11870. }
  11871. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11872. returnSuccessMsg("修改成功!");
  11873. return;
  11874. }
  11875. returnErrorMsg("找不到订单");
  11876. }
  11877. public void orderPlaceInfo()
  11878. {
  11879. string ctids = GetPostString("ctids");
  11880. string[] list = ctids.Split(',');
  11881. foreach (string ctid in list)
  11882. {
  11883. CeErpSukuraData.createInfo(ctid, 3);
  11884. }
  11885. StringBuilder sql = new StringBuilder();
  11886. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11887. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11888. designHelper.api_approveDesign(ctids); //approveDesign
  11889. returnSuccessMsg("");
  11890. }
  11891. public void get_issue_list()
  11892. {
  11893. DataStruct dStruct = GetPostStruct();
  11894. List<string> lw = new List<string>();
  11895. int st = 2;
  11896. string tid = GetPostString("ctid");
  11897. if (tid.Length > 0)
  11898. {
  11899. string select_tid = getTidByCtid(tid);
  11900. lw.Add(string.Format("tid='{0}'", select_tid));
  11901. }
  11902. string shopname = GetPostString("shopname");
  11903. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11904. string buyernick = GetPostString("buyer_nick");
  11905. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11906. string sellermemo = GetPostString("seller_memo");
  11907. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11908. string supplier = GetPostString("supplier");
  11909. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11910. string customer = GetPostString("customer");
  11911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11912. string design = GetPostString("design");
  11913. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11914. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11915. string poscode = CurrentUser.UserPost.Post.Code;
  11916. if (poscode != "SysAdmin")
  11917. {
  11918. string shopid = CurrentUser.User.pemShop;
  11919. lw.Add(string.Format("shopId in ({0})", shopid));
  11920. }
  11921. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11922. {
  11923. lw.Add("IssueState = 1");
  11924. }
  11925. lw.Add("IssueState > 0");
  11926. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11927. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11928. writeGridDataTableJson(dStruct.TotalCount, dt);
  11929. }
  11930. public void saveIssueContent()
  11931. {
  11932. string ctid = GetPostString("ctid");
  11933. if (!string.IsNullOrEmpty(ctid))
  11934. {
  11935. string content = GetPostString("content");
  11936. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11937. if (ceErpTradeAfterSaleExtend == null)
  11938. {
  11939. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11940. ceErpTradeAfterSaleExtend.tid = ctid;
  11941. }
  11942. ceErpTradeAfterSaleExtend.IssueContent = content;
  11943. ceErpTradeAfterSaleExtend.IssueState = 1;
  11944. if (ceErpTradeAfterSaleExtend.ID > 0)
  11945. {
  11946. ceErpTradeAfterSaleExtend.Update();
  11947. }
  11948. else
  11949. {
  11950. ceErpTradeAfterSaleExtend.Create();
  11951. }
  11952. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11953. returnSuccessMsg("添加成功!");
  11954. return;
  11955. }
  11956. returnErrorMsg("找不到订单");
  11957. }
  11958. public void dealIssueContent()
  11959. {
  11960. string ctid = GetPostString("ctid");
  11961. if (!string.IsNullOrEmpty(ctid))
  11962. {
  11963. string content = GetPostString("content");
  11964. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11965. if (ceErpTradeAfterSaleExtend != null)
  11966. {
  11967. ceErpTradeAfterSaleExtend.IssueState = 2;
  11968. ceErpTradeAfterSaleExtend.Update();
  11969. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11970. returnSuccessMsg("修改完成!");
  11971. return;
  11972. }
  11973. }
  11974. returnErrorMsg("找不到订单");
  11975. }
  11976. public void set_tid_attachments()
  11977. {
  11978. string tid = GetPostString("tid");
  11979. string atta = GetPostString("atta");
  11980. if (!string.IsNullOrEmpty(tid))
  11981. {
  11982. if (string.IsNullOrEmpty(atta))
  11983. {
  11984. returnErrorMsg("文件地址为空");
  11985. return;
  11986. }
  11987. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11988. if (ceErpTradeCell != null)
  11989. {
  11990. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11991. if (ceErpTrade == null)
  11992. {
  11993. returnErrorMsg("找不到订单");
  11994. return;
  11995. }
  11996. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11997. bool isSend = false;
  11998. if (dt != null && dt.Rows.Count > 0)
  11999. {
  12000. foreach (DataRow row in dt.Rows)
  12001. {
  12002. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12003. {
  12004. isSend = true;
  12005. }
  12006. }
  12007. if (isSend)
  12008. {
  12009. returnErrorMsg("已发货无法修改");
  12010. return;
  12011. }
  12012. ceErpTrade.Attachments = atta;
  12013. ceErpTrade.Update();
  12014. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12015. returnSuccessMsg("上传成功!");
  12016. return;
  12017. }
  12018. }
  12019. }
  12020. returnErrorMsg("找不到订单");
  12021. }
  12022. public void get_tid_attachments()
  12023. {
  12024. string tid = GetPostString("tid");
  12025. if (!string.IsNullOrEmpty(tid))
  12026. {
  12027. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12028. if (ceErpTradeCell != null)
  12029. {
  12030. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12031. if (ceErpTrade == null)
  12032. {
  12033. returnErrorMsg("找不到订单");
  12034. return;
  12035. }
  12036. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12037. return;
  12038. }
  12039. }
  12040. returnErrorMsg("找不到订单");
  12041. }
  12042. public void check_erp_sameorders()
  12043. {
  12044. if (UrlPostParmsCheck("ctid"))
  12045. {
  12046. string eid = GetPostString("ctid");
  12047. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12048. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12049. if (entity != null && ceErpTrade != null)
  12050. {
  12051. if (entity.OrderState > 6)
  12052. {
  12053. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12054. return;
  12055. }
  12056. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12057. List<string> ids = new List<string>();
  12058. if (dt != null && dt.Rows.Count > 1)
  12059. {
  12060. bool needhe = true;
  12061. foreach (DataRow dr in dt.Rows)
  12062. {
  12063. ids.Add("'" + dr["ctid"] + "'");
  12064. /* //备注有合包
  12065. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12066. {
  12067. needhe = true;
  12068. }
  12069. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12070. {
  12071. needhe = true;
  12072. }
  12073. //顺丰快递
  12074. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12075. {
  12076. needhe = true;
  12077. }*/
  12078. }
  12079. if (!needhe)
  12080. {
  12081. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12082. return;
  12083. }
  12084. StringBuilder sql = new StringBuilder();
  12085. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12086. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12087. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12088. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12089. foreach (DataRow dr in dt.Rows)
  12090. {
  12091. dr["dstate"] = 0;
  12092. dr["dnumber"] = 0;
  12093. foreach (DataRow row in dt1.Rows)
  12094. {
  12095. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12096. {
  12097. dr["dstate"] = 2;
  12098. dr["default"] = 1;
  12099. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12100. }
  12101. }
  12102. if (eid.Equals(dr["ctid"].ToString()))
  12103. {
  12104. dr["dstate"] = 1;
  12105. dr["default"] = 1;
  12106. }
  12107. }
  12108. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12109. return;
  12110. }
  12111. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12112. return;
  12113. }
  12114. returnErrorMsg("未找到订单");
  12115. return;
  12116. }
  12117. returnErrorMsg("缺少必要的参数");
  12118. }
  12119. public void get_mark_number()
  12120. {
  12121. string eid = GetPostString("ctid");
  12122. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12123. if (entity != null)
  12124. {
  12125. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12126. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12127. int current = 1;
  12128. if (ceErpDeliverMark == null)
  12129. {
  12130. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12131. List<string> ids = new List<string>();
  12132. if (dt != null && dt.Rows.Count > 1)
  12133. {
  12134. foreach (DataRow dr in dt.Rows)
  12135. {
  12136. ids.Add("'" + dr["ctid"] + "'");
  12137. }
  12138. //查询已有的编号
  12139. StringBuilder sql = new StringBuilder();
  12140. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12141. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12142. if (dt1 == null || dt1.Rows.Count == 0)
  12143. {
  12144. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12145. List<int> list_number = new List<int>();
  12146. foreach (DataRow row in numbers.Rows)
  12147. {
  12148. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12149. }
  12150. //查询空余编号
  12151. for (int i = 0; i < list_number.Count + 2; i++)
  12152. {
  12153. if (!list_number.Contains(current))
  12154. {
  12155. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12156. //防止查询过程中有新数据生成
  12157. if (ceErpDeliverMark1 == null)
  12158. {
  12159. break;
  12160. }
  12161. }
  12162. current++;
  12163. }
  12164. }
  12165. else
  12166. {
  12167. foreach (DataRow row in dt1.Rows)
  12168. {
  12169. current = Convert.ToInt32(row["markNumber"]);
  12170. }
  12171. }
  12172. ceErpDeliverMark = new CeErpDeliverMark();
  12173. ceErpDeliverMark.ctid = eid;
  12174. ceErpDeliverMark.createtime = DateTime.Now;
  12175. if (ceErpTrade != null)
  12176. {
  12177. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12178. }
  12179. ceErpDeliverMark.markNumber = current;
  12180. ceErpDeliverMark.Create();
  12181. }
  12182. }
  12183. else
  12184. {
  12185. current = ceErpDeliverMark.markNumber;
  12186. }
  12187. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12188. return;
  12189. }
  12190. }
  12191. public void aftersaleCytSend()
  12192. {
  12193. string ctid = GetPostString("ctid");
  12194. if (!string.IsNullOrEmpty(ctid))
  12195. {
  12196. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12197. if (ceErpTradeCell != null)
  12198. {
  12199. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12200. }
  12201. returnSuccessMsg("推送成功");
  12202. return;
  12203. }
  12204. returnErrorMsg("缺少必要的参数");
  12205. }
  12206. public void packOrderInfo()
  12207. {
  12208. string ctids = GetPostString("ctids");
  12209. if (!string.IsNullOrEmpty(ctids))
  12210. {
  12211. string[] ctid_list = ctids.Split(',');
  12212. if (ctid_list.Length > 20)
  12213. {
  12214. returnErrorMsg("单次下载次数不能超过20个");
  12215. return;
  12216. }
  12217. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12218. StringBuilder sql = new StringBuilder();
  12219. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12220. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12221. int supplierId = 0;
  12222. StringBuilder insterSql = new StringBuilder();
  12223. for (int i = 0; i < dt.Rows.Count; i++)
  12224. {
  12225. DataRow row = dt.Rows[i];
  12226. if (i == 0)
  12227. {
  12228. supplierId = Convert.ToInt32(row["SupplierId"]);
  12229. }
  12230. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12231. {
  12232. returnErrorMsg("同车间的订单才能一起打包");
  12233. return;
  12234. }
  12235. int orderState = Convert.ToInt32(row["OrderState"]);
  12236. if (orderState != 5)
  12237. {
  12238. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12239. return;
  12240. }
  12241. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12242. }
  12243. CeErpPackData ceErpPackData = new CeErpPackData();
  12244. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12245. ceErpPackData.supplierId = supplierId;
  12246. ceErpPackData.createtime = DateTime.Now;
  12247. ceErpPackData.createBy = CurrentUser.UserID;
  12248. ceErpPackData.createName = CurrentUser.UserName;
  12249. ceErpPackData.Create();
  12250. if (ceErpPackData.ID > 0)
  12251. {
  12252. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12253. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12254. }
  12255. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12256. returnSuccessMsg("打包成功");
  12257. return;
  12258. }
  12259. returnErrorMsg("缺少必要的参数");
  12260. }
  12261. public void rePackOrderInfo()
  12262. {
  12263. string id = GetPostString("id");
  12264. if (!string.IsNullOrEmpty(id))
  12265. {
  12266. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12267. if (ceErpPackData == null)
  12268. {
  12269. returnSuccessMsg("查无数据");
  12270. return;
  12271. }
  12272. ceErpPackData.upStatus = 0;
  12273. ceErpPackData.message = "";
  12274. ceErpPackData.Update();
  12275. returnSuccessMsg("打包成功");
  12276. return;
  12277. }
  12278. returnErrorMsg("缺少必要的参数");
  12279. }
  12280. public void backPackOrderInfo()
  12281. {
  12282. string id = GetPostString("id");
  12283. if (!string.IsNullOrEmpty(id))
  12284. {
  12285. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12286. if (ceErpPackData == null)
  12287. {
  12288. returnSuccessMsg("查无数据");
  12289. return;
  12290. }
  12291. ceErpPackData.upStatus = 4;
  12292. ceErpPackData.Update();
  12293. List<string> list = new List<string>();
  12294. StringBuilder sql = new StringBuilder();
  12295. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12296. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12297. for (int i = 0; i < dt.Rows.Count; i++)
  12298. {
  12299. DataRow row = dt.Rows[i];
  12300. list.Add("'" + row["ctid"].ToString() + "'");
  12301. }
  12302. string textCtids = string.Join(",", list);
  12303. 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));
  12304. 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, "无法打包退回"));
  12305. returnSuccessMsg("退回成功");
  12306. return;
  12307. }
  12308. returnErrorMsg("缺少必要的参数");
  12309. }
  12310. public void addPackDownNum()
  12311. {
  12312. string id = GetPostString("id");
  12313. if (!string.IsNullOrEmpty(id))
  12314. {
  12315. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12316. returnSuccessMsg("下载成功");
  12317. return;
  12318. }
  12319. returnErrorMsg("缺少必要的参数");
  12320. }
  12321. public void get_pack_list()
  12322. {
  12323. DataStruct dStruct = GetPostStruct();
  12324. List<string> lw = new List<string>();
  12325. string supplier = GetPostString("supplier");
  12326. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12327. string posTag = CurrentUser.UserPost.Post.Code;
  12328. if (posTag == "Supplier")
  12329. {
  12330. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12331. }
  12332. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12333. dStruct.Order = "createtime desc";
  12334. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12335. writeGridDataTableJson(dStruct.TotalCount, dt);
  12336. }
  12337. public void get_pack_order_list()
  12338. {
  12339. string packId = GetPostString("packId");
  12340. if (string.IsNullOrEmpty(packId))
  12341. {
  12342. returnErrorMsg("缺少必要的参数");
  12343. return;
  12344. }
  12345. StringBuilder sql = new StringBuilder();
  12346. 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);
  12347. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12348. if (dt == null || dt.Rows.Count == 0)
  12349. {
  12350. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12351. return;
  12352. }
  12353. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12354. return;
  12355. }
  12356. public void get_supplier_product_time_list()
  12357. {
  12358. DataStruct dStruct = GetPostStruct();
  12359. List<string> lw = new List<string>();
  12360. string supplier = GetPostString("supplier");
  12361. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12362. string posTag = CurrentUser.UserPost.Post.Code;
  12363. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12364. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12365. writeGridDataTableJson(dStruct.TotalCount, dt);
  12366. }
  12367. public void saveSupplierProductTime()
  12368. {
  12369. string productId = GetPostString("productId");
  12370. if (string.IsNullOrEmpty(productId))
  12371. {
  12372. returnErrorMsg("缺少必要的参数");
  12373. return;
  12374. }
  12375. string productName = GetPostString("productName");
  12376. int supplierId = GetPostInt("supplierId");
  12377. if (supplierId == 0)
  12378. {
  12379. returnErrorMsg("缺少必要的参数");
  12380. return;
  12381. }
  12382. int quantity = GetPostInt("quantity");
  12383. int sendDay = GetPostInt("sendTime");
  12384. string supplierName = GetPostString("supplierName");
  12385. string craft = GetPostString("craft");
  12386. string deadLine = GetPostString("deadLine");
  12387. string dayDeadLine = GetPostString("dayDeadLine");
  12388. try
  12389. {
  12390. int eid = GetPostInt("eid");
  12391. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12392. if (ceErpSupplierProductTime == null)
  12393. {
  12394. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12395. }
  12396. ceErpSupplierProductTime.productId = productId;
  12397. ceErpSupplierProductTime.productName = productName;
  12398. ceErpSupplierProductTime.supplierId = supplierId;
  12399. ceErpSupplierProductTime.supplierName = supplierName;
  12400. ceErpSupplierProductTime.craft = craft;
  12401. ceErpSupplierProductTime.sendDay = sendDay;
  12402. ceErpSupplierProductTime.quantity = quantity;
  12403. if (!string.IsNullOrEmpty(deadLine))
  12404. {
  12405. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12406. }
  12407. if (!string.IsNullOrEmpty(dayDeadLine))
  12408. {
  12409. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12410. }
  12411. if (ceErpSupplierProductTime.ID == 0)
  12412. {
  12413. ceErpSupplierProductTime.Save();
  12414. }
  12415. else
  12416. {
  12417. ceErpSupplierProductTime.Update();
  12418. }
  12419. }
  12420. catch (Exception e)
  12421. {
  12422. }
  12423. returnSuccessMsg("保存成功");
  12424. return;
  12425. }
  12426. public void delSupplierProductTime()
  12427. {
  12428. int eid = GetPostInt("eid");
  12429. if (eid > 0)
  12430. {
  12431. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12432. if (ceErpSupplierProductTime == null)
  12433. {
  12434. returnErrorMsg("查无数据");
  12435. return;
  12436. }
  12437. ceErpSupplierProductTime.Delete();
  12438. returnSuccessMsg("保存成功");
  12439. return;
  12440. }
  12441. returnErrorMsg("缺少必要的参数");
  12442. }
  12443. public void getExpressInfo()
  12444. {
  12445. string ctid = GetPostString("ctid");
  12446. if (!string.IsNullOrEmpty(ctid))
  12447. {
  12448. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12449. if (ceErpTradeCell != null)
  12450. {
  12451. string outSid = ceErpTradeCell.OutSid;
  12452. if (outSid.Length > 0)
  12453. {
  12454. 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);
  12455. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12456. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12457. return;
  12458. }
  12459. }
  12460. returnErrorMsg("查无记录");
  12461. return;
  12462. }
  12463. returnErrorMsg("缺少必要的参数");
  12464. }
  12465. public void getExpressPostData()
  12466. {
  12467. string express = GetPostString("express");
  12468. if (!string.IsNullOrEmpty(express))
  12469. {
  12470. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12471. if (ceErpExpressInfo != null)
  12472. {
  12473. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12474. return;
  12475. }
  12476. }
  12477. returnErrorMsg("缺少必要的参数");
  12478. }
  12479. public void checkSupplierOrder()
  12480. {
  12481. string ctids = GetPostString("ctids");
  12482. if (ctids != null)
  12483. {
  12484. List<string> list = new List<string>();
  12485. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12486. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12487. for (int i = 0; i < dt.Rows.Count; i++)
  12488. {
  12489. DataRow row = dt.Rows[i];
  12490. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12491. {
  12492. continue;
  12493. }
  12494. list.Add(row["seller_memo"].ToString());
  12495. }
  12496. if (list.Count > 0)
  12497. {
  12498. 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, "点击下载按钮"));
  12499. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12500. return;
  12501. }
  12502. }
  12503. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12504. return;
  12505. }
  12506. public void addPersonId()
  12507. {
  12508. string tid = GetPostString("tid");
  12509. string personId = GetPostString("personId");
  12510. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12511. if (ceErpTrade != null)
  12512. {
  12513. ceErpTrade.receiver_zip = personId;
  12514. ceErpTrade.Update();
  12515. returnSuccessMsg("保存成功");
  12516. return;
  12517. }
  12518. returnErrorMsg("缺少必要的参数");
  12519. }
  12520. }
  12521. }