sync.order.cs 566 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183
  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.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.Api_SyncOrderByTime("598825");
  52. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  53. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  54. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  55. //banniuApiHelper.sendLogisticsInfo(null);
  56. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  57. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  58. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2449287014185573080");
  59. //int sid = commonHelper.autoDistributeToSupplier(entity);
  60. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  61. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1738821978000,\"deliveryType\":\"OFFLINE\",\"discountFee\":-34.0,\"flag\":\"NONE\",\"lines\":[{\"mark2\":[],\"num\":9,\"outerId\":\"\",\"payment\":350.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2213077796486/O1CN01Tg7cpd1xmdrqFR8F9_!!2-item_pic.png\",\"platServiceFee\":0.0,\"price\":35.0,\"refOlId\":\"2458934582736842566\",\"refSkuId\":\"0\",\"refSpuId\":\"817084548604\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":38.8889,\"singleFee\":38.89,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"雅柔纸卡片定制logo广告宣传纹理卡纸印刷保养展示饰品卡小卡特种纸名片打印制作包装售后硬卡设计产品养护卡\",\"totalFee\":350.0,\"totalPrice\":315.0,\"totalSellPrice\":350.0},{\"isFreeGift\":true,\"mark2\":[\"GIFT\"],\"num\":1,\"outerId\":\"\",\"payment\":0.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2213077796486/O1CN01Su0uey1xmdtXkF7zu_!!4611686018427381382-0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":1.0,\"refOlId\":\"2458934582737842566\",\"refSkuId\":\"0\",\"refSpuId\":\"856312416459\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.0,\"singleFee\":0.0,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【联系客服领礼金】【售后保障服务】\",\"totalFee\":0.0,\"totalPrice\":1.0,\"totalSellPrice\":0.0}],\"logisticsOrderNo\":\"\",\"mark2\":[\"GIFT\"],\"modifyTime\":1738821982000,\"openBuyerId\":\"AAEpRHraABkUZRPgSx2LbmHS\",\"openBuyerNick\":\"如**\",\"openSellerNick\":\"领淘文具旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1738821813000,\"payTime\":1738821976000,\"payment\":350.0,\"platServiceFee\":0.0,\"posCode\":\"lingtao\",\"posId\":600090,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"石家庄市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"裕华区\",\"receiverId\":\"a908c5702ff4d1d42009017efc49d0dc$\",\"receiverState\":\"河北省\",\"receiverTown\":\"建通街道\",\"refOid\":\"2458934582735842566\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"90x130mm-200张-卡片-300克铜版纸-双面印刷不覆膜裁切-如何怎样你奈-丹儿-170,90x90mm-200张-卡片-80克硫酸纸-不覆膜单色裁切-如何怎样你奈-丹儿-180\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":350.0,\"totalPrice\":316.0,\"totalSellPrice\":350.0,\"type\":\"SALE\"}}");
  62. //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}}");
  63. List<string> lw = new List<string>();
  64. string tid = GetPostString("ctid");
  65. string date1 = GetPostString("date1");
  66. //12-1 修改
  67. string urgent = GetPostString("urgent");
  68. string back = GetPostString("back");
  69. string offlineSearch = GetPostString("offlineSearch");
  70. int paramsCount = 0;
  71. if (!string.IsNullOrWhiteSpace(urgent))
  72. {
  73. if (urgent.Equals("true"))
  74. {
  75. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  76. }
  77. }
  78. if (!string.IsNullOrWhiteSpace(back))
  79. {
  80. if (back.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(offlineSearch))
  86. {
  87. if (offlineSearch.Equals("true"))
  88. {
  89. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  90. }
  91. }
  92. //end
  93. string date2 = GetPostString("date2");
  94. string buyernick = GetPostString("buyer_nick");
  95. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  96. {
  97. if (tid.Length <= 0 && buyernick.Length <= 0)
  98. {
  99. return;
  100. }
  101. }
  102. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  103. {
  104. if (tid.Length > 0)
  105. {
  106. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  107. }
  108. if (buyernick.Length > 0)
  109. {
  110. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  111. }
  112. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  113. if (dw.Length > 0)
  114. {
  115. lw.Add(dw);
  116. }
  117. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  118. {
  119. string usershop = CurrentUser.User.pemShop;
  120. lw.Add(string.Format("ShopId in ({0})", usershop));
  121. }
  122. }
  123. else
  124. {
  125. if (ex_psize == 0)
  126. {
  127. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  128. }
  129. if (PKey != "admin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. paramsCount++;
  134. }
  135. }
  136. string uploaddate1 = GetPostString("uploaddate1");
  137. string uploaddate2 = GetPostString("uploaddate2");
  138. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  139. if (update.Length > 0) lw.Add(update);
  140. string deliverydate1 = GetPostString("deliverydate1");
  141. string deliverydate2 = GetPostString("deliverydate2");
  142. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  143. if (deliverydate.Length > 0)
  144. {
  145. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  146. };
  147. string shopname = GetPostString("shopname");
  148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  149. string addwechat = GetPostString("addwechat");
  150. if (addwechat.Length > 0)
  151. {
  152. int addWt = Convert.ToInt32(addwechat);
  153. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  154. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  155. }
  156. string customer = GetPostString("customer");
  157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  158. string design = GetPostString("design");
  159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  160. string orderState = GetPostString("orderState");
  161. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  162. string address = GetPostString("address");
  163. 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));
  164. string sellermemo = GetPostString("seller_memo");
  165. if (sellermemo.Length > 0)
  166. {
  167. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  168. }
  169. string backReason = GetPostString("backReason");
  170. if (backReason.Length > 0)
  171. {
  172. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  173. }
  174. string apdate1 = GetPostString("apdate1");
  175. string apdate2 = GetPostString("apdate2");
  176. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  177. if (dwap.Length > 0) lw.Add(dwap);
  178. string price1 = GetPostString("price1");
  179. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  180. string price2 = GetPostString("price2");
  181. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  182. string isoldcustomer = GetPostString("isoldcus");
  183. string finishdate1 = GetPostString("finishdate1");
  184. string finishdate2 = GetPostString("finishdate2");
  185. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  186. bool isFinish = false;
  187. if (finishdate.Length > 0)
  188. {
  189. lw.Add(finishdate);
  190. isFinish = true;
  191. paramsCount++;
  192. }
  193. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  194. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  195. if (ex_psize > 0)
  196. {
  197. int UserID = CurrentUser.UserID;
  198. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  199. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  200. {
  201. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  202. }
  203. dStruct.Order = "pay_time desc";
  204. }
  205. string isNew = GetPostString("isNew");
  206. if (isNew == "true")
  207. {
  208. lw.Add(string.Format("IsNew = {0}", 1));
  209. }
  210. string overtime = GetPostString("overtime");
  211. if (overtime == "1")
  212. {
  213. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  214. }
  215. String usePost = CurrentUser.UserPost.Post.Code;
  216. if (usePost.Equals("Operation") == true)
  217. {
  218. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  219. }
  220. else
  221. {
  222. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. //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";
  225. if (dStruct.PageSize == 100000)
  226. {
  227. dStruct.Order = "";
  228. }
  229. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  230. DataTable dt = null;
  231. string tablename = "view_orderlist";
  232. if (isFinish)
  233. {
  234. tablename = "view_orderlist_end";
  235. }
  236. dt = WebCache.GetData(tablename, dStruct);
  237. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  238. if (dt != null && dt.Rows.Count > 0)
  239. {
  240. foreach (DataRow dr in dt.Rows)
  241. {
  242. try
  243. {
  244. if (dr["refund_fees"] != null)
  245. {
  246. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  247. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  248. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  249. if (payment == refund_fees)
  250. {
  251. dr["refund_fees"] = Math.Round(refund_fees, 2);
  252. continue; // 跳过当前迭代
  253. }
  254. else if (refund_fees == total_fee)
  255. {
  256. dr["refund_fees"] = payment;
  257. continue; // 跳过当前迭代
  258. }
  259. else
  260. {
  261. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  262. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  263. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  264. }
  265. }
  266. // 对象操作
  267. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  268. ceErpTradeCell.ctid = dr["ctid"].ToString();
  269. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  270. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  271. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  272. if (dStruct.PageSize != 100000)
  273. {
  274. if (dr["DispatchSort"].ToString() == "2")
  275. {
  276. dr["gongchuang"] = 200;
  277. }
  278. else
  279. {
  280. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  281. dr["gongchuang"] = response.code;
  282. }
  283. }
  284. }
  285. catch (NullReferenceException ex)
  286. {
  287. // 处理空引用异常
  288. dr["refund_fees"] = "0.00";
  289. }
  290. }
  291. }
  292. writeGridDataTableJson(dStruct.TotalCount, dt);
  293. }
  294. public void get_erp_orderlist_sumprice()
  295. {
  296. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  297. return;
  298. List<string> lw = new List<string>();
  299. string tid = GetPostString("ctid");
  300. string date1 = GetPostString("date1");
  301. string date2 = GetPostString("date2");
  302. if (tid.Length > 0 || date1.Length > 0)
  303. {
  304. lw.Add(string.Format("ctid like '%{0}%'", tid));
  305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  306. if (dw.Length > 0) lw.Add(dw);
  307. }
  308. else
  309. {
  310. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  311. }
  312. string shopname = GetPostString("shopname");
  313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  314. string buyernick = GetPostString("buyer_nick");
  315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  316. string customer = GetPostString("customer");
  317. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  318. string design = GetPostString("design");
  319. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  320. string orderState = GetPostString("orderState");
  321. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  322. string address = GetPostString("address");
  323. 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));
  324. string sellermemo = GetPostString("seller_memo");
  325. if (sellermemo.Length > 0)
  326. {
  327. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  328. }
  329. string apdate1 = GetPostString("apdate1");
  330. string apdate2 = GetPostString("apdate2");
  331. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  332. if (dwap.Length > 0) lw.Add(dwap);
  333. string price1 = GetPostString("price1");
  334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  335. string price2 = GetPostString("price2");
  336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  337. string isoldcustomer = GetPostString("isoldcus");
  338. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  339. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  340. if (PKey != "admin")
  341. {
  342. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  343. lw.Add(string.Format("shopId in ({0})", usershop));
  344. }
  345. //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";
  346. string mainWhere = string.Join(" and ", lw.ToArray());
  347. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  348. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  349. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  350. decimal total = 0;
  351. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  352. {
  353. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  354. }
  355. var res = new
  356. {
  357. data = total
  358. };
  359. string ro_jsond = JsonConvert.SerializeObject(res);
  360. returnSuccess(ro_jsond);
  361. return;
  362. }
  363. public void get_erp_CustomerServiceGather()
  364. {
  365. string userWhere = "", orderWhere = "";
  366. List<string> lw = new List<string>();
  367. string customer = GetPostString("customer");
  368. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  369. string shopname = GetPostString("shopname");
  370. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  371. string date1 = GetPostString("date1");
  372. string date2 = GetPostString("date2");
  373. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  374. if (dw.Length > 0) lw.Add(dw);
  375. orderWhere = string.Join(" and ", lw.ToArray());
  376. 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 " +
  377. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  381. ") as b on a.ID = b.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  385. ") as d on a.ID = d.CustomerUserId " +
  386. "left join " +
  387. "( " +
  388. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  389. ") as e on a.ID = e.CustomerUserId " +
  390. "left join " +
  391. "( " +
  392. " select CustomerUserId, RefundCount, RefundSum from " +
  393. " ( " +
  394. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  395. " from CE_ErpTradeRefund a " +
  396. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  397. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  398. " group by CustomerUserId " +
  399. " ) as a " +
  400. ") as f on a.ID = f.CustomerUserId " +
  401. "where a.PostCode = 'CustomerService'",
  402. userWhere, orderWhere);
  403. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  404. writeGridDataTableJson(dt.Rows.Count, dt);
  405. //writeGridDataTableJson(dt.Rows.Count, dt);
  406. }
  407. //设计汇总
  408. public void get_erp_DesignerGather()
  409. {
  410. string userWhere = "", orderWhere = "";
  411. List<string> lw = new List<string>();
  412. string Designer = GetPostString("designer");
  413. int org = GetPostInt("org");
  414. if (Designer.Length > 0)
  415. {
  416. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  417. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  418. }
  419. else if (org > 0)
  420. {
  421. userWhere = string.Format(" where OrgID ={0}", org);
  422. }
  423. string shopname = GetPostString("shopname");
  424. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  425. string state = GetPostString("state");
  426. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  427. string OrderArea = GetPostString("order_area");
  428. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  429. string date1 = GetPostString("date1");
  430. string date2 = GetPostString("date2");
  431. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  432. if (dw.Length > 0) lw.Add(dw);
  433. string UpDate1 = GetPostString("UpDate1");
  434. string UpDate2 = GetPostString("UpDate2");
  435. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  436. if (dw.Length > 0) lw.Add(dw);
  437. orderWhere = string.Join(" and ", lw.ToArray());
  438. 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 (" +
  439. "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 " +
  440. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  444. ") as b on a.ID = b.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as d on a.ID = d.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  452. ") as e on a.ID = e.DesignUserId " +
  453. "left join " +
  454. "( " +
  455. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  456. ") as g on a.ID = g.DesignUserId " +
  457. "left join " +
  458. "( " +
  459. " select CustomerUserId, RefundCount, RefundSum from " +
  460. " ( " +
  461. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  462. " from CE_ErpTradeRefund a " +
  463. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  464. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  465. " group by CustomerUserId " +
  466. " ) as a " +
  467. ") as f on a.ID = f.CustomerUserId " +
  468. "where a.PostCode = 'Designer') as z",
  469. userWhere, orderWhere);
  470. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  471. writeGridDataTableJson(dt.Rows.Count, dt);
  472. }
  473. //删除tradecell的订单
  474. public void del_erp_cellorder()
  475. {
  476. if (UrlPostParmsCheck("ctid"))
  477. {
  478. string eid = GetPostString("ctid");
  479. CeErpTradeCell.DelByCtid(eid);
  480. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  481. returnSuccessMsg("删除成功");
  482. }
  483. }
  484. public void clear_erp_refundstate()
  485. {
  486. if (UrlPostParmsCheck("ids"))
  487. {
  488. string eids = GetPostString("ids");
  489. string[] ctidList = eids.Split(',');
  490. foreach (string ctid in ctidList)
  491. {
  492. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  493. if (entity != null)
  494. {
  495. entity.IsRefund = 0;
  496. entity.Update();
  497. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  498. }
  499. else
  500. continue;
  501. }
  502. returnSuccessMsg("操作成功");
  503. return;
  504. }
  505. returnErrorMsg("缺少必要参数");
  506. }
  507. public void set_erp_urgency()
  508. {
  509. if (UrlPostParmsCheck("ctid"))
  510. {
  511. string eid = GetPostString("ctid");
  512. CeErpTradeCell entity = null;
  513. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  514. if (entity != null)
  515. {
  516. string utime = GetPostString("urgencytime");
  517. if (utime.Length > 0)
  518. {
  519. entity.UrgencyTime = Convert.ToDateTime(utime);
  520. }
  521. else
  522. {
  523. returnErrorMsg("请选择加急时间");
  524. return;
  525. }
  526. if (entity.OrderState <= 4)
  527. {
  528. //entity.seller_memo = entity.seller_memo + "-加急";
  529. string smemo = entity.seller_memo;
  530. int kindex = smemo.IndexOf(")");
  531. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  532. if (lastoneStr != "-")
  533. {
  534. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  535. }
  536. string prememo = smemo.Substring(0, kindex + 2);
  537. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  538. int lastkindex = lastmemo.IndexOf("(");
  539. DateTime urgtime = Convert.ToDateTime(utime);
  540. string newlastmemo = "";
  541. if (lastkindex == 0)
  542. {
  543. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  544. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  545. }
  546. else
  547. {
  548. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  549. }
  550. entity.seller_memo = prememo + newlastmemo;
  551. }
  552. entity.IsUrgency = true;
  553. entity.Update();
  554. ApiVo apiVo = new ApiVo();
  555. apiVo.orderNumber = entity.ctid;
  556. apiVo.actionName = "changeDesign";
  557. apiVo.orderRemarks = entity.seller_memo;
  558. apiVo.remarkSign = 3;
  559. designHelper.API_WorkCore(apiVo); //changeDesign
  560. CeErpSukuraData.createInfo(entity.ctid, 7);
  561. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  562. returnSuccessMsg("设置成功!");
  563. return;
  564. }
  565. returnErrorMsg("找不到记录");
  566. }
  567. }
  568. public void set_erp_reset()
  569. {
  570. if (UrlPostParmsCheck("ctid"))
  571. {
  572. string eid = GetPostString("ctid");
  573. CeErpTradeCell entity = null;
  574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  575. if (entity != null)
  576. {
  577. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  578. {
  579. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  580. {
  581. returnErrorMsg("财务要求已下单已发货无法重置");
  582. return;
  583. }
  584. }
  585. entity.IsUrgency = false;
  586. entity.seller_memo = "";
  587. entity.OtherMemo = "";
  588. entity.OrderState = 0;
  589. entity.IsReturn = 0;
  590. //entity.IsRefund = 0;
  591. entity.MemoOpt = 0;
  592. entity.AfterSaleState = 0;
  593. entity.AfterSaleResponsible = "";
  594. entity.AfterSaleUserId = 0;
  595. entity.IsNeedBill = 0;
  596. entity.CustomerUserId = 0;
  597. entity.DesignUserId = 0;
  598. entity.SupplierId = 0;
  599. entity.PlaceUserId = 0;
  600. entity.ptid = "";
  601. entity.IsSample = 0;
  602. entity.IsXianHuo = 0;
  603. entity.isDianziOrder = 0;
  604. entity.FinishPlaceTime = null;
  605. entity.Update();
  606. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  607. if (trade != null)
  608. {
  609. trade.seller_memo = "";
  610. trade.Update();
  611. }
  612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  613. returnSuccessMsg("重置成功!");
  614. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  615. if (desginBill != null)
  616. {
  617. desginBill.isDel = 1;
  618. desginBill.Update();
  619. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  620. }
  621. ApiVo apiVo = new ApiVo();
  622. apiVo.orderNumber = entity.ctid;
  623. apiVo.actionName = "resetDesign";
  624. designHelper.API_WorkCore(apiVo);//resetDesign
  625. return;
  626. }
  627. returnErrorMsg("找不到记录");
  628. }
  629. }
  630. public void save_erp_sellermemo()
  631. {
  632. if (UrlPostParmsCheck("ctid"))
  633. {
  634. string ctid = GetPostString("ctid");
  635. CeErpTradeCell entity = null;
  636. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  637. if (entity != null)
  638. {
  639. string memo = GetPostString("seller_memo");
  640. memo = memo.Replace(" ", "");
  641. if (memo.Contains("补差"))
  642. {
  643. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  644. return;
  645. }
  646. if (entity.seller_memo != memo)
  647. {
  648. if (entity.IsSample == 2)
  649. {
  650. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  651. return;
  652. }
  653. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  654. {
  655. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  656. {
  657. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  658. return;
  659. }
  660. }
  661. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  662. }
  663. commonHelper.getCytPrice(entity);
  664. int memoopt = GetPostInt("MemoOpt");
  665. Boolean ismemoopt = false;
  666. if (memoopt > 0)
  667. {
  668. string stropt = "";
  669. if (memoopt == 1)
  670. {
  671. stropt = "“改稿”";
  672. ismemoopt = true;
  673. }
  674. else if (memoopt == 2)
  675. {
  676. stropt = "“定稿”";
  677. }
  678. else if (memoopt == 3)
  679. {
  680. stropt = "“查货”";
  681. CeErpSukuraData.createInfo(entity.ctid, 6);
  682. }
  683. entity.MemoOpt = Convert.ToInt32(memoopt);
  684. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  685. }
  686. if (entity.OrderState < 5)
  687. {
  688. memo = memo.Replace("(", "(");
  689. memo = memo.Replace(")", ")");
  690. }
  691. entity.seller_memo = memo;
  692. entity.Update();
  693. ApiVo apiVo = new ApiVo();
  694. apiVo.orderNumber = entity.ctid;
  695. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  696. apiVo.orderRemarks = memo;
  697. apiVo.remarkSign = memoopt;
  698. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  699. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  700. returnSuccessMsg("保存成功!");
  701. return;
  702. }
  703. returnErrorMsg("找不到记录");
  704. }
  705. }
  706. public void ins_erp_checkorder()
  707. {
  708. if (UrlPostParmsCheck("ctid"))
  709. {
  710. string ctid = GetPostString("ctid");
  711. CeErpTradeCell entity = null;
  712. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  713. if (entity != null)
  714. {
  715. if (entity.OrderState < 6)
  716. {
  717. returnErrorMsg("下单完成后才可查货");
  718. return;
  719. }
  720. /*if (entity.OrderState > 6)
  721. {
  722. returnErrorMsg("订单已发货");
  723. return;
  724. }*/
  725. if (entity.FinishPlaceTime != null)
  726. {
  727. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  728. {
  729. returnErrorMsg("下单时间不足,无法查货");
  730. return;
  731. }
  732. }
  733. entity.MemoOpt = 3;
  734. entity.CheckOrderTime = DateTime.Now;
  735. entity.Update();
  736. CeErpSukuraData.createInfo(entity.ctid, 6);
  737. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  738. returnSuccessMsg("操作成功!");
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_othermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. entity.OtherMemo = GetPostString("otherMemo");
  754. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  755. {
  756. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  757. StringBuilder sql = new StringBuilder();
  758. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  759. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  760. if (dt != null && dt.Rows.Count > 0)
  761. {
  762. foreach (DataRow dr in dt.Rows)
  763. {
  764. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  765. {
  766. //品类一直
  767. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  768. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  769. if (ceErpSampleCustomer == null)
  770. {
  771. ceErpSampleCustomer = new CeErpSampleCustomer();
  772. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  773. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  774. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  775. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  776. ceErpSampleCustomer.shopId = entity.ShopId;
  777. }
  778. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  779. ceErpSampleCustomer.lastTid = entity.tid;
  780. if (ceErpSampleCustomer.ID > 0)
  781. {
  782. ceErpSampleCustomer.Update();
  783. }
  784. else
  785. {
  786. ceErpSampleCustomer.Create();
  787. }
  788. }
  789. }
  790. }
  791. }
  792. //if (entity.IsOldCustomer == 1)
  793. //{
  794. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  795. //{
  796. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  797. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  798. //}
  799. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  800. //{
  801. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  802. // {
  803. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  804. // {
  805. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  806. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  807. // }
  808. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  809. // {
  810. // entity.OrderState = 2;
  811. // entity.DesignUserId = 0;
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  813. // }
  814. // else
  815. // {
  816. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  817. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  818. // }
  819. // }
  820. //}
  821. //}
  822. entity.Update();
  823. returnSuccessMsg("保存成功!");
  824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  825. return;
  826. }
  827. returnErrorMsg("找不到记录");
  828. }
  829. }
  830. public void save_erp_customermemo()
  831. {
  832. if (UrlPostParmsCheck("ctid"))
  833. {
  834. string ctid = GetPostString("ctid");
  835. CeErpTradeCell entity = null;
  836. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  837. if (entity != null)
  838. {
  839. entity.CustomerMemo = GetPostString("CustomerMemo");
  840. entity.Update();
  841. ApiVo apiVo = new ApiVo();
  842. apiVo.orderNumber = entity.ctid;
  843. apiVo.actionName = "followRemarks";
  844. apiVo.orderRemarks = entity.CustomerMemo;
  845. designHelper.API_WorkCore(apiVo);//followRemarks
  846. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  847. returnSuccessMsg("保存成功!");
  848. return;
  849. }
  850. returnErrorMsg("找不到记录");
  851. }
  852. }
  853. public void upd_erp_addmemotag()
  854. {
  855. if (UrlPostParmsCheck("ctid"))
  856. {
  857. ;
  858. string eid = GetPostString("ctid");
  859. string sfTagstr = GetPostString("memotag");
  860. CeErpTradeCell entity = null;
  861. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  862. if (entity != null)
  863. {
  864. if (entity.OrderState == 0)
  865. {
  866. returnErrorMsg("请先领单");
  867. return;
  868. }
  869. //撤销顺丰
  870. if (sfTagstr == "撤销顺丰")
  871. {
  872. entity.IsSF = 0;
  873. string reMsg = "";
  874. string oldmemo = entity.seller_memo;
  875. if (entity.OrderState < 5)
  876. {
  877. oldmemo = oldmemo.Replace("顺丰到付", "");
  878. oldmemo = oldmemo.Replace("顺丰寄付", "");
  879. entity.seller_memo = oldmemo;
  880. }
  881. else
  882. {
  883. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  884. {
  885. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  886. }
  887. }
  888. entity.Update();
  889. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  890. api.orderNumber = entity.ctid;
  891. api.actionName = "followRemarks";
  892. api.orderRemarks = entity.seller_memo;
  893. api.isSf = entity.IsSF.ToString();
  894. designHelper.API_WorkCore(api);//followRemarks
  895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  896. returnSuccessMsg("撤销成功!" + reMsg);
  897. return;
  898. }
  899. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  900. {
  901. //string oldmemo = entity.seller_memo;
  902. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  903. string sfStr = GetPostString("memotag");
  904. string smemo = entity.seller_memo;
  905. int kindex = smemo.IndexOf(")");
  906. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  907. if (lastoneStr != "-")
  908. {
  909. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  910. }
  911. string prememo = smemo.Substring(0, kindex + 2);
  912. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  913. int lastkindex = lastmemo.IndexOf("(");
  914. string newlastmemo = "";
  915. if (lastkindex == 0)
  916. {
  917. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  918. newlastmemo = "(" + sfStr + "." + useLastmemo;
  919. }
  920. else
  921. {
  922. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  923. }
  924. entity.seller_memo = prememo + newlastmemo;
  925. }
  926. string sfTagMSg = "";
  927. if (sfTagstr == "顺丰寄付")
  928. {
  929. entity.IsSF = 1;
  930. sfTagMSg = "顺丰寄付";
  931. }
  932. else if (sfTagstr == "顺丰到付")
  933. {
  934. entity.IsSF = 2;
  935. sfTagMSg = "顺丰到付";
  936. }
  937. entity.Update();
  938. ApiVo apiVo = new ApiVo();
  939. apiVo.orderNumber = entity.ctid;
  940. apiVo.actionName = "orderRemarks";
  941. apiVo.orderRemarks = entity.seller_memo;
  942. apiVo.isSf = entity.IsSF.ToString();
  943. designHelper.API_WorkCore(apiVo);//orderRemarks
  944. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  945. returnSuccessMsg("标记成功!");
  946. return;
  947. }
  948. returnErrorMsg("找不到记录");
  949. }
  950. }
  951. public void upd_erp_ordertag()
  952. {
  953. if (UrlPostParmsCheck("ctid"))
  954. {
  955. string eid = GetPostString("ctid");
  956. CeErpTradeCell entity = null;
  957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  958. if (entity != null)
  959. {
  960. int tag = GetPostInt("wechattag");
  961. //if(tag==4 && entity.IsSample == 2)
  962. //{
  963. // returnErrorMsg("补差价单不能标记微信单");
  964. // return;
  965. //}
  966. entity.wechatTag = tag;
  967. entity.Update();
  968. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  969. if (tag == 1)
  970. {
  971. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  972. if (cash == null)
  973. {
  974. CeErpTrade main = CeErpTrade.Get(entity.tid);
  975. cash = new CeErpReturnCash();
  976. cash.tid = entity.tid;
  977. cash.seller_nick = main.seller_nick;
  978. cash.payment = trade.payment;
  979. cash.buyer_nick = main.buyer_nick;
  980. cash.cashstate = 0;
  981. cash.rtype = "微信返现";
  982. cash.returnprice = 0;
  983. cash.created = DateTime.Now;
  984. cash.con = "订单标记微信单";
  985. cash.img = "";
  986. cash.applyuserid = CurrentUser.UserID;
  987. cash.Create();
  988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  989. }
  990. else
  991. {
  992. cash.cashstate = 0;
  993. cash.Update();
  994. }
  995. CeErpSukuraData.createInfo(entity.ctid, 9);
  996. }
  997. else if (tag == 2)
  998. {
  999. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1000. if (cash == null)
  1001. {
  1002. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1003. cash = new CeErpReturnCash();
  1004. cash.tid = entity.tid;
  1005. cash.seller_nick = main.seller_nick;
  1006. cash.payment = trade.payment;
  1007. cash.buyer_nick = main.buyer_nick;
  1008. cash.cashstate = 0;
  1009. cash.rtype = "推购返现";
  1010. cash.returnprice = 5;
  1011. cash.created = DateTime.Now;
  1012. cash.con = "订单标记推购单";
  1013. cash.img = "";
  1014. cash.applyuserid = CurrentUser.UserID;
  1015. cash.Create();
  1016. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1017. }
  1018. else
  1019. {
  1020. cash.cashstate = 0;
  1021. cash.Update();
  1022. }
  1023. CeErpSukuraData.createInfo(entity.ctid, 9);
  1024. }
  1025. else if (tag == 3)
  1026. {
  1027. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1028. if (pers == null)
  1029. {
  1030. pers = new CeErpPersuade();
  1031. pers.ctid = entity.ctid;
  1032. pers.pstate = 0;
  1033. pers.created = DateTime.Now;
  1034. pers.applyuserid = CurrentUser.UserID;
  1035. pers.Create();
  1036. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1037. }
  1038. else
  1039. {
  1040. pers.pstate = 0;
  1041. pers.Update();
  1042. }
  1043. }
  1044. else if (tag == 4 || tag == 5)
  1045. {
  1046. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1047. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1048. if (pers == null)
  1049. {
  1050. pers = new CeErpStayGoods();
  1051. pers.t_id = entity.tid;
  1052. pers.status = "待审核";
  1053. pers.audit_type = 0;
  1054. if (tag == 4)
  1055. {
  1056. pers.stay_type = "微信推购";
  1057. }
  1058. else
  1059. {
  1060. pers.stay_type = "旺旺推购";
  1061. }
  1062. if (entity.IsXianHuo == 0)
  1063. {
  1064. pers.product_id = entity.ProductId;
  1065. }
  1066. pers.wangwang = main.buyer_nick;
  1067. pers.shop_name = main.seller_nick;
  1068. pers.creata_time = DateTime.Now;
  1069. pers.create_u_id = CurrentUser.UserID;
  1070. pers.create_u_name = CurrentUser.UserName;
  1071. pers.Create();
  1072. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1073. }
  1074. else
  1075. {
  1076. pers.audit_type = 0;
  1077. pers.Update();
  1078. }
  1079. CeErpSukuraData.createInfo(entity.ctid, 10);
  1080. }
  1081. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1082. returnSuccessMsg("标记成功!");
  1083. return;
  1084. }
  1085. returnErrorMsg("找不到记录");
  1086. }
  1087. }
  1088. public void upd_erp_ordertag_cancel()
  1089. {
  1090. if (UrlPostParmsCheck("ctid"))
  1091. {
  1092. string eid = GetPostString("ctid");
  1093. CeErpTradeCell entity = null;
  1094. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1095. if (entity != null)
  1096. {
  1097. entity.wechatTag = 0;
  1098. entity.Update();
  1099. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1100. if (pers != null)
  1101. {
  1102. pers.status = "取消推购";
  1103. pers.audit_type = 3;
  1104. pers.Update();
  1105. }
  1106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1107. returnSuccessMsg("标记成功!");
  1108. return;
  1109. }
  1110. returnErrorMsg("找不到记录");
  1111. }
  1112. }
  1113. public void upd_erp_addweichattag()
  1114. {
  1115. if (UrlPostParmsCheck("ctid"))
  1116. {
  1117. ;
  1118. string eid = GetPostString("ctid");
  1119. CeErpTradeCell entity = null;
  1120. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1121. if (entity != null)
  1122. {
  1123. if (entity.IsAddWechat > 0)
  1124. {
  1125. returnErrorMsg("此单已经标记过了");
  1126. return;
  1127. }
  1128. 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);
  1129. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1130. if (dt.Rows.Count > 0)
  1131. {
  1132. entity.IsAddWechat = 2;
  1133. }
  1134. else
  1135. {
  1136. entity.IsAddWechat = 1;
  1137. }
  1138. entity.Update();
  1139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1140. returnSuccessMsg("标记成功!");
  1141. return;
  1142. }
  1143. returnErrorMsg("找不到记录");
  1144. }
  1145. }
  1146. public void upd_erp_getmyorder()
  1147. {
  1148. if (UrlPostParmsCheck("ctid"))
  1149. {
  1150. ;
  1151. string eid = GetPostString("ctid");
  1152. CeErpTradeCell entity = null;
  1153. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1154. if (entity != null)
  1155. {
  1156. if (entity.ctid.IndexOf("C") != -1)
  1157. {
  1158. StringBuilder sql = new StringBuilder();
  1159. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1160. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1161. if (dt.Rows.Count > 0)
  1162. {
  1163. decimal total = 0;
  1164. foreach (DataRow dr in dt.Rows)
  1165. {
  1166. total += Convert.ToDecimal(dr["payment"]);
  1167. }
  1168. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1169. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1170. {
  1171. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1172. return;
  1173. }
  1174. }
  1175. }
  1176. entity.CustomerUserId = CurrentUser.UserID;
  1177. if (entity.OrderState < 2)
  1178. {
  1179. entity.OrderState = 2;
  1180. if (entity.ShopId != 0)
  1181. {
  1182. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1183. }
  1184. }
  1185. entity.Update();
  1186. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1187. returnSuccessMsg("领单成功!");
  1188. return;
  1189. }
  1190. returnErrorMsg("找不到记录");
  1191. }
  1192. }
  1193. public void getmyorder_from_init()
  1194. {
  1195. if (UrlPostParmsCheck("ctid"))
  1196. {
  1197. string eid = GetPostString("ctid");
  1198. CeErpTradeCell entity = null;
  1199. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1200. if (entity != null)
  1201. {
  1202. string sellerMemo = GetPostString("sellerMemo");
  1203. if (sellerMemo.Length > 0)
  1204. {
  1205. entity.seller_memo = sellerMemo;
  1206. }
  1207. string oterhMemo = GetPostString("otherMemo");
  1208. if (oterhMemo.Length > 0)
  1209. {
  1210. entity.OtherMemo = oterhMemo;
  1211. }
  1212. int urg = GetPostInt("urgency");
  1213. entity.IsUrgency = (urg == 1 ? true : false);
  1214. int wechat = GetPostInt("wechat");
  1215. int command = GetPostInt("command");
  1216. if (wechat == 1)
  1217. {
  1218. entity.wechatTag = 1;
  1219. }
  1220. if (command == 1)
  1221. {
  1222. entity.wechatTag = 2;
  1223. }
  1224. string pPro = GetPostString("pprofession");
  1225. if (pPro.Length > 0)
  1226. {
  1227. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1228. string spro = GetPostString("profession");
  1229. if (spro.Length > 0)
  1230. {
  1231. entity.ProfessionId = Convert.ToInt32(spro);
  1232. }
  1233. }
  1234. string proId = GetPostString("productId");
  1235. if (proId.Length > 0)
  1236. {
  1237. entity.ProductId = Convert.ToInt32(proId);
  1238. }
  1239. entity.Material = GetPostString("material");
  1240. entity.Craft = GetPostString("craft");
  1241. entity.CustomerUserId = CurrentUser.UserID;
  1242. if (entity.OrderState < 2)
  1243. {
  1244. entity.OrderState = 2;
  1245. if (entity.ShopId != 0)
  1246. {
  1247. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1248. }
  1249. }
  1250. entity.Update();
  1251. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1252. returnSuccessMsg("领单成功!");
  1253. return;
  1254. }
  1255. returnErrorMsg("找不到记录");
  1256. }
  1257. }
  1258. public void upd_erp_setrelationorder()
  1259. {
  1260. if (UrlPostParmsCheck("ctid"))
  1261. {
  1262. ;
  1263. string eid = GetPostString("ctid");
  1264. string ftid = GetPostString("ftid");
  1265. CeErpTradeCell entity = null;
  1266. CeErpTradeCell fentity = null;
  1267. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1268. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1269. if (fentity == null)
  1270. {
  1271. returnErrorMsg("找不到关联的主订单");
  1272. return;
  1273. }
  1274. if (entity != null)
  1275. {
  1276. if (entity.OrderState >= 5)
  1277. {
  1278. returnErrorMsg("本单已经设计完成无法关联");
  1279. return;
  1280. }
  1281. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1282. {
  1283. returnErrorMsg("线下单续审核后才能关联!");
  1284. return;
  1285. }
  1286. entity.ptid = ftid;
  1287. entity.OrderState = fentity.OrderState;
  1288. //entity.status = fentity.status;
  1289. entity.CustomerUserId = fentity.CustomerUserId;
  1290. entity.DesignUserId = fentity.DesignUserId;
  1291. entity.seller_memo = "补差价单:" + ftid;
  1292. entity.IsSample = 2;
  1293. entity.Update();
  1294. ApiVo apiVo = new ApiVo();
  1295. apiVo.orderNumber = ftid;
  1296. apiVo.payment = entity.payment;
  1297. apiVo.actionName = "repairDesign";
  1298. designHelper.API_WorkCore(apiVo);//repairDesign
  1299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1300. returnSuccessMsg("关联成功!");
  1301. return;
  1302. }
  1303. else
  1304. returnErrorMsg("找不到记录");
  1305. }
  1306. }
  1307. public void download_erp_neworder()
  1308. {
  1309. string seller = GetPostString("seller_nick");
  1310. string tid = GetPostString("tid");
  1311. if (seller.Length <= 0 || tid.Length <= 0)
  1312. {
  1313. returnErrorMsg("数据错误");
  1314. }
  1315. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1316. //{
  1317. // returnErrorMsg("找不到店铺Sessionkey");
  1318. //}
  1319. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1320. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1321. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1322. if (res.IndexOf("refOid") == -1)
  1323. {
  1324. returnErrorMsg("下载订单数据失败");
  1325. return;
  1326. }
  1327. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1328. returnSuccessMsg("下载完成");
  1329. //tmcHelper.createNewOrder(res);
  1330. //CeErpTrade entr = null;
  1331. //entr = CeErpTrade.Get(tid);
  1332. //if (entr != null)
  1333. //{
  1334. // returnSuccess("下载成功");
  1335. // //下载成功之后,Cell表生成对应的订单;
  1336. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1337. //}
  1338. //else
  1339. //{
  1340. // returnErrorMsg("下载失败或者创建订单失败");
  1341. //}
  1342. }
  1343. public void set_erp_atersale()
  1344. {
  1345. if (UrlPostParmsCheck("ctid"))
  1346. {
  1347. string eid = GetPostString("ctid");
  1348. string reason = GetPostString("AfterSaleReason");
  1349. CeErpTradeCell entity = null;
  1350. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1351. if (entity != null)
  1352. {
  1353. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1354. {
  1355. returnErrorMsg("此订单已经在售后");
  1356. return;
  1357. }
  1358. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1359. //entity.AfterSaleReason = reason;
  1360. entity.AfterSaleTime = DateTime.Now;
  1361. entity.Update();
  1362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1363. returnSuccessMsg("转售后成功!");
  1364. return;
  1365. }
  1366. returnErrorMsg("找不到记录");
  1367. }
  1368. }
  1369. public void set_erp_withdraw()
  1370. {
  1371. if (UrlPostParmsCheck("ctid"))
  1372. {
  1373. try
  1374. {
  1375. string eid = GetPostString("ctid");//商品id
  1376. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1377. CeWithdraw ceWithdrawSelect = null;
  1378. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1379. if (ceWithdrawSelect != null)
  1380. {
  1381. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1382. {
  1383. ceWithdrawSelect.status = -1;
  1384. ceWithdrawSelect.Update();
  1385. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1386. returnSuccessMsg("重新发起审核成功");
  1387. return;
  1388. }
  1389. else
  1390. {
  1391. returnSuccessMsg("请勿重复申请!");
  1392. return;
  1393. }
  1394. }
  1395. else
  1396. {
  1397. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1398. if (string.IsNullOrEmpty(CustomerUserId))
  1399. {
  1400. CustomerUserId = "-1";
  1401. }
  1402. int Userid = CurrentUser.UserID;//用户id
  1403. CeWithdraw ceWithdraw = new CeWithdraw();
  1404. ceWithdraw.tid = eid;
  1405. ceWithdraw.userid = Userid;
  1406. ceWithdraw.providerid = CustomerUserId;
  1407. ceWithdraw.status = 3;
  1408. ceWithdraw.creationtime = DateTime.Now;
  1409. ceWithdraw.Create();
  1410. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1411. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1412. return;
  1413. }
  1414. }
  1415. catch
  1416. {
  1417. returnErrorMsg("申请撤回订单失败");
  1418. return;
  1419. }
  1420. }
  1421. }
  1422. public void ins_erp_billinfo()
  1423. {
  1424. if (UrlPostParmsCheck("ctid"))
  1425. {
  1426. string eid = GetPostString("ctid");
  1427. CeErpTradeCell entity = null;
  1428. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1429. if (entity != null)
  1430. {
  1431. CeErpBill bill = CeErpBill.GetByTid(eid);
  1432. bool isHave = false;
  1433. if (bill != null)
  1434. {
  1435. isHave = true;
  1436. if (bill.state != 4)
  1437. {
  1438. returnErrorMsg("此单已经申请过发票了");
  1439. return;
  1440. }
  1441. }
  1442. if (entity.IsNeedBill == 0)
  1443. {
  1444. entity.IsNeedBill = 1;
  1445. }
  1446. entity.Update();
  1447. string errjson = "";
  1448. try
  1449. {
  1450. CeErpBill bill_entity = new CeErpBill();
  1451. bill_entity.tid = entity.tid;
  1452. bill_entity.title = GetPostString("title");
  1453. string taxstr = GetPostString("tax");
  1454. taxstr = taxstr.Replace(" ", "");
  1455. bill_entity.tax = taxstr;
  1456. bill_entity.bank = GetPostString("bank");
  1457. string bankacstr = GetPostString("bankac");
  1458. bankacstr = bankacstr.Replace(" ", "");
  1459. bill_entity.bankac = bankacstr;
  1460. bill_entity.address = GetPostString("address");
  1461. bill_entity.phone = GetPostString("phone");
  1462. bill_entity.price = GetPostString("price");
  1463. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1464. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1465. {
  1466. billCount += 1;
  1467. }
  1468. string prebill = "ltb";
  1469. for (int idx = 1; idx <= billCount; idx++)
  1470. {
  1471. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1472. string billoid = prebill + idx + dtstr;
  1473. bill_entity.billOrderId += billoid;
  1474. if (idx < billCount)
  1475. {
  1476. bill_entity.billOrderId += ",";
  1477. }
  1478. }
  1479. bill_entity.productId = GetPostInt("ProductName");
  1480. bill_entity.num = GetPostInt("num");
  1481. bill_entity.unit = GetPostString("unit");
  1482. bill_entity.type = GetPostString("type");
  1483. bill_entity.sendType = GetPostString("SendType");
  1484. bill_entity.email = GetPostString("email");
  1485. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1486. bill_entity.shopName = GetPostString("ShopName");
  1487. bill_entity.applymemo = GetPostString("applyMemo");
  1488. bill_entity.createTime = DateTime.Now;
  1489. bill_entity.state = 0;
  1490. bill_entity.userId = CurrentUser.UserID;
  1491. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1492. bill_entity.Create();
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1497. returnErrorMsg("创建发票出错!");
  1498. return;
  1499. }
  1500. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1501. returnSuccessMsg("发票申请成功!");
  1502. return;
  1503. }
  1504. returnErrorMsg("找不到记录");
  1505. }
  1506. }
  1507. public void ins_erp_neworder()
  1508. {
  1509. if (UrlPostParmsCheck("receiver_name"))
  1510. {
  1511. CeErpTrade entity = new CeErpTrade();
  1512. string plat_form = GetPostString("platform");
  1513. string preStr = "N_";
  1514. if (plat_form == "拼多多")
  1515. {
  1516. preStr = "P_";
  1517. }
  1518. else if (plat_form == "阿里巴巴")
  1519. {
  1520. preStr = "A_";
  1521. }
  1522. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1523. entity.seller_nick = GetPostString("seller_nick");
  1524. entity.buyer_nick = GetPostString("buyer_nick");
  1525. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1526. entity.total_fee = entity.payment;
  1527. entity.pay_time = DateTime.Now;
  1528. entity.status = "NOT_SHIPPED";
  1529. entity.receiver_name = GetPostString("receiver_name");
  1530. entity.receiver_mobile = GetPostString("receiver_mobile");
  1531. entity.receiver_state = GetPostString("receiver_state");
  1532. entity.receiver_city = GetPostString("receiver_city");
  1533. entity.receiver_district = GetPostString("receiver_district");
  1534. entity.receiver_address = GetPostString("receiver_address");
  1535. if (entity.receiver_state == "" || entity.receiver_city == "")
  1536. {
  1537. returnErrorMsg("收件地址不能为空");
  1538. return;
  1539. }
  1540. int shopId = 0;
  1541. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1542. if (nShop != null)
  1543. {
  1544. shopId = nShop.ID;
  1545. }
  1546. if (shopId != 34 && entity.payment == 0)
  1547. {
  1548. returnErrorMsg("公司自用的单金额才能为0");
  1549. return;
  1550. }
  1551. entity.Create();
  1552. CeErpTradeCell entitycell = new CeErpTradeCell();
  1553. entitycell.ctid = entity.tid;
  1554. entitycell.tid = entity.tid;
  1555. entitycell.ShopId = shopId;
  1556. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1557. entitycell.OrderState = 0;
  1558. entitycell.pay_time = entity.pay_time;
  1559. entitycell.IsOffLineOrder = 1;
  1560. entitycell.Create();
  1561. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1562. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1563. return;
  1564. }
  1565. }
  1566. public void ins_erp_neworder2()
  1567. {
  1568. if (UrlPostParmsCheck("receiver_name"))
  1569. {
  1570. //string plat_form = GetPostString("platform");
  1571. string preStr = "X_";
  1572. string memo = GetPostString("memo");
  1573. string productId = GetPostString("productId");
  1574. string primg = GetPostString("proofimg");
  1575. string sellerNick = GetPostString("seller_nick");
  1576. string addFrom = GetPostString("addfrom");
  1577. if (addFrom == "1")
  1578. {
  1579. preStr = "N_";
  1580. }
  1581. int shopId = 0;
  1582. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1583. if (nShop != null)
  1584. {
  1585. shopId = nShop.ID;
  1586. }
  1587. else
  1588. {
  1589. returnErrorMsg("找不到对应店铺");
  1590. return;
  1591. }
  1592. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1593. {
  1594. returnErrorMsg("必须上传付款凭证");
  1595. return;
  1596. }
  1597. CeErpTrade entity = new CeErpTrade();
  1598. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1599. entity.seller_nick = sellerNick;
  1600. entity.buyer_nick = GetPostString("buyer_nick");
  1601. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1602. entity.total_fee = entity.payment;
  1603. entity.pay_time = DateTime.Now;
  1604. entity.status = "NOT_SHIPPED";
  1605. entity.receiver_name = GetPostString("receiver_name");
  1606. entity.receiver_mobile = GetPostString("receiver_mobile");
  1607. entity.receiver_state = GetPostString("receiver_state");
  1608. entity.receiver_city = GetPostString("receiver_city");
  1609. entity.receiver_district = GetPostString("receiver_district");
  1610. entity.receiver_address = GetPostString("receiver_address");
  1611. entity.seller_memo = memo;
  1612. entity.orderFrom = 20;
  1613. entity.orderType = 15;
  1614. if (entity.receiver_state == "" || entity.receiver_city == "")
  1615. {
  1616. returnErrorMsg("收件地址不能为空");
  1617. return;
  1618. }
  1619. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1620. {
  1621. returnErrorMsg("公司自用的单金额才能为0");
  1622. return;
  1623. }
  1624. entity.Create();
  1625. string toWhere = GetPostString("towhere");
  1626. CeErpTradeCell entitycell = new CeErpTradeCell();
  1627. entitycell.ctid = entity.tid;
  1628. //唯一标识
  1629. entitycell.OrderSn = entity.tid;
  1630. //string orderSn = dataHelper.getSaleOrderSn();
  1631. //if (orderSn != "")
  1632. // {
  1633. // entitycell.OrderSn = orderSn;
  1634. // }
  1635. entitycell.tid = entity.tid;
  1636. //if (preStr == "X_")
  1637. //{
  1638. entitycell.IsOffLineOrder = 1;
  1639. //}
  1640. entitycell.CustomerUserId = CurrentUser.UserID;
  1641. entitycell.PayProofImg = primg;
  1642. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1643. entitycell.ProductId = Convert.ToInt32(productId);
  1644. entitycell.ShopId = shopId;
  1645. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1646. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1647. {
  1648. entitycell.IsXianHuo = 1;
  1649. }
  1650. entitycell.pay_time = entity.pay_time;
  1651. if (toWhere == "1")
  1652. {
  1653. entitycell.OrderState = 2;
  1654. }
  1655. else
  1656. {
  1657. entitycell.OrderState = 6;
  1658. entitycell.FinishPlaceTime = entitycell.pay_time;
  1659. }
  1660. if (shopId == 94)
  1661. {
  1662. entitycell.OrderState = 4;
  1663. entitycell.WaitDesignTime = entitycell.pay_time;
  1664. entitycell.StartDesignTime = entitycell.pay_time;
  1665. entitycell.DesignUserId = 218;
  1666. }
  1667. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1668. {
  1669. entitycell.OrderState = -1;//修改12-5
  1670. CeWithdraw ceWithdraw = new CeWithdraw();
  1671. ceWithdraw.tid = entity.tid;
  1672. ceWithdraw.providerid = "-1";
  1673. ceWithdraw.status = -1;
  1674. ceWithdraw.creationtime = DateTime.Now;
  1675. ceWithdraw.userid = 1337;
  1676. ceWithdraw.Create();
  1677. }
  1678. entitycell.Create();
  1679. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1680. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1681. {
  1682. addPlaceRegist(entitycell, CurrentUser.UserID);
  1683. }
  1684. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1685. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1686. return;
  1687. }
  1688. }
  1689. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1690. {
  1691. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1692. entity.PlactTime = tradecell.pay_time;
  1693. entity.AddUserId = userid;
  1694. entity.FileName = tradecell.seller_memo;
  1695. entity.Supplier = 24;
  1696. entity.CreateTime = DateTime.Now;
  1697. entity.Did = tradecell.ctid;
  1698. entity.tid = tradecell.tid;
  1699. entity.splitTag = tradecell.SplitTag;
  1700. entity.CurState = "未完成";
  1701. entity.Create();
  1702. }
  1703. public void get_erp_offlinelist()
  1704. {
  1705. DataStruct dStruct = GetPostStruct();
  1706. List<string> lw = new List<string>();
  1707. string tid = GetPostString("ctid");
  1708. string date1 = GetPostString("date1");
  1709. string date2 = GetPostString("date2");
  1710. if (tid.Length > 0 || date1.Length > 0)
  1711. {
  1712. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1713. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1714. if (dw.Length > 0) lw.Add(dw);
  1715. }
  1716. else
  1717. {
  1718. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1719. }
  1720. string shopname = GetPostString("shopname");
  1721. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1722. string buyernick = GetPostString("buyer_nick");
  1723. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1724. string customer = GetPostString("customer");
  1725. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1726. string design = GetPostString("design");
  1727. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1728. string orderState = GetPostString("orderState");
  1729. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1730. string address = GetPostString("address");
  1731. 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));
  1732. string sellermemo = GetPostString("seller_memo");
  1733. if (sellermemo.Length > 0)
  1734. {
  1735. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1736. }
  1737. string price1 = GetPostString("price1");
  1738. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1739. string price2 = GetPostString("price2");
  1740. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1741. //if (PKey != "admin")
  1742. //{
  1743. // string usershop = CurrentUser.User.pemShop;
  1744. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1745. //}
  1746. //if (ex_psize > 0)
  1747. //{
  1748. dStruct.Order = "pay_time desc";
  1749. //}
  1750. //else
  1751. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1752. lw.Add(string.Format("IsOffLineOrder=1"));
  1753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1754. DataTable dt = null;
  1755. dt = WebCache.GetData("view_erptradecell", dStruct);
  1756. writeGridDataTableJson(dStruct.TotalCount, dt);
  1757. }
  1758. public void get_erp_returncashrecord()
  1759. {
  1760. DataStruct dStruct = GetPostStruct();
  1761. List<string> lw = new List<string>();
  1762. string tid = GetPostString("ctid");
  1763. if (tid.Length > 0)
  1764. {
  1765. lw.Add(string.Format("tid like '%{0}%'", tid));
  1766. dStruct.Order = "id desc";
  1767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1768. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1769. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1770. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1771. return;
  1772. }
  1773. returnErrorMsg("id数据错误!");
  1774. }
  1775. public void ins_erp_returncashrecord()
  1776. {
  1777. if (UrlPostParmsCheck("tid"))
  1778. {
  1779. string tid = GetPostString("tid");
  1780. string retype = GetPostString("type");
  1781. StringBuilder sql = new StringBuilder();
  1782. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1783. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1784. if (dt.Rows.Count > 0)
  1785. {
  1786. returnErrorMsg("相同返现类型记录已存在");
  1787. return;
  1788. }
  1789. CeErpReturnCash entity = new CeErpReturnCash();
  1790. entity.tid = tid;
  1791. entity.seller_nick = GetPostString("seller_nick");
  1792. string pment = GetPostString("payment");
  1793. if (pment.Length > 0)
  1794. {
  1795. entity.payment = Convert.ToDouble(pment);
  1796. }
  1797. entity.buyer_nick = GetPostString("buyer_nick");
  1798. entity.cashstate = 0;
  1799. entity.rtype = retype;
  1800. string rPrice = GetPostString("returnprice");
  1801. if (rPrice.Length > 0)
  1802. {
  1803. entity.returnprice = Convert.ToDouble(rPrice);
  1804. }
  1805. entity.created = DateTime.Now;
  1806. entity.con = GetPostString("con");
  1807. entity.img = GetPostString("img");
  1808. entity.applyuserid = CurrentUser.UserID;
  1809. entity.Create();
  1810. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1811. returnSuccessMsg("操作成功!");
  1812. return;
  1813. }
  1814. }
  1815. public void set_erp_predelivery()
  1816. {
  1817. if (UrlPostParmsCheck("ctid"))
  1818. {
  1819. string eid = GetPostString("ctid");
  1820. CeErpTradeCell entity = null;
  1821. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1822. if (entity != null)
  1823. {
  1824. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1825. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1826. //{
  1827. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1828. // return;
  1829. //}
  1830. entity.IsPreDelivery = 1;
  1831. entity.Update();
  1832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1833. returnSuccessMsg("预发货成功!");
  1834. return;
  1835. //string shop = GetPostString("seller_nick");
  1836. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1837. //string comName = GetPostString("comName");
  1838. //string comCode = GetPostString("comCode");
  1839. //string outSid = GetPostString("outSid");//运单号
  1840. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1841. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1842. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1843. //string apires = "";
  1844. //if (deliveryType == "虚拟发货")
  1845. //{
  1846. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1847. //}
  1848. //else
  1849. //{
  1850. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1851. //}
  1852. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1853. ////{
  1854. //if (apires.IndexOf("发货成功") != -1)
  1855. //{
  1856. // if (deliveryType != "虚拟发货")
  1857. // {
  1858. // //还要插入快递信息到 快递信息表
  1859. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1860. // exinfo.tid = eid;
  1861. // exinfo.out_sid = outSid;
  1862. // exinfo.company_code = comCode;
  1863. // exinfo.company_name = comName;
  1864. // exinfo.delivery_memo = deliveryMemo;
  1865. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1866. // exinfo.deliveryType = deliveryType;
  1867. // exinfo.Create();
  1868. // }
  1869. // returnSuccessMsg("发货成功!");
  1870. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1871. //}
  1872. //else
  1873. //{
  1874. // returnErrorMsg("淘宝发货失败!!");
  1875. //}
  1876. //return;
  1877. }
  1878. returnErrorMsg("找不到订单记录");
  1879. }
  1880. }
  1881. public void get_erp_unusuallist()
  1882. {
  1883. DataStruct dStruct = GetPostStruct();
  1884. List<string> lw = new List<string>();
  1885. string tid = GetPostString("ctid");
  1886. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1887. string shopname = GetPostString("shopname");
  1888. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1889. string buyernick = GetPostString("buyer_nick");
  1890. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1891. string ResponsibleMan = GetPostString("responsible");
  1892. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1893. string date1 = GetPostString("date1");
  1894. string date2 = GetPostString("date2");
  1895. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1896. if (dw.Length > 0) lw.Add(dw);
  1897. string price1 = GetPostString("price1");
  1898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1899. string price2 = GetPostString("price2");
  1900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1901. string orderState = GetPostString("orderState");
  1902. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1903. string sellermemo = GetPostString("seller_memo");
  1904. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1905. lw.Add(string.Format("UnusualTag > 0"));
  1906. lw.Add(string.Format("IsRefund<={0}", 1));
  1907. dStruct.Order = "pay_time desc";
  1908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1910. writeGridDataTableJson(dStruct.TotalCount, dt);
  1911. }
  1912. public void set_erp_unusualtonomal()
  1913. {
  1914. if (UrlPostParmsCheck("ctid"))
  1915. {
  1916. string eid = GetPostString("ctid");
  1917. CeErpTradeCell entity = null;
  1918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1919. if (entity != null)
  1920. {
  1921. entity.UnusualTag = -1;
  1922. entity.Update();
  1923. returnSuccessMsg("忽略成功!");
  1924. return;
  1925. }
  1926. returnErrorMsg("找不到记录");
  1927. }
  1928. }
  1929. public void ins_erp_unusualreason()
  1930. {
  1931. if (UrlPostParmsCheck("ctid"))
  1932. {
  1933. string eid = GetPostString("ctid");
  1934. CeErpTradeCell entity = null;
  1935. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1936. if (entity != null)
  1937. {
  1938. entity.MemoOpt = 4;
  1939. entity.UnusualCon = GetPostString("con");
  1940. entity.Update();
  1941. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1942. if (trade != null)
  1943. {
  1944. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1945. }
  1946. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1947. returnSuccessMsg("操作成功!");
  1948. return;
  1949. }
  1950. returnErrorMsg("找不到记录");
  1951. }
  1952. }
  1953. public void upd_erp_sampleorder()
  1954. {
  1955. if (UrlPostParmsCheck("ctid"))
  1956. {
  1957. string eid = GetPostString("ctid");
  1958. string[] eArr = eid.Split(',');
  1959. if (eArr.Length > 1)
  1960. {
  1961. List<string> eLst = new List<string>();
  1962. for (int i = 0; i < eArr.Length; i++)
  1963. {
  1964. eLst.Add("'" + eArr[i] + "'");
  1965. }
  1966. eid = string.Join(",", eLst.ToArray());
  1967. }
  1968. else
  1969. {
  1970. eid = "'" + eid + "'";
  1971. }
  1972. StringBuilder sql = new StringBuilder();
  1973. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1974. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1975. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1976. if (dt.Rows.Count > 0)
  1977. {
  1978. string errmsg = "";
  1979. foreach (DataRow dr in dt.Rows)
  1980. {
  1981. StringBuilder sqlsb = new StringBuilder();
  1982. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1983. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1984. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1985. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1986. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1987. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1988. {
  1989. continue;
  1990. }
  1991. else
  1992. {
  1993. string emsg = commonHelper.KeepChinese(apires);
  1994. errmsg += emsg;
  1995. }
  1996. }
  1997. if (errmsg.Length > 0)
  1998. {
  1999. returnErrorMsg(errmsg);
  2000. return;
  2001. }
  2002. returnSuccessMsg("操作成功");
  2003. return;
  2004. }
  2005. returnErrorMsg("找不到记录");
  2006. }
  2007. }
  2008. public void upd_erp_transcustomer()
  2009. {
  2010. if (UrlPostParmsCheck("ctid"))
  2011. {
  2012. string eid = GetPostString("ctid");
  2013. int userid = GetPostInt("CustomerUserId");
  2014. CeErpTradeCell entity = null;
  2015. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2016. if (entity != null)
  2017. {
  2018. //string[] mlist = entity.seller_memo.Split('-');
  2019. //string sql = "select * from view_erpuser where id=" + userid;
  2020. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2021. //if (dt != null && dt.Rows.Count > 0)
  2022. //{
  2023. // string nmemo = "";
  2024. // for(int i = 0; i < mlist.Length - 1; i++)
  2025. // {
  2026. // nmemo += mlist[i];
  2027. // nmemo += "-";
  2028. // }
  2029. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2030. // entity.seller_memo = nmemo;
  2031. //}
  2032. entity.CustomerUserId = userid;
  2033. entity.Update();
  2034. returnSuccessMsg("操作成功!");
  2035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2036. return;
  2037. }
  2038. returnErrorMsg("找不到记录");
  2039. }
  2040. }
  2041. public void upd_erp_transdesigner()
  2042. {
  2043. if (UrlPostParmsCheck("ctid"))
  2044. {
  2045. string eids = GetPostString("ctid");
  2046. string[] ctidList = eids.Split(',');
  2047. int userid = GetPostInt("DesignUserId");
  2048. foreach (string ctid in ctidList)
  2049. {
  2050. CeErpTradeCell entity = null;
  2051. CeErpDesignerBill entitys = null;
  2052. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2053. entitys = CeErpDesignerBill.GetByTid(ctid);
  2054. if (entity != null)
  2055. {
  2056. if (entity.OrderState > 4)
  2057. {
  2058. continue;
  2059. }
  2060. //存在退款不能流转
  2061. if (entity.IsRefund > 0)
  2062. {
  2063. continue;
  2064. }
  2065. entity.DesignUserId = userid;
  2066. entity.WaitDesignTime = DateTime.Now;
  2067. entity.Update();
  2068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2069. }
  2070. }
  2071. returnSuccessMsg("操作成功!");
  2072. }
  2073. }
  2074. public void upd_erp_distributedesigner()
  2075. {
  2076. if (UrlPostParmsCheck("ctid"))
  2077. {
  2078. string eid = GetPostString("ctid");
  2079. int userid = GetPostInt("DesignUserId");
  2080. string[] idlist = eid.Split(',');
  2081. if (idlist.Length <= 0)
  2082. {
  2083. returnErrorMsg("订单不能为空");
  2084. return;
  2085. }
  2086. foreach (string ctid in idlist)
  2087. {
  2088. CeErpTradeCell entity = null;
  2089. CeErpDesignerBill entitys = null;
  2090. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2091. else continue;
  2092. if (entity != null)
  2093. {
  2094. if (userid == 2125 || userid == 3542)
  2095. { }
  2096. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2097. {
  2098. returnErrorMsg("金额错误的订单无法指派");
  2099. return;
  2100. }
  2101. if (entity.OrderState >= 5)
  2102. {
  2103. returnErrorMsg("已经设计完成无法指派");
  2104. return;
  2105. }
  2106. if (entity.OrderState == -1)
  2107. {
  2108. returnErrorMsg("审核中的订单无法指派");
  2109. return;
  2110. }
  2111. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2112. {
  2113. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2114. return;
  2115. }
  2116. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2117. {
  2118. returnErrorMsg("指派设计共创无法再次指派!");
  2119. return;
  2120. }
  2121. entity.OrderState = 3;
  2122. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2123. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2124. {
  2125. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2126. entity.SupplierId = suid;
  2127. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2128. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2129. }
  2130. if (userid == 2125 && entity.seller_memo != "")
  2131. {
  2132. apiDesign.API_GetPrintData_CreateOrder(entity);
  2133. }
  2134. if (userid == 3542 && entity.seller_memo != "")
  2135. {
  2136. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2137. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2138. if (response.msg != "设计共创:成功")
  2139. {
  2140. returnErrorMsg(response.msg);
  2141. return;
  2142. }
  2143. entity.DispatchSort = 2;
  2144. entity.OrderState = 3;
  2145. }
  2146. entity.DesignUserId = userid;
  2147. entity.WaitDesignTime = DateTime.Now;
  2148. entity.Update();
  2149. string name = commonHelper.getUserNameById(userid);
  2150. commonHelper.UpdateRelationOrder(entity.ctid);
  2151. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2152. }
  2153. }
  2154. returnSuccessMsg("操作成功!");
  2155. return;
  2156. }
  2157. }
  2158. public void get_erp_myorderlist()
  2159. {
  2160. DataStruct dStruct = GetPostStruct();
  2161. List<string> lw = new List<string>();
  2162. string tid = GetPostString("ctid");
  2163. if (tid.Length > 0)
  2164. {
  2165. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2166. }
  2167. else
  2168. {
  2169. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2170. }
  2171. //12-1 修改
  2172. string urgent = GetPostString("urgent");
  2173. string back = GetPostString("back");
  2174. string offlineSearch = GetPostString("offlineSearch");
  2175. if (!string.IsNullOrWhiteSpace(urgent))
  2176. {
  2177. if (urgent.Equals("true"))
  2178. {
  2179. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2180. }
  2181. }
  2182. if (!string.IsNullOrWhiteSpace(back))
  2183. {
  2184. if (back.Equals("true"))
  2185. {
  2186. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2187. }
  2188. }
  2189. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2190. {
  2191. if (offlineSearch.Equals("true"))
  2192. {
  2193. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2194. }
  2195. }
  2196. //end
  2197. string shopname = GetPostString("shopname");
  2198. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2199. string buyernick = GetPostString("buyer_nick");
  2200. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2201. string design = GetPostString("design");
  2202. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2203. string orderState = GetPostString("orderState");
  2204. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2205. string sellermemo = GetPostString("seller_memo");
  2206. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2207. string date1 = GetPostString("date1");
  2208. string date2 = GetPostString("date2");
  2209. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2210. if (dw.Length > 0) lw.Add(dw);
  2211. string price1 = GetPostString("price1");
  2212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2213. string price2 = GetPostString("price2");
  2214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2215. string urgency = GetPostString("urgency");
  2216. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2217. string after = GetPostString("after");
  2218. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2219. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2220. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2221. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2223. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2224. writeGridDataTableJson(dStruct.TotalCount, dt);
  2225. }
  2226. public void get_erp_myreturnorderlist()
  2227. {
  2228. DataStruct dStruct = GetPostStruct();
  2229. List<string> lw = new List<string>();
  2230. string tid = GetPostString("ctid");
  2231. if (tid.Length > 0)
  2232. {
  2233. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2234. }
  2235. else
  2236. {
  2237. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2238. }
  2239. string shopname = GetPostString("shopname");
  2240. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2241. string buyernick = GetPostString("buyer_nick");
  2242. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2243. string design = GetPostString("design");
  2244. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2245. string orderState = GetPostString("orderState");
  2246. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2247. string sellermemo = GetPostString("seller_memo");
  2248. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2249. string date1 = GetPostString("date1");
  2250. string date2 = GetPostString("date2");
  2251. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2252. if (dw.Length > 0) lw.Add(dw);
  2253. string price1 = GetPostString("price1");
  2254. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2255. string price2 = GetPostString("price2");
  2256. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2257. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2258. {
  2259. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2260. }
  2261. else
  2262. {
  2263. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2264. }
  2265. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2266. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2267. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2269. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2270. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2271. if (dt != null && dt.Rows.Count > 0)
  2272. {
  2273. foreach (DataRow dr in dt.Rows)
  2274. {
  2275. try
  2276. {
  2277. // 对象操作
  2278. if (dStruct.PageSize != 100000)
  2279. {
  2280. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2281. dr["gongchuang"] = response.code;
  2282. }
  2283. }
  2284. catch (NullReferenceException ex)
  2285. {
  2286. // 处理空引用异常
  2287. }
  2288. }
  2289. }
  2290. writeGridDataTableJson(dStruct.TotalCount, dt);
  2291. }
  2292. public void get_erp_myorderlist_pregather()
  2293. {
  2294. string date1 = GetPostString("date1");
  2295. string date2 = GetPostString("date2");
  2296. int userId = CurrentUser.UserID; //客服id
  2297. string orderWhere = "";
  2298. List<string> lw = new List<string>();
  2299. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2300. if (dw.Length > 0) lw.Add(dw);
  2301. lw.Add(string.Format("CustomerUserId={0}", userId));
  2302. lw.Add(string.Format("OrderState<9"));
  2303. orderWhere = string.Join(" and ", lw.ToArray());
  2304. string orderWhere2 = "";
  2305. List<string> lw2 = new List<string>();
  2306. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2307. if (dw2.Length > 0) lw2.Add(dw2);
  2308. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2309. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2310. string sql = string.Format("select *" +
  2311. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2312. "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 " +
  2313. "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 " +
  2314. "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");
  2315. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2316. //writeGridDataTableJson(dt.Rows.Count, dt);
  2317. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2318. }
  2319. public void upd_erp_publishorder()
  2320. {
  2321. if (UrlPostParmsCheck("ctid"))
  2322. {
  2323. string eid = GetPostString("ctid");
  2324. CeErpTradeCell entity = null;
  2325. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2326. if (entity != null)
  2327. {
  2328. entity.OrderState = 0; //发布后,变为待抢单
  2329. entity.Update();
  2330. commonHelper.UpdateRelationOrder(entity.ctid);
  2331. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2332. returnSuccessMsg("发布成功!");
  2333. return;
  2334. }
  2335. returnErrorMsg("找不到记录");
  2336. }
  2337. }
  2338. public void get_erp_my_tiporder()
  2339. {
  2340. StringBuilder sql = new StringBuilder();
  2341. int userId = 0;
  2342. if (CurrentUser != null) userId = CurrentUser.UserID;
  2343. string posCode = CurrentUser.UserPost.Post.Code;
  2344. string isTipedAfterSaleVerify = GetPostString("af");
  2345. DataTable dt = new DataTable();
  2346. if (posCode != "Supplier")
  2347. {
  2348. if (posCode == "CustomerService" || posCode == "Director")
  2349. {
  2350. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2351. }
  2352. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2353. {
  2354. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2355. }
  2356. else
  2357. {
  2358. string teamIds = CurrentUser.User.TeamIds;
  2359. if (teamIds == "")
  2360. {
  2361. teamIds = "0";
  2362. }
  2363. 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);
  2364. }
  2365. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2366. }
  2367. if (dt.Rows.Count <= 0)
  2368. {
  2369. string key = "aftersale_order_" + userId;
  2370. if (RedisHelper.HasKey(key))
  2371. {
  2372. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2373. dt.Columns.Add("ctid", typeof(string));
  2374. dt.Columns.Add("IsReadTag", typeof(int));
  2375. foreach (var i in list)
  2376. {
  2377. DataRow data = dt.NewRow();
  2378. data["ctid"] = i;
  2379. data["IsReadTag"] = 4;
  2380. dt.Rows.Add(data);
  2381. }
  2382. RedisHelper.StringDelete(key);
  2383. }
  2384. }
  2385. if (dt.Rows.Count <= 0)
  2386. {
  2387. sql = new StringBuilder();
  2388. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2389. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2390. }
  2391. if (posCode == "Supplier")
  2392. {
  2393. string ids = CurrentUser.User.pemVend;
  2394. if (ids != null && ids.Length > 0)
  2395. {
  2396. string[] ids_list = ids.Split(',');
  2397. foreach (var item in ids_list)
  2398. {
  2399. string key = "return_order_" + item;
  2400. if (RedisHelper.HasKey(key))
  2401. {
  2402. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2403. dt.Columns.Add("ctid", typeof(string));
  2404. dt.Columns.Add("IsReadTag", typeof(int));
  2405. foreach (var i in list)
  2406. {
  2407. DataRow data = dt.NewRow();
  2408. data["ctid"] = i;
  2409. data["IsReadTag"] = 1;
  2410. dt.Rows.Add(data);
  2411. }
  2412. RedisHelper.StringDelete(key);
  2413. }
  2414. }
  2415. }
  2416. if (dt.Rows.Count <= 0)
  2417. {
  2418. sql = new StringBuilder();
  2419. 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);
  2420. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2421. }
  2422. }
  2423. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2424. }
  2425. public void reset_erp_tiporder()
  2426. {
  2427. string ids = GetPostString("ids");
  2428. string[] ctidList = ids.Split(',');
  2429. foreach (string ctid in ctidList)
  2430. {
  2431. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2432. if (enty != null)
  2433. {
  2434. enty.IsReadTag = 0;
  2435. enty.Update();
  2436. }
  2437. }
  2438. returnSuccessMsg("成功!");
  2439. return;
  2440. }
  2441. public void get_erp_designlist()
  2442. {
  2443. DataStruct dStruct = GetPostStruct();
  2444. List<string> lw = new List<string>();
  2445. string tid = GetPostString("ctid");
  2446. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2447. string shopname = GetPostString("shopname");
  2448. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2449. string buyernick = GetPostString("buyer_nick");
  2450. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2451. string customer = GetPostString("customer");
  2452. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2453. string design = GetPostString("design");
  2454. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2455. string orderState = GetPostString("orderState");
  2456. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2457. lw.Add(string.Format("OrderState<6"));
  2458. string address = GetPostString("address");
  2459. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2460. string sellermemo = GetPostString("seller_memo");
  2461. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2462. string date1 = GetPostString("date1");
  2463. string date2 = GetPostString("date2");
  2464. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2465. if (dw.Length > 0) lw.Add(dw);
  2466. string apdate1 = GetPostString("apdate1");
  2467. string apdate2 = GetPostString("apdate2");
  2468. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2469. if (dwap.Length > 0) lw.Add(dwap);
  2470. string price1 = GetPostString("price1");
  2471. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2472. string price2 = GetPostString("price2");
  2473. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2474. string designTime = GetPostString("designtime");
  2475. if (designTime.Length > 0)
  2476. {
  2477. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2478. }
  2479. string usershop = CurrentUser.User.pemShop;
  2480. if (usershop.Length > 0)
  2481. {
  2482. lw.Add(string.Format("shopId in ({0})", usershop));
  2483. }
  2484. int myOrgid = CurrentUser.UserPost.OrgID;
  2485. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2486. if (myOrgCode.IndexOf("Designer") != -1)
  2487. {
  2488. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2489. {
  2490. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2491. }
  2492. else
  2493. {
  2494. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2495. }
  2496. }
  2497. else
  2498. {
  2499. string orgId = GetPostString("designerhd");
  2500. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2501. }
  2502. if (tid.Length > 0 || buyernick.Length > 0)
  2503. {
  2504. lw.Add(string.Format("OrderState >= 3"));
  2505. }
  2506. else
  2507. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2508. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2509. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2510. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2511. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2512. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2513. if (dt != null && dt.Rows.Count > 0)
  2514. {
  2515. foreach (DataRow dr in dt.Rows)
  2516. {
  2517. try
  2518. {
  2519. // 对象操作
  2520. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2521. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2522. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2523. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2524. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2525. if (dStruct.PageSize != 100000)
  2526. {
  2527. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2528. dr["gongchuang"] = response.code;
  2529. }
  2530. }
  2531. catch (NullReferenceException ex)
  2532. {
  2533. }
  2534. }
  2535. }
  2536. writeGridDataTableJson(dStruct.TotalCount, dt);
  2537. }
  2538. public void get_erp_mydesignlist()
  2539. {
  2540. DataStruct dStruct = GetPostStruct();
  2541. List<string> lw = new List<string>();
  2542. string tid = GetPostString("ctid");
  2543. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2544. string shopname = GetPostString("shopname");
  2545. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2546. string buyernick = GetPostString("buyer_nick");
  2547. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2548. string customer = GetPostString("customer");
  2549. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2550. string orderState = GetPostString("orderState");
  2551. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2552. //lw.Add(string.Format("OrderState<6"));
  2553. string date1 = GetPostString("date1");
  2554. string date2 = GetPostString("date2");
  2555. string dw = GetDateWhere("pay_time", date1, date2);
  2556. if (dw.Length > 0) lw.Add(dw);
  2557. string apdate1 = GetPostString("apdate1");
  2558. string apdate2 = GetPostString("apdate2");
  2559. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2560. if (dwap.Length > 0) lw.Add(dwap);
  2561. string price1 = GetPostString("price1");
  2562. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2563. string price2 = GetPostString("price2");
  2564. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2565. string olddownload = GetPostString("olddown");
  2566. if (olddownload == "1")
  2567. {
  2568. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2569. }
  2570. else if (olddownload == "2")
  2571. {
  2572. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2573. }
  2574. string sellermemo = GetPostString("seller_memo");
  2575. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2576. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2577. if (CurrentUser.User.TeamIds.Length > 0)
  2578. {
  2579. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2580. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2581. else
  2582. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2583. }
  2584. else
  2585. {
  2586. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2587. }
  2588. if (tid.Length <= 0)
  2589. {
  2590. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2591. }
  2592. lw.Add(string.Format("IsReturn!=3"));
  2593. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2594. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2595. string teamids = CurrentUser.User.TeamIds.ToString();
  2596. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2597. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2598. if (dt != null && dt.Rows.Count > 0)
  2599. {
  2600. foreach (DataRow dr in dt.Rows)
  2601. {
  2602. try
  2603. {
  2604. // 对象操作
  2605. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2606. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2607. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2608. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2609. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2610. if (dStruct.PageSize != 100000)
  2611. {
  2612. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2613. dr["gongchuang"] = response.code;
  2614. }
  2615. }
  2616. catch (NullReferenceException ex)
  2617. {
  2618. }
  2619. }
  2620. }
  2621. writeGridDataTableJson(dStruct.TotalCount, dt);
  2622. }
  2623. public void set_erp_startdesign()
  2624. {
  2625. if (UrlPostParmsCheck("ctid"))
  2626. {
  2627. string eid = GetPostString("ctid");
  2628. CeErpTradeCell entity = null;
  2629. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2630. if (entity != null)
  2631. {
  2632. if (entity.OrderState != 3)
  2633. {
  2634. returnErrorMsg("请刷新,订单已经设计了");
  2635. return;
  2636. }
  2637. entity.StartDesignTime = DateTime.Now;
  2638. entity.OrderState = 4;
  2639. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2640. {
  2641. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2642. entity.SupplierId = suid;
  2643. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2644. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2645. }
  2646. //entity.MakeSupplier = suname;
  2647. entity.Update();
  2648. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2649. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2650. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2651. commonHelper.getCytPrice(entity);
  2652. returnSuccessMsg("操作成功!");
  2653. return;
  2654. }
  2655. returnErrorMsg("找不到记录");
  2656. }
  2657. }
  2658. public void ins_erp_designselfmemo()
  2659. {
  2660. if (UrlPostParmsCheck("ctid"))
  2661. {
  2662. string eid = GetPostString("ctid");
  2663. string con = GetPostString("con");
  2664. CeErpTradeCell entity = null;
  2665. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2666. if (entity != null)
  2667. {
  2668. entity.DesignSelfMemo = con;
  2669. entity.Update();
  2670. returnSuccessMsg("操作成功!");
  2671. return;
  2672. }
  2673. returnErrorMsg("找不到记录");
  2674. }
  2675. }
  2676. public void ins_erp_designprice()
  2677. {
  2678. if (UrlPostParmsCheck("ctid"))
  2679. {
  2680. string eid = GetPostString("ctid");
  2681. int uid = CurrentUser.UserID;
  2682. string userName = CurrentUser.UserName;
  2683. CeErpTradeCell entity = null;
  2684. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2685. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2686. if (entitys == null)
  2687. {
  2688. entitys = new CeErpDesignerBill();
  2689. }
  2690. if (entity != null)
  2691. {
  2692. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2693. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2694. entity.StartDesignTime = DateTime.Now;
  2695. entity.OrderState = 4;
  2696. string suname = "";
  2697. if (entity.SupplierId == 0)
  2698. {
  2699. int sid = commonHelper.autoDistributeToSupplier(entity);
  2700. entity.SupplierId = sid;
  2701. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2702. }
  2703. entity.Update();
  2704. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2705. if (ceErpUserPost != null)
  2706. {
  2707. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2708. if (ceErpPost != null)
  2709. {
  2710. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2711. {
  2712. entitys.tid = entity.ctid;
  2713. entitys.oid = entity.tid;
  2714. entitys.uid = uid;
  2715. entitys.userName = userName;
  2716. entitys.designerType = 1;
  2717. entitys.designerTypeText = "内部设计师";
  2718. entitys.price = Convert.ToDouble(GetPostString("price"));
  2719. entitys.designNum = GetPostInt("designNum");
  2720. entitys.modifyNum = GetPostInt("modifyNum");
  2721. entitys.designSize = GetPostString("designSize");
  2722. entitys.modifySize = GetPostString("modifySize");
  2723. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2724. {
  2725. entitys.create_time = DateTime.Now;
  2726. entitys.create_u_id = uid;
  2727. entitys.create_u_name = userName;
  2728. entitys.Save();
  2729. }
  2730. else
  2731. {
  2732. entitys.update_time = DateTime.Now;
  2733. entitys.update_u_id = uid;
  2734. entitys.update_u_name = userName;
  2735. entitys.Update();
  2736. }
  2737. }
  2738. }
  2739. }
  2740. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2741. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2742. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2743. if (suname != "")
  2744. {
  2745. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2746. }
  2747. commonHelper.getCytPrice(entity);
  2748. returnSuccessMsg("操作成功!");
  2749. return;
  2750. }
  2751. returnErrorMsg("找不到记录");
  2752. }
  2753. }
  2754. public void upload_erp_filecomplete()
  2755. {
  2756. if (UrlPostParmsCheck("ctid"))
  2757. {
  2758. string eid = GetPostString("ctid");
  2759. CeErpTradeCell entity = null;
  2760. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2761. if (entity != null)
  2762. {
  2763. entity.OrderState = 5; //设计完成
  2764. entity.Update();
  2765. returnSuccessMsg(eid + "上传成功,设计完成!");
  2766. return;
  2767. }
  2768. returnErrorMsg("找不到订单记录");
  2769. }
  2770. }
  2771. public void get_erp_designovertimelist()
  2772. {
  2773. DataStruct dStruct = GetPostStruct();
  2774. List<string> lw = new List<string>();
  2775. string tid = GetPostString("ctid");
  2776. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2777. string shopname = GetPostString("shopname");
  2778. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2779. string buyernick = GetPostString("buyer_nick");
  2780. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2781. string ResponsibleMan = GetPostString("responsible");
  2782. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2783. string date1 = GetPostString("date1");
  2784. string date2 = GetPostString("date2");
  2785. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2786. if (dw.Length > 0) lw.Add(dw);
  2787. string price1 = GetPostString("price1");
  2788. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2789. string price2 = GetPostString("price2");
  2790. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2791. string orderState = GetPostString("orderState");
  2792. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2793. string sellermemo = GetPostString("seller_memo");
  2794. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2795. lw.Add(string.Format("UnusualTag=3"));
  2796. lw.Add(string.Format("IsRefund<={0}", 1));
  2797. dStruct.Order = "WaitDesignTime desc";
  2798. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2799. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2800. writeGridDataTableJson(dStruct.TotalCount, dt);
  2801. }
  2802. //设计管理 获取抢单大厅列表
  2803. public void get_erp_grabinglist()
  2804. {
  2805. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2806. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2807. bool oldOrder = false;
  2808. if (org != null)
  2809. {
  2810. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2811. }
  2812. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2813. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2814. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2815. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2816. //先处理订单数据
  2817. if (dt.Rows.Count > 0)
  2818. {
  2819. Dictionary<string, int> design = null;
  2820. int count = 0;
  2821. foreach (DataRow row in dt.Rows)
  2822. {
  2823. if (map.ContainsKey(row["ShopId"].ToString()))
  2824. {
  2825. map.TryGetValue(row["ShopId"].ToString(), out design);
  2826. }
  2827. else
  2828. {
  2829. design = new Dictionary<string, int>();
  2830. }
  2831. if (design.ContainsKey(row["ProductId"].ToString()))
  2832. {
  2833. design.TryGetValue(row["ProductId"].ToString(), out count);
  2834. }
  2835. count++;
  2836. design[row["ProductId"].ToString()] = count;
  2837. map[row["ShopId"].ToString()] = design;
  2838. }
  2839. }
  2840. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2841. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2842. //把店铺排序和技能排序分类
  2843. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2844. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2845. if (design_dt.Rows.Count > 0)
  2846. {
  2847. Dictionary<string, string> design = null;
  2848. List<string> shopIds = null;
  2849. foreach (DataRow row in design_dt.Rows)
  2850. {
  2851. if ("0".Equals(row["designId"].ToString()))
  2852. {
  2853. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2854. {
  2855. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2856. }
  2857. else
  2858. {
  2859. shopIds = new List<string>();
  2860. }
  2861. shopIds.Add(row["shopId"].ToString());
  2862. shop_orders[row["orders"].ToString()] = shopIds;
  2863. }
  2864. else
  2865. {
  2866. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2867. {
  2868. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2869. }
  2870. else
  2871. {
  2872. design = new Dictionary<string, string>();
  2873. }
  2874. design[row["orders"].ToString()] = row["designId"].ToString();
  2875. design_orders[row["shopId"].ToString()] = design;
  2876. }
  2877. }
  2878. //处理成key value后根据key排序
  2879. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2880. foreach (List<string> val in shop_orders.Values)
  2881. {
  2882. if (val != null)
  2883. {
  2884. foreach (string key in val)
  2885. {
  2886. if (design_orders.ContainsKey(key.ToString()))
  2887. {
  2888. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2889. }
  2890. }
  2891. }
  2892. }
  2893. }
  2894. //校验哪个优先级有订单
  2895. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2896. foreach (string key in shop_orders.Keys)
  2897. {
  2898. List<string> ids = null;
  2899. shop_orders.TryGetValue(key, out ids);
  2900. //id为shopid
  2901. foreach (string id in ids)
  2902. {
  2903. Dictionary<string, int> list = null;
  2904. Dictionary<string, string> desing = null;
  2905. map.TryGetValue(id, out list);
  2906. design_orders.TryGetValue(id, out desing);
  2907. if (list != null && desing != null)
  2908. {
  2909. foreach (var item in desing)
  2910. {
  2911. int count = 0;
  2912. if (list.ContainsKey(item.Value))
  2913. {
  2914. list.TryGetValue(item.Value, out count);
  2915. if (count > 0)
  2916. {
  2917. designIds[id] = item.Value;
  2918. break;
  2919. }
  2920. }
  2921. }
  2922. }
  2923. }
  2924. if (designIds.Count > 0)
  2925. {
  2926. break;
  2927. }
  2928. }
  2929. DataTable table = new DataTable();
  2930. table.Columns.Add("tid", typeof(string));
  2931. table.Columns.Add("ctid", typeof(string));
  2932. table.Columns.Add("seller_nick", typeof(string));
  2933. table.Columns.Add("productName", typeof(string));
  2934. table.Columns.Add("pay_time", typeof(string));
  2935. table.Columns.Add("seller_memo", typeof(string));
  2936. if (designIds.Count > 0)
  2937. {
  2938. string shopId = "";
  2939. string productId = "";
  2940. foreach (var designInfo in designIds)
  2941. {
  2942. shopId = designInfo.Key;
  2943. productId = designInfo.Value;
  2944. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2945. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2946. if (dt.Rows.Count > 0)
  2947. {
  2948. foreach (DataRow row in dt.Rows)
  2949. {
  2950. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2951. {
  2952. DataRow data = table.NewRow();
  2953. data["ctid"] = row["ctid"].ToString();
  2954. data["tid"] = row["tid"].ToString();
  2955. data["seller_nick"] = ceErpShop.ShopName;
  2956. data["pay_time"] = row["pay_time"].ToString();
  2957. data["seller_memo"] = row["seller_memo"].ToString();
  2958. data["productName"] = ceErpProduct.PType;
  2959. table.Rows.Add(data);
  2960. }
  2961. }
  2962. }
  2963. }
  2964. }
  2965. writeGridDataTableJson(table.Rows.Count, table);
  2966. }
  2967. private object rushLockObject = new object();
  2968. public void set_erp_grabingorder()
  2969. {
  2970. if (UrlPostParmsCheck("ctid"))
  2971. {
  2972. int total = CurrentUser.User.Person.Total;
  2973. int userId = CurrentUser.User.ID;
  2974. int noFinish = CurrentUser.User.Person.NoFinish;
  2975. int finalization = CurrentUser.User.Person.Finalization;
  2976. string eids = GetPostString("ctid");
  2977. string key = "RushKey_" + userId;
  2978. int count = 0;
  2979. if (erpRedis.RedisHelper.KeyExists(key))
  2980. {
  2981. string redisCount = erpRedis.RedisHelper.StringGet(key);
  2982. if (redisCount != null)
  2983. {
  2984. count = Convert.ToInt32(redisCount);
  2985. }
  2986. }
  2987. if (count >= total)
  2988. {
  2989. returnErrorMsg("半小时内已经抢" + total + "单");
  2990. return;
  2991. }
  2992. string[] ctidlist = eids.Split(',');
  2993. if (count + ctidlist.Length > total)
  2994. {
  2995. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  2996. return;
  2997. }
  2998. int itag = 0;
  2999. lock (rushLockObject)
  3000. {
  3001. if (ctidlist.Length > 0)
  3002. {
  3003. string[] dtList = new string[ctidlist.Length];
  3004. for (int i = 0; i < ctidlist.Length; i++)
  3005. {
  3006. dtList[i] = "'" + ctidlist[i] + "'";
  3007. }
  3008. 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"));
  3009. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3010. if (dt_user.Rows.Count > 0)
  3011. {
  3012. int doing = 0;//未定稿
  3013. int finish = 0;//已完成
  3014. foreach (DataRow dr in dt_user.Rows)
  3015. {
  3016. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3017. {
  3018. doing++;
  3019. }
  3020. else
  3021. {
  3022. finish++;
  3023. }
  3024. }
  3025. if (doing >= noFinish)
  3026. {
  3027. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3028. return;
  3029. }
  3030. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3031. {
  3032. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3033. return;
  3034. }
  3035. }
  3036. //校验选择单子状态
  3037. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3038. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3039. if (dt.Rows.Count > 0)
  3040. {
  3041. List<string> list = new List<string>();
  3042. foreach (DataRow dr in dt.Rows)
  3043. {
  3044. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3045. {
  3046. list.Add(dr["ctid"].ToString());
  3047. }
  3048. }
  3049. if (list.Count > 0)
  3050. {
  3051. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3052. return;
  3053. }
  3054. }
  3055. foreach (string ctid in ctidlist)
  3056. {
  3057. CeErpTradeCell entity = null;
  3058. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3059. if (entity != null)
  3060. {
  3061. entity.OrderState = 3;
  3062. entity.DesignUserId = CurrentUser.UserID;
  3063. entity.WaitDesignTime = DateTime.Now;
  3064. entity.StartDesignTime = DateTime.Now;
  3065. entity.Update();
  3066. commonHelper.UpdateRelationOrder(entity.ctid);
  3067. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3069. itag++;
  3070. }
  3071. }
  3072. }
  3073. }
  3074. count += ctidlist.Length;
  3075. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3076. if (itag == 0)
  3077. returnErrorMsg("没有找到相关订单");
  3078. else
  3079. returnSuccessMsg("抢单成功!");
  3080. return;
  3081. }
  3082. }
  3083. public void get_erp_waitorderlist()
  3084. {
  3085. DataStruct dStruct = GetPostStruct();
  3086. List<string> lw = new List<string>();
  3087. string tid = GetPostString("ctid");
  3088. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3089. string shopname = GetPostString("shopname");
  3090. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3091. string buyernick = GetPostString("buyer_nick");
  3092. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3093. string customer = GetPostString("customer");
  3094. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3095. string design = GetPostString("design");
  3096. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3097. string orderState = GetPostString("orderState");
  3098. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3099. string supplier = GetPostString("supplier");
  3100. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3101. string sellermemo = GetPostString("seller_memo");
  3102. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3103. string otherMemo = GetPostString("otherMemo");
  3104. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3105. string address = GetPostString("address");
  3106. 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));
  3107. string date1 = GetPostString("date1");
  3108. string date2 = GetPostString("date2");
  3109. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3110. if (dw.Length > 0) lw.Add(dw);
  3111. string price1 = GetPostString("price1");
  3112. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3113. string price2 = GetPostString("price2");
  3114. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3115. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3116. lw.Add(string.Format("IsSample != 2 "));
  3117. lw.Add(string.Format("OrderState = 5 "));
  3118. lw.Add(string.Format("IsRefund<={0}", 1));
  3119. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3120. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3121. string pagesize = GetPostString("pagesize");
  3122. if (pagesize != null)
  3123. {
  3124. dStruct.PageSize = 200;
  3125. }
  3126. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3127. foreach (DataRow dr in dt.Rows)
  3128. {
  3129. 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();
  3130. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3131. {
  3132. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3133. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3134. entity.SupplierId = suid;
  3135. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3136. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3137. entity.Update();
  3138. }
  3139. }
  3140. writeGridDataTableJson(dStruct.TotalCount, dt);
  3141. }
  3142. public void get_erp_supplierwaitorderlist()
  3143. {
  3144. DataStruct dStruct = GetPostStruct();
  3145. List<string> lw = new List<string>();
  3146. string tid = GetPostString("ctid");
  3147. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3148. string shopname = GetPostString("shopname");
  3149. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3150. string sellermemo = GetPostString("seller_memo");
  3151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3152. string date1 = GetPostString("date1");
  3153. string date2 = GetPostString("date2");
  3154. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3155. if (dw.Length > 0) lw.Add(dw);
  3156. lw.Add(string.Format("OrderState = 5 "));
  3157. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3158. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3159. {
  3160. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3161. }
  3162. string supplier = GetPostString("supplier");
  3163. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3164. {
  3165. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3166. }
  3167. lw.Add(string.Format("IsRefund<={0}", 1));
  3168. dStruct.Order = "FinishDesignTime desc";
  3169. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3170. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3171. if (dt != null)
  3172. {
  3173. foreach (DataRow dr in dt.Rows)
  3174. {
  3175. 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();
  3176. }
  3177. }
  3178. writeGridDataTableJson(dStruct.TotalCount, dt);
  3179. }
  3180. public void upd_erp_verifytosupplier()
  3181. {
  3182. if (UrlPostParmsCheck("ctid"))
  3183. {
  3184. string eids = GetPostString("ctid");
  3185. CeErpTradeCell entity = null;
  3186. string[] eidsList = eids.Split(',');
  3187. if (eidsList.Length <= 0)
  3188. {
  3189. returnErrorMsg("订单号不能空");
  3190. return;
  3191. }
  3192. List<string> tLst = new List<string>();
  3193. foreach (string ctidstr in eidsList)
  3194. {
  3195. tLst.Add("'" + ctidstr + "'");
  3196. CeErpDataSendOrderInfo.createObject(ctidstr);
  3197. }
  3198. string needtids = string.Join(",", tLst.ToArray());
  3199. StringBuilder sql = new StringBuilder();
  3200. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3201. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3202. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3203. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3204. returnSuccessMsg("操作成功!");
  3205. return;
  3206. /**foreach (string ctidstr in eidsList)
  3207. {
  3208. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3209. if (entity != null)
  3210. {
  3211. if (entity.SupplierId == 0)
  3212. {
  3213. continue;
  3214. }
  3215. entity.IsVerifyToSupplier = true;
  3216. if (entity.IsReturn == 1) //1是供应商打回
  3217. {
  3218. entity.IsReturn = 0;
  3219. }
  3220. entity.FinishPlaceTime = DateTime.Now;
  3221. entity.PlaceUserId = CurrentUser.UserID;
  3222. entity.Update();
  3223. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3224. }
  3225. }
  3226. returnSuccessMsg("操作成功!");
  3227. return;**/
  3228. }
  3229. }
  3230. public void upd_erp_supplierback()
  3231. {
  3232. if (UrlPostParmsCheck("ctid"))
  3233. {
  3234. string eid = GetPostString("ctid");
  3235. string reason = GetPostString("returnreason");
  3236. CeErpTradeCell entity = null;
  3237. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3238. if (entity != null)
  3239. {
  3240. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3241. {
  3242. string key = "return_order_" + entity.SupplierId;
  3243. List<string> list = new List<string>();
  3244. if (RedisHelper.HasKey(key))
  3245. {
  3246. object data = RedisHelper.StringGet(key);
  3247. list = Convert.ToString(data).Split(',').ToList();
  3248. }
  3249. list.Add(eid);
  3250. RedisHelper.StringSet(key, string.Join(",", list));
  3251. }
  3252. entity.IsVerifyToSupplier = false;
  3253. entity.IsReturn = 1;
  3254. entity.ReturnTime = DateTime.Now;
  3255. entity.ReturnReason = reason;
  3256. if (entity.OrderState == 6)
  3257. {
  3258. entity.OrderState = 5;
  3259. }
  3260. entity.Update();
  3261. CeErpSukuraData.createInfo(entity.ctid, 5);
  3262. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3263. returnSuccessMsg("操作成功!");
  3264. return;
  3265. }
  3266. returnErrorMsg("找不到订单记录");
  3267. }
  3268. }
  3269. public void upd_erp_toaftersaleorder()
  3270. {
  3271. if (UrlPostParmsCheck("ctid"))
  3272. {
  3273. string eid = GetPostString("ctid");
  3274. string reason = GetPostString("returnreason");
  3275. CeErpTradeCell entity = null;
  3276. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3277. if (entity != null)
  3278. {
  3279. if (entity.isAfterSaleOrder != 1)
  3280. {
  3281. returnErrorMsg("带S的售后单才能打回给售后");
  3282. return;
  3283. }
  3284. if (entity.OrderState >= 5)
  3285. {
  3286. returnErrorMsg("已经设计完成了不能打回给售后");
  3287. return;
  3288. }
  3289. entity.OrderState = 0;
  3290. entity.IsReturn = 3;
  3291. entity.ReturnTime = DateTime.Now;
  3292. entity.ReturnReason = reason;
  3293. entity.Update();
  3294. CeErpSukuraData.createInfo(entity.ctid, 5);
  3295. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3296. returnSuccessMsg("操作成功!");
  3297. return;
  3298. }
  3299. returnErrorMsg("找不到订单记录");
  3300. }
  3301. }
  3302. public void upd_erp_aftersaletodesign()
  3303. {
  3304. if (UrlPostParmsCheck("ctid"))
  3305. {
  3306. string eid = GetPostString("ctid");
  3307. CeErpTradeCell entity = null;
  3308. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3309. if (entity != null)
  3310. {
  3311. entity.OrderState = 3;
  3312. entity.IsReturn = 0;
  3313. entity.Update();
  3314. CeErpSukuraData.createInfo(entity.ctid, 5);
  3315. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3316. returnSuccessMsg("操作成功!");
  3317. return;
  3318. }
  3319. returnErrorMsg("找不到订单记录");
  3320. }
  3321. }
  3322. public void assign_erp_supplier()
  3323. {
  3324. if (UrlPostParmsCheck("ctid"))
  3325. {
  3326. string eids = GetPostString("ctid");
  3327. int sid = GetPostInt("SupplierName");
  3328. string fromTag = GetPostString("tag");
  3329. string[] eidList = eids.Split(',');
  3330. if (eidList.Length <= 0)
  3331. {
  3332. returnErrorMsg("指派不能为空");
  3333. return;
  3334. }
  3335. string errMsg = "";
  3336. string suname = commonHelper.getSupplierNameById(sid);
  3337. foreach (string ctid in eidList)
  3338. {
  3339. CeErpTradeCell entity = null;
  3340. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3341. if (entity != null)
  3342. {
  3343. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3344. {
  3345. errMsg += (ctid + "指派失败!!!");
  3346. continue;
  3347. }
  3348. entity.SupplierId = sid;
  3349. entity.Update();
  3350. commonHelper.UpdateRelationOrder(entity.ctid);
  3351. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3352. if (entity.OrderState >= 6)
  3353. {
  3354. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3355. //{
  3356. // string msl = entity.MakeSupplier;
  3357. // string[] mslist = msl.Split(',');
  3358. // 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);
  3359. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3360. //}
  3361. //else
  3362. //{
  3363. StringBuilder sql = new StringBuilder();
  3364. 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);
  3365. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3366. //}
  3367. }
  3368. }
  3369. else
  3370. {
  3371. continue;
  3372. }
  3373. }
  3374. if (errMsg.Length > 0)
  3375. {
  3376. returnErrorMsg(errMsg);
  3377. return;
  3378. }
  3379. returnSuccessMsg("操作成功!");
  3380. return;
  3381. }
  3382. }
  3383. public void assign_erp_makesupplier()
  3384. {
  3385. if (UrlPostParmsCheck("ctid"))
  3386. {
  3387. string eids = GetPostString("ctid");
  3388. string sname = GetPostString("SupplierName");
  3389. string[] eidList = eids.Split(',');
  3390. if (eidList.Length <= 0)
  3391. {
  3392. returnErrorMsg("指派不能为空");
  3393. return;
  3394. }
  3395. List<string> tLst = new List<string>();
  3396. foreach (string ctid in eidList)
  3397. {
  3398. CeErpTradeCell entity = null;
  3399. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3400. if (entity != null)
  3401. {
  3402. entity.MakeSupplier = sname;
  3403. entity.Update();
  3404. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3405. tLst.Add("'" + ctid + "'");
  3406. }
  3407. else
  3408. {
  3409. continue;
  3410. }
  3411. }
  3412. string ctids = string.Join(",", tLst.ToArray());
  3413. StringBuilder sql2 = new StringBuilder();
  3414. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3415. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3416. returnSuccessMsg("操作成功!");
  3417. return;
  3418. }
  3419. }
  3420. public void ins_erp_returnreason()
  3421. {
  3422. if (UrlPostParmsCheck("ctid"))
  3423. {
  3424. string eid = GetPostString("ctid");
  3425. CeErpTradeCell entity = null;
  3426. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3427. string userpost = CurrentUser.UserPost.Post.Code;
  3428. if (entity != null)
  3429. {
  3430. bool isPlace = false;
  3431. if (entity.OrderState > 6)
  3432. {
  3433. returnErrorMsg("已发货无法打回!");
  3434. return;
  3435. }
  3436. if (entity.OrderState == 6)
  3437. {
  3438. isPlace = true;
  3439. }
  3440. bool isNeedUpdateCell2 = false;
  3441. if (entity.OrderState >= 6)
  3442. {
  3443. isNeedUpdateCell2 = true;
  3444. }
  3445. int returnTag = 2;
  3446. if (userpost == "Supplier")
  3447. {
  3448. returnTag = 1;
  3449. }
  3450. if (entity.IsXianHuo == 0)
  3451. {
  3452. if (returnTag == 2)
  3453. {
  3454. int toType = GetPostInt("totype");
  3455. if (toType == 1)
  3456. {
  3457. entity.OrderState = 0;
  3458. entity.ReturnUserType = 1;
  3459. string clearman = GetPostString("clearman");
  3460. if (!string.IsNullOrEmpty(clearman))
  3461. {
  3462. entity.DesignUserId = 0;
  3463. }
  3464. }
  3465. else
  3466. {
  3467. entity.OrderState = 3;
  3468. entity.ReturnUserType = 2;
  3469. }
  3470. entity.IsReadTag = 1;
  3471. }
  3472. else if (returnTag == 1)
  3473. {
  3474. entity.OrderState = 5;
  3475. }
  3476. entity.IsVerifyToSupplier = false;
  3477. }
  3478. if (entity.IsXianHuo == 1)
  3479. {
  3480. entity.OrderState = 5;
  3481. }
  3482. entity.UnusualTag = 0;
  3483. entity.UnusualTime = null;
  3484. entity.UnusualCon = "";
  3485. entity.IsReturn = returnTag;
  3486. entity.ReturnTime = DateTime.Now;
  3487. entity.ReturnReason = GetPostString("returnreason");
  3488. entity.Update();
  3489. if (entity.OrderState == 3)
  3490. {
  3491. ApiVo apiVo = new ApiVo();
  3492. apiVo.orderNumber = entity.ctid;
  3493. apiVo.actionName = "rebutDesign";
  3494. apiVo.orderRemarks = entity.ReturnReason;
  3495. designHelper.API_WorkCore(apiVo);//rebutDesign
  3496. }
  3497. CeErpSukuraData.createInfo(entity.ctid, 5);
  3498. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3499. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3500. if (isPlace)
  3501. {
  3502. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3503. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3504. if (dth != null && dth.Rows.Count > 0)
  3505. {
  3506. dataSendOrderBean dataSendOrderBean = null;
  3507. foreach (DataRow item in dth.Rows)
  3508. {
  3509. try
  3510. {
  3511. dataSendOrderBean = new dataSendOrderBean();
  3512. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3513. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3514. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3515. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3516. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3517. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3518. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3519. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3520. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3521. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3522. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3523. dataSendOrderBean.Radio1723534706288 = "打回";
  3524. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3525. if (result != null)
  3526. {
  3527. if ("0".Equals(result.errcode))
  3528. {
  3529. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3530. }
  3531. else
  3532. {
  3533. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3534. }
  3535. }
  3536. }
  3537. catch (Exception ex)
  3538. {
  3539. }
  3540. }
  3541. }
  3542. }
  3543. if (isNeedUpdateCell2)
  3544. {
  3545. if (entity.MakeSupplier.IndexOf(",") != -1)
  3546. {
  3547. StringBuilder sql2 = new StringBuilder();
  3548. 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);
  3549. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3550. }
  3551. else
  3552. {
  3553. StringBuilder sql2 = new StringBuilder();
  3554. 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);
  3555. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3556. }
  3557. }
  3558. returnSuccessMsg("操作成功!");
  3559. return;
  3560. }
  3561. returnErrorMsg("找不到订单记录");
  3562. }
  3563. }
  3564. public void cyt_erp_returnreason()
  3565. {
  3566. if (UrlPostParmsCheck("ctid"))
  3567. {
  3568. string eid = GetPostString("ctid");
  3569. CeErpTradeCell entity = null;
  3570. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3571. string userpost = CurrentUser.UserPost.Post.Code;
  3572. if (entity != null)
  3573. {
  3574. if (entity.OrderState > 6)
  3575. {
  3576. returnErrorMsg("已发货无法打回!");
  3577. return;
  3578. }
  3579. JObject jsonObject = new JObject
  3580. {
  3581. { "Userid", "77886" },
  3582. { "Pwd", "lt666888" },
  3583. { "LTOrderId",eid }
  3584. };
  3585. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3586. JObject jsonObjects = JObject.Parse(response);
  3587. string msg = (string)jsonObjects["msg"];
  3588. if (msg != "取消成功")
  3589. {
  3590. returnErrorMsg(msg);
  3591. return;
  3592. }
  3593. bool isNeedUpdateCell2 = false;
  3594. if (entity.OrderState >= 6)
  3595. {
  3596. isNeedUpdateCell2 = true;
  3597. }
  3598. int returnTag = 2;
  3599. if (userpost == "Supplier")
  3600. {
  3601. returnTag = 1;
  3602. }
  3603. if (entity.IsXianHuo == 0)
  3604. {
  3605. if (returnTag == 2)
  3606. {
  3607. int toType = GetPostInt("totype");
  3608. if (toType == 1)
  3609. {
  3610. entity.OrderState = 0;
  3611. entity.ReturnUserType = 1;
  3612. }
  3613. else
  3614. {
  3615. entity.OrderState = 4;
  3616. entity.ReturnUserType = 2;
  3617. }
  3618. entity.IsReadTag = 1;
  3619. }
  3620. else if (returnTag == 1)
  3621. {
  3622. entity.OrderState = 5;
  3623. }
  3624. entity.IsVerifyToSupplier = false;
  3625. }
  3626. entity.UnusualTag = 0;
  3627. entity.UnusualTime = null;
  3628. entity.UnusualCon = "";
  3629. entity.IsReturn = returnTag;
  3630. entity.ReturnTime = DateTime.Now;
  3631. entity.ReturnReason = GetPostString("returnreason");
  3632. entity.Update();
  3633. if (entity.OrderState == 4)
  3634. {
  3635. ApiVo apiVo = new ApiVo();
  3636. apiVo.orderNumber = entity.ctid;
  3637. apiVo.actionName = "rebutDesign";
  3638. apiVo.orderRemarks = entity.ReturnReason;
  3639. designHelper.API_WorkCore(apiVo);//rebutDesign
  3640. }
  3641. CeErpSukuraData.createInfo(entity.ctid, 5);
  3642. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3643. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3644. if (isNeedUpdateCell2)
  3645. {
  3646. if (entity.MakeSupplier.IndexOf(",") != -1)
  3647. {
  3648. StringBuilder sql2 = new StringBuilder();
  3649. 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);
  3650. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3651. }
  3652. else
  3653. {
  3654. StringBuilder sql2 = new StringBuilder();
  3655. 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);
  3656. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3657. }
  3658. }
  3659. returnSuccessMsg("操作成功!");
  3660. return;
  3661. }
  3662. returnErrorMsg("找不到订单记录");
  3663. }
  3664. }
  3665. public void upd_erp_xianhuoreturntag()
  3666. {
  3667. if (UrlPostParmsCheck("ctid"))
  3668. {
  3669. string eids = GetPostString("ctid");
  3670. string[] ctids = eids.Split(',');
  3671. foreach (string ctid in ctids)
  3672. {
  3673. CeErpTradeCell entity = null;
  3674. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3675. if (entity != null)
  3676. {
  3677. entity.IsReturn = 0;
  3678. entity.Update();
  3679. CeErpSukuraData.createInfo(entity.ctid, 5);
  3680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3681. }
  3682. }
  3683. returnSuccessMsg("操作成功!");
  3684. return;
  3685. }
  3686. }
  3687. public void get_erp_waitdeliverylist()
  3688. {
  3689. DataStruct dStruct = GetPostStruct();
  3690. List<string> lw = new List<string>();
  3691. string tid = GetPostString("ctid");
  3692. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3693. string shopname = GetPostString("shopname");
  3694. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3695. string buyernick = GetPostString("buyer_nick");
  3696. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3697. //if (tid.Length == 0 && buyernick.Length == 0)
  3698. //{
  3699. // lw.Add(string.Format("IsRefund<={0}", 1));
  3700. //}
  3701. string customer = GetPostString("customer");
  3702. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3703. string design = GetPostString("design");
  3704. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3705. string orderState = GetPostString("orderState");
  3706. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3707. string address = GetPostString("address");
  3708. 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));
  3709. string sellermemo = GetPostString("seller_memo");
  3710. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3711. string supplier = GetPostString("supplier");
  3712. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3713. string OrderArea = GetPostString("order_area");
  3714. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3715. string placedate1 = GetPostString("placedate1");
  3716. string placedate2 = GetPostString("placedate2");
  3717. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3718. if (fdw.Length > 0) lw.Add(fdw);
  3719. string price1 = GetPostString("price1");
  3720. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3721. string price2 = GetPostString("price2");
  3722. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3723. string unusualCon = GetPostString("unusualcon");
  3724. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3725. string otherMemo = GetPostString("otherMemo");
  3726. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3727. string posTag = CurrentUser.UserPost.Post.Code;
  3728. if (posTag == "Supplier")
  3729. {
  3730. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3731. }
  3732. lw.Add(string.Format("OrderState = 6 "));
  3733. lw.Add(string.Format("type != 'PDD' "));
  3734. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3735. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3736. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3737. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3738. writeGridDataTableJson(dStruct.TotalCount, dt);
  3739. }
  3740. public void get_erp_pddderiving()
  3741. {
  3742. DataStruct dStruct = GetPostStruct();
  3743. List<string> lw = new List<string>();
  3744. string tid = GetPostString("ctid");
  3745. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3746. string shopname = GetPostString("shopname");
  3747. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3748. string buyernick = GetPostString("buyer_nick");
  3749. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3750. //if (tid.Length == 0 && buyernick.Length == 0)
  3751. //{
  3752. // lw.Add(string.Format("IsRefund<={0}", 1));
  3753. //}
  3754. string customer = GetPostString("customer");
  3755. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3756. string design = GetPostString("design");
  3757. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3758. string orderState = GetPostString("orderState");
  3759. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3760. string address = GetPostString("address");
  3761. 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));
  3762. string sellermemo = GetPostString("seller_memo");
  3763. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3764. string supplier = GetPostString("supplier");
  3765. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3766. string OrderArea = GetPostString("order_area");
  3767. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3768. string placedate1 = GetPostString("placedate1");
  3769. string placedate2 = GetPostString("placedate2");
  3770. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3771. if (fdw.Length > 0) lw.Add(fdw);
  3772. string price1 = GetPostString("price1");
  3773. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3774. string price2 = GetPostString("price2");
  3775. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3776. string unusualCon = GetPostString("unusualcon");
  3777. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3778. string posTag = CurrentUser.UserPost.Post.Code;
  3779. if (posTag == "Supplier")
  3780. {
  3781. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3782. }
  3783. lw.Add(string.Format("OrderState = 6 "));
  3784. lw.Add(string.Format("type = 'PDD' "));
  3785. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3786. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3787. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3788. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3789. writeGridDataTableJson(dStruct.TotalCount, dt);
  3790. }
  3791. public void get_erp_jdderiving()
  3792. {
  3793. DataStruct dStruct = GetPostStruct();
  3794. List<string> lw = new List<string>();
  3795. string tid = GetPostString("ctid");
  3796. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3797. string shopname = GetPostString("shopname");
  3798. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3799. string buyernick = GetPostString("buyer_nick");
  3800. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3801. //if (tid.Length == 0 && buyernick.Length == 0)
  3802. //{
  3803. // lw.Add(string.Format("IsRefund<={0}", 1));
  3804. //}
  3805. string customer = GetPostString("customer");
  3806. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3807. string design = GetPostString("design");
  3808. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3809. string orderState = GetPostString("orderState");
  3810. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3811. string address = GetPostString("address");
  3812. 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));
  3813. string sellermemo = GetPostString("seller_memo");
  3814. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3815. string supplier = GetPostString("supplier");
  3816. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3817. string OrderArea = GetPostString("order_area");
  3818. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3819. string placedate1 = GetPostString("placedate1");
  3820. string placedate2 = GetPostString("placedate2");
  3821. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3822. if (fdw.Length > 0) lw.Add(fdw);
  3823. string price1 = GetPostString("price1");
  3824. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3825. string price2 = GetPostString("price2");
  3826. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3827. string unusualCon = GetPostString("unusualcon");
  3828. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3829. string posTag = CurrentUser.UserPost.Post.Code;
  3830. if (posTag == "Supplier")
  3831. {
  3832. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3833. }
  3834. lw.Add(string.Format("OrderState = 6 "));
  3835. lw.Add(string.Format("type = 'JD' "));
  3836. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3837. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3838. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3839. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3840. writeGridDataTableJson(dStruct.TotalCount, dt);
  3841. }
  3842. public void get_erp_demoorderlist()
  3843. {
  3844. DataStruct dStruct = GetPostStruct();
  3845. List<string> lw = new List<string>();
  3846. string tid = GetPostString("ctid");
  3847. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3848. string shopname = GetPostString("shopname");
  3849. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3850. string buyernick = GetPostString("buyer_nick");
  3851. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3852. string customer = GetPostString("customer");
  3853. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3854. string design = GetPostString("design");
  3855. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3856. string orderState = GetPostString("orderState");
  3857. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3858. string address = GetPostString("address");
  3859. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3860. string sellermemo = GetPostString("seller_memo");
  3861. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3862. string supplier = GetPostString("supplier");
  3863. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3864. string OrderArea = GetPostString("order_area");
  3865. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3866. string date1 = GetPostString("date1");
  3867. string date2 = GetPostString("date2");
  3868. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3869. if (dw.Length > 0) lw.Add(dw);
  3870. string price1 = GetPostString("price1");
  3871. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3872. string price2 = GetPostString("price2");
  3873. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3874. string posTag = CurrentUser.UserPost.Post.Code;
  3875. if (posTag == "Supplier")
  3876. {
  3877. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3878. }
  3879. //lw.Add(string.Format("OrderState = 6 "));
  3880. lw.Add(string.Format("IsSample={0}", 3));
  3881. lw.Add(string.Format("IsRefund<={0}", 1));
  3882. dStruct.Order = "pay_time desc";
  3883. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3884. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3885. writeGridDataTableJson(dStruct.TotalCount, dt);
  3886. }
  3887. public void save_erp_checkmemo()
  3888. {
  3889. if (UrlPostParmsCheck("ctid"))
  3890. {
  3891. string ctid = GetPostString("ctid");
  3892. CeErpTradeCell entity = null;
  3893. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3894. if (entity != null)
  3895. {
  3896. entity.CheckMemo = GetPostString("CheckMemo");
  3897. entity.Update();
  3898. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3899. if (trade != null)
  3900. {
  3901. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3902. }
  3903. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3904. returnSuccessMsg("保存成功!");
  3905. return;
  3906. }
  3907. returnErrorMsg("找不到记录");
  3908. }
  3909. }
  3910. public void get_erp_returnlist()
  3911. {
  3912. DataStruct dStruct = GetPostStruct();
  3913. List<string> lw = new List<string>();
  3914. string tid = GetPostString("ctid");
  3915. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3916. string shopname = GetPostString("shopname");
  3917. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3918. string buyernick = GetPostString("buyer_nick");
  3919. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3920. string customer = GetPostString("customer");
  3921. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3922. string design = GetPostString("design");
  3923. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3924. string orderState = GetPostString("orderState");
  3925. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3926. string address = GetPostString("address");
  3927. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3928. string sellermemo = GetPostString("seller_memo");
  3929. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3930. string supplier = GetPostString("supplier");
  3931. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3932. string date1 = GetPostString("date1");
  3933. string date2 = GetPostString("date2");
  3934. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3935. if (dw.Length > 0) lw.Add(dw);
  3936. string bdate1 = GetPostString("backdate1");
  3937. string bdate2 = GetPostString("backdate2");
  3938. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3939. if (dw_back.Length > 0) lw.Add(dw_back);
  3940. string price1 = GetPostString("price1");
  3941. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3942. string price2 = GetPostString("price2");
  3943. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3944. lw.Add(string.Format("IsReturn>0"));
  3945. lw.Add(string.Format("IsXianHuo=0"));
  3946. lw.Add(string.Format("IsReturn!=3"));
  3947. string backtype = GetPostString("backtype");
  3948. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3949. dStruct.Order = "FinishDesignTime desc";
  3950. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3951. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3952. writeGridDataTableJson(dStruct.TotalCount, dt);
  3953. }
  3954. public void get_erp_today_sumreturn()
  3955. {
  3956. DataStruct dStruct = GetPostStruct();
  3957. List<string> lw = new List<string>();
  3958. string bdate1 = GetPostString("returnTimeS");
  3959. string bdate2 = GetPostString("returnTimeE");
  3960. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3961. if (dw_back.Length > 0) lw.Add(dw_back);
  3962. lw.Add(string.Format("IsReturn=0"));
  3963. lw.Add(string.Format("IsXianHuo=0"));
  3964. string mainWhere = string.Join(" and ", lw.ToArray());
  3965. string sql = "";
  3966. if (dw_back.Length > 0)
  3967. {
  3968. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  3969. }
  3970. else
  3971. {
  3972. 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 + "'";
  3973. }
  3974. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3975. decimal total = 0, today_finish = 0;
  3976. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  3977. {
  3978. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  3979. }
  3980. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  3981. {
  3982. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  3983. }
  3984. var res = new
  3985. {
  3986. data = total,
  3987. data1 = today_finish,
  3988. };
  3989. string ro_jsond = JsonConvert.SerializeObject(res);
  3990. returnSuccess(ro_jsond);
  3991. return;
  3992. }
  3993. public void get_erp_allreturnlist()
  3994. {
  3995. DataStruct dStruct = GetPostStruct();
  3996. List<string> lw = new List<string>();
  3997. string tid = GetPostString("ctid");
  3998. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3999. string shopname = GetPostString("shopname");
  4000. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4001. string buyernick = GetPostString("buyer_nick");
  4002. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4003. string customer = GetPostString("customer");
  4004. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4005. string design = GetPostString("design");
  4006. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4007. string orderState = GetPostString("orderState");
  4008. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4009. string address = GetPostString("address");
  4010. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4011. string sellermemo = GetPostString("seller_memo");
  4012. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4013. string supplier = GetPostString("supplier");
  4014. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4015. string date1 = GetPostString("date1");
  4016. string date2 = GetPostString("date2");
  4017. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4018. if (dw.Length > 0) lw.Add(dw);
  4019. string bdate1 = GetPostString("backdate1");
  4020. string bdate2 = GetPostString("backdate2");
  4021. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4022. if (dw_back.Length > 0) lw.Add(dw_back);
  4023. string price1 = GetPostString("price1");
  4024. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4025. string price2 = GetPostString("price2");
  4026. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4027. string backreason = GetPostString("backreason");
  4028. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4029. lw.Add(string.Format("IsXianHuo=0"));
  4030. lw.Add(string.Format("ReturnTime != ''"));
  4031. string backtype = GetPostString("backtype");
  4032. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4033. dStruct.Order = "FinishDesignTime desc";
  4034. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4035. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4036. writeGridDataTableJson(dStruct.TotalCount, dt);
  4037. }
  4038. public void get_erp_aftersalereturnlist()
  4039. {
  4040. DataStruct dStruct = GetPostStruct();
  4041. List<string> lw = new List<string>();
  4042. string tid = GetPostString("ctid");
  4043. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4044. string shopname = GetPostString("shopname");
  4045. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4046. string buyernick = GetPostString("buyer_nick");
  4047. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4048. string customer = GetPostString("customer");
  4049. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4050. string design = GetPostString("design");
  4051. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4052. string orderState = GetPostString("orderState");
  4053. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4054. string address = GetPostString("address");
  4055. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4056. string sellermemo = GetPostString("seller_memo");
  4057. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4058. string supplier = GetPostString("supplier");
  4059. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4060. string date1 = GetPostString("date1");
  4061. string date2 = GetPostString("date2");
  4062. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4063. if (dw.Length > 0) lw.Add(dw);
  4064. string bdate1 = GetPostString("backdate1");
  4065. string bdate2 = GetPostString("backdate2");
  4066. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4067. if (dw_back.Length > 0) lw.Add(dw_back);
  4068. string price1 = GetPostString("price1");
  4069. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4070. string price2 = GetPostString("price2");
  4071. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4072. lw.Add(string.Format("IsReturn=3"));
  4073. string backtype = GetPostString("backtype");
  4074. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4075. string backreason = GetPostString("backreason");
  4076. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4077. dStruct.Order = "ReturnTime desc";
  4078. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4079. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4080. writeGridDataTableJson(dStruct.TotalCount, dt);
  4081. }
  4082. public void get_erp_xianhuoreturnlist()
  4083. {
  4084. DataStruct dStruct = GetPostStruct();
  4085. List<string> lw = new List<string>();
  4086. string tid = GetPostString("ctid");
  4087. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4088. string shopname = GetPostString("shopname");
  4089. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4090. string buyernick = GetPostString("buyer_nick");
  4091. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4092. string customer = GetPostString("customer");
  4093. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4094. string design = GetPostString("design");
  4095. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4096. string orderState = GetPostString("orderState");
  4097. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4098. string address = GetPostString("address");
  4099. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4100. string sellermemo = GetPostString("seller_memo");
  4101. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4102. string supplier = GetPostString("supplier");
  4103. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4104. string OrderArea = GetPostString("order_area");
  4105. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4106. string date1 = GetPostString("date1");
  4107. string date2 = GetPostString("date2");
  4108. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4109. if (dw.Length > 0) lw.Add(dw);
  4110. string price1 = GetPostString("price1");
  4111. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4112. string price2 = GetPostString("price2");
  4113. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4114. string posTag = CurrentUser.UserPost.Post.Code;
  4115. if (posTag == "Supplier")
  4116. {
  4117. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4118. }
  4119. lw.Add(string.Format("OrderState=6 "));
  4120. lw.Add(string.Format("IsXianHuo=1 "));
  4121. lw.Add(string.Format("IsReturn>0 "));
  4122. lw.Add(string.Format("IsReturn!=3"));
  4123. lw.Add(string.Format("IsRefund<={0}", 1));
  4124. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4125. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4126. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4127. writeGridDataTableJson(dStruct.TotalCount, dt);
  4128. }
  4129. public void set_erp_orderdelivery()
  4130. {
  4131. if (UrlPostParmsCheck("ctid"))
  4132. {
  4133. string eid = GetPostString("ctid");
  4134. CeErpTradeCell entity = null;
  4135. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4136. if (entity != null)
  4137. {
  4138. if (entity.OrderState >= 7)
  4139. {
  4140. returnErrorMsg("此单已发货,无需重复发货");
  4141. return;
  4142. }
  4143. if (entity.OrderState != 6)
  4144. {
  4145. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4146. return;
  4147. }
  4148. string shop = GetPostString("seller_nick");
  4149. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4150. string comName = GetPostString("comName");
  4151. string comCode = GetPostString("comCode");
  4152. string outSid = GetPostString("outSid");
  4153. string deliveryType = GetPostString("deliveryType");
  4154. string deliveryMemo = GetPostString("deliveryMemo");
  4155. outSid = outSid.Trim();
  4156. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4157. if (mainEn == null)
  4158. {
  4159. returnErrorMsg("找不到原始订单记录");
  4160. return;
  4161. }
  4162. bool isInitOrderDeliv = false;
  4163. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4164. {
  4165. isInitOrderDeliv = true;
  4166. }
  4167. string apires = "";
  4168. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4169. 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)
  4170. {
  4171. apires = "发货成功true";
  4172. }
  4173. else
  4174. {
  4175. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4176. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4177. }
  4178. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4179. {
  4180. entity.OrderState = 7;//发货后订单已发货
  4181. entity.OutSid = outSid;
  4182. entity.MemoOpt = 0;
  4183. entity.FinishDeliveryTime = DateTime.Now;
  4184. entity.Update();
  4185. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4186. commonHelper.UpdateRelationOrder(entity.ctid);
  4187. //还要插入快递信息到 快递信息表
  4188. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4189. exinfo.tid = eid;
  4190. exinfo.out_sid = outSid;
  4191. exinfo.company_code = comCode;
  4192. exinfo.company_name = comName;
  4193. exinfo.delivery_memo = deliveryMemo;
  4194. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4195. exinfo.deliveryType = deliveryType;
  4196. exinfo.Create();
  4197. returnSuccessMsg("发货操作成功!");
  4198. commonHelper.UpdateRelationOrder(entity.ctid);
  4199. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4200. CeErpSukuraData.createInfo(entity.ctid, 4);
  4201. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4202. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4203. }
  4204. else
  4205. {
  4206. string errmsg = commonHelper.KeepChinese(apires);
  4207. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4208. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4209. }
  4210. return;
  4211. }
  4212. returnErrorMsg("找不到订单记录");
  4213. }
  4214. }
  4215. public void set_erp_multidelivery()
  4216. {
  4217. string eids = GetPostString("tids");
  4218. string[] eidList = eids.Split(',');
  4219. if (eidList.Length <= 0)
  4220. {
  4221. returnErrorMsg("发货不能为空");
  4222. return;
  4223. }
  4224. foreach (string ctid in eidList)
  4225. {
  4226. if (ctid.Length <= 0) continue;
  4227. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4228. if (expInfo != null)
  4229. {
  4230. StringBuilder sql = new StringBuilder();
  4231. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4232. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4233. if (dt.Rows.Count > 0)
  4234. {
  4235. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4236. {
  4237. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4238. expInfo.state = "异常";
  4239. expInfo.isMultiDelivery = 1;
  4240. expInfo.Update();
  4241. continue;
  4242. }
  4243. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4244. {
  4245. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4246. expInfo.state = "异常";
  4247. expInfo.Update();
  4248. continue;
  4249. }
  4250. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4251. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4252. bool isInitOrderDeliv = false;
  4253. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4254. {
  4255. isInitOrderDeliv = true;
  4256. expInfo.isMultiDelivery = 1;
  4257. }
  4258. if (ctid.IndexOf("N") != -1)
  4259. {
  4260. StringBuilder sqlbucha = new StringBuilder();
  4261. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4262. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4263. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4264. commonHelper.UpdateRelationOrder(ctid);
  4265. expInfo.delivery_memo = "发货成功";
  4266. expInfo.state = "发货成功";
  4267. expInfo.isMultiDelivery = 1;
  4268. expInfo.Update();
  4269. }
  4270. else
  4271. {
  4272. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4273. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4274. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4275. {
  4276. expInfo.delivery_memo = "发货成功";
  4277. expInfo.state = "发货成功";
  4278. expInfo.isMultiDelivery = 1;
  4279. expInfo.Update();
  4280. commonHelper.UpdateRelationOrder(ctid);
  4281. CeErpSukuraData.createInfo(ctid, 4);
  4282. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4283. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4284. }
  4285. else
  4286. {
  4287. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4288. expInfo.state = "异常";
  4289. expInfo.Update();
  4290. }
  4291. }
  4292. }
  4293. }
  4294. }
  4295. returnSuccessMsg("操作完成");
  4296. }
  4297. public void reset_erp_memoopt()
  4298. {
  4299. if (UrlPostParmsCheck("ctid"))
  4300. {
  4301. string eid = GetPostString("ctid");
  4302. CeErpTradeCell entity = null;
  4303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4304. if (entity != null)
  4305. {
  4306. string stropt = "";
  4307. if (entity.MemoOpt == 1)
  4308. {
  4309. stropt = "“改稿”";
  4310. }
  4311. else if (entity.MemoOpt == 2)
  4312. {
  4313. stropt = "“定稿”";
  4314. }
  4315. else if (entity.MemoOpt == 3)
  4316. {
  4317. stropt = "“完成查货”";
  4318. CeErpSukuraData.createInfo(entity.ctid, 6);
  4319. }
  4320. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4321. entity.MemoOpt = 0;
  4322. entity.Update();
  4323. returnSuccessMsg("操作成功!");
  4324. return;
  4325. }
  4326. returnErrorMsg("找不到记录");
  4327. }
  4328. }
  4329. public void get_erp_deliveryunusual()
  4330. {
  4331. DataStruct dStruct = GetPostStruct();
  4332. List<string> lw = new List<string>();
  4333. string tid = GetPostString("ctid");
  4334. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4335. string shopname = GetPostString("shopname");
  4336. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4337. string buyernick = GetPostString("buyer_nick");
  4338. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4339. string customer = GetPostString("customer");
  4340. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4341. string design = GetPostString("design");
  4342. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4343. string sellermemo = GetPostString("seller_memo");
  4344. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4345. string supplier = GetPostString("supplier");
  4346. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4347. string date1 = GetPostString("date1");
  4348. string date2 = GetPostString("date2");
  4349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4350. if (dw.Length > 0) lw.Add(dw);
  4351. string placedate1 = GetPostString("placedate1");
  4352. string placedate2 = GetPostString("placedate2");
  4353. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4354. if (dw_place.Length > 0) lw.Add(dw_place);
  4355. string price1 = GetPostString("price1");
  4356. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4357. string price2 = GetPostString("price2");
  4358. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4359. string unusualCon = GetPostString("unusualcon");
  4360. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4361. string posTag = CurrentUser.UserPost.Post.Code;
  4362. if (posTag == "Supplier")
  4363. {
  4364. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4365. }
  4366. lw.Add(string.Format("OrderState = 6"));
  4367. lw.Add(string.Format("UnusualTag = 5"));
  4368. lw.Add(string.Format("IsRefund<={0}", 1));
  4369. dStruct.Order = "FinishPlaceTime desc";
  4370. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4371. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4372. writeGridDataTableJson(dStruct.TotalCount, dt);
  4373. }
  4374. public void get_erp_deliveryedlist()
  4375. {
  4376. DataStruct dStruct = GetPostStruct();
  4377. List<string> lw = new List<string>();
  4378. string tid = GetPostString("ctid");
  4379. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4380. string shopname = GetPostString("shopname");
  4381. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4382. string buyernick = GetPostString("buyer_nick");
  4383. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4384. string customer = GetPostString("customer");
  4385. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4386. string design = GetPostString("design");
  4387. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4388. string sellermemo = GetPostString("seller_memo");
  4389. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4390. string logistics = GetPostString("logistics");
  4391. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4392. string date1 = GetPostString("date1");
  4393. string date2 = GetPostString("date2");
  4394. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4395. //if (dw.Length > 0) lw.Add(dw);
  4396. string placedate1 = GetPostString("placedate1");
  4397. string placedate2 = GetPostString("placedate2");
  4398. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4399. if (fdw.Length > 0) lw.Add(fdw);
  4400. string devdate1 = GetPostString("deliverydate1");
  4401. string devdate2 = GetPostString("deliverydate2");
  4402. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4403. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4404. string price1 = GetPostString("price1");
  4405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4406. string price2 = GetPostString("price2");
  4407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4408. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4409. {
  4410. if (tid.Length > 0)
  4411. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4412. if (buyernick.Length > 0)
  4413. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4414. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4415. if (dw.Length > 0) lw.Add(dw);
  4416. }
  4417. else
  4418. {
  4419. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4420. }
  4421. string posTag = CurrentUser.UserPost.Post.Code;
  4422. if (posTag == "Supplier")
  4423. {
  4424. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4425. }
  4426. else
  4427. {
  4428. string supplier = GetPostString("supplier");
  4429. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4430. }
  4431. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4432. lw.Add(string.Format("IsRefund!={0}", 2));
  4433. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4434. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4435. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4436. if (dt != null)
  4437. {
  4438. foreach (DataRow dr in dt.Rows)
  4439. {
  4440. 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();
  4441. }
  4442. }
  4443. writeGridDataTableJson(dStruct.TotalCount, dt);
  4444. }
  4445. public void get_erp_pdddeliveryed()
  4446. {
  4447. DataStruct dStruct = GetPostStruct();
  4448. List<string> lw = new List<string>();
  4449. string tid = GetPostString("ctid");
  4450. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4451. string shopname = GetPostString("shopname");
  4452. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4453. string buyernick = GetPostString("buyer_nick");
  4454. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4455. string customer = GetPostString("customer");
  4456. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4457. string design = GetPostString("design");
  4458. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4459. string sellermemo = GetPostString("seller_memo");
  4460. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4461. string logistics = GetPostString("logistics");
  4462. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4463. string date1 = GetPostString("date1");
  4464. string date2 = GetPostString("date2");
  4465. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4466. //if (dw.Length > 0) lw.Add(dw);
  4467. string placedate1 = GetPostString("placedate1");
  4468. string placedate2 = GetPostString("placedate2");
  4469. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4470. if (fdw.Length > 0) lw.Add(fdw);
  4471. string devdate1 = GetPostString("deliverydate1");
  4472. string devdate2 = GetPostString("deliverydate2");
  4473. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4474. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4475. string price1 = GetPostString("price1");
  4476. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4477. string price2 = GetPostString("price2");
  4478. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4479. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4480. {
  4481. if (tid.Length > 0)
  4482. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4483. if (buyernick.Length > 0)
  4484. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4485. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4486. if (dw.Length > 0) lw.Add(dw);
  4487. }
  4488. else
  4489. {
  4490. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4491. }
  4492. string posTag = CurrentUser.UserPost.Post.Code;
  4493. if (posTag == "Supplier")
  4494. {
  4495. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4496. }
  4497. else
  4498. {
  4499. string supplier = GetPostString("supplier");
  4500. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4501. }
  4502. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4503. lw.Add(string.Format("type = 'PDD' "));
  4504. lw.Add(string.Format("IsRefund!={0}", 2));
  4505. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4507. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4508. foreach (DataRow dr in dt.Rows)
  4509. {
  4510. 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();
  4511. }
  4512. writeGridDataTableJson(dStruct.TotalCount, dt);
  4513. }
  4514. public void get_erp_jddeliveryed()
  4515. {
  4516. DataStruct dStruct = GetPostStruct();
  4517. List<string> lw = new List<string>();
  4518. string tid = GetPostString("ctid");
  4519. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4520. string shopname = GetPostString("shopname");
  4521. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4522. string buyernick = GetPostString("buyer_nick");
  4523. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4524. string customer = GetPostString("customer");
  4525. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4526. string design = GetPostString("design");
  4527. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4528. string sellermemo = GetPostString("seller_memo");
  4529. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4530. string date1 = GetPostString("date1");
  4531. string date2 = GetPostString("date2");
  4532. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4533. //if (dw.Length > 0) lw.Add(dw);
  4534. string placedate1 = GetPostString("placedate1");
  4535. string placedate2 = GetPostString("placedate2");
  4536. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4537. if (fdw.Length > 0) lw.Add(fdw);
  4538. string devdate1 = GetPostString("deliverydate1");
  4539. string devdate2 = GetPostString("deliverydate2");
  4540. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4541. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4542. string price1 = GetPostString("price1");
  4543. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4544. string price2 = GetPostString("price2");
  4545. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4546. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4547. {
  4548. if (tid.Length > 0)
  4549. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4550. if (buyernick.Length > 0)
  4551. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4552. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4553. if (dw.Length > 0) lw.Add(dw);
  4554. }
  4555. else
  4556. {
  4557. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4558. }
  4559. string posTag = CurrentUser.UserPost.Post.Code;
  4560. if (posTag == "Supplier")
  4561. {
  4562. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4563. }
  4564. else
  4565. {
  4566. string supplier = GetPostString("supplier");
  4567. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4568. }
  4569. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4570. lw.Add(string.Format("type = 'JD' "));
  4571. lw.Add(string.Format("IsRefund!={0}", 2));
  4572. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4573. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4574. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4575. foreach (DataRow dr in dt.Rows)
  4576. {
  4577. 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();
  4578. }
  4579. writeGridDataTableJson(dStruct.TotalCount, dt);
  4580. }
  4581. public void get_erp_allplacelist()
  4582. {
  4583. DataStruct dStruct = GetPostStruct();
  4584. List<string> lw = new List<string>();
  4585. string tid = GetPostString("ctid");
  4586. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4587. string shopname = GetPostString("shopname");
  4588. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4589. string buyernick = GetPostString("buyer_nick");
  4590. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4591. string customer = GetPostString("customer");
  4592. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4593. string design = GetPostString("design");
  4594. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4595. string sellermemo = GetPostString("seller_memo");
  4596. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4597. string supplier = GetPostString("supplier");
  4598. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4599. string date1 = GetPostString("date1");
  4600. string date2 = GetPostString("date2");
  4601. string pldate1 = GetPostString("placedate1");
  4602. string pldate2 = GetPostString("placedate2");
  4603. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4604. //if (dw.Length > 0) lw.Add(dw);
  4605. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4606. {
  4607. if (tid.Length > 0)
  4608. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4609. if (buyernick.Length > 0)
  4610. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4611. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4612. if (dw.Length > 0) lw.Add(dw);
  4613. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4614. if (dw_place.Length > 0) lw.Add(dw_place);
  4615. }
  4616. else
  4617. {
  4618. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4619. {
  4620. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4621. }
  4622. }
  4623. string price1 = GetPostString("price1");
  4624. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4625. string price2 = GetPostString("price2");
  4626. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4627. string posTag = CurrentUser.UserPost.Post.Code;
  4628. if (posTag == "Supplier")
  4629. {
  4630. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4631. }
  4632. lw.Add(string.Format("OrderState >= 6"));
  4633. lw.Add(string.Format("IsSample != 2 "));
  4634. lw.Add(string.Format("isDianziOrder = 0 "));
  4635. //lw.Add(string.Format("IsRefund<={0}", 1));
  4636. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4637. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4638. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4639. foreach (DataRow dr in dt.Rows)
  4640. {
  4641. 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();
  4642. }
  4643. writeGridDataTableJson(dStruct.TotalCount, dt);
  4644. }
  4645. public void get_erp_financeallplacelist()
  4646. {
  4647. DataStruct dStruct = GetPostStruct();
  4648. List<string> lw = new List<string>();
  4649. string tid = GetPostString("ctid");
  4650. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4651. string shopname = GetPostString("shopname");
  4652. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4653. string buyernick = GetPostString("buyer_nick");
  4654. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4655. string customer = GetPostString("customer");
  4656. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4657. string design = GetPostString("design");
  4658. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4659. string sellermemo = GetPostString("seller_memo");
  4660. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4661. string supplier = GetPostString("supplier");
  4662. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4663. string date1 = GetPostString("date1");
  4664. string date2 = GetPostString("date2");
  4665. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4666. if (dw.Length > 0) lw.Add(dw);
  4667. string pldate1 = GetPostString("placedate1");
  4668. string pldate2 = GetPostString("placedate2");
  4669. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4670. if (dw_place.Length > 0) lw.Add(dw_place);
  4671. string price1 = GetPostString("price1");
  4672. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4673. string price2 = GetPostString("price2");
  4674. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4675. string posTag = CurrentUser.UserPost.Post.Code;
  4676. if (posTag == "Supplier")
  4677. {
  4678. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4679. }
  4680. //lw.Add(string.Format("OrderState >= 6"));
  4681. lw.Add(string.Format("IsSample != 2 "));
  4682. lw.Add(string.Format("isDianziOrder = 0 "));
  4683. //lw.Add(string.Format("IsRefund<={0}", 1));
  4684. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4685. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4686. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4687. foreach (DataRow dr in dt.Rows)
  4688. {
  4689. 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();
  4690. }
  4691. writeGridDataTableJson(dStruct.TotalCount, dt);
  4692. }
  4693. public void get_erp_expresslist()
  4694. {
  4695. int listtype = GetInt("ltype");
  4696. DataStruct dStruct = GetPostStruct();
  4697. List<string> lw = new List<string>();
  4698. string tid = GetPostString("tid");
  4699. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4700. string outsid = GetPostString("out_sid");
  4701. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4702. string importer = GetPostString("ImportUserName");
  4703. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4704. string file = GetPostString("import_file");
  4705. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4706. string printman = GetPostString("printman");
  4707. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4708. string date1 = GetPostString("date1");
  4709. string date2 = GetPostString("date2");
  4710. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4711. if (dw.Length > 0) lw.Add(dw);
  4712. string fdate1 = GetPostString("finishdate1");
  4713. string fdate2 = GetPostString("finishdate2");
  4714. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4715. if (fdw.Length > 0) lw.Add(fdw);
  4716. if (listtype == 1)
  4717. {
  4718. lw.Add(string.Format("importUserId !=0"));
  4719. }
  4720. string posTag = CurrentUser.UserPost.Post.Code;
  4721. if (posTag == "Supplier")
  4722. {
  4723. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4724. }
  4725. if (dStruct.PageSize != 100000)
  4726. {
  4727. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4728. }
  4729. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4730. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4731. writeGridDataTableJson(dStruct.TotalCount, dt);
  4732. }
  4733. public void set_erp_buchaorderdelivery()
  4734. {
  4735. if (UrlPostParmsCheck("ctid"))
  4736. {
  4737. string eid = GetPostString("ctid");
  4738. CeErpTradeCell entity = null;
  4739. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4740. if (entity != null)
  4741. {
  4742. if (entity.IsSample != 2)
  4743. {
  4744. returnErrorMsg("补差价单才能标记为已发货");
  4745. return;
  4746. }
  4747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4748. entity.OrderState = 7;
  4749. entity.Update();
  4750. returnSuccessMsg("操作成功!");
  4751. return;
  4752. }
  4753. returnErrorMsg("找不到记录");
  4754. }
  4755. }
  4756. public void get_stdtemplates()
  4757. {
  4758. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4759. //string res = taobaoHelper.test();
  4760. string res = apiHelper.API_PrintTemplate();
  4761. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4762. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4763. {
  4764. int sidx = res.IndexOf("error_code");
  4765. int eidx = res.IndexOf("success");
  4766. string msg = res.Substring(sidx, eidx - sidx);
  4767. returnErrorMsg(msg);
  4768. return;
  4769. }
  4770. if (res.Length <= 0)
  4771. {
  4772. returnErrorMsg("模板数据为空!");
  4773. return;
  4774. }
  4775. ReturnSuccess(res);
  4776. }
  4777. public void cancel_print_order()
  4778. {
  4779. if (UrlPostParmsCheck("ctid"))
  4780. {
  4781. string ctid = GetPostString("ctid");
  4782. CeErpTradeCell entity = null;
  4783. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4784. if (entity != null)
  4785. {
  4786. string res = "";
  4787. string code = entity.LastBillWaybillCode;
  4788. if (code == "")
  4789. {
  4790. code = entity.OutSid;
  4791. }
  4792. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4793. XLog.SaveLog(0, "取消面单" + res);
  4794. }
  4795. }
  4796. }
  4797. public void set_erp_printwaybill()
  4798. {
  4799. if (UrlPostParmsCheck("ctid"))
  4800. {
  4801. string ctid = GetPostString("ctid");
  4802. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4803. string cpName = GetPostString("cpname");
  4804. string isTogether = GetPostString("together");
  4805. //var res_obj = new
  4806. //{
  4807. // restype = 1,
  4808. // 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\"}"
  4809. //};
  4810. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4811. //ReturnSuccess(ro_json);
  4812. //return;
  4813. bool isUseLastWayBillCode = false;
  4814. CeErpTradeCell entity = null;
  4815. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4816. if (entity != null)
  4817. {
  4818. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4819. {
  4820. isUseLastWayBillCode = true;
  4821. }
  4822. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4823. {
  4824. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4825. return;
  4826. }
  4827. }
  4828. string res = "";
  4829. Api_waybill_code_response_Obj fullObj = null;
  4830. string pData_str = "";
  4831. string curUseWayBillCode = "";
  4832. if (isUseLastWayBillCode == false)
  4833. {
  4834. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4835. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4836. if (res.IndexOf("failure") != -1)
  4837. {
  4838. //int idx = res.IndexOf("sub_message");
  4839. //int idx2 = res.IndexOf("flag");
  4840. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4841. string errMsgNeed = commonHelper.KeepChinese(res);
  4842. var res_objd = new
  4843. {
  4844. restype = 0,
  4845. data = "获取面单失败" + errMsgNeed
  4846. };
  4847. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4848. returnSuccess(ro_jsond);
  4849. if (res.IndexOf("停发") != -1)
  4850. {
  4851. entity.UnusualCon = "物流停发";
  4852. entity.Update();
  4853. }
  4854. //returnErrorMsg("获取面单失败,"+emsg);
  4855. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4856. return;
  4857. }
  4858. else if (res.IndexOf("errorMsg") != -1)
  4859. {
  4860. //int idx = res.IndexOf("errorMsg");
  4861. //int idx2 = res.IndexOf("}]}");
  4862. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4863. string errMsgNeed = commonHelper.KeepChinese(res);
  4864. var res_objf = new
  4865. {
  4866. restype = 0,
  4867. data = "获取面单失败2" + errMsgNeed
  4868. };
  4869. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4870. if (res.IndexOf("停发") != -1)
  4871. {
  4872. entity.UnusualCon = "物流停发";
  4873. entity.Update();
  4874. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4875. if (trade != null)
  4876. {
  4877. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4878. }
  4879. }
  4880. returnSuccess(ro_jsonf);
  4881. //returnErrorMsg("获取面单失败," + emsg);
  4882. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4883. return;
  4884. }
  4885. try
  4886. {
  4887. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4888. //res = res.Replace(" ", "");
  4889. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4890. }
  4891. catch (Exception ex)
  4892. {
  4893. XLog.SaveLog(0, "生成fullObj" + res);
  4894. var res_objf = new
  4895. {
  4896. restype = 0,
  4897. data = "生成fullObj发生错误" + ex.Message
  4898. };
  4899. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4900. returnSuccess(ro_jsonf);
  4901. return;
  4902. }
  4903. if (fullObj.response.data.content.Count > 0)
  4904. {
  4905. ContentItem codeObj = fullObj.response.data.content[0];
  4906. if (cpCode.IndexOf("SFFQ-") != -1)
  4907. {
  4908. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4909. }
  4910. else
  4911. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4912. curUseWayBillCode = codeObj.waybillCode;
  4913. }
  4914. else
  4915. {
  4916. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4917. var res_objf = new
  4918. {
  4919. restype = 0,
  4920. data = "生成fullObj找不到快递单号waybillCode"
  4921. };
  4922. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4923. returnSuccess(ro_jsonf);
  4924. return;
  4925. }
  4926. }
  4927. else
  4928. {
  4929. //使用上次打印的快递单号
  4930. if (cpCode == "SFFQ-LY")
  4931. {
  4932. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4933. }
  4934. else
  4935. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4936. curUseWayBillCode = entity.LastBillWaybillCode;
  4937. }
  4938. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4939. {
  4940. var res_obje = new
  4941. {
  4942. restype = 0,
  4943. data = "获取加密打印数据失败"
  4944. };
  4945. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4946. returnSuccess(ro_jsone);
  4947. entity.LastBillCpCode = cpCode;
  4948. entity.LastBillWaybillCode = curUseWayBillCode;
  4949. entity.Update();
  4950. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4951. //returnErrorMsg("获取加密打印数据失败");
  4952. return;
  4953. }
  4954. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4955. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4956. string btnType = "";
  4957. if (entity != null)
  4958. {
  4959. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4960. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4961. //cpcode是 YTO-CAINIAO
  4962. //string comCode = cpCode.Split('-')[0].ToString();
  4963. string apires = "";
  4964. if (ctid.IndexOf("N") != -1)
  4965. {
  4966. apires = "发货成功";
  4967. }
  4968. else
  4969. {
  4970. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4971. }
  4972. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  4973. //打单后发货
  4974. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  4975. {
  4976. try
  4977. {
  4978. btnType = "待发货";
  4979. entity.OutSid = curUseWayBillCode;
  4980. entity.OrderState = 7;
  4981. entity.IsUrgency = false;
  4982. entity.LastBillCpCode = "";
  4983. entity.LastBillWaybillCode = "";
  4984. entity.FinishDeliveryTime = DateTime.Now;
  4985. entity.IsReturn = 0;
  4986. entity.MemoOpt = 0;
  4987. entity.Update();
  4988. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  4989. //还要插入快递信息到 快递信息表
  4990. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4991. exinfo.tid = entity.ctid;
  4992. exinfo.out_sid = entity.OutSid;
  4993. exinfo.company_code = cpCode;
  4994. exinfo.company_name = cpName;
  4995. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4996. exinfo.deliveryType = "发货成功";
  4997. exinfo.print_time = DateTime.Now;
  4998. exinfo.printUser = CurrentUser.UserName;
  4999. exinfo.Create();
  5000. commonHelper.UpdateRelationOrder(entity.ctid);
  5001. CeErpSukuraData.createInfo(ctid, 4);
  5002. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5003. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5004. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5005. if (isTogether == "1")
  5006. {
  5007. StringBuilder sqlsb = new StringBuilder();
  5008. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5009. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5010. }
  5011. }
  5012. catch (Exception ex)
  5013. {
  5014. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5015. }
  5016. }
  5017. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5018. {
  5019. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5020. if (entity.OrderState == 6)
  5021. {
  5022. entity.OrderState = 7;
  5023. }
  5024. entity.FinishDeliveryTime = DateTime.Now;
  5025. btnType = "已发货";
  5026. entity.Update();
  5027. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5028. exinfo.tid = entity.ctid;
  5029. exinfo.out_sid = entity.OutSid;
  5030. exinfo.company_code = cpCode;
  5031. exinfo.company_name = cpName;
  5032. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5033. exinfo.deliveryType = "发货成功";
  5034. exinfo.print_time = DateTime.Now;
  5035. exinfo.printUser = CurrentUser.UserName;
  5036. exinfo.Create();
  5037. commonHelper.UpdateRelationOrder(entity.ctid);
  5038. CeErpSukuraData.createInfo(entity.ctid, 4);
  5039. if (isTogether == "1")
  5040. {
  5041. StringBuilder sqlsb = new StringBuilder();
  5042. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5043. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5044. }
  5045. //不处理
  5046. }
  5047. else
  5048. {
  5049. entity.LastBillCpCode = cpCode;
  5050. entity.LastBillWaybillCode = curUseWayBillCode;
  5051. entity.Update();
  5052. string errmsg = commonHelper.KeepChinese(apires);
  5053. var res_objz = new
  5054. {
  5055. restype = 0,
  5056. data = "打单后发货失败"
  5057. };
  5058. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5059. returnSuccess(ro_jsonz);
  5060. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5061. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5062. return;
  5063. }
  5064. }
  5065. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5066. var res_obj = new
  5067. {
  5068. restype = 1,
  5069. data = pData_str
  5070. };
  5071. string ro_json = JsonConvert.SerializeObject(res_obj);
  5072. ReturnSuccess(ro_json);
  5073. return;
  5074. }
  5075. }
  5076. private string GetUTF8String(byte[] vs)
  5077. {
  5078. throw new NotImplementedException();
  5079. }
  5080. public void set_erp_printwaybill_cn()
  5081. {
  5082. if (UrlPostParmsCheck("ctid"))
  5083. {
  5084. string ctid = GetPostString("ctid");
  5085. string cpCode = GetPostString("cpcode");
  5086. string cpName = GetPostString("cpname");
  5087. string tempUrl = GetPostString("tempurl");
  5088. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5089. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5090. //string res = taobaoHelper.test();
  5091. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5092. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5093. {
  5094. int sidx = res.IndexOf("errorMsg");
  5095. int eidx = res.IndexOf("}");
  5096. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5097. var res_objzxx = new
  5098. {
  5099. restype = 0,
  5100. data = msg
  5101. };
  5102. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5103. returnSuccess(ro_jsonzxx);
  5104. //returnErrorMsg(msg);
  5105. return;
  5106. }
  5107. int idx = res.IndexOf("waybillCode");
  5108. int idx2 = res.IndexOf("printData");
  5109. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5110. string eid = GetPostString("ctid");
  5111. CeErpTradeCell entity = null;
  5112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5113. if (entity != null)
  5114. {
  5115. string osid = entity.OutSid;
  5116. entity.OutSid = osid + "," + outsid;
  5117. entity.FinishDeliveryTime = DateTime.Now;
  5118. entity.OrderState = 7;
  5119. entity.IsReturn = 0;
  5120. entity.Update();
  5121. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5122. exinfo.tid = entity.ctid;
  5123. exinfo.out_sid = outsid;
  5124. exinfo.company_code = cpCode;
  5125. exinfo.company_name = cpName;
  5126. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5127. exinfo.deliveryType = "发货成功";
  5128. exinfo.print_time = DateTime.Now;
  5129. exinfo.printUser = CurrentUser.UserName;
  5130. exinfo.Create();
  5131. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5132. }
  5133. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5134. var res_objz = new
  5135. {
  5136. restype = 1,
  5137. data = res
  5138. };
  5139. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5140. returnSuccess(ro_jsonz);
  5141. //ReturnSuccess(res);
  5142. }
  5143. }
  5144. ////打单,打印面单 获取面单号
  5145. //public void set_erp_printwaybill()
  5146. //{
  5147. // if (UrlPostParmsCheck("ctid"))
  5148. // {
  5149. // string ctid = GetPostString("ctid");
  5150. // string cpCode = GetPostString("cpcode");
  5151. // string tempUrl = GetPostString("tempurl");
  5152. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5153. // //string res = taobaoHelper.test();
  5154. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5155. // if (res.IndexOf("error_response") != -1)
  5156. // {
  5157. // int sidx = res.IndexOf("sub_msg");
  5158. // int eidx = res.IndexOf("request_id");
  5159. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5160. // returnErrorMsg(msg);
  5161. // return;
  5162. // }
  5163. // int idx = res.IndexOf("waybill_code");
  5164. // int idx2 = res.IndexOf("}]}");
  5165. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5166. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5167. // ReturnSuccess(res);
  5168. // }
  5169. //}
  5170. public void cancel_erp_aftersale()
  5171. {
  5172. if (UrlPostParmsCheck("ctid"))
  5173. {
  5174. string eid = GetPostString("ctid");
  5175. CeErpTradeCell entity = null;
  5176. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5177. if (entity != null)
  5178. {
  5179. //有过处理的售后,取消也不能删除 售 字,保留
  5180. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5181. {
  5182. entity.AfterSaleState = 4;
  5183. }
  5184. else
  5185. entity.AfterSaleState = 0;
  5186. entity.Update();
  5187. returnSuccessMsg("操作成功!");
  5188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5189. return;
  5190. }
  5191. returnErrorMsg("找不到订单记录");
  5192. }
  5193. }
  5194. public void get_erp_aftersalelist()
  5195. {
  5196. DataStruct dStruct = GetPostStruct();
  5197. List<string> lw = new List<string>();
  5198. int st = GetInt("st");
  5199. string tid = GetPostString("ctid");
  5200. if (st == 3)
  5201. {
  5202. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5203. }
  5204. else
  5205. {
  5206. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5207. }
  5208. string shopname = GetPostString("shopname");
  5209. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5210. string buyernick = GetPostString("buyer_nick");
  5211. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5212. string sellermemo = GetPostString("seller_memo");
  5213. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5214. string orderState = GetPostString("orderState");
  5215. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5216. string afterState = GetPostString("afterstate");
  5217. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5218. string date1 = GetPostString("date1");
  5219. string date2 = GetPostString("date2");
  5220. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5221. if (dw.Length > 0) lw.Add(dw);
  5222. string price1 = GetPostString("price1");
  5223. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5224. string price2 = GetPostString("price2");
  5225. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5226. //lw.Add(string.Format("IsRefund!={0}", 1));
  5227. string reason = GetPostString("reason");
  5228. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5229. string method = GetPostString("method");
  5230. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5231. string handler = GetPostString("handler");
  5232. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5233. string handledate1 = GetPostString("handledate1");
  5234. string handledate2 = GetPostString("handledate2");
  5235. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5236. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5237. string finish1 = GetPostString("finishdate1");
  5238. string finish2 = GetPostString("finishdate2");
  5239. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5240. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5241. string afterdate1 = GetPostString("afterdate1");
  5242. string afterdate2 = GetPostString("afterdate2");
  5243. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5244. if (afterDate.Length > 0) lw.Add(afterDate);
  5245. string supplier = GetPostString("supplier");
  5246. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5247. string responsible = GetPostString("responsibleman");
  5248. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5249. string customer = GetPostString("customer");
  5250. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5251. string design = GetPostString("design");
  5252. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5253. string afterMemoType = GetPostString("aftermemotype");
  5254. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5255. string posCode = CurrentUser.UserPost.Post.Code;
  5256. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5257. //{
  5258. // string vstate = GetPostString("vstate");
  5259. // if (vstate.Length > 0)
  5260. // {
  5261. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5262. // }
  5263. // if (posCode == "Supplier")
  5264. // {
  5265. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5266. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5267. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5268. // }
  5269. // else
  5270. // {
  5271. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5272. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5273. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5274. // {
  5275. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5276. // }
  5277. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5278. // {
  5279. // int orgid = CurrentUser.UserPost.OrgID;
  5280. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5281. // }
  5282. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5283. // {
  5284. // string shopid = CurrentUser.User.pemShop;
  5285. // lw.Add(string.Format("shopId in ({0})", shopid));
  5286. // }
  5287. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5288. // //{
  5289. // // int org_id = CurrentUser.UserPost.OrgID;
  5290. // // lw.Add(string.Format("OrgID={0}", org_id));
  5291. // //}
  5292. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5293. // }
  5294. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5295. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5296. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5297. //}
  5298. if (st == 5)
  5299. {
  5300. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5301. {
  5302. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5303. {
  5304. string shopid = CurrentUser.User.pemShop;
  5305. lw.Add(string.Format("shopId in ({0})", shopid));
  5306. }
  5307. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5308. {
  5309. int mrOrgid = CurrentUser.UserPost.OrgID;
  5310. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5311. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5312. }
  5313. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5314. //{
  5315. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5316. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5317. //}
  5318. else
  5319. {
  5320. string userIdStr = "";
  5321. if (posCode == "CustomerService")
  5322. {
  5323. userIdStr = CurrentUser.UserID + "_k";
  5324. }
  5325. else if (posCode == "Designer" || posCode == "wxDesigner")
  5326. {
  5327. userIdStr = CurrentUser.UserID + "_s";
  5328. }
  5329. else if (posCode == "Place")
  5330. {
  5331. userIdStr = CurrentUser.UserID + "_x";
  5332. }
  5333. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5334. }
  5335. }
  5336. string placedate1 = GetPostString("placedate1");
  5337. string placedate2 = GetPostString("placedate2");
  5338. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5339. if (dwplace.Length > 0) lw.Add(dwplace);
  5340. string supState = GetPostString("supState");
  5341. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5342. string searchType = GetPostString("searchType");
  5343. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5344. {
  5345. lw.Add(string.Format("BackNum>1"));
  5346. }
  5347. lw.Add(string.Format("AfterSaleState>0"));
  5348. if (ex_psize > 0)
  5349. {
  5350. if (CurrentUser.UserPost.Post.Code == "Finance")
  5351. dStruct.Order = "pay_time desc";
  5352. else
  5353. dStruct.Order = "HandleTime desc";
  5354. }
  5355. else
  5356. dStruct.Order = "HandleTime desc";
  5357. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5358. DataTable dt = WebCache.GetData("view_test", dStruct);
  5359. writeGridDataTableJson(dStruct.TotalCount, dt);
  5360. }
  5361. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5362. //{
  5363. // lw.Add(string.Format("AfterSaleState=4"));
  5364. // string code = CurrentUser.UserPost.Post.Code;
  5365. // if (code == "CustomerService")
  5366. // {
  5367. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5368. // }
  5369. // else if (code == "Designer" || code == "DesignerMr")
  5370. // {
  5371. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5372. // }
  5373. // else if (code == "Place" || code == "PlaceMr")
  5374. // {
  5375. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5376. // }
  5377. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5378. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5379. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5380. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5381. //}
  5382. //else //处理中的售后,待处理和处理中合并
  5383. //{
  5384. // if (afterState.Length <= 0)
  5385. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5386. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5387. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5388. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5389. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5390. //}
  5391. }
  5392. public void get_erp_disagreeftersalelist()
  5393. {
  5394. DataStruct dStruct = GetPostStruct();
  5395. List<string> lw = new List<string>();
  5396. int st = 2;
  5397. string tid = GetPostString("ctid");
  5398. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5399. string shopname = GetPostString("shopname");
  5400. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5401. string buyernick = GetPostString("buyer_nick");
  5402. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5403. string sellermemo = GetPostString("seller_memo");
  5404. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5405. string orderState = GetPostString("orderState");
  5406. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5407. string afterState = GetPostString("afterstate");
  5408. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5409. string date1 = GetPostString("date1");
  5410. string date2 = GetPostString("date2");
  5411. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5412. if (dw.Length > 0) lw.Add(dw);
  5413. string price1 = GetPostString("price1");
  5414. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5415. string price2 = GetPostString("price2");
  5416. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5417. //lw.Add(string.Format("IsRefund!={0}", 1));
  5418. string reason = GetPostString("reason");
  5419. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5420. string method = GetPostString("method");
  5421. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5422. string handler = GetPostString("handler");
  5423. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5424. string handledate1 = GetPostString("handledate1");
  5425. string handledate2 = GetPostString("handledate2");
  5426. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5427. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5428. string afterdate1 = GetPostString("afterdate1");
  5429. string afterdate2 = GetPostString("afterdate2");
  5430. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5431. if (afterDate.Length > 0) lw.Add(afterDate);
  5432. string backdate1 = GetPostString("backdate1");
  5433. string backdate2 = GetPostString("backdate2");
  5434. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5435. if (backDate.Length > 0) lw.Add(backDate);
  5436. string supplier = GetPostString("supplier");
  5437. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5438. string responsible = GetPostString("responsibleman");
  5439. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5440. string customer = GetPostString("customer");
  5441. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5442. string design = GetPostString("design");
  5443. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5444. string afterSaleMemo = GetPostString("afterSaleMemo");
  5445. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5446. string afterMemoType = GetPostString("aftermemotype");
  5447. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5448. string aftersakereason = GetPostString("aftersakereason");
  5449. if (aftersakereason.Length > 0)
  5450. {
  5451. if (aftersakereason == "1")
  5452. {
  5453. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5454. }
  5455. if (aftersakereason == "2")
  5456. {
  5457. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5458. }
  5459. }
  5460. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5461. string poscode = CurrentUser.UserPost.Post.Code;
  5462. if (poscode != "SysAdmin")
  5463. {
  5464. string shopid = CurrentUser.User.pemShop;
  5465. lw.Add(string.Format("shopId in ({0})", shopid));
  5466. }
  5467. string searchType = GetPostString("searchType");
  5468. if (searchType == "wait")
  5469. {
  5470. lw.Add(string.Format("HandleTime is null"));
  5471. }
  5472. if (searchType == "handling")
  5473. {
  5474. lw.Add(string.Format("HandleTime is not null "));
  5475. }
  5476. if (searchType == "back" || searchType == "puBack")
  5477. {
  5478. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5479. }
  5480. if (searchType == "reBack")
  5481. {
  5482. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5483. }
  5484. if (searchType == "moreBack")
  5485. {
  5486. lw.Add(string.Format("backNum > 1"));
  5487. }
  5488. lw.Add(string.Format("(AfterSaleState=5)"));
  5489. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5490. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5491. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5492. writeGridDataTableJson(dStruct.TotalCount, dt);
  5493. }
  5494. public void get_erp_handlingaftersalelist()
  5495. {
  5496. DataStruct dStruct = GetPostStruct();
  5497. List<string> lw = new List<string>();
  5498. int st = 2;
  5499. string tid = GetPostString("ctid");
  5500. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5501. string shopname = GetPostString("shopname");
  5502. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5503. string buyernick = GetPostString("buyer_nick");
  5504. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5505. string sellermemo = GetPostString("seller_memo");
  5506. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5507. string orderState = GetPostString("orderState");
  5508. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5509. string afterState = GetPostString("afterstate");
  5510. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5511. string date1 = GetPostString("date1");
  5512. string date2 = GetPostString("date2");
  5513. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5514. if (dw.Length > 0) lw.Add(dw);
  5515. string price1 = GetPostString("price1");
  5516. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5517. string price2 = GetPostString("price2");
  5518. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5519. //lw.Add(string.Format("IsRefund!={0}", 1));
  5520. string reason = GetPostString("reason");
  5521. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5522. string method = GetPostString("method");
  5523. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5524. string handler = GetPostString("handler");
  5525. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5526. string handledate1 = GetPostString("handledate1");
  5527. string handledate2 = GetPostString("handledate2");
  5528. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5529. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5530. string afterdate1 = GetPostString("afterdate1");
  5531. string afterdate2 = GetPostString("afterdate2");
  5532. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5533. if (afterDate.Length > 0) lw.Add(afterDate);
  5534. string supplier = GetPostString("supplier");
  5535. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5536. string responsible = GetPostString("responsibleman");
  5537. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5538. string customer = GetPostString("customer");
  5539. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5540. string design = GetPostString("design");
  5541. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5542. string afterSaleMemo = GetPostString("afterSaleMemo");
  5543. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5544. string afterMemoType = GetPostString("aftermemotype");
  5545. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5546. string afterresult = GetPostString("afterresult");
  5547. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5548. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5549. string poscode = CurrentUser.UserPost.Post.Code;
  5550. if (poscode != "SysAdmin")
  5551. {
  5552. string shopid = CurrentUser.User.pemShop;
  5553. lw.Add(string.Format("shopId in ({0})", shopid));
  5554. }
  5555. string searchType = GetPostString("searchType");
  5556. if (searchType == "wait")
  5557. {
  5558. lw.Add(string.Format("HandleTime is null"));
  5559. }
  5560. if (searchType == "documentary")
  5561. {
  5562. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5563. }
  5564. if (searchType == "handling")
  5565. {
  5566. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5567. }
  5568. if (searchType == "back" || searchType == "puBack")
  5569. {
  5570. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5571. }
  5572. if (searchType == "reBack")
  5573. {
  5574. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5575. }
  5576. if (afterState.Length <= 0)
  5577. {
  5578. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5579. }
  5580. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5581. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5582. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5583. writeGridDataTableJson(dStruct.TotalCount, dt);
  5584. }
  5585. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5586. //public void get_erp_back_handlingaftersalelist()
  5587. //{
  5588. // DataStruct dStruct = GetPostStruct();
  5589. // List<string> lw = new List<string>();
  5590. // string tid = GetPostString("ctid");
  5591. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5592. // string shopname = GetPostString("shopname");
  5593. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5594. // string buyernick = GetPostString("buyer_nick");
  5595. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5596. // string sellermemo = GetPostString("seller_memo");
  5597. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5598. // string orderState = GetPostString("orderState");
  5599. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5600. // string afterState = GetPostString("afterstate");
  5601. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5602. // string date1 = GetPostString("date1");
  5603. // string date2 = GetPostString("date2");
  5604. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5605. // if (dw.Length > 0) lw.Add(dw);
  5606. // string price1 = GetPostString("price1");
  5607. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5608. // string price2 = GetPostString("price2");
  5609. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5610. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5611. // string reason = GetPostString("reason");
  5612. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5613. // string method = GetPostString("method");
  5614. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5615. // string handler = GetPostString("handler");
  5616. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5617. // string handledate1 = GetPostString("handledate1");
  5618. // string handledate2 = GetPostString("handledate2");
  5619. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5620. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5621. // string afterdate1 = GetPostString("afterdate1");
  5622. // string afterdate2 = GetPostString("afterdate2");
  5623. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5624. // if (afterDate.Length > 0) lw.Add(afterDate);
  5625. // string supplier = GetPostString("supplier");
  5626. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5627. // string responsible = GetPostString("responsibleman");
  5628. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5629. // string customer = GetPostString("customer");
  5630. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5631. // string design = GetPostString("design");
  5632. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5633. // string afterMemoType = GetPostString("aftermemotype");
  5634. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5635. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5636. // if (afterState.Length <= 0)
  5637. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5638. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5639. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5640. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5641. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5642. //}
  5643. public void get_erp_aftersaleverifylist()
  5644. {
  5645. DataStruct dStruct = GetPostStruct();
  5646. List<string> lw = new List<string>();
  5647. string tid = GetPostString("ctid");
  5648. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5649. string shopname = GetPostString("shopname");
  5650. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5651. string buyernick = GetPostString("buyer_nick");
  5652. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5653. string sellermemo = GetPostString("seller_memo");
  5654. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5655. string orderState = GetPostString("orderState");
  5656. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5657. //lw.Add(string.Format("IsRefund!={0}", 1));
  5658. string reason = GetPostString("reason");
  5659. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5660. string method = GetPostString("method");
  5661. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5662. string handler = GetPostString("handler");
  5663. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5664. string handledate1 = GetPostString("handledate1");
  5665. string handledate2 = GetPostString("handledate2");
  5666. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5667. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5668. string finish1 = GetPostString("finishdate1");
  5669. string finish2 = GetPostString("finishdate2");
  5670. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5671. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5672. string supplier = GetPostString("supplier");
  5673. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5674. string responsible = GetPostString("responsibleman");
  5675. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5676. string posCode = CurrentUser.UserPost.Post.Code;
  5677. string vstate = GetPostString("vstate");
  5678. if (vstate.Length > 0)
  5679. {
  5680. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5681. }
  5682. if (posCode == "Supplier")
  5683. {
  5684. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5685. lw.Add(string.Format("VerifyState = 0"));
  5686. lw.Add("type = 1");
  5687. lw.Add(string.Format("AfterSaleState={0}", 3));
  5688. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5689. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5690. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5691. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5692. writeGridDataTableJson(dStruct.TotalCount, dt);
  5693. }
  5694. else if (posCode == "logistics")
  5695. {
  5696. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5697. lw.Add(string.Format("VerifyState = 0"));
  5698. lw.Add("type = 2");
  5699. lw.Add(string.Format("AfterSaleState={0}", 3));
  5700. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5701. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5702. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5703. writeGridDataTableJson(dStruct.TotalCount, dt);
  5704. }
  5705. else
  5706. {
  5707. lw.Add(string.Format("(AfterSaleState = 3)"));
  5708. string reasonState = GetPostString("reasonState");
  5709. lw.Add("type = 0");
  5710. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5711. || posCode == "Summarize" || posCode == "Finance")
  5712. {
  5713. if (reasonState == "2")
  5714. {
  5715. lw.Add("VerifyState = 3");
  5716. }
  5717. else if (reasonState == "1")
  5718. {
  5719. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5720. }
  5721. else
  5722. {
  5723. lw.Add("VerifyState in (0,3)");
  5724. }
  5725. //不加条件,可以看全部
  5726. }
  5727. 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")
  5728. {
  5729. int orgid = CurrentUser.UserPost.OrgID;
  5730. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5731. if (string.IsNullOrEmpty(manageOrgId))
  5732. {
  5733. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5734. }
  5735. else
  5736. {
  5737. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5738. }
  5739. if (reasonState == "1")
  5740. {
  5741. lw.Add("VerifyState = 3");
  5742. }
  5743. else if (reasonState == "2")
  5744. {
  5745. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5746. }
  5747. else
  5748. {
  5749. }
  5750. }
  5751. else
  5752. {
  5753. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5754. }
  5755. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5756. //{
  5757. // int org_id = CurrentUser.UserPost.OrgID;
  5758. // lw.Add(string.Format("OrgID={0}", org_id));
  5759. //}
  5760. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5761. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5762. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5763. writeGridDataTableJson(dStruct.TotalCount, dt);
  5764. }
  5765. }
  5766. public void get_erp_finishaftersalelist()
  5767. {
  5768. DataStruct dStruct = GetPostStruct();
  5769. List<string> lw = new List<string>();
  5770. int st = 4;
  5771. string tid = GetPostString("ctid");
  5772. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5773. string shopname = GetPostString("shopname");
  5774. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5775. //lw.Add(string.Format("IsRefund!={0}", 1));
  5776. string reason = GetPostString("reason");
  5777. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5778. string method = GetPostString("method");
  5779. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5780. string buyernick = GetPostString("buyer_nick");
  5781. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5782. string handler = GetPostString("handler");
  5783. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5784. string handledate1 = GetPostString("handledate1");
  5785. string handledate2 = GetPostString("handledate2");
  5786. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5787. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5788. string finish1 = GetPostString("finishdate1");
  5789. string finish2 = GetPostString("finishdate2");
  5790. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5791. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5792. string supplier = GetPostString("supplier");
  5793. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5794. string responsible = GetPostString("responsibleman");
  5795. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5796. string vstate = GetPostString("vstate");
  5797. if (vstate.Length > 0)
  5798. {
  5799. if ("3".Equals(vstate))
  5800. {
  5801. lw.Add(string.Format("IsTem=1"));
  5802. }
  5803. else
  5804. {
  5805. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5806. }
  5807. }
  5808. lw.Add(string.Format("AfterSaleState=4"));
  5809. string code = CurrentUser.UserPost.Post.Code;
  5810. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5811. {
  5812. //不加条件,可以看全部
  5813. }
  5814. else if (code == "Supplier")
  5815. {
  5816. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5817. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5818. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5819. }
  5820. else if (code == "logistics")
  5821. {
  5822. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5823. lw.Add("type = 2");
  5824. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5825. }
  5826. 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")
  5827. {
  5828. int orgid = CurrentUser.UserPost.OrgID;
  5829. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5830. if (string.IsNullOrEmpty(manageOrgIds))
  5831. {
  5832. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5833. }
  5834. else
  5835. {
  5836. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5837. }
  5838. }
  5839. else
  5840. {
  5841. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5842. }
  5843. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5844. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5845. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5846. writeGridDataTableJson(dStruct.TotalCount, dt);
  5847. }
  5848. public void handle_erp_aftersale()
  5849. {
  5850. if (UrlPostParmsCheck("ctid"))
  5851. {
  5852. string eid = GetPostString("ctid");
  5853. string responStr = GetPostString("AfterSaleResponsible");
  5854. if (responStr.Length <= 0)
  5855. {
  5856. returnErrorMsg("售后责任人不能为空");
  5857. return;
  5858. }
  5859. bool isDesign = false;
  5860. double designFree = 0.00;
  5861. int responsibleId = 0;
  5862. CeErpTradeCell entity = null;
  5863. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5864. if (entity != null)
  5865. {
  5866. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5867. string afterMethod = GetPostString("AfterSaleMethod");
  5868. if (isNeedNewOrder == 1)
  5869. {
  5870. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5871. bool ishav = true;
  5872. if (newentity == null)
  5873. {
  5874. newentity = entity.Clone() as CeErpTradeCell;
  5875. ishav = false;
  5876. newentity.ctid = "S_" + entity.ctid;
  5877. newentity.OrderState = 0;
  5878. }
  5879. //唯一标识
  5880. newentity.OrderSn = newentity.ctid;
  5881. /* string orderSn = dataHelper.getSaleOrderSn();
  5882. if (orderSn != "")
  5883. {
  5884. newentity.OrderSn = orderSn;
  5885. }*/
  5886. newentity.AfterSaleState = 0;
  5887. newentity.AfterSaleMethod = afterMethod;
  5888. if (!ishav)
  5889. {
  5890. string memo_str = newentity.seller_memo;
  5891. memo_str = memo_str.Replace("(", "(");
  5892. memo_str = memo_str.Replace(")", ")");
  5893. int sIndex = memo_str.IndexOf("(");
  5894. int eIndex = memo_str.IndexOf(")");
  5895. if (sIndex == -1 || eIndex == -1)
  5896. {
  5897. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5898. return;
  5899. }
  5900. string first = memo_str.Substring(0, sIndex + 1);
  5901. string memoCtid = newentity.OrderSn;
  5902. //if (memoCtid.IndexOf("C") != -1)
  5903. //{
  5904. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5905. //if (CIdx.IndexOf("+") != -1)
  5906. //{
  5907. //CIdx = "C" + CIdx.Split('+')[1];
  5908. //}
  5909. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5910. //}
  5911. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5912. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5913. string newMemo = first + memoCtid + last;
  5914. newentity.seller_memo = newMemo;
  5915. newentity.FinishPlaceTime = null;
  5916. newentity.UnusualTag = 0;
  5917. newentity.UnusualCon = "";
  5918. newentity.UnusualTime = null;
  5919. newentity.AfterSaleMemo = "";
  5920. newentity.AfterSaleMethod = afterMethod;
  5921. newentity.AfterSalePreTime = null;
  5922. newentity.AfterSaleReason = "";
  5923. newentity.AfterSaleResponsible = "";
  5924. newentity.AfterSaleState = 0;
  5925. newentity.AfterSaleTime = null;
  5926. newentity.AfterSaleUserId = 0;
  5927. newentity.AfterSaleSupplierState = 0;
  5928. newentity.LastBillWaybillCode = "";
  5929. newentity.LastBillCpCode = "";
  5930. newentity.FinishAfterSaleTime = null;
  5931. newentity.HandleTime = null;
  5932. newentity.IsSF = 0;
  5933. newentity.IsOldCustomer = 0;
  5934. newentity.UrgencyTime = null;
  5935. newentity.ResponsibleUserId = "";
  5936. newentity.IsVerifyToSupplier = false;
  5937. newentity.payment = 0;
  5938. newentity.CheckMemo = "";
  5939. newentity.OutSid = "";
  5940. newentity.CheckOrderTime = null;
  5941. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5942. }
  5943. newentity.isAfterSaleOrder = 1;
  5944. newentity.IsRefund = 0;
  5945. string receiveMobile = GetPostString("receiver_mobile");
  5946. if (receiveMobile.Length > 0)
  5947. {
  5948. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5949. if (trade != null)
  5950. {
  5951. trade.receiver_name = GetPostString("receiver_name");
  5952. trade.receiver_mobile = receiveMobile;
  5953. trade.receiver_state = GetPostString("receiver_state");
  5954. trade.receiver_city = GetPostString("receiver_city");
  5955. trade.receiver_district = GetPostString("receiver_district");
  5956. trade.receiver_address = GetPostString("receiver_address");
  5957. newentity.IsOffLineOrder = 1;
  5958. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  5959. }
  5960. }
  5961. string st = GetPostString("ToState");
  5962. if (st.Length > 0)
  5963. {
  5964. if (newentity.OrderState <= 3)
  5965. {
  5966. newentity.WaitDesignTime = DateTime.Now;
  5967. newentity.StartDesignTime = null;
  5968. newentity.FinishDesignTime = null;
  5969. newentity.OrderState = 3;
  5970. if (st == "下单员")
  5971. {
  5972. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  5973. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  5974. {
  5975. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  5976. }
  5977. }
  5978. else
  5979. {
  5980. newentity.WaitDesignTime = DateTime.Now;
  5981. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  5982. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  5983. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  5984. {
  5985. DataRow user = dt1.Rows[0];
  5986. //找主管
  5987. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  5988. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  5989. if (dt != null && dt.Rows.Count > 0)
  5990. {
  5991. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  5992. newentity.DesignUserId = designMr;
  5993. string key = "aftersale_order_" + designMr;
  5994. if (RedisHelper.HasKey(key))
  5995. {
  5996. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5997. list.Add(newentity.ctid);
  5998. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5999. }
  6000. }
  6001. //账号正常
  6002. if (user["State"].ToString() == "0")
  6003. {
  6004. newentity.DesignUserId = entity.DesignUserId;
  6005. string key = "aftersale_order_" + entity.DesignUserId;
  6006. if (RedisHelper.HasKey(key))
  6007. {
  6008. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6009. list.Add(newentity.ctid);
  6010. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6011. }
  6012. }
  6013. }
  6014. }
  6015. }
  6016. if (entity.IsXianHuo == 1)
  6017. {
  6018. newentity.OrderState = 6;
  6019. entity.FinishPlaceTime = DateTime.Now;
  6020. }
  6021. }
  6022. if (ishav)
  6023. {
  6024. newentity.Update();
  6025. }
  6026. else
  6027. {
  6028. newentity.Create();
  6029. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6030. }
  6031. if (st != "下单员")
  6032. {
  6033. designHelper.API_GetPrintData_CreateOrder(newentity);
  6034. }
  6035. }
  6036. //处理售后扩展
  6037. string resIdStr = GetPostString("ResponsibleUserId");
  6038. string refundFees = GetPostString("refundFrees");
  6039. int IsComplain = GetPostInt("isComplain");
  6040. int IsBad = GetPostInt("isBad");
  6041. string IsOriginal = GetPostString("isOriginal");
  6042. double diffResultPrice = GetPostDouble("diffResultPrice");
  6043. string textResult = GetPostString("textResult");
  6044. string supplierResponsible = GetPostString("supplierResponsible");
  6045. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6046. if (ceErpTradeAfterSaleExtend == null)
  6047. {
  6048. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6049. ceErpTradeAfterSaleExtend.tid = eid;
  6050. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6051. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6052. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6053. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6054. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6055. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6056. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6057. ceErpTradeAfterSaleExtend.Create();
  6058. }
  6059. else
  6060. {
  6061. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6062. {
  6063. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6064. }
  6065. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6066. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6067. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6068. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6069. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6070. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6071. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6072. ceErpTradeAfterSaleExtend.Update();
  6073. }
  6074. int gysid = GetPostInt("ResponsibleSupId");
  6075. entity.AfterSaleUserId = CurrentUser.UserID;
  6076. entity.ResponsibleUserId = resIdStr;
  6077. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6078. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6079. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6080. {
  6081. CeErpTradeResponsible.DelByTid(eid, -1);
  6082. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6083. int backNum = 0;
  6084. if (number != null)
  6085. {
  6086. backNum = number.BackNum;
  6087. }
  6088. char[] separator = { ',' };
  6089. string[] sArray = resIdStr.Split(separator);
  6090. string[] refundFreeList = { };
  6091. if (refundFees.Length > 0)
  6092. {
  6093. refundFreeList = refundFees.Split(separator);
  6094. }
  6095. int index = -1;
  6096. foreach (string i in sArray)
  6097. {
  6098. index++;
  6099. if (i.Length <= 0) continue;
  6100. char[] separator2 = { '_' };
  6101. string idstr = i.Split(separator2)[0];
  6102. string idtype = i.Split(separator2)[1];
  6103. double refudFree = 0;
  6104. if (refundFreeList.Length > 0)
  6105. {
  6106. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6107. }
  6108. if (idtype == "s")
  6109. {
  6110. isDesign = true;
  6111. designFree = refudFree;
  6112. }
  6113. int userId = Convert.ToInt32(idstr);
  6114. int type = 0;
  6115. if (idtype == "g")
  6116. {
  6117. type = 1;
  6118. }
  6119. if (idtype == "w")
  6120. {
  6121. type = 2;
  6122. }
  6123. if (idtype == "t")
  6124. {
  6125. type = 3;
  6126. }
  6127. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6128. if (ceErpTradeResponsible == null)
  6129. {
  6130. ceErpTradeResponsible = new CeErpTradeResponsible();
  6131. ceErpTradeResponsible.tid = eid;
  6132. ceErpTradeResponsible.UserId = userId;
  6133. ceErpTradeResponsible.createdTime = DateTime.Now;
  6134. ceErpTradeResponsible.type = type;
  6135. if (type == 1)
  6136. {
  6137. ceErpTradeResponsible.IsSup = 1;
  6138. }
  6139. if (type == 2)
  6140. {
  6141. ceErpTradeResponsible.IsFlow = 1;
  6142. }
  6143. }
  6144. ceErpTradeResponsible.RefundFee = refudFree;
  6145. ceErpTradeResponsible.VerifyState = 0;
  6146. if (userId == 2125 || idtype == "w")
  6147. {
  6148. ceErpTradeResponsible.VerifyState = 1;
  6149. }
  6150. if (idtype == "w" && userId == 101)
  6151. {
  6152. ceErpTradeResponsible.VerifyState = 0;
  6153. }
  6154. if (ceErpTradeResponsible.ID > 0)
  6155. {
  6156. ceErpTradeResponsible.Update();
  6157. }
  6158. else
  6159. {
  6160. ceErpTradeResponsible.Create();
  6161. }
  6162. if (isDesign)
  6163. {
  6164. responsibleId = ceErpTradeResponsible.ID;
  6165. }
  6166. }
  6167. CeErpTradeResponsible.NumByTid(backNum, eid);
  6168. }
  6169. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6170. if (ceErpTradeCellExtend != null)
  6171. {
  6172. ceErpTradeCellExtend.returnVisit = 0;
  6173. ceErpTradeCellExtend.Update();
  6174. }
  6175. if (entity.HandleTime != null)
  6176. {
  6177. if (entity.AfterSaleState == 1)
  6178. {
  6179. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6180. }
  6181. else
  6182. {
  6183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6184. }
  6185. }
  6186. else
  6187. {
  6188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6189. entity.HandleTime = DateTime.Now;
  6190. }
  6191. bool isCompale = false;
  6192. if (entity.AfterSaleState == 5)
  6193. {
  6194. isCompale = true;
  6195. entity.AfterSaleState = 3;
  6196. }
  6197. entity.AfterSaleSupplierState = 0;
  6198. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6199. {
  6200. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6201. }
  6202. string sImgs = GetPostString("img");
  6203. entity.AfterSaleSupplierImg = sImgs;
  6204. entity.supRefundType = GetPostString("supRefundType");
  6205. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6206. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6207. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6208. entity.AfterSaleMemoType = GetPostString("MemoType");
  6209. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6210. {
  6211. entity.AfterSaleSupplierState = 2;
  6212. }
  6213. string df = GetPostString("DeductFee");
  6214. if (df == "")
  6215. {
  6216. df = "0";
  6217. }
  6218. string rf = GetPostString("RefundFee");
  6219. if (rf == "")
  6220. {
  6221. rf = "0";
  6222. }
  6223. string pm = GetPostString("AfterSalePayment");
  6224. if (pm == "")
  6225. {
  6226. pm = "0";
  6227. }
  6228. entity.AfterSalePayment = Convert.ToDouble(pm);
  6229. entity.DeductFee = Convert.ToDouble(df);
  6230. entity.RefundFee = Convert.ToDouble(rf);
  6231. entity.Update();
  6232. string toState = GetPostString("ToState");
  6233. string original = GetPostString("isOriginal");
  6234. ApiVo apiVo = new ApiVo();
  6235. apiVo.orderNumber = entity.ctid;
  6236. apiVo.actionName = "afterDesign";
  6237. apiVo.orderRemarks = entity.AfterSaleMethod;
  6238. apiVo.reasonRemarks = entity.AfterSaleReason;
  6239. apiVo.isDesign = isDesign;
  6240. apiVo.designFree = designFree;
  6241. apiVo.responsibleId = responsibleId;
  6242. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6243. if (toState == "设计师")
  6244. {
  6245. apiVo.isOriginal = Convert.ToBoolean(original);
  6246. }
  6247. designHelper.API_WorkCore(apiVo);//afterDesign
  6248. CeErpMethod methodSql = new CeErpMethod();
  6249. methodSql.con = entity.AfterSaleMethod;
  6250. methodSql.addTime = DateTime.Now;
  6251. methodSql.Create();
  6252. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6253. CeErpMethod.ExecuteNonQuery(delsql);
  6254. if (isCompale)
  6255. {
  6256. aftersale_data_change(entity.ctid);
  6257. }
  6258. returnSuccessMsg("操作成功!");
  6259. return;
  6260. }
  6261. returnErrorMsg("找不到订单记录");
  6262. }
  6263. }
  6264. public void ins_erp_toresponsible()
  6265. {
  6266. if (UrlPostParmsCheck("ctid"))
  6267. {
  6268. string eid = GetPostString("ctid");
  6269. CeErpTradeCell entity = null;
  6270. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6271. if (entity != null)
  6272. {
  6273. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6274. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6275. {
  6276. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6277. return;
  6278. }
  6279. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6280. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6281. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6282. entity.AfterSalePreTime = DateTime.Now;
  6283. //预完成给售后主管审核客户问题直接完成
  6284. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6285. {
  6286. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6287. {
  6288. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6289. }
  6290. }
  6291. entity.AfterSaleState = 2;
  6292. entity.Update();
  6293. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6294. aftersale_data_change(entity.ctid);
  6295. returnSuccessMsg("操作成功!");
  6296. return;
  6297. }
  6298. returnErrorMsg("找不到订单记录");
  6299. }
  6300. }
  6301. public void cancel_erp_aftersaleanddelnew()
  6302. {
  6303. if (UrlPostParmsCheck("ctid"))
  6304. {
  6305. string eid = GetPostString("ctid");
  6306. CeErpTradeCell entity = null;
  6307. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6308. if (entity != null)
  6309. {
  6310. entity.AfterSaleState = 0;
  6311. entity.AfterSaleReason = "";
  6312. entity.AfterSaleMethod = "";
  6313. entity.AfterSaleMemo = "";
  6314. entity.AfterSaleResponsible = "";
  6315. entity.ResponsibleUserId = "";
  6316. entity.DeductFee = 0;
  6317. entity.RefundFee = 0;
  6318. entity.IsArbitrate = 0;
  6319. CeErpTradeResponsible.DelByTid(eid, -1);
  6320. entity.Update();
  6321. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6322. if (after != null)
  6323. {
  6324. if (after.OrderState < 5)
  6325. CeErpTradeCell.DelByCtid("S_" + eid);
  6326. }
  6327. returnSuccessMsg("操作成功!");
  6328. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6329. return;
  6330. }
  6331. returnErrorMsg("找不到订单记录");
  6332. }
  6333. }
  6334. public void get_erp_aftersale_pregather()
  6335. {
  6336. List<string> lw = new List<string>();
  6337. int st = GetInt("st");
  6338. string tid = GetPostString("ctid");
  6339. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6340. string shopname = GetPostString("shopname");
  6341. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6342. string buyernick = GetPostString("buyer_nick");
  6343. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6344. string sellermemo = GetPostString("seller_memo");
  6345. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6346. string orderState = GetPostString("orderState");
  6347. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6348. string reason = GetPostString("reason");
  6349. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6350. string method = GetPostString("method");
  6351. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6352. string handler = GetPostString("handler");
  6353. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6354. string handledate1 = GetPostString("handledate1");
  6355. string handledate2 = GetPostString("handledate2");
  6356. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6357. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6358. string supplier = GetPostString("supplier");
  6359. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6360. string responsible = GetPostString("responsibleman");
  6361. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6362. string customer = GetPostString("customer");
  6363. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6364. string design = GetPostString("design");
  6365. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6366. string afterMemoType = GetPostString("aftermemotype");
  6367. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6368. string afterSaleMemo = GetPostString("afterSaleMemo");
  6369. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6370. string afterresult = GetPostString("afterresult");
  6371. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6372. string poscode = CurrentUser.UserPost.Post.Code;
  6373. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6374. {
  6375. string shopid = CurrentUser.User.pemShop;
  6376. lw.Add(string.Format("shopId in ({0})", shopid));
  6377. }
  6378. var mainwhere = string.Join(" and ", lw.ToArray());
  6379. string ro_json = "";
  6380. string type = GetPostString("gather_type");
  6381. if (poscode == "AfterSale")
  6382. {
  6383. //处理中
  6384. if (type == "Handling")
  6385. {
  6386. 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) : ""));
  6387. DataTable dt = null;
  6388. try
  6389. {
  6390. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6391. }
  6392. catch (Exception e)
  6393. {
  6394. dt = new DataTable();
  6395. }
  6396. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6397. return;
  6398. }
  6399. if (type == "Wait")
  6400. {
  6401. //待处理
  6402. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6403. DataTable dt1 = null;
  6404. try
  6405. {
  6406. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6407. }
  6408. catch (Exception e)
  6409. {
  6410. dt1 = new DataTable();
  6411. }
  6412. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6413. return;
  6414. }
  6415. if (type == "back")
  6416. {
  6417. //打回
  6418. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6419. DataTable dt2 = null;
  6420. try
  6421. {
  6422. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6423. }
  6424. catch (Exception e)
  6425. {
  6426. dt2 = new DataTable();
  6427. }
  6428. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6429. return;
  6430. }
  6431. if (type == "preCompletion")
  6432. {
  6433. //预完成
  6434. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6435. DataTable dt3 = null;
  6436. try
  6437. {
  6438. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6439. }
  6440. catch (Exception e)
  6441. {
  6442. dt3 = new DataTable();
  6443. }
  6444. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6445. return;
  6446. }
  6447. if (type == "documentary")
  6448. {
  6449. //跟单中
  6450. 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) : ""));
  6451. DataTable dt4 = null;
  6452. try
  6453. {
  6454. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6455. }
  6456. catch (Exception e)
  6457. {
  6458. dt4 = new DataTable();
  6459. }
  6460. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6461. return;
  6462. }
  6463. if (type == "reBack")
  6464. {
  6465. //被打回
  6466. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6467. DataTable dt1 = null;
  6468. try
  6469. {
  6470. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6471. }
  6472. catch (Exception e)
  6473. {
  6474. dt1 = new DataTable();
  6475. }
  6476. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6477. return;
  6478. }
  6479. }
  6480. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6481. {
  6482. if (type == "puBack")
  6483. {
  6484. //退回
  6485. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6486. DataTable dt = null;
  6487. try
  6488. {
  6489. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6490. }
  6491. catch (Exception e)
  6492. {
  6493. dt = new DataTable();
  6494. }
  6495. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6496. return;
  6497. }
  6498. if (type == "reBack")
  6499. {
  6500. //打回
  6501. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6502. DataTable dt1 = null;
  6503. try
  6504. {
  6505. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6506. }
  6507. catch (Exception e)
  6508. {
  6509. dt1 = new DataTable();
  6510. }
  6511. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6512. return;
  6513. }
  6514. if (type == "examEd")
  6515. {
  6516. //已审核
  6517. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6518. DataTable dt2 = null;
  6519. try
  6520. {
  6521. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6522. }
  6523. catch (Exception e)
  6524. {
  6525. dt2 = new DataTable();
  6526. }
  6527. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6528. return;
  6529. }
  6530. if (type == "waitExam")
  6531. {
  6532. //待审核
  6533. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6534. DataTable dt3 = null;
  6535. try
  6536. {
  6537. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6538. }
  6539. catch (Exception e)
  6540. {
  6541. dt3 = new DataTable();
  6542. }
  6543. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6544. return;
  6545. }
  6546. if (type == "Handling")
  6547. {
  6548. //处理中
  6549. 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) : ""));
  6550. DataTable dt4 = null;
  6551. try
  6552. {
  6553. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6554. }
  6555. catch (Exception e)
  6556. {
  6557. dt4 = new DataTable();
  6558. }
  6559. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6560. return;
  6561. }
  6562. if (type == "Wait")
  6563. {
  6564. //待处理
  6565. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6566. DataTable dt5 = null;
  6567. try
  6568. {
  6569. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6570. }
  6571. catch (Exception e)
  6572. {
  6573. dt5 = new DataTable();
  6574. }
  6575. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6576. return;
  6577. }
  6578. if (type == "documentary")
  6579. {
  6580. //跟单中
  6581. 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) : ""));
  6582. DataTable dt6 = null;
  6583. try
  6584. {
  6585. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6586. }
  6587. catch (Exception e)
  6588. {
  6589. dt6 = new DataTable();
  6590. }
  6591. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6592. return;
  6593. }
  6594. }
  6595. returnSuccess(ro_json);
  6596. }
  6597. public void end_erp_aftersale()
  6598. {
  6599. if (UrlPostParmsCheck("ctid"))
  6600. {
  6601. string eid = GetPostString("ctid");
  6602. CeErpTradeCell entity = null;
  6603. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6604. if (entity != null)
  6605. {
  6606. string stype = GetPostString("stype");
  6607. string typeStr = stype;
  6608. entity.AfterSaleState = 4;
  6609. entity.FinishAfterSaleTime = DateTime.Now;
  6610. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6611. entity.Update();
  6612. ApiVo apiVo = new ApiVo();
  6613. apiVo.orderNumber = entity.ctid;
  6614. apiVo.actionName = "afterOver";
  6615. designHelper.API_WorkCore(apiVo); //afterOver
  6616. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6617. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6618. CeErpSukuraData.createInfo(entity.ctid, 8);
  6619. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6620. returnSuccessMsg("操作成功!");
  6621. return;
  6622. }
  6623. returnErrorMsg("找不到订单记录");
  6624. }
  6625. }
  6626. public void ins_erp_finishaftersale()
  6627. {
  6628. if (UrlPostParmsCheck("id"))
  6629. {
  6630. string eid = GetPostString("id");
  6631. CeErpTradeResponsible entity = null;
  6632. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6633. if (entity != null)
  6634. {
  6635. entity.VerifyState = 1;
  6636. entity.VerifyTime = DateTime.Now;
  6637. entity.Update();
  6638. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6639. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6640. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6641. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6642. if (dt.Rows.Count <= 0)
  6643. {
  6644. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6645. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6646. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6647. CeErpSukuraData.createInfo(entity.tid, 8);
  6648. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6649. {
  6650. CeErpDesignerBill.Del(entity.tid);
  6651. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6652. }
  6653. }
  6654. returnSuccessMsg("操作成功!");
  6655. return;
  6656. }
  6657. returnErrorMsg("找不到订单记录");
  6658. }
  6659. }
  6660. public void upd_erp_arbitrateaftersale()
  6661. {
  6662. if (UrlPostParmsCheck("id"))
  6663. {
  6664. string eid = GetPostString("id");
  6665. CeErpTradeResponsible entity = null;
  6666. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6667. if (entity != null)
  6668. {
  6669. entity.IsArbitrate = 1;
  6670. entity.ArbitradeMemo = GetPostString("reason");
  6671. entity.VerifyState = 2;
  6672. entity.Update();
  6673. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6674. if (tradecell != null)
  6675. {
  6676. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6677. tradecell.IsArbitrate = 1;
  6678. tradecell.Update();
  6679. }
  6680. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6681. returnSuccessMsg("操作成功!");
  6682. return;
  6683. }
  6684. returnErrorMsg("找不到订单记录");
  6685. }
  6686. }
  6687. public void upd_erp_backaftersale()
  6688. {
  6689. if (UrlPostParmsCheck("tid"))
  6690. {
  6691. string eid = GetPostString("tid");
  6692. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6693. int backNum = 0;
  6694. if (number != null)
  6695. {
  6696. backNum = number.BackNum;
  6697. }
  6698. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6699. CeErpTradeCell entity = null;
  6700. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6701. if (entity != null)
  6702. {
  6703. entity.AfterSaleBackReason = GetPostString("backreason");
  6704. entity.AfterSaleState = 1;
  6705. entity.AfterSaleSupplierState = 0;
  6706. entity.Update();
  6707. returnSuccessMsg("操作成功!");
  6708. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6709. return;
  6710. }
  6711. returnErrorMsg("找不到订单记录");
  6712. }
  6713. }
  6714. public void get_erp_supplieraftersalelist()
  6715. {
  6716. DataStruct dStruct = GetPostStruct();
  6717. List<string> lw = new List<string>();
  6718. string tid = GetPostString("ctid");
  6719. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6720. string shopname = GetPostString("shopname");
  6721. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6722. string buyernick = GetPostString("buyer_nick");
  6723. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6724. string sellermemo = GetPostString("seller_memo");
  6725. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6726. string orderState = GetPostString("orderState");
  6727. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6728. string afterState = GetPostString("afterstate");
  6729. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6730. string date1 = GetPostString("date1");
  6731. string date2 = GetPostString("date2");
  6732. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6733. if (dw.Length > 0) lw.Add(dw);
  6734. string price1 = GetPostString("price1");
  6735. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6736. string price2 = GetPostString("price2");
  6737. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6738. string reason = GetPostString("reason");
  6739. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6740. string method = GetPostString("method");
  6741. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6742. string handledate1 = GetPostString("handledate1");
  6743. string handledate2 = GetPostString("handledate2");
  6744. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6745. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6746. string handler = GetPostString("handler");
  6747. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6748. string afterdate1 = GetPostString("afterdate1");
  6749. string afterdate2 = GetPostString("afterdate2");
  6750. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6751. if (afterDate.Length > 0) lw.Add(afterDate);
  6752. string customer = GetPostString("customer");
  6753. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6754. string design = GetPostString("design");
  6755. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6756. string afterMemoType = GetPostString("aftermemotype");
  6757. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6758. string vstate = GetPostString("vstate");
  6759. if (vstate.Length > 0)
  6760. {
  6761. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6762. }
  6763. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6764. string supplier = GetPostString("supplier");
  6765. int supid = commonHelper.getSupplierIDByName(supplier);
  6766. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6767. string posCode = CurrentUser.UserPost.Post.Code;
  6768. if (posCode == "Supplier")
  6769. {
  6770. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6771. }
  6772. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6773. {
  6774. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6775. }
  6776. else
  6777. {
  6778. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6779. }
  6780. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6781. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6782. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6783. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6784. writeGridDataTableJson(dStruct.TotalCount, dt);
  6785. }
  6786. public void upd_erp_supverifyaftersale()
  6787. {
  6788. if (UrlPostParmsCheck("id"))
  6789. {
  6790. string id = GetPostString("id");
  6791. int st = GetPostInt("afterstate");
  6792. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6793. CeErpTradeCell entity = null;
  6794. if (ceErpTradeResponsible != null)
  6795. {
  6796. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6797. }
  6798. string afmemo = GetPostString("supmemo");
  6799. string image = GetPostString("image");
  6800. if (entity != null)
  6801. {
  6802. entity.AfterSaleSupplierState = st;
  6803. entity.AfterSaleSupplierMemo = afmemo;
  6804. entity.AfterSaleSupplierState = st;
  6805. if (st == 1)
  6806. {
  6807. ceErpTradeResponsible.VerifyState = 1;
  6808. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6809. ceErpTradeResponsible.Update();
  6810. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6811. if (isAll)
  6812. {
  6813. entity.AfterSaleState = 4;
  6814. entity.FinishAfterSaleTime = DateTime.Now;
  6815. }
  6816. }
  6817. else
  6818. {
  6819. CeErpTradeResponsible.dateByTid(entity.ctid);
  6820. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6821. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6822. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6823. if (num <= 1)
  6824. {
  6825. entity.AfterSaleState = 1;
  6826. }
  6827. else
  6828. {
  6829. entity.AfterSaleState = 5;
  6830. }
  6831. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6832. if (ceErpTradeAfterSaleExtend != null)
  6833. {
  6834. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6835. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6836. ceErpTradeAfterSaleExtend.Update();
  6837. }
  6838. else
  6839. {
  6840. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6841. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6842. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6843. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6844. ceErpTradeAfterSaleExtend.Create();
  6845. }
  6846. }
  6847. if (entity.AfterSaleState == 4)
  6848. {
  6849. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6850. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6851. {
  6852. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6853. }
  6854. ApiVo apiVo = new ApiVo();
  6855. apiVo.orderNumber = entity.ctid;
  6856. apiVo.actionName = "afterOver";
  6857. designHelper.API_WorkCore(apiVo); //afterOver
  6858. }
  6859. entity.Update();
  6860. returnSuccessMsg("操作成功!");
  6861. CeErpSukuraData.createInfo(entity.ctid, 8);
  6862. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6863. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6864. return;
  6865. }
  6866. returnErrorMsg("找不到订单记录");
  6867. }
  6868. }
  6869. public void upd_erp_masteraftersale()
  6870. {
  6871. if (UrlPostParmsCheck("id"))
  6872. {
  6873. string id = GetPostString("id");
  6874. int st = GetPostInt("afterstate");
  6875. string afmemo = GetPostString("supmemo");
  6876. string image = GetPostString("image");
  6877. string textResult = GetPostString("textResult");
  6878. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6879. if (ceErpTradeResponsible != null)
  6880. {
  6881. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6882. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6883. ceErpTradeResponsible.Update();
  6884. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6885. if (entity != null)
  6886. {
  6887. entity.AfterSaleSupplierState = st;
  6888. entity.AfterSaleSupplierMemo = afmemo;
  6889. if (st == 1)
  6890. {
  6891. }
  6892. else
  6893. {
  6894. CeErpTradeResponsible.dateByTid(entity.ctid);
  6895. //退回到售后
  6896. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6897. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6898. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6899. if (num <= 1)
  6900. {
  6901. entity.AfterSaleState = 1;
  6902. }
  6903. else
  6904. {
  6905. entity.AfterSaleState = 5;
  6906. }
  6907. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6908. if (ceErpTradeAfterSaleExtend != null)
  6909. {
  6910. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6911. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6912. ceErpTradeAfterSaleExtend.Update();
  6913. }
  6914. else
  6915. {
  6916. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6917. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6918. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6919. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6920. ceErpTradeAfterSaleExtend.Create();
  6921. }
  6922. }
  6923. entity.Update();
  6924. returnSuccessMsg("操作成功!");
  6925. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6926. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6927. return;
  6928. }
  6929. }
  6930. returnErrorMsg("找不到订单记录");
  6931. }
  6932. }
  6933. public void upd_erp_personaftersale()
  6934. {
  6935. if (UrlPostParmsCheck("id"))
  6936. {
  6937. string id = GetPostString("id");
  6938. int st = GetPostInt("afterstate");
  6939. string afmemo = GetPostString("supmemo");
  6940. string image = GetPostString("image");
  6941. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6942. if (ceErpTradeResponsible != null)
  6943. {
  6944. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6945. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6946. ceErpTradeResponsible.Update();
  6947. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6948. if (entity != null)
  6949. {
  6950. entity.AfterSaleSupplierMemo = afmemo;
  6951. entity.AfterSaleSupplierState = st;
  6952. if (st == 1)
  6953. {
  6954. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6955. if (isAll)
  6956. {
  6957. entity.AfterSaleState = 4;
  6958. entity.FinishAfterSaleTime = DateTime.Now;
  6959. }
  6960. }
  6961. else
  6962. {
  6963. CeErpTradeResponsible.dateByTid(entity.ctid);
  6964. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6965. if (ceErpTradeAfterSaleExtend != null)
  6966. {
  6967. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6968. ceErpTradeAfterSaleExtend.Update();
  6969. }
  6970. else
  6971. {
  6972. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6973. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6974. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6975. ceErpTradeAfterSaleExtend.Create();
  6976. }
  6977. //退回到主管
  6978. //entity.AfterSaleState = 2;
  6979. }
  6980. if (entity.AfterSaleState == 4)
  6981. {
  6982. ApiVo apiVo = new ApiVo();
  6983. apiVo.orderNumber = entity.ctid;
  6984. apiVo.actionName = "afterOver";
  6985. designHelper.API_WorkCore(apiVo); //afterOver
  6986. }
  6987. entity.Update();
  6988. returnSuccessMsg("操作成功!");
  6989. CeErpSukuraData.createInfo(entity.ctid, 8);
  6990. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6991. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6992. return;
  6993. }
  6994. }
  6995. returnErrorMsg("找不到订单记录");
  6996. }
  6997. }
  6998. public void set_erp_supplierrefundtag()
  6999. {
  7000. if (UrlPostParmsCheck("ctid"))
  7001. {
  7002. string eid = GetPostString("ctid");
  7003. CeErpTradeCell entity = null;
  7004. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7005. if (entity != null)
  7006. {
  7007. entity.IsSupplierRefund = GetPostInt("tag");
  7008. entity.Update();
  7009. returnSuccessMsg("操作成功!");
  7010. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7011. return;
  7012. }
  7013. returnErrorMsg("找不到订单记录");
  7014. }
  7015. }
  7016. public void get_erp_refundlist()
  7017. {
  7018. DataStruct dStruct = GetPostStruct();
  7019. List<string> lw = new List<string>();
  7020. string tid = GetPostString("tid");
  7021. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7022. //string rid = GetPostString("refund_id");
  7023. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7024. string shopname = GetPostString("shopname");
  7025. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7026. string buyernick = GetPostString("buyer_nick");
  7027. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7028. string customer = GetPostString("customer");
  7029. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7030. string design = GetPostString("design");
  7031. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7032. string sellermemo = GetPostString("seller_memo");
  7033. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7034. //string date1 = GetPostString("date1");
  7035. //string date2 = GetPostString("date2");
  7036. //string dateType = GetPostString("dateType");
  7037. //if (dateType.Length > 0)
  7038. //{
  7039. // if (dateType == "1001") dateType = "0";
  7040. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7041. // if (searchDT.Count == 2)
  7042. // {
  7043. // date1 = searchDT[0].ToString();
  7044. // date2 = searchDT[1].ToString();
  7045. // }
  7046. //}
  7047. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7048. //if (dw.Length > 0) lw.Add(dw);
  7049. string redate1 = GetPostString("refunddate1");
  7050. string redate2 = GetPostString("refunddate2");
  7051. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7052. if (dwdate.Length > 0) lw.Add(dwdate);
  7053. string price1 = GetPostString("price1");
  7054. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7055. string price2 = GetPostString("price2");
  7056. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7057. string ispartrefund = GetPostString("ispartrefund");
  7058. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7059. string refundState = GetPostString("refundvstate");
  7060. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7061. int st = GetInt("st");
  7062. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7063. {
  7064. string responsible = GetPostString("responsibleman");
  7065. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7066. lw.Add(string.Format("RefundState>={0}", st));
  7067. string code = CurrentUser.UserPost.Post.Code;
  7068. if (code == "CustomerService")
  7069. {
  7070. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7071. }
  7072. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7073. {
  7074. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7075. }
  7076. else if (code == "Place" || code == "PlaceMr")
  7077. {
  7078. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7079. }
  7080. dStruct.Order = "RefundState asc,created desc";
  7081. }
  7082. else if (st == 10)
  7083. {
  7084. string responsible = GetPostString("responsibleman");
  7085. if (responsible == "空白")
  7086. {
  7087. lw.Add(string.Format("ResponsibleUserName = ''"));
  7088. }
  7089. else if (responsible.Length > 0)
  7090. {
  7091. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7092. }
  7093. lw.Add(string.Format("RefundState>=0"));
  7094. dStruct.Order = "created desc";
  7095. }
  7096. else
  7097. {
  7098. string responsible = GetPostString("responsibleman");
  7099. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7100. lw.Add(string.Format("RefundState={0}", st));
  7101. dStruct.Order = "created desc";
  7102. }
  7103. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7104. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7105. dt.Columns.Add("refund_fees");
  7106. foreach (DataRow dr in dt.Rows)
  7107. {
  7108. String status = dr["status"].ToString();
  7109. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7110. {
  7111. dr["refund_fees"] = dr["refund_fee"];
  7112. }
  7113. else
  7114. {
  7115. dr["refund_fees"] = "0.0";
  7116. }
  7117. }
  7118. writeGridDataTableJson(dStruct.TotalCount, dt);
  7119. }
  7120. public void get_erp_refunddesignlist()
  7121. {
  7122. DataStruct dStruct = GetPostStruct();
  7123. List<string> lw = new List<string>();
  7124. string tid = GetPostString("tid");
  7125. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7126. string shopname = GetPostString("shopname");
  7127. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7128. string buyernick = GetPostString("buyer_nick");
  7129. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7130. string customer = GetPostString("customer");
  7131. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7132. string design = GetPostString("design");
  7133. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7134. string sellermemo = GetPostString("seller_memo");
  7135. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7136. string redate1 = GetPostString("refunddate1");
  7137. string redate2 = GetPostString("refunddate2");
  7138. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7139. if (dwdate.Length > 0) lw.Add(dwdate);
  7140. string price1 = GetPostString("price1");
  7141. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7142. string price2 = GetPostString("price2");
  7143. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7144. string ispartrefund = GetPostString("ispartrefund");
  7145. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7146. string designerorg = GetPostString("designerorg");
  7147. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7148. string refundState = GetPostString("refundState");
  7149. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7150. int myOrgid = CurrentUser.UserPost.OrgID;
  7151. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7152. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7153. {
  7154. if (CurrentUser.User.TeamIds.Length > 0)
  7155. {
  7156. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7157. }
  7158. else
  7159. {
  7160. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7161. }
  7162. }
  7163. else if ("SysAdmin".Equals(myOrgCode))
  7164. {
  7165. }
  7166. else
  7167. {
  7168. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7169. {
  7170. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7171. }
  7172. else
  7173. {
  7174. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7175. }
  7176. }
  7177. lw.Add("OrderState in (3,4,5,9) ");
  7178. dStruct.Order = "created desc";
  7179. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7180. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7181. dt.Columns.Add("refund_fees");
  7182. foreach (DataRow dr in dt.Rows)
  7183. {
  7184. String status = dr["status"].ToString();
  7185. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7186. {
  7187. dr["refund_fees"] = dr["refund_fee"];
  7188. }
  7189. else
  7190. {
  7191. dr["refund_fees"] = "0.0";
  7192. }
  7193. }
  7194. writeGridDataTableJson(dStruct.TotalCount, dt);
  7195. }
  7196. public void handle_erp_refundtag()
  7197. {
  7198. if (UrlPostParmsCheck("refund_id"))
  7199. {
  7200. string eid = GetPostString("refund_id");
  7201. string respMan = GetPostString("ResponsibleName");
  7202. if (respMan.Length <= 0)
  7203. {
  7204. returnErrorMsg("责任人不能为空");
  7205. return;
  7206. }
  7207. CeErpTradeRefund entity = null;
  7208. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7209. if (entity != null)
  7210. {
  7211. entity.ResponsibleUserName = respMan;
  7212. string userid = GetPostString("ResponsibleUserId");
  7213. if (userid.Length > 0)
  7214. {
  7215. entity.ResponsibleUserId = userid;
  7216. }
  7217. entity.Memo = GetPostString("Memo");
  7218. if (respMan.IndexOf("客服") != -1 ||
  7219. respMan.IndexOf("设计师") != -1 ||
  7220. respMan.IndexOf("下单员") != -1)
  7221. {
  7222. entity.RefundState = 2;
  7223. }
  7224. else
  7225. {
  7226. entity.RefundState = 3;
  7227. }
  7228. entity.modified = DateTime.Now;
  7229. entity.Update();
  7230. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7231. returnSuccessMsg("操作成功!");
  7232. return;
  7233. }
  7234. returnErrorMsg("找不到订单记录");
  7235. }
  7236. }
  7237. public void handle_erp_designrefundtag()
  7238. {
  7239. if (UrlPostParmsCheck("refund_id"))
  7240. {
  7241. string eid = GetPostString("refund_id");
  7242. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7243. if (ceErpTradeCellExtend == null)
  7244. {
  7245. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7246. ceErpTradeCellExtend.ctid = eid;
  7247. }
  7248. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7249. if (ceErpTradeCellExtend.ID > 0)
  7250. {
  7251. ceErpTradeCellExtend.Update();
  7252. }
  7253. else
  7254. {
  7255. ceErpTradeCellExtend.Create();
  7256. }
  7257. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7258. returnSuccessMsg("操作成功!");
  7259. return;
  7260. }
  7261. returnErrorMsg("找不到订单记录");
  7262. }
  7263. public void upd_erp_refundverify()
  7264. {
  7265. if (UrlPostParmsCheck("refund_id"))
  7266. {
  7267. string eid = GetPostString("refund_id");
  7268. CeErpTradeRefund entity = null;
  7269. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7270. if (entity != null)
  7271. {
  7272. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7273. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7274. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7275. {
  7276. entity.RefundState = 2;
  7277. }
  7278. else
  7279. {
  7280. entity.RefundState = 3;
  7281. }
  7282. entity.Update();
  7283. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7284. returnSuccessMsg("操作成功!");
  7285. return;
  7286. }
  7287. returnErrorMsg("找不到订单记录");
  7288. }
  7289. }
  7290. public void upd_erp_refundapprove()
  7291. {
  7292. if (UrlPostParmsCheck("refund_id"))
  7293. {
  7294. string eid = GetPostString("refund_id");
  7295. CeErpTradeRefund entity = null;
  7296. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7297. if (entity != null)
  7298. {
  7299. int apr = GetPostInt("approve");
  7300. if (apr == 0)
  7301. {
  7302. entity.RefundState = 1;
  7303. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7304. }
  7305. else if (apr == 1)
  7306. {
  7307. entity.RefundState = 3;
  7308. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7309. }
  7310. entity.modified = DateTime.Now;
  7311. entity.Update();
  7312. returnSuccessMsg("操作成功!");
  7313. return;
  7314. }
  7315. returnErrorMsg("找不到订单记录");
  7316. }
  7317. }
  7318. public void get_erp_billlist()
  7319. {
  7320. DataStruct dStruct = GetPostStruct();
  7321. List<string> lw = new List<string>();
  7322. string title = GetPostString("title");
  7323. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7324. string tid = GetPostString("tid");
  7325. string tids = GetPostString("tids");
  7326. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7327. if (tids.Length > 0)
  7328. {
  7329. tids = "'" + tids + "'";
  7330. tids = tids.Replace(",", "','");
  7331. lw.Add(string.Format("tid in ({0})", tids));
  7332. }
  7333. string shopname = GetPostString("shopname");
  7334. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7335. string buyernick = GetPostString("buyer_nick");
  7336. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7337. string customer = GetPostString("customer");
  7338. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7339. string date1 = GetPostString("date1");
  7340. string date2 = GetPostString("date2");
  7341. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7342. if (dw.Length > 0) lw.Add(dw);
  7343. string price1 = GetPostString("price1");
  7344. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7345. string price2 = GetPostString("price2");
  7346. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7347. string returndate1 = GetPostString("returndate1");
  7348. string returndate2 = GetPostString("returndate2");
  7349. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7350. if (dw1.Length > 0) lw.Add(dw1);
  7351. string billtype = GetPostString("billtype");
  7352. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7353. string billstate = GetPostString("billstate");
  7354. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7355. string usershop = CurrentUser.User.pemShop;
  7356. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7357. dStruct.Order = "createTime desc";
  7358. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7359. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7360. //foreach (DataRow dr in dt.Rows)
  7361. //{
  7362. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7363. //}
  7364. writeGridDataTableJson(dStruct.TotalCount, dt);
  7365. }
  7366. public void modify_erp_billinfo()
  7367. {
  7368. if (UrlPostParmsCheck("ID"))
  7369. {
  7370. string eid = GetPostString("ID");
  7371. CeErpBill bill_entity = null;
  7372. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7373. if (bill_entity != null)
  7374. {
  7375. bill_entity.tid = GetPostString("tid");
  7376. bill_entity.title = GetPostString("title");
  7377. bill_entity.tax = GetPostString("tax");
  7378. bill_entity.bank = GetPostString("bank");
  7379. bill_entity.bankac = GetPostString("bankac");
  7380. bill_entity.address = GetPostString("address");
  7381. bill_entity.phone = GetPostString("phone");
  7382. bill_entity.price = GetPostString("price");
  7383. bill_entity.productId = GetPostInt("ProductName");
  7384. bill_entity.num = GetPostInt("num");
  7385. bill_entity.unit = GetPostString("unit");
  7386. bill_entity.type = GetPostString("type");
  7387. bill_entity.sendType = GetPostString("SendType");
  7388. bill_entity.email = GetPostString("email");
  7389. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7390. bill_entity.shopName = GetPostString("ShopName");
  7391. bill_entity.applymemo = GetPostString("applymemo");
  7392. bill_entity.modifyTime = DateTime.Now;
  7393. bill_entity.createTime = DateTime.Now;
  7394. bill_entity.state = 0;
  7395. bill_entity.Update();
  7396. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7397. returnSuccessMsg("发票修改成功!");
  7398. return;
  7399. }
  7400. returnErrorMsg("找不到对应记录");
  7401. }
  7402. }
  7403. public void set_erp_invoicing()
  7404. {
  7405. if (UrlPostParmsCheck("id"))
  7406. {
  7407. try
  7408. {
  7409. string eid = GetPostString("id");
  7410. CeErpBill bill_entity = null;
  7411. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7412. if (bill_entity != null)
  7413. {
  7414. int ComId = GetPostInt("ComId");
  7415. //string memo = GetPostString("Memo");
  7416. int allInfo = GetPostInt("allinfo");
  7417. string clert = CurrentUser.User.Name;
  7418. //string detailValue = GetPostString("detailvalue");
  7419. string billId = bill_entity.billOrderId;
  7420. string[] billIdList = billId.Split(',');
  7421. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7422. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7423. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7424. {
  7425. billCount += 1;
  7426. }
  7427. if (billId.Length <= 0 || billIdList.Length != billCount)
  7428. {
  7429. bill_entity.billOrderId = "";
  7430. string prebill = "ltb";
  7431. for (int idx = 1; idx <= billCount; idx++)
  7432. {
  7433. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7434. string billoid = prebill + idx + dtstr;
  7435. bill_entity.billOrderId += billoid;
  7436. if (idx < billCount)
  7437. {
  7438. bill_entity.billOrderId += ",";
  7439. }
  7440. }
  7441. }
  7442. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7443. if (bill_entity.state == 5)
  7444. {
  7445. string errMsg = bill_entity.failerror;
  7446. string[] errlist = errMsg.Split('|');
  7447. string[] errTags = new string[errlist.Length];
  7448. for (int itag = 0; itag < errlist.Length; itag++)
  7449. {
  7450. if (errlist[itag].Length <= 0) continue;
  7451. errTags[itag] = errlist[itag].Split('&')[0];
  7452. }
  7453. for (int iii = 0; iii < errTags.Length; iii++)
  7454. {
  7455. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7456. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7457. if (billOrderList.Length >= erroBillOrderTag)
  7458. {
  7459. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7460. if (needModifyBillId.Length <= 19)
  7461. {
  7462. needModifyBillId = needModifyBillId + "1";
  7463. }
  7464. else
  7465. {
  7466. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7467. last = last + 1;
  7468. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7469. }
  7470. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7471. }
  7472. }
  7473. }
  7474. bool isHaveBillSucces = false;
  7475. string totalRes = "";
  7476. bill_entity.failerror = "";
  7477. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7478. {
  7479. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7480. totalRes += res;
  7481. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7482. {
  7483. isHaveBillSucces = true;
  7484. bill_entity.comId = ComId;
  7485. bill_entity.state = 1;
  7486. bill_entity.executeTime = DateTime.Now;
  7487. bill_entity.executeUser = clert;
  7488. }
  7489. else
  7490. {
  7491. bill_entity.state = 5;
  7492. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7493. }
  7494. }
  7495. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7496. bill_entity.Update();
  7497. if (isHaveBillSucces)
  7498. {
  7499. StringBuilder sql = new StringBuilder();
  7500. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7501. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7502. }
  7503. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7504. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7505. {
  7506. returnErrorMsg("开票失败");
  7507. }
  7508. else
  7509. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7510. return;
  7511. }
  7512. returnErrorMsg("找不到对应记录");
  7513. }
  7514. catch (Exception ex)
  7515. {
  7516. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7517. returnErrorMsg("操作失败");
  7518. }
  7519. }
  7520. }
  7521. public void get_erp_invoicing_back()
  7522. {
  7523. if (UrlPostParmsCheck("id"))
  7524. {
  7525. try
  7526. {
  7527. string id = GetPostString("id");
  7528. CeErpBill entiy = CeErpBill.Get(id);
  7529. if (entiy != null)
  7530. {
  7531. if (entiy.state == 0)
  7532. {
  7533. returnErrorMsg("发票还未开具");
  7534. return;
  7535. }
  7536. string[] billOrderList = entiy.billOrderId.Split(',');
  7537. int iTag = 0;
  7538. entiy.fplsh = "";
  7539. entiy.fpdm = "";
  7540. entiy.fphm = "";
  7541. foreach (string billOrderId in billOrderList)
  7542. {
  7543. iTag++;
  7544. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7545. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7546. {
  7547. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7548. try
  7549. {
  7550. Invoicing_get_response_Obj iObj = null;
  7551. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7552. if (iObj != null)
  7553. {
  7554. entiy.state = 2;
  7555. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7556. entiy.fpdm += iObj.list[0].c_fpdm;
  7557. entiy.fphm += iObj.list[0].c_fphm;
  7558. if (iTag < billOrderList.Length)
  7559. {
  7560. entiy.fplsh += ",";
  7561. entiy.fpdm += ",";
  7562. entiy.fphm += ",";
  7563. }
  7564. entiy.Update();
  7565. }
  7566. StringBuilder sql = new StringBuilder();
  7567. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7568. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7569. returnSuccessMsg("开票成功");
  7570. }
  7571. catch (Exception ex)
  7572. {
  7573. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7574. }
  7575. return;
  7576. }
  7577. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7578. {
  7579. var res_obj = new
  7580. {
  7581. data = "开票中"
  7582. };
  7583. string ro_json = JsonConvert.SerializeObject(res_obj);
  7584. returnSuccess(ro_json);
  7585. return;
  7586. }
  7587. else
  7588. {
  7589. int eidx = res.IndexOf("c_resultmsg");
  7590. int lidx = res.IndexOf("c_status");
  7591. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7592. entiy.state = 5;
  7593. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7594. entiy.Update();
  7595. returnErrorMsg("开票失败");
  7596. return;
  7597. }
  7598. }
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7604. }
  7605. return;
  7606. }
  7607. }
  7608. public void get_erp_invoicing()
  7609. {
  7610. if (UrlPostParmsCheck("id"))
  7611. {
  7612. try
  7613. {
  7614. string id = GetPostString("id");
  7615. CeErpBill entiy = CeErpBill.Get(id);
  7616. if (entiy != null)
  7617. {
  7618. if (entiy.state == 0)
  7619. {
  7620. returnErrorMsg("发票还未开具");
  7621. return;
  7622. }
  7623. if (entiy.sendType == "纸质发票")
  7624. {
  7625. if (entiy.img.Length <= 0)
  7626. {
  7627. returnErrorMsg("查无纸质发票");
  7628. return;
  7629. }
  7630. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7631. returnSuccess(returnres);
  7632. return;
  7633. }
  7634. string[] billOrderList = entiy.billOrderId.Split(',');
  7635. int iTag = 0;
  7636. string fpUrl = "";
  7637. entiy.fplsh = "";
  7638. entiy.fpdm = "";
  7639. entiy.fphm = "";
  7640. foreach (string billOrderId in billOrderList)
  7641. {
  7642. iTag++;
  7643. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7644. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7645. {
  7646. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7647. Invoicing_get_response_Obj iObj = null;
  7648. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7649. if (iObj != null)
  7650. {
  7651. //entiy.state = 2;
  7652. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7653. entiy.fpdm += iObj.list[0].c_fpdm;
  7654. entiy.fphm += iObj.list[0].c_fphm;
  7655. if (iTag < billOrderList.Length)
  7656. {
  7657. entiy.fplsh += ",";
  7658. entiy.fpdm += ",";
  7659. entiy.fphm += ",";
  7660. }
  7661. entiy.Update();
  7662. fpUrl += iObj.list[0].c_url + ",";
  7663. }
  7664. //returnSuccess(res);
  7665. StringBuilder sql = new StringBuilder();
  7666. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7667. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7668. }
  7669. else
  7670. {
  7671. int eidx = res.IndexOf("c_resultmsg");
  7672. //int lidx = res.IndexOf("c_status");
  7673. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7674. //开票失败
  7675. entiy.state = 5;
  7676. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7677. entiy.Update();
  7678. returnErrorMsg("开票失败");
  7679. return;
  7680. }
  7681. }
  7682. var returnObj = new
  7683. {
  7684. data = fpUrl
  7685. };
  7686. string ro_json = JsonConvert.SerializeObject(returnObj);
  7687. returnSuccess(ro_json);
  7688. }
  7689. }
  7690. catch (Exception ex)
  7691. {
  7692. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7693. }
  7694. return;
  7695. }
  7696. }
  7697. public void save_erp_billimg()
  7698. {
  7699. if (UrlPostParmsCheck("id"))
  7700. {
  7701. string eid = GetPostString("id");
  7702. CeErpBill bill_entity = null;
  7703. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7704. if (bill_entity != null)
  7705. {
  7706. bill_entity.img = GetPostString("img");
  7707. bill_entity.executeTime = DateTime.Now;
  7708. bill_entity.state = 2;
  7709. bill_entity.Update();
  7710. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7711. returnSuccessMsg("保存成功");
  7712. }
  7713. return;
  7714. }
  7715. }
  7716. public void upd_erp_billreturnback()
  7717. {
  7718. if (UrlPostParmsCheck("id"))
  7719. {
  7720. int eid = GetPostInt("id");
  7721. CeErpBill bill_entity = null;
  7722. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7723. if (bill_entity != null)
  7724. {
  7725. bill_entity.state = 3;
  7726. bill_entity.returnReason = GetPostString("reason");
  7727. bill_entity.Update();
  7728. returnSuccessMsg("驳回成功!");
  7729. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7730. }
  7731. return;
  7732. }
  7733. }
  7734. public void cancel_erp_bill()
  7735. {
  7736. if (UrlPostParmsCheck("id"))
  7737. {
  7738. int eid = GetPostInt("id");
  7739. int detailValue = GetPostInt("detailvalue");
  7740. CeErpBill bill_entity = null;
  7741. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7742. string cres = "";
  7743. string gres = "";
  7744. if (bill_entity != null)
  7745. {
  7746. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7747. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7748. {
  7749. int iTag = 0;
  7750. bill_entity.fplsh = "";
  7751. bill_entity.fpdm = "";
  7752. bill_entity.fphm = "";
  7753. foreach (string billOrderId in billOrderList)
  7754. {
  7755. iTag++;
  7756. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7757. if (gres.IndexOf("success") != -1)
  7758. {
  7759. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7760. Invoicing_get_response_Obj iObj = null;
  7761. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7762. if (iObj != null)
  7763. {
  7764. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7765. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7766. bill_entity.fphm += iObj.list[0].c_fphm;
  7767. if (iTag < billOrderList.Length)
  7768. {
  7769. bill_entity.fplsh += ",";
  7770. bill_entity.fpdm += ",";
  7771. bill_entity.fphm += ",";
  7772. }
  7773. bill_entity.Update();
  7774. }
  7775. }
  7776. else
  7777. {
  7778. returnErrorMsg(gres);
  7779. return;
  7780. }
  7781. }
  7782. }
  7783. if (bill_entity.sendType == "纸质发票")
  7784. {
  7785. //作废
  7786. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7787. //if (DateTime.Now.Month == extime.Month)
  7788. //{
  7789. //cres = taobaoHelper.cancel_invoicing(eid);
  7790. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7791. //{
  7792. bill_entity.state = 4;//已作废
  7793. bill_entity.Update();
  7794. returnSuccessMsg("发票已作废");
  7795. return;
  7796. //}
  7797. //else
  7798. //{
  7799. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7800. // bill_entity.Update();
  7801. // returnErrorMsg(cres);
  7802. // return;
  7803. //}
  7804. //}
  7805. //else
  7806. //{
  7807. // returnErrorMsg("纸质发票只能作废本月的发票");
  7808. // return;
  7809. //}
  7810. }
  7811. //红冲
  7812. int redTag = 0;
  7813. string[] fpdmList = bill_entity.fpdm.Split(',');
  7814. string[] fphmList = bill_entity.fphm.Split(',');
  7815. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7816. {
  7817. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7818. return;
  7819. }
  7820. foreach (string billOrderId in billOrderList)
  7821. {
  7822. redTag++;
  7823. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7824. cres += onecres;
  7825. cres += ",";
  7826. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7827. {
  7828. bill_entity.state = 4;//已作废
  7829. //bill_entity.Update();
  7830. //returnSuccessMsg("发票已红冲");
  7831. }
  7832. else if (onecres.IndexOf("重复冲红") != -1)
  7833. {
  7834. bill_entity.state = 4;//已作废
  7835. //bill_entity.Update();
  7836. //returnSuccessMsg("发票已红冲");
  7837. }
  7838. else
  7839. {
  7840. string errmsg = commonHelper.KeepChinese(onecres);
  7841. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7842. }
  7843. }
  7844. bill_entity.Update();
  7845. if (cres.IndexOf("失败") != -1)
  7846. returnErrorMsg("红冲失败");
  7847. else
  7848. returnSuccessMsg("发票已红冲");
  7849. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7850. return;
  7851. }
  7852. return;
  7853. }
  7854. }
  7855. public void del_erp_billorder()
  7856. {
  7857. if (UrlPostParmsCheck("id"))
  7858. {
  7859. string eid = GetPostString("id");
  7860. CeErpBill.Del(eid);
  7861. CeErpBill bill = CeErpBill.Get(eid);
  7862. if (bill != null)
  7863. {
  7864. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7865. }
  7866. returnSuccessMsg("删除成功");
  7867. }
  7868. }
  7869. public void finish_erp_bill()
  7870. {
  7871. if (UrlPostParmsCheck("ids"))
  7872. {
  7873. string eids = GetPostString("ids");
  7874. string[] list = eids.Split(',');
  7875. foreach (string eid in list)
  7876. {
  7877. CeErpBill bill = CeErpBill.Get(eid);
  7878. if (bill != null)
  7879. {
  7880. bill.state = 2;
  7881. bill.Update();
  7882. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7883. }
  7884. }
  7885. returnSuccessMsg("操作成功");
  7886. }
  7887. }
  7888. public void get_erp_returncash()
  7889. {
  7890. DataStruct dStruct = GetPostStruct();
  7891. List<string> lw = new List<string>();
  7892. string tid = GetPostString("tid");
  7893. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7894. string shopname = GetPostString("shopname");
  7895. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7896. string buyernick = GetPostString("buyer_nick");
  7897. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7898. string customer = GetPostString("customer");
  7899. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7900. string returndate1 = GetPostString("returndate1");
  7901. string returndate2 = GetPostString("returndate2");
  7902. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7903. if (dw.Length > 0) lw.Add(dw);
  7904. string finishDate1 = GetPostString("finishdate1");
  7905. string finishDate2 = GetPostString("finishdate2");
  7906. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7907. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7908. string returntype = GetPostString("returntype");
  7909. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7910. string returnvstate = GetPostString("returnvstate");
  7911. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7912. dStruct.Order = "created desc";
  7913. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7914. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7915. writeGridDataTableJson(dStruct.TotalCount, dt);
  7916. }
  7917. public void get_erp_staygoods()
  7918. {
  7919. DataStruct dStruct = GetPostStruct();
  7920. List<string> lw = new List<string>();
  7921. string tid = GetPostString("tid");
  7922. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7923. string shopname = GetPostString("shopname");
  7924. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7925. string wangwang = GetPostString("wangwang");
  7926. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7927. string customer = GetPostString("customer");
  7928. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7929. string returndate1 = GetPostString("returndate1");
  7930. string returndate2 = GetPostString("returndate2");
  7931. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7932. if (dw.Length > 0) lw.Add(dw);
  7933. string finishDate1 = GetPostString("finishdate1");
  7934. string finishDate2 = GetPostString("finishdate2");
  7935. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7936. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7937. string returnvstate = GetPostString("returnvstate");
  7938. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7939. string persuadetype = GetPostString("persuadetype");
  7940. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7941. string customerOrg = GetPostString("customerOrg");
  7942. if (customerOrg.Length > 0)
  7943. {
  7944. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7945. }
  7946. dStruct.Order = "creata_time desc";
  7947. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7948. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7949. writeGridDataTableJson(dStruct.TotalCount, dt);
  7950. }
  7951. public void upd_erp_staygoods()
  7952. {
  7953. if (UrlPostParmsCheck("id"))
  7954. {
  7955. int eid = GetPostInt("id");
  7956. CeErpStayGoods entity = null;
  7957. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7958. if (entity != null)
  7959. {
  7960. entity.audit_type = 1;
  7961. entity.audit_time = DateTime.Now;
  7962. entity.audit_u_id = CurrentUser.UserID;
  7963. entity.audit_u_name = CurrentUser.UserName;
  7964. entity.Update();
  7965. returnSuccessMsg("审核成功!");
  7966. return;
  7967. }
  7968. returnErrorMsg("找不到订单记录");
  7969. }
  7970. }
  7971. public void upd_erp_stayGoodsback()
  7972. {
  7973. if (UrlPostParmsCheck("id"))
  7974. {
  7975. int eid = GetPostInt("id");
  7976. CeErpStayGoods entity = null;
  7977. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7978. if (entity != null)
  7979. {
  7980. entity.audit_text = GetPostString("reason");
  7981. entity.audit_type = 2;
  7982. entity.audit_time = DateTime.Now;
  7983. entity.audit_u_id = CurrentUser.UserID;
  7984. entity.audit_u_name = CurrentUser.UserName;
  7985. entity.Update();
  7986. returnSuccessMsg("退回成功!");
  7987. return;
  7988. }
  7989. returnErrorMsg("找不到订单记录");
  7990. }
  7991. }
  7992. public void upd_erp_returncashverify()
  7993. {
  7994. if (UrlPostParmsCheck("ID"))
  7995. {
  7996. int eid = GetPostInt("ID");
  7997. CeErpReturnCash entity = null;
  7998. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7999. if (entity != null)
  8000. {
  8001. entity.cashstate = 1;
  8002. entity.verifytime = DateTime.Now;
  8003. entity.verifyuserid = CurrentUser.UserID;
  8004. entity.Update();
  8005. returnSuccessMsg("审核成功!");
  8006. return;
  8007. }
  8008. returnErrorMsg("找不到订单记录");
  8009. }
  8010. }
  8011. public void upd_all_erp_returncashverify()
  8012. {
  8013. if (UrlPostParmsCheck("ID"))
  8014. {
  8015. String[] list = GetPostString("ID").Split(',');
  8016. CeErpReturnCash entity = null;
  8017. for (int i = 0; i < list.Length; i++)
  8018. {
  8019. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8020. if (entity != null)
  8021. {
  8022. if (entity.cashstate == 1)
  8023. {
  8024. returnErrorMsg("已审核过的订单不需要在审核!");
  8025. return;
  8026. }
  8027. entity.cashstate = 1;
  8028. entity.verifytime = DateTime.Now;
  8029. entity.verifyuserid = CurrentUser.UserID;
  8030. entity.Update();
  8031. }
  8032. }
  8033. returnSuccessMsg("审核成功!");
  8034. return;
  8035. }
  8036. }
  8037. public void upd_erp_returncashback()
  8038. {
  8039. if (UrlPostParmsCheck("ID"))
  8040. {
  8041. int eid = GetPostInt("ID");
  8042. CeErpReturnCash entity = null;
  8043. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8044. if (entity != null)
  8045. {
  8046. entity.backreason = GetPostString("reason");
  8047. entity.cashstate = 2;
  8048. entity.verifytime = DateTime.Now;
  8049. entity.verifyuserid = CurrentUser.UserID;
  8050. entity.Update();
  8051. returnSuccessMsg("退回成功!");
  8052. return;
  8053. }
  8054. returnErrorMsg("找不到订单记录");
  8055. }
  8056. }
  8057. public void upd_erp_returnprice()
  8058. {
  8059. if (UrlPostParmsCheck("ID"))
  8060. {
  8061. int eid = GetPostInt("ID");
  8062. CeErpReturnCash entity = null;
  8063. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8064. if (entity != null)
  8065. {
  8066. if (entity.cashstate == 1)
  8067. {
  8068. returnErrorMsg("审核通过了不能改");
  8069. return;
  8070. }
  8071. entity.returnprice = GetPostDouble("returnprice");
  8072. entity.Update();
  8073. returnSuccessMsg("修改成功!");
  8074. return;
  8075. }
  8076. returnErrorMsg("找不到订单记录");
  8077. }
  8078. }
  8079. public void del_erp_returncash()
  8080. {
  8081. if (UrlPostParmsCheck("ID"))
  8082. {
  8083. int eid = GetPostInt("ID");
  8084. CeErpReturnCash.Del(eid);
  8085. returnSuccessMsg("操作成功");
  8086. return;
  8087. }
  8088. }
  8089. public void test_for_do_sql()
  8090. {
  8091. string sql = GetPostString("sqlstr");
  8092. if (sql.Length > 0)
  8093. {
  8094. try
  8095. {
  8096. DbHelper.DbConn.ExecuteNonQuery(sql);
  8097. var res_obj = new
  8098. {
  8099. data = "成功",
  8100. };
  8101. string ro_json = JsonConvert.SerializeObject(res_obj);
  8102. returnSuccess(ro_json);
  8103. }
  8104. catch (Exception ex)
  8105. {
  8106. var res_obj = new
  8107. {
  8108. data = ex.Message,
  8109. };
  8110. string ro_json = JsonConvert.SerializeObject(res_obj);
  8111. returnSuccess(ro_json);
  8112. }
  8113. }
  8114. }
  8115. public void get_user_info()
  8116. {
  8117. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8118. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8119. }
  8120. public void get_total_data()
  8121. {
  8122. int userId = CurrentUser.UserID;
  8123. string sql = "";
  8124. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8125. {
  8126. 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);
  8127. }
  8128. else
  8129. {
  8130. 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 " +
  8131. "(select ID from CE_ErpUser where ID = {0}) d " +
  8132. "left join " +
  8133. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8134. ") a on d.ID = a.id left join " +
  8135. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8136. ") b on a.id = b.id1 left join" +
  8137. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8138. ") c on a.id = c.id2;", userId);
  8139. }
  8140. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8141. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8142. }
  8143. public void get_date_area_total_data2()
  8144. {
  8145. int userId = CurrentUser.UserID;
  8146. string date_type = GetPostString("timetype");
  8147. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8148. string sql = "";
  8149. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8150. {
  8151. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8152. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8153. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8154. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8155. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8156. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8157. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8158. ") a on e.ID = a.id left join " +
  8159. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8160. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8161. ") b on a.id = b.id1 " +
  8162. "left join " +
  8163. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8164. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8165. ") c on a.id = c.id2 " +
  8166. "left join " +
  8167. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8168. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8169. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8170. }
  8171. else
  8172. {
  8173. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8174. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8175. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8176. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8177. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8178. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8179. ") a on e.ID = a.id left join " +
  8180. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8181. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8182. ") c on a.id = c.id2 " +
  8183. "left join " +
  8184. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8185. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8186. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8187. }
  8188. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8189. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8190. }
  8191. public void get_date_area_total_data()
  8192. {
  8193. int userId = CurrentUser.UserID;
  8194. string date_type = GetPostString("timetype");
  8195. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8196. string date1 = searchDT[0].ToString();
  8197. string date2 = searchDT[1].ToString();
  8198. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8199. {
  8200. SqlParameter[] sqlParameter ={
  8201. new SqlParameter("@userId", SqlDbType.Int,4),
  8202. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8203. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8204. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8205. };
  8206. sqlParameter[0].Value = userId;
  8207. sqlParameter[1].Value = date1;
  8208. sqlParameter[2].Value = date2;
  8209. sqlParameter[3].Direction = ParameterDirection.Output;
  8210. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8211. string res = sqlParameter[3].Value.ToString();
  8212. var res_obj = new
  8213. {
  8214. data = res
  8215. };
  8216. string ro_json = JsonConvert.SerializeObject(res_obj);
  8217. returnSuccess(ro_json);
  8218. }
  8219. else
  8220. {
  8221. SqlParameter[] sqlParameter ={
  8222. new SqlParameter("@userId", SqlDbType.Int,4),
  8223. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8224. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8225. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8226. };
  8227. sqlParameter[0].Value = userId;
  8228. sqlParameter[1].Value = date1;
  8229. sqlParameter[2].Value = date2;
  8230. sqlParameter[3].Direction = ParameterDirection.Output;
  8231. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8232. string res = sqlParameter[3].Value.ToString();
  8233. var res_obj = new
  8234. {
  8235. data = res
  8236. };
  8237. string ro_json = JsonConvert.SerializeObject(res_obj);
  8238. returnSuccess(ro_json);
  8239. }
  8240. //writeGridDataViewJson(dt.Rows.Count, dv);
  8241. }
  8242. public void get_order_list()
  8243. {
  8244. string strFields = GetPostString("paraFields");
  8245. string strOrder = GetPostString("paraOrder");
  8246. string strWhere = GetPostString("paraWhere");
  8247. string strPageSize = GetPostString("paraPageSize");
  8248. DataStruct dStruct = GetPostStruct();
  8249. dStruct.PageSize = int.Parse(strPageSize);
  8250. dStruct.Fileds = strFields;
  8251. dStruct.Order = strOrder;
  8252. dStruct.MainWhere = strWhere;
  8253. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8254. writeGridDataTableJson(dStruct.TotalCount, dt);
  8255. }
  8256. ////获取待开始订单列表
  8257. //public void get_wait_design_order_list()
  8258. //{
  8259. // string date_type = GetPostString("date_type");
  8260. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8261. // DataStruct dStruct = GetPostStruct();
  8262. // dStruct.PageSize = 1000;
  8263. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8264. // List<string> lw = new List<string>();
  8265. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8266. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8267. // dStruct.Order = "WaitDesignTime asc";
  8268. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8269. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8270. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8271. //}
  8272. //获取完成单量排名
  8273. public void get_finish_order_count_ranking()
  8274. {
  8275. /* string date_type = GetPostString("date_type");
  8276. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8277. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8278. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8279. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8280. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8281. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8282. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8283. writeGridDataTableJson(0, new DataTable());
  8284. }
  8285. public void get_finish_order_amount_ranking()
  8286. {
  8287. /*string date_type = GetPostString("date_type");
  8288. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8289. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8290. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8291. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8292. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8293. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8294. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8295. writeGridDataTableJson(0, new DataTable());
  8296. }
  8297. public void get_finish_refund_count_ranking()
  8298. {
  8299. string date_type = GetPostString("date_type");
  8300. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8301. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8302. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8303. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8304. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8305. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8306. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8307. writeGridDataTableJson(dt.Rows.Count, dt);
  8308. }
  8309. public void get_finish_refund_amount_ranking()
  8310. {
  8311. string date_type = GetPostString("date_type");
  8312. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8313. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8314. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8315. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8316. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8317. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8318. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8319. writeGridDataTableJson(dt.Rows.Count, dt);
  8320. }
  8321. public void set_erp_finishorder_director()
  8322. {
  8323. if (UrlPostParmsCheck("ctid"))
  8324. {
  8325. string eid = GetPostString("ctid");
  8326. CeErpTradeCell entity = null;
  8327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8328. if (entity != null)
  8329. {
  8330. entity.OrderState = 8;
  8331. entity.Update();
  8332. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8333. returnSuccessMsg("操作成功!");
  8334. return;
  8335. }
  8336. returnErrorMsg("找不到记录");
  8337. }
  8338. }
  8339. public void get_erp_placeregistlist()
  8340. {
  8341. DataStruct dStruct = GetPostStruct();
  8342. List<string> lw = new List<string>();
  8343. string outsid = GetPostString("outsid");
  8344. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8345. string memo = GetPostString("memo");
  8346. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8347. string filename = GetPostString("filename");
  8348. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8349. string islate = GetPostString("islate");
  8350. if (islate.Length > 0)
  8351. {
  8352. if (islate == "1")
  8353. lw.Add(string.Format("OutLate>0"));
  8354. else
  8355. lw.Add(string.Format("OutLate=0"));
  8356. }
  8357. string placedate1 = GetPostString("placedate1");
  8358. string placedate2 = GetPostString("placedate2");
  8359. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8360. if (dw.Length > 0) lw.Add(dw);
  8361. string deliveryDate1 = GetPostString("deliverydate1");
  8362. string deliveryDate2 = GetPostString("deliverydate2");
  8363. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8364. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8365. dStruct.Order = "ID desc";
  8366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8367. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8368. writeGridDataTableJson(dStruct.TotalCount, dt);
  8369. }
  8370. public void ins_erp_placeregist()
  8371. {
  8372. if (UrlPostParmsCheck("id"))
  8373. {
  8374. string eid = GetPostString("id");
  8375. CeErpPlaceRegister entity = null;
  8376. if (eid == "0")//新增
  8377. {
  8378. entity = new CeErpPlaceRegister();
  8379. string xdTime = GetPostString("placeTime");
  8380. if (xdTime.Length > 0)
  8381. {
  8382. entity.PlactTime = Convert.ToDateTime(xdTime);
  8383. }
  8384. string fhTime = GetPostString("deliveryTime");
  8385. if (fhTime.Length > 0)
  8386. {
  8387. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8388. }
  8389. string preTime = GetPostString("preOutTime");
  8390. if (preTime.Length > 0)
  8391. {
  8392. entity.PreOutTime = Convert.ToDateTime(preTime);
  8393. }
  8394. entity.DeliveryCount = GetPostInt("deliveryCount");
  8395. entity.ReceiveCount = GetPostInt("receiveCount");
  8396. entity.OutSid = GetPostString("outSid");
  8397. entity.FileName = GetPostString("fileName");
  8398. entity.Memo = GetPostString("memo");
  8399. entity.AddUserId = CurrentUser.UserID;
  8400. entity.CreateTime = DateTime.Now;
  8401. entity.Img = GetPostString("img");
  8402. entity.Supplier = GetPostInt("supplier");
  8403. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8404. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8405. {
  8406. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8407. DateTime dt2 = (DateTime)entity.PreOutTime;
  8408. TimeSpan span = dt1.Subtract(dt2);
  8409. if (span.Days > 0)
  8410. {
  8411. entity.OutLate = span.Days;
  8412. }
  8413. }
  8414. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8415. entity.Create();
  8416. returnSuccessMsg("添加成功!");
  8417. return;
  8418. }
  8419. else //修改
  8420. {
  8421. entity = CeErpPlaceRegister.Get(eid);
  8422. if (entity != null)
  8423. {
  8424. string xdTime = GetPostString("placeTime");
  8425. if (xdTime.Length > 0)
  8426. {
  8427. entity.PlactTime = Convert.ToDateTime(xdTime);
  8428. }
  8429. string fhTime = GetPostString("deliveryTime");
  8430. if (fhTime.Length > 0)
  8431. {
  8432. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8433. }
  8434. string preTime = GetPostString("preOutTime");
  8435. if (preTime.Length > 0)
  8436. {
  8437. entity.PreOutTime = Convert.ToDateTime(preTime);
  8438. }
  8439. entity.DeliveryCount = GetPostInt("deliveryCount");
  8440. entity.ReceiveCount = GetPostInt("receiveCount");
  8441. if (entity.DeliveryCount == entity.ReceiveCount)
  8442. {
  8443. entity.CurState = "已完成";
  8444. }
  8445. else
  8446. {
  8447. entity.CurState = "未完成";
  8448. }
  8449. entity.OutSid = GetPostString("outSid");
  8450. entity.FileName = GetPostString("fileName");
  8451. entity.Memo = GetPostString("memo");
  8452. entity.Img = GetPostString("img");
  8453. entity.Supplier = GetPostInt("supplier");
  8454. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8455. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8456. {
  8457. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8458. DateTime dt2 = (DateTime)entity.PreOutTime;
  8459. TimeSpan span = dt1.Subtract(dt2);
  8460. if (span.Days > 0)
  8461. {
  8462. entity.OutLate = span.Days;
  8463. }
  8464. }
  8465. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8466. entity.Update();
  8467. returnSuccessMsg("修改成功");
  8468. return;
  8469. }
  8470. returnErrorMsg("找不到对应的记录");
  8471. return;
  8472. }
  8473. }
  8474. returnErrorMsg("缺少必要参数");
  8475. }
  8476. public void del_erp_placeregist()
  8477. {
  8478. string eid = GetPostString("id");
  8479. CeErpPlaceRegister.Del(eid);
  8480. returnSuccessMsg("删除成功!");
  8481. return;
  8482. }
  8483. public void ins_erp_placeregistbyorder()
  8484. {
  8485. string ctid = GetPostString("ctid");
  8486. if (ctid.Length > 0)
  8487. {
  8488. StringBuilder sql = new StringBuilder();
  8489. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8490. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8491. if (dt.Rows.Count > 0)
  8492. {
  8493. foreach (DataRow dr in dt.Rows)
  8494. {
  8495. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8496. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8497. entity.AddUserId = CurrentUser.UserID;
  8498. entity.tid = dr["tid"].ToString();
  8499. entity.Did = Convert.ToString(dr["ctid"]);
  8500. entity.splitTag = dr["SplitTag"].ToString();
  8501. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8502. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8503. if (pre_ctid.Length > 0)
  8504. {
  8505. sellmemo = sellmemo.Replace(pre_ctid, "");
  8506. }
  8507. sellmemo = sellmemo.Replace("[", "");
  8508. sellmemo = sellmemo.Replace("]", "");
  8509. entity.FileName = sellmemo;
  8510. string count = dr["ProductCount"].ToString();
  8511. int usecount = commonHelper.getIntCountFromString(count);
  8512. entity.DeliveryCount = usecount;
  8513. entity.CurState = "未完成";
  8514. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8515. {
  8516. entity.Supplier = 24;//dl手提袋定制
  8517. }
  8518. else
  8519. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8520. entity.CreateTime = DateTime.Now;
  8521. entity.Create();
  8522. }
  8523. returnSuccessMsg("操作成功");
  8524. return;
  8525. }
  8526. returnErrorMsg("没有找到对应订单");
  8527. return;
  8528. }
  8529. returnErrorMsg("缺少订单编号");
  8530. return;
  8531. }
  8532. public void get_erp_persuadelist()
  8533. {
  8534. DataStruct dStruct = GetPostStruct();
  8535. List<string> lw = new List<string>();
  8536. string ctid = GetPostString("ctid");
  8537. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8538. string shopname = GetPostString("shopname");
  8539. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8540. string buyernick = GetPostString("buyer_nick");
  8541. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8542. string customer = GetPostString("customer");
  8543. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8544. string returndate1 = GetPostString("returndate1");
  8545. string returndate2 = GetPostString("returndate2");
  8546. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8547. if (dw.Length > 0) lw.Add(dw);
  8548. string finishDate1 = GetPostString("finishdate1");
  8549. string finishDate2 = GetPostString("finishdate2");
  8550. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8551. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8552. string persuadetype = GetPostString("persuadetype");
  8553. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8554. string returnvstate = GetPostString("returnvstate");
  8555. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8556. dStruct.Order = "created desc";
  8557. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8558. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8559. writeGridDataTableJson(dStruct.TotalCount, dt);
  8560. }
  8561. public void upd_erp_returnpersuadeback()
  8562. {
  8563. if (UrlPostParmsCheck("ID"))
  8564. {
  8565. int eid = GetPostInt("ID");
  8566. CeErpPersuade entity = null;
  8567. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8568. if (entity != null)
  8569. {
  8570. entity.backreason = GetPostString("reason");
  8571. entity.pstate = 2;
  8572. entity.verifytime = DateTime.Now;
  8573. entity.verifyuserid = CurrentUser.UserID;
  8574. entity.Update();
  8575. returnSuccessMsg("退回成功!");
  8576. return;
  8577. }
  8578. returnErrorMsg("找不到订单记录");
  8579. }
  8580. }
  8581. public void upd_erp_returnpersuadeverify()
  8582. {
  8583. if (UrlPostParmsCheck("ID"))
  8584. {
  8585. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8586. {
  8587. returnErrorMsg("暂无权限审核");
  8588. return;
  8589. }
  8590. int eid = GetPostInt("ID");
  8591. CeErpPersuade entity = null;
  8592. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8593. if (entity != null)
  8594. {
  8595. entity.pstate = 1;
  8596. entity.verifytime = DateTime.Now;
  8597. entity.verifyuserid = CurrentUser.UserID;
  8598. entity.Update();
  8599. returnSuccessMsg("审核成功!");
  8600. return;
  8601. }
  8602. returnErrorMsg("找不到订单记录");
  8603. }
  8604. }
  8605. public void del_erp_persuade()
  8606. {
  8607. if (UrlPostParmsCheck("ID"))
  8608. {
  8609. int eid = GetPostInt("ID");
  8610. CeErpPersuade.Del(eid);
  8611. returnSuccessMsg("操作成功");
  8612. return;
  8613. }
  8614. }
  8615. public void get_erp_oldcustoupload()
  8616. {
  8617. DataStruct dStruct = GetPostStruct();
  8618. List<string> lw = new List<string>();
  8619. string buyernick = GetPostString("buyer_nick");
  8620. if (buyernick.Length > 0)
  8621. {
  8622. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8623. }
  8624. else
  8625. return;
  8626. dStruct.Order = "pay_time desc";
  8627. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8628. DataTable dt = null;
  8629. dt = WebCache.GetData("view_erptradecell", dStruct);
  8630. writeGridDataTableJson(dStruct.TotalCount, dt);
  8631. }
  8632. public void get_erp_checkorderlist()
  8633. {
  8634. DataStruct dStruct = GetPostStruct();
  8635. List<string> lw = new List<string>();
  8636. string tid = GetPostString("ctid");
  8637. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8638. string shopname = GetPostString("shopname");
  8639. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8640. string buyernick = GetPostString("buyer_nick");
  8641. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8642. string customer = GetPostString("customer");
  8643. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8644. string design = GetPostString("design");
  8645. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8646. string orderState = GetPostString("orderState");
  8647. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8648. string address = GetPostString("address");
  8649. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8650. string sellermemo = GetPostString("seller_memo");
  8651. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8652. string supplier = GetPostString("supplier");
  8653. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8654. {
  8655. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8656. }
  8657. else
  8658. {
  8659. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8660. }
  8661. string checkst = GetPostString("checkstate");
  8662. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8663. string date1 = GetPostString("date1");
  8664. string date2 = GetPostString("date2");
  8665. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8666. if (dw.Length > 0) lw.Add(dw);
  8667. string placedate1 = GetPostString("placedate1");
  8668. string placedate2 = GetPostString("placedate2");
  8669. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8670. if (fdw.Length > 0) lw.Add(fdw);
  8671. string price1 = GetPostString("price1");
  8672. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8673. string price2 = GetPostString("price2");
  8674. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8675. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8676. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8678. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8679. writeGridDataTableJson(dStruct.TotalCount, dt);
  8680. }
  8681. public void ins_erp_startCheck()
  8682. {
  8683. if (UrlPostParmsCheck("ctid"))
  8684. {
  8685. string eid = GetPostString("ctid");
  8686. CeErpTradeCell entity = null;
  8687. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8688. if (entity != null)
  8689. {
  8690. entity.MemoOpt = 4;
  8691. entity.Update();
  8692. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8693. CeErpSukuraData.createInfo(entity.ctid, 6);
  8694. returnSuccessMsg("操作成功!");
  8695. return;
  8696. }
  8697. returnErrorMsg("找不到记录");
  8698. }
  8699. }
  8700. public void upd_erp_sendXlw()
  8701. {
  8702. if (UrlPostParmsCheck("ctid"))
  8703. {
  8704. string eid = GetPostString("ctid");
  8705. CeErpTradeCell entity = null;
  8706. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8707. if (entity != null)
  8708. {
  8709. if (entity.IsSendGift == 1)
  8710. {
  8711. returnErrorMsg("请勿重复标记");
  8712. return;
  8713. }
  8714. entity.IsSendGift = 1;
  8715. entity.Update();
  8716. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8717. returnSuccessMsg("操作成功!");
  8718. return;
  8719. }
  8720. returnErrorMsg("找不到记录");
  8721. }
  8722. }
  8723. public void cancel_sendXlw()
  8724. {
  8725. if (UrlPostParmsCheck("ctid"))
  8726. {
  8727. string eid = GetPostString("ctid");
  8728. CeErpTradeCell entity = null;
  8729. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8730. if (entity != null)
  8731. {
  8732. if (entity.IsSendGift == 0)
  8733. {
  8734. returnErrorMsg("未标记小礼物");
  8735. return;
  8736. }
  8737. entity.IsSendGift = 0;
  8738. entity.Update();
  8739. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8740. returnSuccessMsg("操作成功!");
  8741. return;
  8742. }
  8743. returnErrorMsg("找不到记录");
  8744. }
  8745. }
  8746. public void get_erp_designbill()
  8747. {
  8748. DataStruct dStruct = GetPostStruct();
  8749. List<string> lw = new List<string>();
  8750. int isMy = GetInt("my");
  8751. if (isMy == 1)
  8752. {
  8753. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8754. }
  8755. string tid = GetPostString("tid");
  8756. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8757. string userName = GetPostString("design");
  8758. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8759. string price1 = GetPostString("price1");
  8760. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8761. string price2 = GetPostString("price2");
  8762. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8763. string rePrice1 = GetPostString("rePrice1");
  8764. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8765. string rePrice2 = GetPostString("rePrice2");
  8766. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8767. string designerType = GetPostString("designerType");
  8768. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8769. string orderState = GetPostString("orderState");
  8770. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8771. string endTime1 = GetPostString("endTime1");
  8772. string endTime2 = GetPostString("endTime2");
  8773. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8774. if (dw.Length > 0) lw.Add(dw);
  8775. string isDk = GetPostString("isDk");
  8776. if (isDk == "1")
  8777. {
  8778. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8779. }
  8780. else if (isDk == "0")
  8781. {
  8782. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8783. }
  8784. dStruct.Order = "oid, create_time desc";
  8785. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8786. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8787. writeGridDataTableJson(dStruct.TotalCount, dt);
  8788. }
  8789. public void upd_erp_designerbill()
  8790. {
  8791. if (UrlPostParmsCheck("ID"))
  8792. {
  8793. string eid = GetPostString("ID");
  8794. CeErpDesignerBill entity = null;
  8795. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8796. if (entity != null)
  8797. {
  8798. if (GetPostDouble("designerpirce") > 0)
  8799. {
  8800. entity.realPrice = GetPostDouble("designerpirce");
  8801. entity.update_time = DateTime.Now;
  8802. entity.update_u_id = CurrentUser.UserID;
  8803. entity.update_u_name = CurrentUser.UserName;
  8804. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8805. entity.Update();
  8806. returnSuccessMsg("操作成功!");
  8807. return;
  8808. }
  8809. else
  8810. {
  8811. entity.price = GetPostDouble("price");
  8812. entity.update_time = DateTime.Now;
  8813. entity.update_u_id = CurrentUser.UserID;
  8814. entity.update_u_name = CurrentUser.UserName;
  8815. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8816. entity.Update();
  8817. returnSuccessMsg("操作成功!");
  8818. return;
  8819. }
  8820. }
  8821. returnErrorMsg("找不到记录");
  8822. }
  8823. }
  8824. public void audit_erp_designerbill()
  8825. {
  8826. if (UrlPostParmsCheck("ID"))
  8827. {
  8828. string eid = GetPostString("ID");
  8829. CeErpDesignerBill entity = null;
  8830. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8831. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8832. if (entity != null)
  8833. {
  8834. entity.realPrice = GetPostDouble("designerpirce");
  8835. entity.update_time = DateTime.Now;
  8836. entity.update_u_id = CurrentUser.UserID;
  8837. entity.update_u_name = CurrentUser.UserName;
  8838. entity.isAudit = 1;
  8839. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8840. entity.Update();
  8841. if (orderEntity != null)
  8842. {
  8843. orderEntity.IsReadTag = 3;
  8844. orderEntity.Update();
  8845. }
  8846. returnSuccessMsg("操作成功!");
  8847. return;
  8848. }
  8849. returnErrorMsg("找不到记录");
  8850. }
  8851. }
  8852. public void all_audit_erp_designerbill()
  8853. {
  8854. if (UrlPostParmsCheck("idList"))
  8855. {
  8856. string[] list = GetPostString("idList").Split(',');
  8857. CeErpDesignerBill entity = null;
  8858. for (int i = 0; i < list.Length; i++)
  8859. {
  8860. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8861. if (entity == null) return;
  8862. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8863. if (orderEntity == null) return;
  8864. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8865. entity.update_time = DateTime.Now;
  8866. entity.update_u_id = CurrentUser.UserID;
  8867. entity.update_u_name = CurrentUser.UserName;
  8868. entity.isAudit = 1;
  8869. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8870. entity.Update();
  8871. orderEntity.IsReadTag = 3;
  8872. orderEntity.Update();
  8873. }
  8874. returnSuccessMsg("操作成功!");
  8875. return;
  8876. }
  8877. }
  8878. public void get_erp_sameorders()
  8879. {
  8880. if (UrlPostParmsCheck("ctid"))
  8881. {
  8882. string eid = GetPostString("ctid");
  8883. CeErpTradeCell entity = null;
  8884. entity = CeErpTradeCell.GetByCtid(eid);
  8885. if (entity != null)
  8886. {
  8887. StringBuilder sql = new StringBuilder();
  8888. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8889. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8890. var res = new
  8891. {
  8892. data = dt.Rows.Count
  8893. };
  8894. string ro_jsond = JsonConvert.SerializeObject(res);
  8895. returnSuccess(ro_jsond);
  8896. return;
  8897. }
  8898. returnErrorMsg("未找到订单");
  8899. return;
  8900. }
  8901. returnErrorMsg("缺少必要的参数");
  8902. }
  8903. public void get_erp_islasthavesameorder()
  8904. {
  8905. if (UrlPostParmsCheck("ctid"))
  8906. {
  8907. string eid = GetPostString("ctid");
  8908. string[] ctidList = eid.Split(',');
  8909. StringBuilder sql = new StringBuilder();
  8910. string tisCtid = "";
  8911. foreach (string ctid in ctidList)
  8912. {
  8913. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8914. if (entity != null)
  8915. {
  8916. sql = new StringBuilder();
  8917. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8918. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8919. if (dth.Rows.Count > 0)
  8920. {
  8921. tisCtid += entity.ctid;
  8922. tisCtid += ",";
  8923. }
  8924. }
  8925. }
  8926. if (tisCtid.Length > 0)
  8927. {
  8928. var res = new
  8929. {
  8930. data = tisCtid
  8931. };
  8932. string ro_jsond = JsonConvert.SerializeObject(res);
  8933. returnSuccess(ro_jsond);
  8934. }
  8935. else
  8936. {
  8937. var res = new
  8938. {
  8939. data = ""
  8940. };
  8941. string ro_jsond = JsonConvert.SerializeObject(res);
  8942. returnSuccess(ro_jsond);
  8943. }
  8944. return;
  8945. }
  8946. returnErrorMsg("缺少必要的参数");
  8947. }
  8948. public void file_client_down_url()
  8949. {
  8950. if (!UrlPostParmsCheck("userId"))
  8951. {
  8952. returnErrorMsg("缺少必要的参数");
  8953. }
  8954. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  8955. }
  8956. public void checkout_form_data()
  8957. {
  8958. if (!UrlPostParmsCheck("tid"))
  8959. {
  8960. returnErrorMsg("缺少必要的参数");
  8961. }
  8962. string tid = GetPostString("tid");
  8963. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  8964. if (ceErpOrderFormData != null)
  8965. {
  8966. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  8967. returnSuccess(ro_jsond);
  8968. return;
  8969. }
  8970. returnErrorMsg("尚未有文件!");
  8971. }
  8972. public void back_supplier_audit()
  8973. {
  8974. int userId = CurrentUser.UserID;
  8975. StringBuilder sql = new StringBuilder();
  8976. 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);
  8977. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8978. if (dt.Rows.Count > 0)
  8979. {
  8980. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8981. }
  8982. else
  8983. {
  8984. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8985. }
  8986. }
  8987. public void back_supplier_query()
  8988. {
  8989. string eid = GetPostString("ctid");
  8990. if (eid != "")
  8991. {
  8992. StringBuilder sql = new StringBuilder();
  8993. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  8994. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8995. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8996. }
  8997. else
  8998. {
  8999. returnErrorMsg("找不到订单记录");
  9000. return;
  9001. }
  9002. }
  9003. public void verified_to_order()
  9004. {
  9005. int userId = CurrentUser.UserID;
  9006. StringBuilder sql = new StringBuilder();
  9007. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9008. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9009. if (dt.Rows.Count > 0)
  9010. {
  9011. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9012. }
  9013. else
  9014. {
  9015. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9016. }
  9017. }
  9018. public void upd_supplier_audit()
  9019. {
  9020. if (UrlPostParmsCheck("ctid"))
  9021. {
  9022. string eid = GetPostString("ctid");
  9023. string reason = GetPostString("returnreason");
  9024. CeErpTradeCell entity = null;
  9025. CeWithdraw withdraw = null;
  9026. withdraw = CeWithdraw.GetByTid(eid);
  9027. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9028. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9029. {
  9030. if (withdraw != null)
  9031. {
  9032. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9033. {
  9034. returnSuccessMsg("您没有权限操作!");
  9035. return;
  9036. }
  9037. else
  9038. {
  9039. if (reason.Equals("1"))
  9040. {
  9041. if (entity.OrderState == -1)
  9042. {
  9043. if (entity.FinishPlaceTime == null)
  9044. {
  9045. entity.OrderState = 2;
  9046. }
  9047. else
  9048. {
  9049. entity.OrderState = 6;
  9050. }
  9051. }
  9052. entity.Update();
  9053. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9054. if (withdraw != null)
  9055. {
  9056. withdraw.status = int.Parse(reason);
  9057. withdraw.Update();
  9058. }
  9059. returnSuccessMsg("操作成功!");
  9060. return;
  9061. }
  9062. else
  9063. {
  9064. withdraw.status = int.Parse(reason);
  9065. withdraw.acknowledgingtime = DateTime.Now;
  9066. withdraw.Update();
  9067. returnSuccessMsg("查看详细请点击线下订单查询");
  9068. return;
  9069. }
  9070. }
  9071. }
  9072. // 第一个字符是 'N'
  9073. }
  9074. if (eid[0] != 'N')
  9075. {
  9076. }
  9077. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9078. {
  9079. entity.IsVerifyToSupplier = false;
  9080. entity.IsReturn = 1;
  9081. entity.ReturnTime = DateTime.Now;
  9082. entity.ReturnReason = reason;
  9083. if (entity.OrderState == 6)
  9084. {
  9085. entity.OrderState = 5;
  9086. }
  9087. entity.Update();
  9088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9089. if (withdraw != null)
  9090. {
  9091. withdraw.status = int.Parse(reason);
  9092. withdraw.Update();
  9093. }
  9094. returnSuccessMsg("操作成功!");
  9095. return;
  9096. }
  9097. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9098. {
  9099. ;
  9100. if (withdraw != null)
  9101. {
  9102. withdraw.status = int.Parse(reason);
  9103. withdraw.acknowledgingtime = DateTime.Now;
  9104. withdraw.Update();
  9105. returnSuccessMsg("供应商取消撤回!");
  9106. return;
  9107. }
  9108. }
  9109. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9110. {
  9111. if (entity.OrderState == -1)
  9112. {
  9113. if (entity.FinishPlaceTime == null)
  9114. {
  9115. entity.OrderState = 2;
  9116. }
  9117. else
  9118. {
  9119. entity.OrderState = 3;
  9120. }
  9121. commonHelper.getCytPrice(entity);
  9122. }
  9123. entity.Update();
  9124. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9125. if (withdraw != null)
  9126. {
  9127. withdraw.status = int.Parse(reason);
  9128. withdraw.Update();
  9129. }
  9130. returnSuccessMsg("操作成功!");
  9131. return;
  9132. }
  9133. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9134. {
  9135. if (withdraw == null)
  9136. {
  9137. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9138. return;
  9139. }
  9140. }
  9141. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9142. {
  9143. if (withdraw != null)
  9144. {
  9145. withdraw.status = int.Parse(reason);
  9146. withdraw.acknowledgingtime = DateTime.Now;
  9147. withdraw.Update();
  9148. returnSuccessMsg("查看详细请点击线下订单查询");
  9149. return;
  9150. }
  9151. }
  9152. return;
  9153. }
  9154. }
  9155. //校验报价
  9156. public void refund_order_tip()
  9157. {
  9158. int userid = CurrentUser.UserID;
  9159. int sectionId = CurrentUser.UserPost.OrgID;
  9160. StringBuilder sql = new StringBuilder();
  9161. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9162. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9163. List<string> ids = new List<string>();
  9164. if (dth.Rows.Count > 0)
  9165. {
  9166. foreach (DataRow dr in dth.Rows)
  9167. {
  9168. ids.Add(dr["ID"].ToString());
  9169. }
  9170. try
  9171. {
  9172. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9173. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9174. }
  9175. catch (Exception ex)
  9176. {
  9177. }
  9178. }
  9179. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9180. }
  9181. public void refund_order_Design()
  9182. {
  9183. int userid = CurrentUser.UserID;
  9184. int sectionId = CurrentUser.UserPost.OrgID;
  9185. StringBuilder sql = new StringBuilder();
  9186. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9187. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9188. List<string> ids = new List<string>();
  9189. if (dth.Rows.Count > 0)
  9190. {
  9191. foreach (DataRow dr in dth.Rows)
  9192. {
  9193. ids.Add(dr["ID"].ToString());
  9194. }
  9195. try
  9196. {
  9197. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9198. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9199. }
  9200. catch (Exception ex)
  9201. {
  9202. }
  9203. }
  9204. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9205. }
  9206. public void change_order_info()
  9207. {
  9208. int userid = CurrentUser.UserID;
  9209. StringBuilder sql = new StringBuilder();
  9210. 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);
  9211. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9212. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9213. }
  9214. public void change_win_mome()
  9215. {
  9216. if (UrlPostParmsCheck("id,ctid"))
  9217. {
  9218. string id = GetPostString("id");
  9219. string ctid = GetPostString("ctid");
  9220. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9221. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9222. if (ce == null || ceErpMessageTip == null)
  9223. {
  9224. returnSuccessMsg("未找到对应的订单!");
  9225. return;
  9226. }
  9227. int type = GetPostInt("type");
  9228. string content = GetPostString("content");
  9229. if (type == 0)
  9230. {
  9231. content = content.Replace("(", "(");
  9232. content = content.Replace(")", ")");
  9233. string check = MidStrEx(content, "(", ")").Trim();
  9234. if (string.IsNullOrEmpty(check))
  9235. {
  9236. returnSuccessMsg("文件名格式不正确");
  9237. return;
  9238. }
  9239. }
  9240. ce.seller_memo = content;
  9241. ce.Update();
  9242. ceErpMessageTip.isVisit = true;
  9243. ceErpMessageTip.Update();
  9244. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9245. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9246. ApiVo apiVo = new ApiVo();
  9247. apiVo.orderNumber = ce.ctid;
  9248. apiVo.actionName = "demandDesign";
  9249. apiVo.orderRemarks = content;
  9250. apiVo.demandExamine = type + 1;
  9251. designHelper.API_WorkCore(apiVo);//demandDesign
  9252. returnSuccessMsg("修改成功!");
  9253. }
  9254. }
  9255. public static string MidStrEx(string sourse, string startstr, string endstr)
  9256. {
  9257. string result = string.Empty;
  9258. int startindex, endindex;
  9259. try
  9260. {
  9261. startindex = sourse.IndexOf(startstr);
  9262. if (startindex == -1)
  9263. return result;
  9264. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9265. endindex = tmpstr.IndexOf(endstr);
  9266. if (endindex == -1)
  9267. return result;
  9268. result = tmpstr.Remove(endindex);
  9269. }
  9270. catch (Exception ex)
  9271. {
  9272. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9273. }
  9274. return result;
  9275. }
  9276. public void refund_order_list()
  9277. {
  9278. int userid = CurrentUser.UserID;
  9279. int sectionId = CurrentUser.UserPost.OrgID;
  9280. StringBuilder sql = new StringBuilder();
  9281. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9282. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9283. DataStruct dStruct = GetPostStruct();
  9284. DataTable dt = null;
  9285. List<string> ids = new List<string>();
  9286. List<string> tids = new List<string>();
  9287. if (dth.Rows.Count > 0)
  9288. {
  9289. foreach (DataRow dr in dth.Rows)
  9290. {
  9291. tids.Add("'" + dr["tid"].ToString() + "'");
  9292. ids.Add(dr["id"].ToString());
  9293. }
  9294. try
  9295. {
  9296. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9297. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9298. List<string> lw = new List<string>();
  9299. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9301. dt = WebCache.GetData("view_orderlist", dStruct);
  9302. }
  9303. catch (Exception ex)
  9304. {
  9305. }
  9306. }
  9307. writeGridDataTableJson(dStruct.TotalCount, dt);
  9308. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9309. }
  9310. //新增
  9311. public void order_batch_downloads()
  9312. {
  9313. string ceid = GetPostString("tid");
  9314. String[] tid = ceid.Split(',');
  9315. order_batch_caiyingtong(tid);
  9316. /* (string success, string errors) = UploadFiles(tid);
  9317. returnSuccessMsg(success + errors);*/
  9318. return;
  9319. }
  9320. //报价接口
  9321. public void Get_To_Quote()
  9322. {
  9323. string ceid = GetPostString("ctid");
  9324. if (ceid != null)
  9325. {
  9326. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9327. if (entity != null)
  9328. {
  9329. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9330. double price = 0;
  9331. if (cp == null)
  9332. {
  9333. JObject jsonObject12 = new JObject
  9334. {
  9335. { "UserId", "77886" },
  9336. { "Pwd", "lt666888" },
  9337. { "Filename", entity.seller_memo }
  9338. };
  9339. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9340. JObject jsonObjects1 = JObject.Parse(response1);
  9341. string ms1g = (string)jsonObjects1["msg"];
  9342. if (ms1g == "报价成功")
  9343. {
  9344. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9345. string data = (string)jsonObject1["price"];
  9346. 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 + "');";
  9347. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9348. returnSuccessMsg("获取报价成功:" + data);
  9349. price = Convert.ToDouble(data);
  9350. }
  9351. else
  9352. {
  9353. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9354. return;
  9355. }
  9356. }
  9357. String[] beizhu = entity.seller_memo.Split('-');
  9358. String chanp = "";
  9359. if (beizhu.Length > 0)
  9360. {
  9361. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9362. }
  9363. else
  9364. {
  9365. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9366. }
  9367. JObject jsonObject = new JObject
  9368. {
  9369. { "UserId", "77886" },
  9370. { "Pwd", "lt666888" },
  9371. { "Filename", chanp }
  9372. };
  9373. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9374. JObject jsonObjects = JObject.Parse(response);
  9375. string msg = (string)jsonObjects["msg"];
  9376. if (msg == "报价成功")
  9377. {
  9378. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9379. string data = (string)jsonObject1["price"];
  9380. 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 + "');";
  9381. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9382. returnSuccessMsg("获取报价成功:" + data);
  9383. price = Convert.ToDouble(data);
  9384. }
  9385. else
  9386. {
  9387. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9388. return;
  9389. }
  9390. if (price > 0)
  9391. {
  9392. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9393. if (ceErpTradeCellExtend == null)
  9394. {
  9395. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9396. ceErpTradeCellExtend.ctid = entity.ctid;
  9397. ceErpTradeCellExtend.payment_cyt = price;
  9398. ceErpTradeCellExtend.Create();
  9399. }
  9400. else
  9401. {
  9402. ceErpTradeCellExtend.payment_cyt = price;
  9403. ceErpTradeCellExtend.Update();
  9404. }
  9405. }
  9406. return;
  9407. }
  9408. }
  9409. else
  9410. {
  9411. returnErrorMsg("请至少选择一条数据");
  9412. return;
  9413. }
  9414. }
  9415. //新增
  9416. public void order_To_Supplier()
  9417. {
  9418. string ceid = GetPostString("tid");
  9419. String[] tid = ceid.Split(',');
  9420. if (tid.Length > 0)
  9421. {
  9422. try
  9423. {
  9424. for (int i = 0; i < tid.Length; i++)
  9425. {
  9426. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9427. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9428. entity.SupplierId = suid;
  9429. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9430. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9431. entity.Update();
  9432. }
  9433. }
  9434. catch (Exception ex)
  9435. {
  9436. returnErrorMsg("自动匹配供应商失败");
  9437. return;
  9438. }
  9439. }
  9440. else
  9441. {
  9442. returnErrorMsg("请至少选择一条数据");
  9443. return;
  9444. }
  9445. returnSuccessMsg("自动匹配供应商成功");
  9446. return;
  9447. }
  9448. public (string, string) UploadFiles(string[] urls)
  9449. {
  9450. string success = "";
  9451. string errors = "";
  9452. int userid = CurrentUser.UserID;
  9453. foreach (string url in urls)
  9454. {
  9455. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9456. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9457. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9458. {
  9459. JObject jsonObject = new JObject
  9460. {
  9461. { "Userid", "77886" },
  9462. { "pwd", "cyt86435015" },
  9463. { "content", base64FileContent },
  9464. { "ext", Path.GetExtension(fileName) }
  9465. };
  9466. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9467. JObject jsonObjects = JObject.Parse(response);
  9468. string msg = (string)jsonObjects["msg"];
  9469. if (msg.Equals("上传成功"))
  9470. {
  9471. success += url + " 上传成功";
  9472. }
  9473. else
  9474. {
  9475. errors += url + " 上传失败";
  9476. }
  9477. }
  9478. else
  9479. {
  9480. errors += url + " 格式出现问题";
  9481. }
  9482. }
  9483. if (urls.Length == 0)
  9484. {
  9485. return (success, errors);
  9486. }
  9487. return (success, errors);
  9488. }
  9489. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9490. {
  9491. return true; //总是接受
  9492. }
  9493. public static string HttpPost(string url, string param = null)
  9494. {
  9495. HttpWebRequest request;
  9496. //如果是发送HTTPS请求
  9497. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9498. {
  9499. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9500. request = WebRequest.Create(url) as HttpWebRequest;
  9501. request.ProtocolVersion = HttpVersion.Version10;
  9502. }
  9503. else
  9504. {
  9505. request = WebRequest.Create(url) as HttpWebRequest;
  9506. }
  9507. request.Method = "POST";
  9508. request.ContentType = "application/json";
  9509. request.Accept = "*/*";
  9510. request.Timeout = 120000;
  9511. request.AllowAutoRedirect = false;
  9512. StreamWriter requestStream = null;
  9513. WebResponse response = null;
  9514. string responseStr = null;
  9515. try
  9516. {
  9517. requestStream = new StreamWriter(request.GetRequestStream());
  9518. requestStream.Write(param);
  9519. requestStream.Close();
  9520. response = request.GetResponse();
  9521. if (response != null)
  9522. {
  9523. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9524. responseStr = reader.ReadToEnd();
  9525. reader.Close();
  9526. }
  9527. }
  9528. catch (Exception ex)
  9529. {
  9530. return ex.Message;
  9531. }
  9532. finally
  9533. {
  9534. request = null;
  9535. requestStream = null;
  9536. response = null;
  9537. }
  9538. return responseStr;
  9539. }
  9540. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9541. {
  9542. string base64FileContent;
  9543. string fileName;
  9544. using (WebClient webClient = new WebClient())
  9545. {
  9546. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9547. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9548. {
  9549. using (Stream stream = response.GetResponseStream())
  9550. {
  9551. using (MemoryStream memoryStream = new MemoryStream())
  9552. {
  9553. stream.CopyTo(memoryStream);
  9554. byte[] fileBytes = memoryStream.ToArray();
  9555. base64FileContent = Convert.ToBase64String(fileBytes);
  9556. fileName = response.Headers["Content-Disposition"];
  9557. if (!string.IsNullOrEmpty(fileName))
  9558. {
  9559. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9560. if (index >= 0)
  9561. {
  9562. fileName = fileName.Substring(index + 9).Trim('\"');
  9563. }
  9564. }
  9565. else
  9566. {
  9567. fileName = Path.GetFileName(downloadUrl);
  9568. }
  9569. }
  9570. }
  9571. }
  9572. }
  9573. return (fileName, base64FileContent);
  9574. }
  9575. //新增
  9576. public void order_batch_caiyingtong(string[] downloadUrls)
  9577. {
  9578. try
  9579. {
  9580. //遍历文件
  9581. DataStruct dStruct = GetPostStruct();
  9582. DataTable dt = null;
  9583. int userid = CurrentUser.UserID;
  9584. List<string> ids = new List<string>();//失败组
  9585. List<string> tids = new List<string>();
  9586. using (WebClient webClient = new WebClient())
  9587. {
  9588. foreach (var url in downloadUrls)
  9589. {
  9590. try
  9591. {
  9592. tids.Add("'" + url + "'");
  9593. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9594. if (entity != null)
  9595. {
  9596. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9597. if (cp == null)
  9598. {
  9599. JObject jsonObject = new JObject
  9600. {
  9601. { "Userid", "77886" },
  9602. { "pwd", "lt666888" },
  9603. { "Filename",entity.seller_memo }
  9604. };
  9605. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9606. JObject jsonObjects = JObject.Parse(response);
  9607. string msg = (string)jsonObjects["msg"];
  9608. if (msg == "报价成功")
  9609. {
  9610. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9611. DownloadAndConvertToBase64(url1);
  9612. }
  9613. else
  9614. {
  9615. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9616. }
  9617. }
  9618. else
  9619. {
  9620. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9621. JObject jsonObject = new JObject
  9622. {
  9623. { "Userid", "77886" },
  9624. { "pwd", "lt666888" },
  9625. { "Filename",chanp }
  9626. };
  9627. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9628. JObject jsonObjects = JObject.Parse(response);
  9629. string msg = (string)jsonObjects["msg"];
  9630. if (msg == "报价成功")
  9631. {
  9632. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9633. DownloadAndConvertToBase64(url1);
  9634. }
  9635. else
  9636. {
  9637. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9638. }
  9639. }
  9640. }
  9641. // 上传文件到FTP
  9642. }
  9643. catch (Exception ex)
  9644. {
  9645. Console.WriteLine($"An error occurred: {ex.Message}");
  9646. }
  9647. }
  9648. List<string> lw = new List<string>();
  9649. lw.Add(string.Format("( OrderState < 6 )"));
  9650. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9651. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9652. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9653. if (dt.Rows.Count > 0)
  9654. {
  9655. foreach (DataRow dr in dt.Rows)
  9656. {
  9657. ids.Add(dr["ctid"].ToString());
  9658. }
  9659. }
  9660. String ErrorMsgs = "";
  9661. foreach (String id in ids)
  9662. {
  9663. ErrorMsgs += id + ",";
  9664. }
  9665. if (ErrorMsgs.Length > 1)
  9666. {
  9667. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9668. }
  9669. if (ErrorMsgs.Length < 1)
  9670. {
  9671. ErrorMsgs = "上传成功";
  9672. returnSuccessMsg(ErrorMsgs);
  9673. }
  9674. else
  9675. {
  9676. returnErrorMsg("以下订单" + ErrorMsgs);
  9677. }
  9678. }
  9679. // 删除文件夹及其内容
  9680. /* Directory.Delete(localDirectory, true);*/
  9681. }
  9682. catch { }
  9683. }
  9684. public void get_center_data()
  9685. {
  9686. int userId = CurrentUser.UserID;
  9687. string postCode = CurrentUser.UserPost.Post.Code;
  9688. List<string> lw = new List<string>();
  9689. List<string> ww = new List<string>();
  9690. DateTime currentTime = DateTime.Now;
  9691. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9692. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9693. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9694. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9695. string sql = " SELECT ";
  9696. string startTime = "2023-10-01 11:22:31";
  9697. //设计
  9698. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9699. {
  9700. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9701. 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));
  9702. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9703. 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));
  9704. }
  9705. //客服
  9706. else if (postCode == "CustomerService" || postCode == "Director")
  9707. {
  9708. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9709. 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));
  9710. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9711. 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));
  9712. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9713. 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));
  9714. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9715. 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));
  9716. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9717. 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));
  9718. }
  9719. //售后
  9720. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9721. {
  9722. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9723. 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));
  9724. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9725. 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));
  9726. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9727. 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));
  9728. }
  9729. //下单部
  9730. else if (postCode == "Place" || postCode == "PlaceMr")
  9731. {
  9732. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9733. 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));
  9734. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9735. 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));
  9736. }
  9737. //车间
  9738. else if (postCode == "Supplier")
  9739. {
  9740. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9741. 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));
  9742. }
  9743. DataTable dt = new DataTable();
  9744. if (lw.Count > 0)
  9745. {
  9746. sql += string.Join(" , ", lw);
  9747. sql += " FROM ";
  9748. sql += string.Join(" , ", ww);
  9749. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9750. }
  9751. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9752. }
  9753. public void get_center_data_list()
  9754. {
  9755. int userId = CurrentUser.UserID;
  9756. string postCode = CurrentUser.UserPost.Post.Code;
  9757. string shopIds = CurrentUser.User.pemShop;
  9758. DataStruct dStruct = GetPostStruct();
  9759. List<string> lw = new List<string>();
  9760. DateTime currentTime = DateTime.Now;
  9761. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9762. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9763. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9764. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9765. string startTime = "2023-10-01 11:22:31";
  9766. int order_type = GetPostInt("order_type");
  9767. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9768. {
  9769. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9770. if (order_type == 0)
  9771. {
  9772. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9773. }
  9774. else if (order_type == 3)
  9775. {
  9776. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9777. }
  9778. else
  9779. {
  9780. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9781. }
  9782. }
  9783. //客服
  9784. if (postCode == "CustomerService" || postCode == "Director")
  9785. {
  9786. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9787. if (order_type == 0)
  9788. {
  9789. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9790. }
  9791. else if (order_type == 1)
  9792. {
  9793. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9794. }
  9795. else if (order_type == 2)
  9796. {
  9797. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9798. }
  9799. else if (order_type == 3)
  9800. {
  9801. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9802. }
  9803. else if (order_type == 4)
  9804. {
  9805. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9806. }
  9807. else
  9808. {
  9809. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9810. }
  9811. }
  9812. //售后
  9813. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9814. {
  9815. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9816. if (shopIds != "")
  9817. {
  9818. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9819. }
  9820. if (order_type == 2)
  9821. {
  9822. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9823. }
  9824. else if (order_type == 4)
  9825. {
  9826. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9827. }
  9828. else if (order_type == 5)
  9829. {
  9830. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9831. }
  9832. else
  9833. {
  9834. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9835. }
  9836. }
  9837. //下单部
  9838. if (postCode == "Place" || postCode == "PlaceMr")
  9839. {
  9840. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9841. if (shopIds != "")
  9842. {
  9843. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9844. }
  9845. else if (order_type == 1)
  9846. {
  9847. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9848. }
  9849. else if (order_type == 2)
  9850. {
  9851. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9852. }
  9853. else
  9854. {
  9855. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9856. }
  9857. }
  9858. //车间
  9859. if (postCode == "Supplier")
  9860. {
  9861. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9862. if (order_type == 5)
  9863. {
  9864. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9865. }
  9866. else
  9867. {
  9868. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9869. }
  9870. }
  9871. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9872. dStruct.Fileds = "tid,ctid";
  9873. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9874. writeGridDataTableJson(dStruct.TotalCount, dt);
  9875. }
  9876. public void aftersale_audit_master()
  9877. {
  9878. if (UrlPostParmsCheck("ctid"))
  9879. {
  9880. string ctid = GetPostString("ctid");
  9881. if (ctid.Length > 0)
  9882. {
  9883. bool result = aftersale_data_change(ctid);
  9884. if (result)
  9885. {
  9886. returnSuccessMsg("修改成功!");
  9887. return;
  9888. }
  9889. }
  9890. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9891. }
  9892. }
  9893. public void aftersale_batch_audit_master()
  9894. {
  9895. if (UrlPostParmsCheck("ctids"))
  9896. {
  9897. string ctids = GetPostString("ctids");
  9898. if (ctids.Length > 0)
  9899. {
  9900. List<string> list = new List<string>();
  9901. string[] ctid_list = ctids.Split(',');
  9902. foreach (var item in ctid_list)
  9903. {
  9904. bool result = aftersale_data_change(item);
  9905. if (!result)
  9906. {
  9907. list.Add(item);
  9908. }
  9909. }
  9910. if (list.Count > 0)
  9911. {
  9912. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9913. return;
  9914. }
  9915. returnSuccessMsg("修改成功!");
  9916. return;
  9917. }
  9918. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9919. }
  9920. }
  9921. public bool aftersale_data_change(string ctid)
  9922. {
  9923. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9924. if (ceErpTradeCell != null)
  9925. {
  9926. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9927. ceErpTradeCell.AfterSaleSupplierState = 0;
  9928. StringBuilder sql = new StringBuilder();
  9929. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9930. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9931. CeErpTradeResponsible.DelByTid(ctid, 0);
  9932. 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 == "不理赔")
  9933. {
  9934. CeErpTradeResponsible.DelByTid(ctid, 1);
  9935. ceErpTradeCell.AfterSaleSupplierState = 1;
  9936. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9937. ceErpTradeCell.AfterSaleState = 4;
  9938. }
  9939. else
  9940. {
  9941. ceErpTradeCell.AfterSaleState = 3;
  9942. }
  9943. bool needCyt = false;
  9944. if (dt != null)
  9945. {
  9946. if (dt.Rows.Count == 1)
  9947. {
  9948. bool isEnd = false;
  9949. foreach (DataRow dr in dt.Rows)
  9950. {
  9951. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9952. {
  9953. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9954. isEnd = true;
  9955. }
  9956. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  9957. {
  9958. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9959. isEnd = true;
  9960. }
  9961. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9962. {
  9963. needCyt = true;
  9964. }
  9965. }
  9966. if (isEnd)
  9967. {
  9968. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9969. ceErpTradeCell.AfterSaleState = 4;
  9970. ceErpTradeCell.AfterSaleSupplierState = 1;
  9971. }
  9972. }
  9973. else
  9974. {
  9975. bool isAll = true;
  9976. foreach (DataRow dr in dt.Rows)
  9977. {
  9978. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9979. {
  9980. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9981. continue;
  9982. }
  9983. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  9984. {
  9985. string path = "";
  9986. int OrgID = 0;
  9987. if (!Convert.IsDBNull(dr["OrgPath"]))
  9988. {
  9989. path = dr["OrgPath"].ToString();
  9990. }
  9991. if (!Convert.IsDBNull(dr["OrgID"]))
  9992. {
  9993. OrgID = Convert.ToInt32(dr["OrgID"]);
  9994. }
  9995. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  9996. {
  9997. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9998. continue;
  9999. }
  10000. }
  10001. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10002. {
  10003. needCyt = true;
  10004. }
  10005. isAll = false;
  10006. }
  10007. if (isAll)
  10008. {
  10009. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10010. ceErpTradeCell.AfterSaleState = 4;
  10011. ceErpTradeCell.AfterSaleSupplierState = 1;
  10012. }
  10013. }
  10014. }
  10015. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10016. {
  10017. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10018. }
  10019. if (ceErpTradeCell.AfterSaleState == 4)
  10020. {
  10021. ApiVo apiVo = new ApiVo();
  10022. apiVo.orderNumber = ceErpTradeCell.ctid;
  10023. apiVo.actionName = "afterOver";
  10024. designHelper.API_WorkCore(apiVo); //afterOver
  10025. }
  10026. ceErpTradeCell.Update();
  10027. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10028. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10029. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10030. return true;
  10031. }
  10032. return false;
  10033. }
  10034. public void get_erp_wechatorder()
  10035. {
  10036. DataStruct dStruct = GetPostStruct();
  10037. List<string> lw = new List<string>();
  10038. string tid = GetPostString("tid");
  10039. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10040. string shopname = GetPostString("shopname");
  10041. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10042. string buyernick = GetPostString("buyer_nick");
  10043. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10044. string customer = GetPostString("customer");
  10045. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10046. string returndate1 = GetPostString("returndate1");
  10047. string returndate2 = GetPostString("returndate2");
  10048. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10049. if (dw.Length > 0) lw.Add(dw);
  10050. string finishDate1 = GetPostString("finishdate1");
  10051. string finishDate2 = GetPostString("finishdate2");
  10052. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10053. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10054. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10055. dStruct.Order = "created desc";
  10056. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10057. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10058. writeGridDataTableJson(dStruct.TotalCount, dt);
  10059. }
  10060. public void get_erp_wechatlist_sumprice()
  10061. {
  10062. DataStruct dStruct = GetPostStruct();
  10063. List<string> lw = new List<string>();
  10064. string tid = GetPostString("tid");
  10065. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10066. string shopname = GetPostString("shopname");
  10067. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10068. string buyernick = GetPostString("buyer_nick");
  10069. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10070. string customer = GetPostString("customer");
  10071. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10072. string returndate1 = GetPostString("returndate1");
  10073. string returndate2 = GetPostString("returndate2");
  10074. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10075. if (dw.Length > 0) lw.Add(dw);
  10076. string finishDate1 = GetPostString("finishdate1");
  10077. string finishDate2 = GetPostString("finishdate2");
  10078. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10079. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10080. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10081. string mainWhere = string.Join(" and ", lw.ToArray());
  10082. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10083. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10084. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10085. decimal total = 0;
  10086. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10087. {
  10088. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10089. }
  10090. var res = new
  10091. {
  10092. data = total
  10093. };
  10094. string ro_jsond = JsonConvert.SerializeObject(res);
  10095. returnSuccess(ro_jsond);
  10096. return;
  10097. }
  10098. public void get_erp_qr_waitdeliverylist()
  10099. {
  10100. DataStruct dStruct = GetPostStruct();
  10101. List<string> lw = new List<string>();
  10102. string tid = GetPostString("ctid");
  10103. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10104. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10105. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10106. var res_objz = new
  10107. {
  10108. restype = 1,
  10109. data = dt
  10110. };
  10111. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10112. returnSuccess(ro_jsonz);
  10113. }
  10114. public void get_erp_yield_list()
  10115. {
  10116. DataStruct dStruct = GetPostStruct();
  10117. List<string> lw = new List<string>();
  10118. string tid = GetPostString("ctid");
  10119. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10120. string shopname = GetPostString("shopname");
  10121. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10122. string buyernick = GetPostString("buyer_nick");
  10123. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10124. //if (tid.Length == 0 && buyernick.Length == 0)
  10125. //{
  10126. // lw.Add(string.Format("IsRefund<={0}", 1));
  10127. //}
  10128. string customer = GetPostString("customer");
  10129. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10130. string design = GetPostString("design");
  10131. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10132. string orderState = GetPostString("orderState");
  10133. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10134. string address = GetPostString("address");
  10135. 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));
  10136. string sellermemo = GetPostString("seller_memo");
  10137. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10138. string supplier = GetPostString("supplier");
  10139. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10140. string OrderArea = GetPostString("order_area");
  10141. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10142. string placedate1 = GetPostString("placedate1");
  10143. string placedate2 = GetPostString("placedate2");
  10144. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10145. if (fdw.Length > 0) lw.Add(fdw);
  10146. string price1 = GetPostString("price1");
  10147. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10148. string price2 = GetPostString("price2");
  10149. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10150. string unusualCon = GetPostString("unusualcon");
  10151. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10152. string posTag = CurrentUser.UserPost.Post.Code;
  10153. if (posTag == "Supplier")
  10154. {
  10155. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10156. }
  10157. lw.Add(string.Format("OrderState = 6 "));
  10158. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10159. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10160. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10161. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10162. writeGridDataTableJson(dStruct.TotalCount, dt);
  10163. }
  10164. public void change_erp_sup_state()
  10165. {
  10166. if (UrlPostParmsCheck("ctid"))
  10167. {
  10168. string ctid = GetPostString("ctid");
  10169. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10170. if (ceErpTradeCell != null)
  10171. {
  10172. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10173. if (ceErpTradeCellExtend == null)
  10174. {
  10175. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10176. ceErpTradeCellExtend.ctid = ctid;
  10177. ceErpTradeCellExtend.SupState = 1;
  10178. ceErpTradeCellExtend.Create();
  10179. }
  10180. else
  10181. {
  10182. ceErpTradeCellExtend.SupState = 1;
  10183. ceErpTradeCellExtend.Update();
  10184. }
  10185. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10186. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10187. return;
  10188. }
  10189. returnErrorMsg("找不到订单");
  10190. }
  10191. }
  10192. public void supplier_all_downs()
  10193. {
  10194. if (UrlPostParmsCheck("tids"))
  10195. {
  10196. string tids = GetPostString("tids");
  10197. if (tids != null && tids.Length > 0)
  10198. {
  10199. StringBuilder sql = new StringBuilder();
  10200. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10201. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10202. sql = new StringBuilder();
  10203. 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, "下载设计文件");
  10204. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10205. string[] list = tids.Split(',');
  10206. foreach (string ctid in list)
  10207. {
  10208. CeErpSukuraData.createInfo(ctid, 3);
  10209. }
  10210. designHelper.api_approveDesign(tids); //approveDesign
  10211. returnSuccessMsg("下载成功!");
  10212. return;
  10213. }
  10214. returnErrorMsg("下载订单更新失败");
  10215. }
  10216. }
  10217. public void uploaderFileSuccess()
  10218. {
  10219. if (UrlPostParmsCheck("fileName"))
  10220. {
  10221. string fileName = GetPostString("fileName");
  10222. ApiVo apiVo = new ApiVo();
  10223. apiVo.orderNumber = fileName;
  10224. apiVo.actionName = "finishDesign";
  10225. designHelper.API_WorkCore(apiVo);//finishDesign
  10226. returnSuccessMsg("");
  10227. }
  10228. }
  10229. public void get_sample2_order()
  10230. {
  10231. if (UrlPostParmsCheck("ctid"))
  10232. {
  10233. string ctid = GetPostString("ctid");
  10234. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10235. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10236. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10237. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10238. double total = 0.0;
  10239. double order_price = 0.0;
  10240. if (dt_bu.Rows.Count > 0)
  10241. {
  10242. foreach (DataRow dr in dt_bu.Rows)
  10243. {
  10244. total += Convert.ToDouble(dr["payment"]);
  10245. }
  10246. }
  10247. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10248. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10249. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10250. string tid = ctid.Replace("S_", "");
  10251. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10252. double paymant = 0.0;
  10253. if (entity != null)
  10254. {
  10255. paymant = entity.payment;
  10256. }
  10257. string return_reason = "";
  10258. if (dt_after != null && dt_after.Rows.Count > 0)
  10259. {
  10260. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10261. }
  10262. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10263. }
  10264. }
  10265. public void get_erp_design_status()
  10266. {
  10267. string designName = GetPostString("designName");
  10268. DataStruct dStruct = GetPostStruct();
  10269. if (designName.Length > 0)
  10270. {
  10271. 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";
  10272. sql_user += " and Name like '%" + designName + "%'";
  10273. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10274. List<string> ids_list = new List<string>();
  10275. if (user_table.Rows.Count > 0)
  10276. {
  10277. foreach (DataRow item in user_table.Rows)
  10278. {
  10279. ids_list.Add(item["id"].ToString());
  10280. string ids_s = item["TeamIds"].ToString();
  10281. if (ids_s.Length > 0)
  10282. {
  10283. ids_list.AddRange(ids_s.Split(','));
  10284. }
  10285. }
  10286. }
  10287. HashSet<string> set = new HashSet<string>(ids_list);
  10288. ids_list = set.ToList();
  10289. if (ids_list.Count > 0)
  10290. {
  10291. 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));
  10292. dStruct.MainWhere = sql;
  10293. DataTable dt = null;
  10294. dt = WebCache.GetData("view_ErpUser", dStruct);
  10295. writeGridDataTableJson(dStruct.TotalCount, dt);
  10296. }
  10297. }
  10298. }
  10299. public void change_erp_order_price()
  10300. {
  10301. string ctid = GetPostString("ctid");
  10302. double price = GetPostDouble("price");
  10303. if (ctid.Length > 0)
  10304. {
  10305. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10306. if (ceErpTradeCellExtend == null)
  10307. {
  10308. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10309. ceErpTradeCellExtend.ctid = ctid;
  10310. ceErpTradeCellExtend.payment_cyt = price;
  10311. ceErpTradeCellExtend.Create();
  10312. }
  10313. else
  10314. {
  10315. ceErpTradeCellExtend.payment_cyt = price;
  10316. ceErpTradeCellExtend.Update();
  10317. }
  10318. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10319. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10320. {
  10321. ceErpDataSendOrderInfo.isSync = false;
  10322. ceErpDataSendOrderInfo.Update();
  10323. }
  10324. if (ceErpDataSendOrderInfo == null)
  10325. {
  10326. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10327. ceErpDataSendOrderInfo.isSync = false;
  10328. ceErpDataSendOrderInfo.ctid = ctid;
  10329. ceErpDataSendOrderInfo.Create();
  10330. }
  10331. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10332. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10333. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10334. if (dth != null && dth.Rows.Count > 0)
  10335. {
  10336. dataSendOrderBean dataSendOrderBean = null;
  10337. foreach (DataRow item in dth.Rows)
  10338. {
  10339. try
  10340. {
  10341. dataSendOrderBean = new dataSendOrderBean();
  10342. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10343. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10344. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10345. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10346. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10347. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10348. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10349. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10350. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10351. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10352. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10353. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10354. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10355. if (result != null)
  10356. {
  10357. if ("0".Equals(result.errcode))
  10358. {
  10359. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10360. }
  10361. else
  10362. {
  10363. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10364. }
  10365. }
  10366. }
  10367. catch (Exception ex)
  10368. {
  10369. }
  10370. }
  10371. }
  10372. returnSuccessMsg("修改成功!");
  10373. return;
  10374. }
  10375. returnErrorMsg("找不到订单");
  10376. }
  10377. public void find_he_together()
  10378. {
  10379. string ctid = GetPostString("ctid");
  10380. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10381. List<string> list = new List<string>();
  10382. if (ceErpTradeCell != null)
  10383. {
  10384. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10385. {
  10386. 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);
  10387. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10388. if (table != null && table.Rows.Count > 0)
  10389. {
  10390. foreach (TableRow row in table.Rows)
  10391. {
  10392. }
  10393. }
  10394. }
  10395. }
  10396. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10397. }
  10398. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10399. {
  10400. //chy----19
  10401. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10402. //GD-CYT-----64
  10403. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10404. //ZHX----3
  10405. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10406. //JK----97
  10407. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10408. //ZT----70
  10409. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10410. //LHCY-----98
  10411. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10412. //XD-----90
  10413. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10414. //CYCY-----14
  10415. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10416. };
  10417. //其他改名
  10418. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10419. {
  10420. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10421. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10422. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10423. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10424. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10425. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10426. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10427. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10428. };
  10429. //不统计
  10430. List<int> no_suppliers = new List<int>()
  10431. {
  10432. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10433. };
  10434. //配件单
  10435. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10436. {
  10437. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10438. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10439. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10440. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10441. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10442. {"旗杆",new List<string>(){ "班旗" } },
  10443. {"牙签",new List<string>(){ "不干胶" } }
  10444. };
  10445. public void get_place_order_data()
  10446. {
  10447. string date1 = GetPostString("date1");
  10448. string date2 = GetPostString("date2");
  10449. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10450. DateTime start = DateTime.Parse(starttime);
  10451. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10452. DateTime end = DateTime.Parse(endtime);
  10453. if (date1 != null && date1.Length > 0)
  10454. {
  10455. DateTime dateTime = DateTime.Parse(date1);
  10456. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10457. start = DateTime.Parse(starttime);
  10458. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10459. end = DateTime.Parse(endtime);
  10460. }
  10461. if (date2 != null && date2.Length > 0)
  10462. {
  10463. DateTime dateTime = DateTime.Parse(date2);
  10464. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10465. end = DateTime.Parse(endtime);
  10466. }
  10467. 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);
  10468. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10469. //不干胶-----1,卡片-----29
  10470. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10471. foreach (DataRow row in data.Rows)
  10472. {
  10473. int productId = Convert.ToInt32(row["ProductId"]);
  10474. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10475. if (no_suppliers.Contains(supplierId))
  10476. {
  10477. continue;
  10478. }
  10479. string seller_memo = row["seller_memo"].ToString();
  10480. bool ispj = false;//是否配件单
  10481. bool isfirst = true;//第一个配
  10482. maps.Keys.ForEach(key =>
  10483. {
  10484. //备注包含配件
  10485. if (seller_memo.Contains(key) && isfirst)
  10486. {
  10487. List<string> list = maps[key];
  10488. ispj = true;
  10489. isfirst = false;
  10490. for (int i = 0; i < list.Count; i++)
  10491. {
  10492. if (seller_memo.Contains(list[i]))
  10493. {
  10494. ispj = false;
  10495. break;
  10496. }
  10497. }
  10498. }
  10499. });
  10500. if (ispj)
  10501. {
  10502. continue;
  10503. }
  10504. seller_memo = seller_memo.Replace("UV", "uv");
  10505. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10506. //吊牌归到卡片
  10507. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10508. seller_memo = seller_memo.Replace("卡套", "卡片");
  10509. seller_memo = seller_memo.Replace("封套", "卡片");
  10510. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10511. seller_memo = seller_memo.Replace("腰封", "卡片");
  10512. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10513. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10514. seller_memo = seller_memo.Replace("横幅", "条幅");
  10515. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10516. string map_key = "";
  10517. string type = "";
  10518. if (supplierMap.ContainsKey(supplierId))
  10519. {
  10520. foreach (var kvp in supplierMap[supplierId])
  10521. {
  10522. if (seller_memo.Contains(kvp.Key))
  10523. {
  10524. map_key = kvp.Value;
  10525. type = kvp.Value;
  10526. break;
  10527. }
  10528. }
  10529. }
  10530. if (map_key == "")
  10531. {
  10532. type = "其他";
  10533. map_key = "其他";
  10534. }
  10535. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10536. {
  10537. map_key = suppliers[supplierId];
  10538. }
  10539. if (supplierId == 70)
  10540. {
  10541. supplierId = 70;
  10542. }
  10543. map_key += "_" + row["SupplierName"].ToString();
  10544. Dictionary<string, int> map = null;
  10545. if (other_map.ContainsKey(map_key))
  10546. {
  10547. other_map.TryGetValue(map_key, out map);
  10548. }
  10549. else
  10550. {
  10551. map = new Dictionary<string, int>();
  10552. map.Add("dayDev", 0);//当天出货
  10553. map.Add("dayTotal", 0);//下单总数
  10554. map.Add("payTotal", 0);//500以上
  10555. map.Add("today", 0);//当天出货数量
  10556. map.Add("unusua", 0);//异常数
  10557. other_map.Add(map_key, map);
  10558. other_map.TryGetValue(map_key, out map);
  10559. }
  10560. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10561. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10562. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10563. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10564. {
  10565. map["dayTotal"]++;
  10566. if (supplierId == 97)
  10567. {
  10568. supplierId = 97;
  10569. }
  10570. }
  10571. if (Convert.ToDecimal(row["payment"]) >= 500)
  10572. {
  10573. map["payTotal"]++;
  10574. }
  10575. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10576. {
  10577. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10578. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10579. {
  10580. map["today"]++;
  10581. }
  10582. }
  10583. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10584. {
  10585. map["unusua"]++;
  10586. }
  10587. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10588. //GD-CYT-----64
  10589. DateTime two = palceTimeStart.AddHours(14);
  10590. DateTime three = palceTimeStart.AddHours(15);
  10591. DateTime four = palceTimeStart.AddHours(16);
  10592. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10593. {
  10594. //下午四点前 500-1000
  10595. string count = row["ProductCount"].ToString();
  10596. if (count != null && count.Length > 0)
  10597. {
  10598. int productCount = commonHelper.getPlaceProductCount(count);
  10599. if (productCount >= 500 && productCount <= 1000)
  10600. {
  10601. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10602. {
  10603. map["dayDev"]++;
  10604. }
  10605. }
  10606. }
  10607. }
  10608. //UV
  10609. else if ("uv".Equals(type))
  10610. {
  10611. //ZT----70
  10612. //ZHX----3
  10613. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10614. {
  10615. map["dayDev"]++;
  10616. }
  10617. //JK----97
  10618. //HZX----105
  10619. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10620. {
  10621. map["dayDev"]++;
  10622. if (supplierId == 97)
  10623. {
  10624. supplierId = 97;
  10625. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10626. }
  10627. }
  10628. }
  10629. //帆布---52|条幅---27
  10630. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10631. {
  10632. //LHCY-----98
  10633. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10634. {
  10635. map["dayDev"]++;
  10636. }
  10637. }
  10638. //条幅
  10639. else if ("条幅".Equals(type))
  10640. {
  10641. //XD-----90
  10642. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10643. {
  10644. map["dayDev"]++;
  10645. }
  10646. }
  10647. //桌布
  10648. else if ("桌布".Equals(type))
  10649. {
  10650. //XD-----90
  10651. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10652. {
  10653. map["dayDev"]++;
  10654. }
  10655. }
  10656. //DL---10
  10657. //AYTW---119
  10658. //FS-CYT-DY ----80
  10659. //JK----97
  10660. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10661. {
  10662. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10663. {
  10664. map["dayDev"]++;
  10665. }
  10666. }
  10667. }
  10668. DataTable dt = new DataTable();
  10669. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10670. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10671. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10672. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10673. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10674. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10675. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10676. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10677. other_map.Keys.ForEach(key =>
  10678. {
  10679. DataRow dr = dt.NewRow();
  10680. Dictionary<string, int> map = other_map[key];
  10681. string[] key_list = key.Split('_');
  10682. dr[0] = key_list[0];
  10683. dr[1] = key_list[1];
  10684. if (key_list.Length > 2)
  10685. {
  10686. dr[1] += "(" + key_list[2] + ")";
  10687. }
  10688. dr[2] = map["dayTotal"];
  10689. dr[3] = map["payTotal"];
  10690. dr[4] = map["today"];
  10691. dr[5] = map["unusua"];
  10692. dr[6] = map["dayDev"];
  10693. double rate = 0.00;
  10694. if (map["dayDev"] > 0)
  10695. {
  10696. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10697. }
  10698. dr[7] = rate.ToString();
  10699. dt.Rows.Add(dr);
  10700. });
  10701. DataView dv = new DataView(dt);
  10702. dv.Sort = "SupplierName";
  10703. //dv.Sort = "AllOrder desc";
  10704. DataTable dtNew = dv.ToTable();
  10705. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10706. }
  10707. public void check_order_desing_info()
  10708. {
  10709. string ctid = GetPostString("ctid");
  10710. if (!string.IsNullOrEmpty(ctid))
  10711. {
  10712. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10713. if (ceErpTradeCell != null)
  10714. {
  10715. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10716. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10717. return;
  10718. }
  10719. returnErrorMsg("找不到订单");
  10720. return;
  10721. }
  10722. returnErrorMsg("找不到订单");
  10723. }
  10724. public void get_timeout_detail()
  10725. {
  10726. string poscode = CurrentUser.UserPost.Post.Code;
  10727. DataStruct dStruct = GetPostStruct();
  10728. List<string> lw = new List<string>();
  10729. string id = GetPostString("id");
  10730. string pay_date1 = GetPostString("pay_date1");
  10731. string pay_date2 = GetPostString("pay_date2");
  10732. int type = GetPostInt("type");
  10733. if (type == 0)
  10734. {
  10735. if (pay_date1.Length > 0)
  10736. {
  10737. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10738. }
  10739. if (pay_date2.Length > 0)
  10740. {
  10741. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10742. }
  10743. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10744. }
  10745. if (type == 1)
  10746. {
  10747. if (pay_date1.Length > 0)
  10748. {
  10749. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10750. }
  10751. if (pay_date2.Length > 0)
  10752. {
  10753. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10754. }
  10755. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10756. }
  10757. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10758. DataTable dt = null;
  10759. dt = WebCache.GetData("view_orderlist", dStruct);
  10760. writeGridDataTableJson(dStruct.TotalCount, dt);
  10761. }
  10762. public void saveUrgentChargePrice()
  10763. {
  10764. string ctid = GetPostString("ctid");
  10765. if (!string.IsNullOrEmpty(ctid))
  10766. {
  10767. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10768. if (ceErpTradeCell != null)
  10769. {
  10770. double price = GetPostDouble("price");
  10771. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10772. if (ceErpTradeCellExtend == null)
  10773. {
  10774. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10775. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10776. }
  10777. ceErpTradeCellExtend.urgentCharge = price;
  10778. if (ceErpTradeCellExtend.ID > 0)
  10779. {
  10780. ceErpTradeCellExtend.Update();
  10781. }
  10782. else
  10783. {
  10784. ceErpTradeCellExtend.Save();
  10785. }
  10786. returnSuccessMsg("修改成功!");
  10787. return;
  10788. }
  10789. returnErrorMsg("找不到订单");
  10790. return;
  10791. }
  10792. returnErrorMsg("找不到订单");
  10793. }
  10794. public void finish_erp_order()
  10795. {
  10796. string ctid = GetPostString("ctid");
  10797. if (!string.IsNullOrEmpty(ctid))
  10798. {
  10799. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10800. {
  10801. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10802. if (ceErpTradeCell != null)
  10803. {
  10804. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10805. ceErpTradeCell.Update();
  10806. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10807. returnSuccessMsg("修改成功!");
  10808. return;
  10809. }
  10810. }
  10811. }
  10812. returnErrorMsg("找不到订单");
  10813. }
  10814. public void get_trade_order_list()
  10815. {
  10816. string tid = GetPostString("tid");
  10817. if (!string.IsNullOrEmpty(tid))
  10818. {
  10819. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10820. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10821. writeGridDataTableJson(data.Rows.Count, data);
  10822. return;
  10823. }
  10824. returnErrorMsg("找不到订单");
  10825. }
  10826. public void save_cell_spu()
  10827. {
  10828. string ctid = GetPostString("ctid");
  10829. string spu_id = GetPostString("spu_id");
  10830. if (!string.IsNullOrEmpty(ctid))
  10831. {
  10832. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10833. if (ceErpTradeCellExtend == null)
  10834. {
  10835. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10836. ceErpTradeCellExtend.ctid = ctid;
  10837. }
  10838. ceErpTradeCellExtend.spu_id = spu_id;
  10839. if (ceErpTradeCellExtend.ID == 0)
  10840. {
  10841. ceErpTradeCellExtend.Create();
  10842. }
  10843. else
  10844. {
  10845. ceErpTradeCellExtend.Update();
  10846. }
  10847. returnSuccessMsg("修改成功!");
  10848. return;
  10849. }
  10850. returnErrorMsg("找不到订单");
  10851. }
  10852. public void change_express_info()
  10853. {
  10854. string ctid = GetPostString("ctid");
  10855. string transNo = GetPostString("transNo");
  10856. string transCom = GetPostString("transCom");
  10857. if (!string.IsNullOrEmpty(ctid))
  10858. {
  10859. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10860. if (ceErpTradeCellExtend == null)
  10861. {
  10862. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10863. ceErpTradeCellExtend.ctid = ctid;
  10864. }
  10865. ceErpTradeCellExtend.modExpressNo = transNo;
  10866. ceErpTradeCellExtend.modExpressCom = transCom;
  10867. ceErpTradeCellExtend.readMod = 2;
  10868. if (ceErpTradeCellExtend.ID == 0)
  10869. {
  10870. ceErpTradeCellExtend.Create();
  10871. }
  10872. else
  10873. {
  10874. ceErpTradeCellExtend.Update();
  10875. }
  10876. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10877. returnSuccessMsg("修改成功!");
  10878. return;
  10879. }
  10880. returnErrorMsg("找不到订单");
  10881. }
  10882. public void get_change_express_list()
  10883. {
  10884. DataStruct dStruct = GetPostStruct();
  10885. List<string> lw = new List<string>();
  10886. int st = 2;
  10887. string tid = GetPostString("ctid");
  10888. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10889. string shopname = GetPostString("shopname");
  10890. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10891. string buyernick = GetPostString("buyer_nick");
  10892. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10893. string sellermemo = GetPostString("seller_memo");
  10894. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10895. string supplier = GetPostString("supplier");
  10896. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10897. string customer = GetPostString("customer");
  10898. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10899. string design = GetPostString("design");
  10900. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10901. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10902. string poscode = CurrentUser.UserPost.Post.Code;
  10903. if (poscode != "SysAdmin")
  10904. {
  10905. string shopid = CurrentUser.User.pemShop;
  10906. lw.Add(string.Format("shopId in ({0})", shopid));
  10907. }
  10908. lw.Add("readMod = 2");
  10909. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10910. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10911. writeGridDataTableJson(dStruct.TotalCount, dt);
  10912. }
  10913. public void deal_express_complete()
  10914. {
  10915. string ctid = GetPostString("ctid");
  10916. if (!string.IsNullOrEmpty(ctid))
  10917. {
  10918. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10919. if (ceErpTradeCellExtend == null)
  10920. {
  10921. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10922. ceErpTradeCellExtend.ctid = ctid;
  10923. }
  10924. ceErpTradeCellExtend.readMod = 1;
  10925. if (ceErpTradeCellExtend.ID == 0)
  10926. {
  10927. ceErpTradeCellExtend.Create();
  10928. }
  10929. else
  10930. {
  10931. ceErpTradeCellExtend.Update();
  10932. }
  10933. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10934. returnSuccessMsg("修改成功!");
  10935. return;
  10936. }
  10937. returnErrorMsg("找不到订单");
  10938. }
  10939. public void aftersale_return_visit()
  10940. {
  10941. string ctid = GetPostString("ctid");
  10942. if (!string.IsNullOrEmpty(ctid))
  10943. {
  10944. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10945. if (ceErpTradeCellExtend == null)
  10946. {
  10947. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10948. ceErpTradeCellExtend.ctid = ctid;
  10949. }
  10950. ceErpTradeCellExtend.returnVisit = 1;
  10951. if (ceErpTradeCellExtend.ID == 0)
  10952. {
  10953. ceErpTradeCellExtend.Create();
  10954. }
  10955. else
  10956. {
  10957. ceErpTradeCellExtend.Update();
  10958. }
  10959. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  10960. if (ceErpTradeAfterSaleExtend != null)
  10961. {
  10962. ceErpTradeAfterSaleExtend.TextResult = "";
  10963. ceErpTradeAfterSaleExtend.Update();
  10964. }
  10965. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  10966. returnSuccessMsg("修改成功!");
  10967. return;
  10968. }
  10969. returnErrorMsg("找不到订单");
  10970. }
  10971. public void orderPlaceInfo()
  10972. {
  10973. string ctids = GetPostString("ctids");
  10974. string[] list = ctids.Split(',');
  10975. foreach (string ctid in list)
  10976. {
  10977. CeErpSukuraData.createInfo(ctid, 3);
  10978. }
  10979. designHelper.api_approveDesign(ctids); //approveDesign
  10980. returnSuccessMsg("");
  10981. }
  10982. }
  10983. }