sync.order.cs 562 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084
  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_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  52. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  53. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  54. //banniuApiHelper.sendLogisticsInfo(null);
  55. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  56. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  57. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2449287014185573080");
  58. //int sid = commonHelper.autoDistributeToSupplier(entity);
  59. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  60. //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\"}}");
  61. //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}}");
  62. List<string> lw = new List<string>();
  63. string tid = GetPostString("ctid");
  64. string date1 = GetPostString("date1");
  65. //12-1 修改
  66. string urgent = GetPostString("urgent");
  67. string back = GetPostString("back");
  68. string offlineSearch = GetPostString("offlineSearch");
  69. int paramsCount = 0;
  70. if (!string.IsNullOrWhiteSpace(urgent))
  71. {
  72. if (urgent.Equals("true"))
  73. {
  74. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  75. }
  76. }
  77. if (!string.IsNullOrWhiteSpace(back))
  78. {
  79. if (back.Equals("true"))
  80. {
  81. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  82. }
  83. }
  84. if (!string.IsNullOrWhiteSpace(offlineSearch))
  85. {
  86. if (offlineSearch.Equals("true"))
  87. {
  88. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  89. }
  90. }
  91. //end
  92. string date2 = GetPostString("date2");
  93. string buyernick = GetPostString("buyer_nick");
  94. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  95. {
  96. if (tid.Length <= 0 && buyernick.Length <= 0)
  97. {
  98. return;
  99. }
  100. }
  101. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  102. {
  103. if (tid.Length > 0)
  104. {
  105. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  106. }
  107. if (buyernick.Length > 0)
  108. {
  109. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  110. }
  111. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  112. if (dw.Length > 0)
  113. {
  114. lw.Add(dw);
  115. }
  116. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  117. {
  118. string usershop = CurrentUser.User.pemShop;
  119. lw.Add(string.Format("ShopId in ({0})", usershop));
  120. }
  121. }
  122. else
  123. {
  124. if (ex_psize == 0)
  125. {
  126. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  127. }
  128. if (PKey != "admin")
  129. {
  130. string usershop = CurrentUser.User.pemShop;
  131. lw.Add(string.Format("ShopId in ({0})", usershop));
  132. paramsCount++;
  133. }
  134. }
  135. string uploaddate1 = GetPostString("uploaddate1");
  136. string uploaddate2 = GetPostString("uploaddate2");
  137. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  138. if (update.Length > 0) lw.Add(update);
  139. string shopname = GetPostString("shopname");
  140. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  141. string addwechat = GetPostString("addwechat");
  142. if (addwechat.Length > 0)
  143. {
  144. int addWt = Convert.ToInt32(addwechat);
  145. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  146. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  147. }
  148. string customer = GetPostString("customer");
  149. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  150. string design = GetPostString("design");
  151. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  152. string orderState = GetPostString("orderState");
  153. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  154. string address = GetPostString("address");
  155. 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));
  156. string sellermemo = GetPostString("seller_memo");
  157. if (sellermemo.Length > 0)
  158. {
  159. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  160. }
  161. string backReason = GetPostString("backReason");
  162. if (backReason.Length > 0)
  163. {
  164. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  165. }
  166. string apdate1 = GetPostString("apdate1");
  167. string apdate2 = GetPostString("apdate2");
  168. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  169. if (dwap.Length > 0) lw.Add(dwap);
  170. string price1 = GetPostString("price1");
  171. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  172. string price2 = GetPostString("price2");
  173. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  174. string isoldcustomer = GetPostString("isoldcus");
  175. string finishdate1 = GetPostString("finishdate1");
  176. string finishdate2 = GetPostString("finishdate2");
  177. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  178. bool isFinish = false;
  179. if (finishdate.Length > 0)
  180. {
  181. lw.Add(finishdate);
  182. isFinish = true;
  183. paramsCount++;
  184. }
  185. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  186. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  187. if (ex_psize > 0)
  188. {
  189. int UserID = CurrentUser.UserID;
  190. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  191. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  192. {
  193. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  194. }
  195. dStruct.Order = "pay_time desc";
  196. }
  197. string isNew = GetPostString("isNew");
  198. if (isNew == "true")
  199. {
  200. lw.Add(string.Format("IsNew = {0}", 1));
  201. }
  202. string overtime = GetPostString("overtime");
  203. if (overtime == "1")
  204. {
  205. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  206. }
  207. String usePost = CurrentUser.UserPost.Post.Code;
  208. if (usePost.Equals("Operation") == true)
  209. {
  210. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  211. }
  212. else
  213. {
  214. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  215. }
  216. //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";
  217. if (dStruct.PageSize == 100000)
  218. {
  219. dStruct.Order = "";
  220. }
  221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  222. DataTable dt = null;
  223. string tablename = "view_orderlist";
  224. if (isFinish)
  225. {
  226. tablename = "view_orderlist_end";
  227. }
  228. dt = WebCache.GetData(tablename, dStruct);
  229. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  230. if (dt != null && dt.Rows.Count > 0)
  231. {
  232. foreach (DataRow dr in dt.Rows)
  233. {
  234. try
  235. {
  236. if (dr["refund_fees"] != null)
  237. {
  238. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  239. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  240. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  241. if (payment == refund_fees)
  242. {
  243. dr["refund_fees"] = Math.Round(refund_fees, 2);
  244. continue; // 跳过当前迭代
  245. }
  246. else if (refund_fees == total_fee)
  247. {
  248. dr["refund_fees"] = payment;
  249. continue; // 跳过当前迭代
  250. }
  251. else
  252. {
  253. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  254. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  255. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  256. }
  257. }
  258. // 对象操作
  259. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  260. ceErpTradeCell.ctid = dr["ctid"].ToString();
  261. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  262. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  263. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  264. if (dStruct.PageSize != 100000)
  265. {
  266. if (dr["DispatchSort"].ToString() == "2")
  267. {
  268. dr["gongchuang"] = 200;
  269. }
  270. else
  271. {
  272. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  273. dr["gongchuang"] = response.code;
  274. }
  275. }
  276. }
  277. catch (NullReferenceException ex)
  278. {
  279. // 处理空引用异常
  280. dr["refund_fees"] = "0.00";
  281. }
  282. }
  283. }
  284. writeGridDataTableJson(dStruct.TotalCount, dt);
  285. }
  286. public void get_erp_orderlist_sumprice()
  287. {
  288. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  289. return;
  290. List<string> lw = new List<string>();
  291. string tid = GetPostString("ctid");
  292. string date1 = GetPostString("date1");
  293. string date2 = GetPostString("date2");
  294. if (tid.Length > 0 || date1.Length > 0)
  295. {
  296. lw.Add(string.Format("ctid like '%{0}%'", tid));
  297. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  298. if (dw.Length > 0) lw.Add(dw);
  299. }
  300. else
  301. {
  302. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  303. }
  304. string shopname = GetPostString("shopname");
  305. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  306. string buyernick = GetPostString("buyer_nick");
  307. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  308. string customer = GetPostString("customer");
  309. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  310. string design = GetPostString("design");
  311. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  312. string orderState = GetPostString("orderState");
  313. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  314. string address = GetPostString("address");
  315. 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));
  316. string sellermemo = GetPostString("seller_memo");
  317. if (sellermemo.Length > 0)
  318. {
  319. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  320. }
  321. string apdate1 = GetPostString("apdate1");
  322. string apdate2 = GetPostString("apdate2");
  323. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  324. if (dwap.Length > 0) lw.Add(dwap);
  325. string price1 = GetPostString("price1");
  326. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  327. string price2 = GetPostString("price2");
  328. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  329. string isoldcustomer = GetPostString("isoldcus");
  330. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  331. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  332. if (PKey != "admin")
  333. {
  334. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  335. lw.Add(string.Format("shopId in ({0})", usershop));
  336. }
  337. //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";
  338. string mainWhere = string.Join(" and ", lw.ToArray());
  339. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  340. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  341. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  342. decimal total = 0;
  343. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  344. {
  345. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  346. }
  347. var res = new
  348. {
  349. data = total
  350. };
  351. string ro_jsond = JsonConvert.SerializeObject(res);
  352. returnSuccess(ro_jsond);
  353. return;
  354. }
  355. public void get_erp_CustomerServiceGather()
  356. {
  357. string userWhere = "", orderWhere = "";
  358. List<string> lw = new List<string>();
  359. string customer = GetPostString("customer");
  360. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  361. string shopname = GetPostString("shopname");
  362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  363. string date1 = GetPostString("date1");
  364. string date2 = GetPostString("date2");
  365. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  366. if (dw.Length > 0) lw.Add(dw);
  367. orderWhere = string.Join(" and ", lw.ToArray());
  368. 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 " +
  369. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  370. "left join " +
  371. "( " +
  372. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  373. ") as b on a.ID = b.CustomerUserId " +
  374. "left join " +
  375. "( " +
  376. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  377. ") as d on a.ID = d.CustomerUserId " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  381. ") as e on a.ID = e.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, RefundCount, RefundSum from " +
  385. " ( " +
  386. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  387. " from CE_ErpTradeRefund a " +
  388. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  389. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  390. " group by CustomerUserId " +
  391. " ) as a " +
  392. ") as f on a.ID = f.CustomerUserId " +
  393. "where a.PostCode = 'CustomerService'",
  394. userWhere, orderWhere);
  395. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  396. writeGridDataTableJson(dt.Rows.Count, dt);
  397. //writeGridDataTableJson(dt.Rows.Count, dt);
  398. }
  399. //设计汇总
  400. public void get_erp_DesignerGather()
  401. {
  402. string userWhere = "", orderWhere = "";
  403. List<string> lw = new List<string>();
  404. string Designer = GetPostString("designer");
  405. int org = GetPostInt("org");
  406. if (Designer.Length > 0)
  407. {
  408. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  409. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  410. }
  411. else if (org > 0)
  412. {
  413. userWhere = string.Format(" where OrgID ={0}", org);
  414. }
  415. string shopname = GetPostString("shopname");
  416. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  417. string state = GetPostString("state");
  418. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  419. string OrderArea = GetPostString("order_area");
  420. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  421. string date1 = GetPostString("date1");
  422. string date2 = GetPostString("date2");
  423. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  424. if (dw.Length > 0) lw.Add(dw);
  425. string UpDate1 = GetPostString("UpDate1");
  426. string UpDate2 = GetPostString("UpDate2");
  427. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  428. if (dw.Length > 0) lw.Add(dw);
  429. orderWhere = string.Join(" and ", lw.ToArray());
  430. 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 (" +
  431. "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 " +
  432. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  433. "left join " +
  434. "( " +
  435. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  436. ") as b on a.ID = b.DesignUserId " +
  437. "left join " +
  438. "( " +
  439. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  440. ") as d on a.ID = d.DesignUserId " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  444. ") as e on a.ID = e.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as g on a.ID = g.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select CustomerUserId, RefundCount, RefundSum from " +
  452. " ( " +
  453. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  454. " from CE_ErpTradeRefund a " +
  455. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  456. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  457. " group by CustomerUserId " +
  458. " ) as a " +
  459. ") as f on a.ID = f.CustomerUserId " +
  460. "where a.PostCode = 'Designer') as z",
  461. userWhere, orderWhere);
  462. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  463. writeGridDataTableJson(dt.Rows.Count, dt);
  464. }
  465. //删除tradecell的订单
  466. public void del_erp_cellorder()
  467. {
  468. if (UrlPostParmsCheck("ctid"))
  469. {
  470. string eid = GetPostString("ctid");
  471. CeErpTradeCell.DelByCtid(eid);
  472. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  473. returnSuccessMsg("删除成功");
  474. }
  475. }
  476. public void clear_erp_refundstate()
  477. {
  478. if (UrlPostParmsCheck("ids"))
  479. {
  480. string eids = GetPostString("ids");
  481. string[] ctidList = eids.Split(',');
  482. foreach (string ctid in ctidList)
  483. {
  484. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  485. if (entity != null)
  486. {
  487. entity.IsRefund = 0;
  488. entity.Update();
  489. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  490. }
  491. else
  492. continue;
  493. }
  494. returnSuccessMsg("操作成功");
  495. return;
  496. }
  497. returnErrorMsg("缺少必要参数");
  498. }
  499. public void set_erp_urgency()
  500. {
  501. if (UrlPostParmsCheck("ctid"))
  502. {
  503. string eid = GetPostString("ctid");
  504. CeErpTradeCell entity = null;
  505. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  506. if (entity != null)
  507. {
  508. string utime = GetPostString("urgencytime");
  509. if (utime.Length > 0)
  510. {
  511. entity.UrgencyTime = Convert.ToDateTime(utime);
  512. }
  513. else
  514. {
  515. returnErrorMsg("请选择加急时间");
  516. return;
  517. }
  518. if (entity.OrderState <= 4)
  519. {
  520. //entity.seller_memo = entity.seller_memo + "-加急";
  521. string smemo = entity.seller_memo;
  522. int kindex = smemo.IndexOf(")");
  523. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  524. if (lastoneStr != "-")
  525. {
  526. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  527. }
  528. string prememo = smemo.Substring(0, kindex + 2);
  529. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  530. int lastkindex = lastmemo.IndexOf("(");
  531. DateTime urgtime = Convert.ToDateTime(utime);
  532. string newlastmemo = "";
  533. if (lastkindex == 0)
  534. {
  535. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  536. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  537. }
  538. else
  539. {
  540. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  541. }
  542. entity.seller_memo = prememo + newlastmemo;
  543. }
  544. entity.IsUrgency = true;
  545. entity.Update();
  546. ApiVo apiVo = new ApiVo();
  547. apiVo.orderNumber = entity.ctid;
  548. apiVo.actionName = "changeDesign";
  549. apiVo.orderRemarks = entity.seller_memo;
  550. apiVo.remarkSign = 3;
  551. designHelper.API_WorkCore(apiVo); //changeDesign
  552. CeErpSukuraData.createInfo(entity.ctid, 7);
  553. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  554. returnSuccessMsg("设置成功!");
  555. return;
  556. }
  557. returnErrorMsg("找不到记录");
  558. }
  559. }
  560. public void set_erp_reset()
  561. {
  562. if (UrlPostParmsCheck("ctid"))
  563. {
  564. string eid = GetPostString("ctid");
  565. CeErpTradeCell entity = null;
  566. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  567. if (entity != null)
  568. {
  569. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  570. {
  571. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  572. {
  573. returnErrorMsg("财务要求已下单已发货无法重置");
  574. return;
  575. }
  576. }
  577. entity.IsUrgency = false;
  578. entity.seller_memo = "";
  579. entity.OtherMemo = "";
  580. entity.OrderState = 0;
  581. entity.IsReturn = 0;
  582. //entity.IsRefund = 0;
  583. entity.MemoOpt = 0;
  584. entity.AfterSaleState = 0;
  585. entity.AfterSaleResponsible = "";
  586. entity.AfterSaleUserId = 0;
  587. entity.IsNeedBill = 0;
  588. entity.CustomerUserId = 0;
  589. entity.DesignUserId = 0;
  590. entity.SupplierId = 0;
  591. entity.PlaceUserId = 0;
  592. entity.ptid = "";
  593. entity.IsSample = 0;
  594. entity.IsXianHuo = 0;
  595. entity.isDianziOrder = 0;
  596. entity.FinishPlaceTime = null;
  597. entity.Update();
  598. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  599. if (trade != null)
  600. {
  601. trade.seller_memo = "";
  602. trade.Update();
  603. }
  604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  605. returnSuccessMsg("重置成功!");
  606. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  607. if (desginBill != null)
  608. {
  609. desginBill.isDel = 1;
  610. desginBill.Update();
  611. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  612. }
  613. ApiVo apiVo = new ApiVo();
  614. apiVo.orderNumber = entity.ctid;
  615. apiVo.actionName = "resetDesign";
  616. designHelper.API_WorkCore(apiVo);//resetDesign
  617. return;
  618. }
  619. returnErrorMsg("找不到记录");
  620. }
  621. }
  622. public void save_erp_sellermemo()
  623. {
  624. if (UrlPostParmsCheck("ctid"))
  625. {
  626. string ctid = GetPostString("ctid");
  627. CeErpTradeCell entity = null;
  628. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  629. if (entity != null)
  630. {
  631. string memo = GetPostString("seller_memo");
  632. memo = memo.Replace(" ", "");
  633. if (memo.Contains("补差"))
  634. {
  635. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  636. return;
  637. }
  638. if (entity.seller_memo != memo)
  639. {
  640. if (entity.IsSample == 2)
  641. {
  642. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  643. return;
  644. }
  645. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  646. {
  647. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  648. {
  649. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  650. return;
  651. }
  652. }
  653. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  654. }
  655. commonHelper.getCytPrice(entity);
  656. int memoopt = GetPostInt("MemoOpt");
  657. Boolean ismemoopt = false;
  658. if (memoopt > 0)
  659. {
  660. string stropt = "";
  661. if (memoopt == 1)
  662. {
  663. stropt = "“改稿”";
  664. ismemoopt = true;
  665. }
  666. else if (memoopt == 2)
  667. {
  668. stropt = "“定稿”";
  669. }
  670. else if (memoopt == 3)
  671. {
  672. stropt = "“查货”";
  673. CeErpSukuraData.createInfo(entity.ctid, 6);
  674. }
  675. entity.MemoOpt = Convert.ToInt32(memoopt);
  676. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  677. }
  678. if (entity.OrderState < 5)
  679. {
  680. memo = memo.Replace("(", "(");
  681. memo = memo.Replace(")", ")");
  682. }
  683. entity.seller_memo = memo;
  684. entity.Update();
  685. ApiVo apiVo = new ApiVo();
  686. apiVo.orderNumber = entity.ctid;
  687. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  688. apiVo.orderRemarks = memo;
  689. apiVo.remarkSign = memoopt;
  690. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  691. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  692. returnSuccessMsg("保存成功!");
  693. return;
  694. }
  695. returnErrorMsg("找不到记录");
  696. }
  697. }
  698. public void ins_erp_checkorder()
  699. {
  700. if (UrlPostParmsCheck("ctid"))
  701. {
  702. string ctid = GetPostString("ctid");
  703. CeErpTradeCell entity = null;
  704. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  705. if (entity != null)
  706. {
  707. if (entity.OrderState < 6)
  708. {
  709. returnErrorMsg("下单完成后才可查货");
  710. return;
  711. }
  712. /*if (entity.OrderState > 6)
  713. {
  714. returnErrorMsg("订单已发货");
  715. return;
  716. }*/
  717. if (entity.FinishPlaceTime != null)
  718. {
  719. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  720. {
  721. returnErrorMsg("下单时间不足,无法查货");
  722. return;
  723. }
  724. }
  725. entity.MemoOpt = 3;
  726. entity.CheckOrderTime = DateTime.Now;
  727. entity.Update();
  728. CeErpSukuraData.createInfo(entity.ctid, 6);
  729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  730. returnSuccessMsg("操作成功!");
  731. return;
  732. }
  733. returnErrorMsg("找不到记录");
  734. }
  735. }
  736. public void save_erp_othermemo()
  737. {
  738. if (UrlPostParmsCheck("ctid"))
  739. {
  740. string ctid = GetPostString("ctid");
  741. CeErpTradeCell entity = null;
  742. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  743. if (entity != null)
  744. {
  745. entity.OtherMemo = GetPostString("otherMemo");
  746. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  747. {
  748. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  749. StringBuilder sql = new StringBuilder();
  750. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  751. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  752. if (dt != null && dt.Rows.Count > 0)
  753. {
  754. foreach (DataRow dr in dt.Rows)
  755. {
  756. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  757. {
  758. //品类一直
  759. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  760. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  761. if (ceErpSampleCustomer == null)
  762. {
  763. ceErpSampleCustomer = new CeErpSampleCustomer();
  764. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  765. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  766. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  767. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  768. ceErpSampleCustomer.shopId = entity.ShopId;
  769. }
  770. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  771. ceErpSampleCustomer.lastTid = entity.tid;
  772. if (ceErpSampleCustomer.ID > 0)
  773. {
  774. ceErpSampleCustomer.Update();
  775. }
  776. else
  777. {
  778. ceErpSampleCustomer.Create();
  779. }
  780. }
  781. }
  782. }
  783. }
  784. //if (entity.IsOldCustomer == 1)
  785. //{
  786. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  787. //{
  788. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  789. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  790. //}
  791. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  792. //{
  793. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  794. // {
  795. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  796. // {
  797. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  798. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  799. // }
  800. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  801. // {
  802. // entity.OrderState = 2;
  803. // entity.DesignUserId = 0;
  804. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  805. // }
  806. // else
  807. // {
  808. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  809. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  810. // }
  811. // }
  812. //}
  813. //}
  814. entity.Update();
  815. returnSuccessMsg("保存成功!");
  816. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  817. return;
  818. }
  819. returnErrorMsg("找不到记录");
  820. }
  821. }
  822. public void save_erp_customermemo()
  823. {
  824. if (UrlPostParmsCheck("ctid"))
  825. {
  826. string ctid = GetPostString("ctid");
  827. CeErpTradeCell entity = null;
  828. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  829. if (entity != null)
  830. {
  831. entity.CustomerMemo = GetPostString("CustomerMemo");
  832. entity.Update();
  833. ApiVo apiVo = new ApiVo();
  834. apiVo.orderNumber = entity.ctid;
  835. apiVo.actionName = "followRemarks";
  836. apiVo.orderRemarks = entity.CustomerMemo;
  837. designHelper.API_WorkCore(apiVo);//followRemarks
  838. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  839. returnSuccessMsg("保存成功!");
  840. return;
  841. }
  842. returnErrorMsg("找不到记录");
  843. }
  844. }
  845. public void upd_erp_addmemotag()
  846. {
  847. if (UrlPostParmsCheck("ctid"))
  848. {
  849. ;
  850. string eid = GetPostString("ctid");
  851. string sfTagstr = GetPostString("memotag");
  852. CeErpTradeCell entity = null;
  853. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  854. if (entity != null)
  855. {
  856. if (entity.OrderState == 0)
  857. {
  858. returnErrorMsg("请先领单");
  859. return;
  860. }
  861. //撤销顺丰
  862. if (sfTagstr == "撤销顺丰")
  863. {
  864. entity.IsSF = 0;
  865. string reMsg = "";
  866. string oldmemo = entity.seller_memo;
  867. if (entity.OrderState < 5)
  868. {
  869. oldmemo = oldmemo.Replace("顺丰到付", "");
  870. oldmemo = oldmemo.Replace("顺丰寄付", "");
  871. entity.seller_memo = oldmemo;
  872. }
  873. else
  874. {
  875. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  876. {
  877. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  878. }
  879. }
  880. entity.Update();
  881. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  882. api.orderNumber = entity.ctid;
  883. api.actionName = "followRemarks";
  884. api.orderRemarks = entity.seller_memo;
  885. api.isSf = entity.IsSF.ToString();
  886. designHelper.API_WorkCore(api);//followRemarks
  887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  888. returnSuccessMsg("撤销成功!" + reMsg);
  889. return;
  890. }
  891. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  892. {
  893. //string oldmemo = entity.seller_memo;
  894. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  895. string sfStr = GetPostString("memotag");
  896. string smemo = entity.seller_memo;
  897. int kindex = smemo.IndexOf(")");
  898. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  899. if (lastoneStr != "-")
  900. {
  901. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  902. }
  903. string prememo = smemo.Substring(0, kindex + 2);
  904. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  905. int lastkindex = lastmemo.IndexOf("(");
  906. string newlastmemo = "";
  907. if (lastkindex == 0)
  908. {
  909. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  910. newlastmemo = "(" + sfStr + "." + useLastmemo;
  911. }
  912. else
  913. {
  914. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  915. }
  916. entity.seller_memo = prememo + newlastmemo;
  917. }
  918. string sfTagMSg = "";
  919. if (sfTagstr == "顺丰寄付")
  920. {
  921. entity.IsSF = 1;
  922. sfTagMSg = "顺丰寄付";
  923. }
  924. else if (sfTagstr == "顺丰到付")
  925. {
  926. entity.IsSF = 2;
  927. sfTagMSg = "顺丰到付";
  928. }
  929. entity.Update();
  930. ApiVo apiVo = new ApiVo();
  931. apiVo.orderNumber = entity.ctid;
  932. apiVo.actionName = "orderRemarks";
  933. apiVo.orderRemarks = entity.seller_memo;
  934. apiVo.isSf = entity.IsSF.ToString();
  935. designHelper.API_WorkCore(apiVo);//orderRemarks
  936. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  937. returnSuccessMsg("标记成功!");
  938. return;
  939. }
  940. returnErrorMsg("找不到记录");
  941. }
  942. }
  943. public void upd_erp_ordertag()
  944. {
  945. if (UrlPostParmsCheck("ctid"))
  946. {
  947. string eid = GetPostString("ctid");
  948. CeErpTradeCell entity = null;
  949. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  950. if (entity != null)
  951. {
  952. int tag = GetPostInt("wechattag");
  953. //if(tag==4 && entity.IsSample == 2)
  954. //{
  955. // returnErrorMsg("补差价单不能标记微信单");
  956. // return;
  957. //}
  958. entity.wechatTag = tag;
  959. entity.Update();
  960. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  961. if (tag == 1)
  962. {
  963. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  964. if (cash == null)
  965. {
  966. CeErpTrade main = CeErpTrade.Get(entity.tid);
  967. cash = new CeErpReturnCash();
  968. cash.tid = entity.tid;
  969. cash.seller_nick = main.seller_nick;
  970. cash.payment = trade.payment;
  971. cash.buyer_nick = main.buyer_nick;
  972. cash.cashstate = 0;
  973. cash.rtype = "微信返现";
  974. cash.returnprice = 0;
  975. cash.created = DateTime.Now;
  976. cash.con = "订单标记微信单";
  977. cash.img = "";
  978. cash.applyuserid = CurrentUser.UserID;
  979. cash.Create();
  980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  981. }
  982. else
  983. {
  984. cash.cashstate = 0;
  985. cash.Update();
  986. }
  987. CeErpSukuraData.createInfo(entity.ctid, 9);
  988. }
  989. else if (tag == 2)
  990. {
  991. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  992. if (cash == null)
  993. {
  994. CeErpTrade main = CeErpTrade.Get(entity.tid);
  995. cash = new CeErpReturnCash();
  996. cash.tid = entity.tid;
  997. cash.seller_nick = main.seller_nick;
  998. cash.payment = trade.payment;
  999. cash.buyer_nick = main.buyer_nick;
  1000. cash.cashstate = 0;
  1001. cash.rtype = "推购返现";
  1002. cash.returnprice = 5;
  1003. cash.created = DateTime.Now;
  1004. cash.con = "订单标记推购单";
  1005. cash.img = "";
  1006. cash.applyuserid = CurrentUser.UserID;
  1007. cash.Create();
  1008. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1009. }
  1010. else
  1011. {
  1012. cash.cashstate = 0;
  1013. cash.Update();
  1014. }
  1015. CeErpSukuraData.createInfo(entity.ctid, 9);
  1016. }
  1017. else if (tag == 3)
  1018. {
  1019. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1020. if (pers == null)
  1021. {
  1022. pers = new CeErpPersuade();
  1023. pers.ctid = entity.ctid;
  1024. pers.pstate = 0;
  1025. pers.created = DateTime.Now;
  1026. pers.applyuserid = CurrentUser.UserID;
  1027. pers.Create();
  1028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1029. }
  1030. else
  1031. {
  1032. pers.pstate = 0;
  1033. pers.Update();
  1034. }
  1035. }
  1036. else if (tag == 4 || tag == 5)
  1037. {
  1038. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1039. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1040. if (pers == null)
  1041. {
  1042. pers = new CeErpStayGoods();
  1043. pers.t_id = entity.tid;
  1044. pers.status = "待审核";
  1045. pers.audit_type = 0;
  1046. if (tag == 4)
  1047. {
  1048. pers.stay_type = "微信推购";
  1049. }
  1050. else
  1051. {
  1052. pers.stay_type = "旺旺推购";
  1053. }
  1054. if (entity.IsXianHuo == 0)
  1055. {
  1056. pers.product_id = entity.ProductId;
  1057. }
  1058. pers.wangwang = main.buyer_nick;
  1059. pers.shop_name = main.seller_nick;
  1060. pers.creata_time = DateTime.Now;
  1061. pers.create_u_id = CurrentUser.UserID;
  1062. pers.create_u_name = CurrentUser.UserName;
  1063. pers.Create();
  1064. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1065. }
  1066. else
  1067. {
  1068. pers.audit_type = 0;
  1069. pers.Update();
  1070. }
  1071. CeErpSukuraData.createInfo(entity.ctid, 10);
  1072. }
  1073. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1074. returnSuccessMsg("标记成功!");
  1075. return;
  1076. }
  1077. returnErrorMsg("找不到记录");
  1078. }
  1079. }
  1080. public void upd_erp_ordertag_cancel()
  1081. {
  1082. if (UrlPostParmsCheck("ctid"))
  1083. {
  1084. string eid = GetPostString("ctid");
  1085. CeErpTradeCell entity = null;
  1086. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1087. if (entity != null)
  1088. {
  1089. entity.wechatTag = 0;
  1090. entity.Update();
  1091. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1092. if (pers != null)
  1093. {
  1094. pers.status = "取消推购";
  1095. pers.audit_type = 3;
  1096. pers.Update();
  1097. }
  1098. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1099. returnSuccessMsg("标记成功!");
  1100. return;
  1101. }
  1102. returnErrorMsg("找不到记录");
  1103. }
  1104. }
  1105. public void upd_erp_addweichattag()
  1106. {
  1107. if (UrlPostParmsCheck("ctid"))
  1108. {
  1109. ;
  1110. string eid = GetPostString("ctid");
  1111. CeErpTradeCell entity = null;
  1112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1113. if (entity != null)
  1114. {
  1115. if (entity.IsAddWechat > 0)
  1116. {
  1117. returnErrorMsg("此单已经标记过了");
  1118. return;
  1119. }
  1120. 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);
  1121. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1122. if (dt.Rows.Count > 0)
  1123. {
  1124. entity.IsAddWechat = 2;
  1125. }
  1126. else
  1127. {
  1128. entity.IsAddWechat = 1;
  1129. }
  1130. entity.Update();
  1131. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1132. returnSuccessMsg("标记成功!");
  1133. return;
  1134. }
  1135. returnErrorMsg("找不到记录");
  1136. }
  1137. }
  1138. public void upd_erp_getmyorder()
  1139. {
  1140. if (UrlPostParmsCheck("ctid"))
  1141. {
  1142. ;
  1143. string eid = GetPostString("ctid");
  1144. CeErpTradeCell entity = null;
  1145. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1146. if (entity != null)
  1147. {
  1148. if (entity.ctid.IndexOf("C") != -1)
  1149. {
  1150. StringBuilder sql = new StringBuilder();
  1151. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1152. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1153. if (dt.Rows.Count > 0)
  1154. {
  1155. decimal total = 0;
  1156. foreach (DataRow dr in dt.Rows)
  1157. {
  1158. total += Convert.ToDecimal(dr["payment"]);
  1159. }
  1160. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1161. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1162. {
  1163. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1164. return;
  1165. }
  1166. }
  1167. }
  1168. entity.CustomerUserId = CurrentUser.UserID;
  1169. if (entity.OrderState < 2)
  1170. {
  1171. entity.OrderState = 2;
  1172. if (entity.ShopId != 0)
  1173. {
  1174. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1175. }
  1176. }
  1177. entity.Update();
  1178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1179. returnSuccessMsg("领单成功!");
  1180. return;
  1181. }
  1182. returnErrorMsg("找不到记录");
  1183. }
  1184. }
  1185. public void getmyorder_from_init()
  1186. {
  1187. if (UrlPostParmsCheck("ctid"))
  1188. {
  1189. string eid = GetPostString("ctid");
  1190. CeErpTradeCell entity = null;
  1191. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1192. if (entity != null)
  1193. {
  1194. string sellerMemo = GetPostString("sellerMemo");
  1195. if (sellerMemo.Length > 0)
  1196. {
  1197. entity.seller_memo = sellerMemo;
  1198. }
  1199. string oterhMemo = GetPostString("otherMemo");
  1200. if (oterhMemo.Length > 0)
  1201. {
  1202. entity.OtherMemo = oterhMemo;
  1203. }
  1204. int urg = GetPostInt("urgency");
  1205. entity.IsUrgency = (urg == 1 ? true : false);
  1206. int wechat = GetPostInt("wechat");
  1207. int command = GetPostInt("command");
  1208. if (wechat == 1)
  1209. {
  1210. entity.wechatTag = 1;
  1211. }
  1212. if (command == 1)
  1213. {
  1214. entity.wechatTag = 2;
  1215. }
  1216. string pPro = GetPostString("pprofession");
  1217. if (pPro.Length > 0)
  1218. {
  1219. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1220. string spro = GetPostString("profession");
  1221. if (spro.Length > 0)
  1222. {
  1223. entity.ProfessionId = Convert.ToInt32(spro);
  1224. }
  1225. }
  1226. string proId = GetPostString("productId");
  1227. if (proId.Length > 0)
  1228. {
  1229. entity.ProductId = Convert.ToInt32(proId);
  1230. }
  1231. entity.Material = GetPostString("material");
  1232. entity.Craft = GetPostString("craft");
  1233. entity.CustomerUserId = CurrentUser.UserID;
  1234. if (entity.OrderState < 2)
  1235. {
  1236. entity.OrderState = 2;
  1237. if (entity.ShopId != 0)
  1238. {
  1239. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1240. }
  1241. }
  1242. entity.Update();
  1243. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1244. returnSuccessMsg("领单成功!");
  1245. return;
  1246. }
  1247. returnErrorMsg("找不到记录");
  1248. }
  1249. }
  1250. public void upd_erp_setrelationorder()
  1251. {
  1252. if (UrlPostParmsCheck("ctid"))
  1253. {
  1254. ;
  1255. string eid = GetPostString("ctid");
  1256. string ftid = GetPostString("ftid");
  1257. CeErpTradeCell entity = null;
  1258. CeErpTradeCell fentity = null;
  1259. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1260. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1261. if (fentity == null)
  1262. {
  1263. returnErrorMsg("找不到关联的主订单");
  1264. return;
  1265. }
  1266. if (entity != null)
  1267. {
  1268. if (entity.OrderState >= 5)
  1269. {
  1270. returnErrorMsg("本单已经设计完成无法关联");
  1271. return;
  1272. }
  1273. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1274. {
  1275. returnErrorMsg("线下单续审核后才能关联!");
  1276. return;
  1277. }
  1278. entity.ptid = ftid;
  1279. entity.OrderState = fentity.OrderState;
  1280. //entity.status = fentity.status;
  1281. entity.CustomerUserId = fentity.CustomerUserId;
  1282. entity.DesignUserId = fentity.DesignUserId;
  1283. entity.seller_memo = "补差价单:" + ftid;
  1284. entity.IsSample = 2;
  1285. entity.Update();
  1286. ApiVo apiVo = new ApiVo();
  1287. apiVo.orderNumber = ftid;
  1288. apiVo.payment = entity.payment;
  1289. apiVo.actionName = "repairDesign";
  1290. designHelper.API_WorkCore(apiVo);//repairDesign
  1291. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1292. returnSuccessMsg("关联成功!");
  1293. return;
  1294. }
  1295. else
  1296. returnErrorMsg("找不到记录");
  1297. }
  1298. }
  1299. public void download_erp_neworder()
  1300. {
  1301. string seller = GetPostString("seller_nick");
  1302. string tid = GetPostString("tid");
  1303. if (seller.Length <= 0 || tid.Length <= 0)
  1304. {
  1305. returnErrorMsg("数据错误");
  1306. }
  1307. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1308. //{
  1309. // returnErrorMsg("找不到店铺Sessionkey");
  1310. //}
  1311. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1312. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1313. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1314. if (res.IndexOf("refOid") == -1)
  1315. {
  1316. returnErrorMsg("下载订单数据失败");
  1317. return;
  1318. }
  1319. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1320. returnSuccessMsg("下载完成");
  1321. //tmcHelper.createNewOrder(res);
  1322. //CeErpTrade entr = null;
  1323. //entr = CeErpTrade.Get(tid);
  1324. //if (entr != null)
  1325. //{
  1326. // returnSuccess("下载成功");
  1327. // //下载成功之后,Cell表生成对应的订单;
  1328. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1329. //}
  1330. //else
  1331. //{
  1332. // returnErrorMsg("下载失败或者创建订单失败");
  1333. //}
  1334. }
  1335. public void set_erp_atersale()
  1336. {
  1337. if (UrlPostParmsCheck("ctid"))
  1338. {
  1339. string eid = GetPostString("ctid");
  1340. string reason = GetPostString("AfterSaleReason");
  1341. CeErpTradeCell entity = null;
  1342. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1343. if (entity != null)
  1344. {
  1345. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1346. {
  1347. returnErrorMsg("此订单已经在售后");
  1348. return;
  1349. }
  1350. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1351. //entity.AfterSaleReason = reason;
  1352. entity.AfterSaleTime = DateTime.Now;
  1353. entity.Update();
  1354. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1355. returnSuccessMsg("转售后成功!");
  1356. return;
  1357. }
  1358. returnErrorMsg("找不到记录");
  1359. }
  1360. }
  1361. public void set_erp_withdraw()
  1362. {
  1363. if (UrlPostParmsCheck("ctid"))
  1364. {
  1365. try
  1366. {
  1367. string eid = GetPostString("ctid");//商品id
  1368. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1369. CeWithdraw ceWithdrawSelect = null;
  1370. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1371. if (ceWithdrawSelect != null)
  1372. {
  1373. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1374. {
  1375. ceWithdrawSelect.status = -1;
  1376. ceWithdrawSelect.Update();
  1377. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1378. returnSuccessMsg("重新发起审核成功");
  1379. return;
  1380. }
  1381. else
  1382. {
  1383. returnSuccessMsg("请勿重复申请!");
  1384. return;
  1385. }
  1386. }
  1387. else
  1388. {
  1389. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1390. if (string.IsNullOrEmpty(CustomerUserId))
  1391. {
  1392. CustomerUserId = "-1";
  1393. }
  1394. int Userid = CurrentUser.UserID;//用户id
  1395. CeWithdraw ceWithdraw = new CeWithdraw();
  1396. ceWithdraw.tid = eid;
  1397. ceWithdraw.userid = Userid;
  1398. ceWithdraw.providerid = CustomerUserId;
  1399. ceWithdraw.status = 3;
  1400. ceWithdraw.creationtime = DateTime.Now;
  1401. ceWithdraw.Create();
  1402. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1403. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1404. return;
  1405. }
  1406. }
  1407. catch
  1408. {
  1409. returnErrorMsg("申请撤回订单失败");
  1410. return;
  1411. }
  1412. }
  1413. }
  1414. public void ins_erp_billinfo()
  1415. {
  1416. if (UrlPostParmsCheck("ctid"))
  1417. {
  1418. string eid = GetPostString("ctid");
  1419. CeErpTradeCell entity = null;
  1420. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1421. if (entity != null)
  1422. {
  1423. CeErpBill bill = CeErpBill.GetByTid(eid);
  1424. bool isHave = false;
  1425. if (bill != null)
  1426. {
  1427. isHave = true;
  1428. if (bill.state != 4)
  1429. {
  1430. returnErrorMsg("此单已经申请过发票了");
  1431. return;
  1432. }
  1433. }
  1434. if (entity.IsNeedBill == 0)
  1435. {
  1436. entity.IsNeedBill = 1;
  1437. }
  1438. entity.Update();
  1439. string errjson = "";
  1440. try
  1441. {
  1442. CeErpBill bill_entity = new CeErpBill();
  1443. bill_entity.tid = entity.tid;
  1444. bill_entity.title = GetPostString("title");
  1445. string taxstr = GetPostString("tax");
  1446. taxstr = taxstr.Replace(" ", "");
  1447. bill_entity.tax = taxstr;
  1448. bill_entity.bank = GetPostString("bank");
  1449. string bankacstr = GetPostString("bankac");
  1450. bankacstr = bankacstr.Replace(" ", "");
  1451. bill_entity.bankac = bankacstr;
  1452. bill_entity.address = GetPostString("address");
  1453. bill_entity.phone = GetPostString("phone");
  1454. bill_entity.price = GetPostString("price");
  1455. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1456. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1457. {
  1458. billCount += 1;
  1459. }
  1460. string prebill = "ltb";
  1461. for (int idx = 1; idx <= billCount; idx++)
  1462. {
  1463. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1464. string billoid = prebill + idx + dtstr;
  1465. bill_entity.billOrderId += billoid;
  1466. if (idx < billCount)
  1467. {
  1468. bill_entity.billOrderId += ",";
  1469. }
  1470. }
  1471. bill_entity.productId = GetPostInt("ProductName");
  1472. bill_entity.num = GetPostInt("num");
  1473. bill_entity.unit = GetPostString("unit");
  1474. bill_entity.type = GetPostString("type");
  1475. bill_entity.sendType = GetPostString("SendType");
  1476. bill_entity.email = GetPostString("email");
  1477. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1478. bill_entity.shopName = GetPostString("ShopName");
  1479. bill_entity.applymemo = GetPostString("applyMemo");
  1480. bill_entity.createTime = DateTime.Now;
  1481. bill_entity.state = 0;
  1482. bill_entity.userId = CurrentUser.UserID;
  1483. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1484. bill_entity.Create();
  1485. }
  1486. catch (Exception ex)
  1487. {
  1488. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1489. returnErrorMsg("创建发票出错!");
  1490. return;
  1491. }
  1492. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1493. returnSuccessMsg("发票申请成功!");
  1494. return;
  1495. }
  1496. returnErrorMsg("找不到记录");
  1497. }
  1498. }
  1499. public void ins_erp_neworder()
  1500. {
  1501. if (UrlPostParmsCheck("receiver_name"))
  1502. {
  1503. CeErpTrade entity = new CeErpTrade();
  1504. string plat_form = GetPostString("platform");
  1505. string preStr = "N_";
  1506. if (plat_form == "拼多多")
  1507. {
  1508. preStr = "P_";
  1509. }
  1510. else if (plat_form == "阿里巴巴")
  1511. {
  1512. preStr = "A_";
  1513. }
  1514. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1515. entity.seller_nick = GetPostString("seller_nick");
  1516. entity.buyer_nick = GetPostString("buyer_nick");
  1517. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1518. entity.total_fee = entity.payment;
  1519. entity.pay_time = DateTime.Now;
  1520. entity.status = "NOT_SHIPPED";
  1521. entity.receiver_name = GetPostString("receiver_name");
  1522. entity.receiver_mobile = GetPostString("receiver_mobile");
  1523. entity.receiver_state = GetPostString("receiver_state");
  1524. entity.receiver_city = GetPostString("receiver_city");
  1525. entity.receiver_district = GetPostString("receiver_district");
  1526. entity.receiver_address = GetPostString("receiver_address");
  1527. if (entity.receiver_state == "" || entity.receiver_city == "")
  1528. {
  1529. returnErrorMsg("收件地址不能为空");
  1530. return;
  1531. }
  1532. int shopId = 0;
  1533. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1534. if (nShop != null)
  1535. {
  1536. shopId = nShop.ID;
  1537. }
  1538. if (shopId != 34 && entity.payment == 0)
  1539. {
  1540. returnErrorMsg("公司自用的单金额才能为0");
  1541. return;
  1542. }
  1543. entity.Create();
  1544. CeErpTradeCell entitycell = new CeErpTradeCell();
  1545. entitycell.ctid = entity.tid;
  1546. entitycell.tid = entity.tid;
  1547. entitycell.ShopId = shopId;
  1548. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1549. entitycell.OrderState = 0;
  1550. entitycell.pay_time = entity.pay_time;
  1551. entitycell.IsOffLineOrder = 1;
  1552. entitycell.Create();
  1553. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1554. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1555. return;
  1556. }
  1557. }
  1558. public void ins_erp_neworder2()
  1559. {
  1560. if (UrlPostParmsCheck("receiver_name"))
  1561. {
  1562. //string plat_form = GetPostString("platform");
  1563. string preStr = "X_";
  1564. string memo = GetPostString("memo");
  1565. string productId = GetPostString("productId");
  1566. string primg = GetPostString("proofimg");
  1567. string sellerNick = GetPostString("seller_nick");
  1568. string addFrom = GetPostString("addfrom");
  1569. if (addFrom == "1")
  1570. {
  1571. preStr = "N_";
  1572. }
  1573. int shopId = 0;
  1574. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1575. if (nShop != null)
  1576. {
  1577. shopId = nShop.ID;
  1578. }
  1579. else
  1580. {
  1581. returnErrorMsg("找不到对应店铺");
  1582. return;
  1583. }
  1584. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1585. {
  1586. returnErrorMsg("必须上传付款凭证");
  1587. return;
  1588. }
  1589. CeErpTrade entity = new CeErpTrade();
  1590. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1591. entity.seller_nick = sellerNick;
  1592. entity.buyer_nick = GetPostString("buyer_nick");
  1593. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1594. entity.total_fee = entity.payment;
  1595. entity.pay_time = DateTime.Now;
  1596. entity.status = "NOT_SHIPPED";
  1597. entity.receiver_name = GetPostString("receiver_name");
  1598. entity.receiver_mobile = GetPostString("receiver_mobile");
  1599. entity.receiver_state = GetPostString("receiver_state");
  1600. entity.receiver_city = GetPostString("receiver_city");
  1601. entity.receiver_district = GetPostString("receiver_district");
  1602. entity.receiver_address = GetPostString("receiver_address");
  1603. entity.seller_memo = memo;
  1604. entity.orderFrom = 20;
  1605. entity.orderType = 15;
  1606. if (entity.receiver_state == "" || entity.receiver_city == "")
  1607. {
  1608. returnErrorMsg("收件地址不能为空");
  1609. return;
  1610. }
  1611. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1612. {
  1613. returnErrorMsg("公司自用的单金额才能为0");
  1614. return;
  1615. }
  1616. entity.Create();
  1617. string toWhere = GetPostString("towhere");
  1618. CeErpTradeCell entitycell = new CeErpTradeCell();
  1619. entitycell.ctid = entity.tid;
  1620. //唯一标识
  1621. entitycell.OrderSn = entity.tid;
  1622. //string orderSn = dataHelper.getSaleOrderSn();
  1623. //if (orderSn != "")
  1624. // {
  1625. // entitycell.OrderSn = orderSn;
  1626. // }
  1627. entitycell.tid = entity.tid;
  1628. //if (preStr == "X_")
  1629. //{
  1630. entitycell.IsOffLineOrder = 1;
  1631. //}
  1632. entitycell.CustomerUserId = CurrentUser.UserID;
  1633. entitycell.PayProofImg = primg;
  1634. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1635. entitycell.ProductId = Convert.ToInt32(productId);
  1636. entitycell.ShopId = shopId;
  1637. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1638. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1639. {
  1640. entitycell.IsXianHuo = 1;
  1641. }
  1642. entitycell.pay_time = entity.pay_time;
  1643. if (toWhere == "1")
  1644. {
  1645. entitycell.OrderState = 2;
  1646. }
  1647. else
  1648. {
  1649. entitycell.OrderState = 6;
  1650. entitycell.FinishPlaceTime = entitycell.pay_time;
  1651. }
  1652. if (shopId == 94)
  1653. {
  1654. entitycell.OrderState = 4;
  1655. entitycell.WaitDesignTime = entitycell.pay_time;
  1656. entitycell.StartDesignTime = entitycell.pay_time;
  1657. entitycell.DesignUserId = 218;
  1658. }
  1659. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1660. {
  1661. entitycell.OrderState = -1;//修改12-5
  1662. CeWithdraw ceWithdraw = new CeWithdraw();
  1663. ceWithdraw.tid = entity.tid;
  1664. ceWithdraw.providerid = "-1";
  1665. ceWithdraw.status = -1;
  1666. ceWithdraw.creationtime = DateTime.Now;
  1667. ceWithdraw.userid = 1337;
  1668. ceWithdraw.Create();
  1669. }
  1670. entitycell.Create();
  1671. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1672. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1673. {
  1674. addPlaceRegist(entitycell, CurrentUser.UserID);
  1675. }
  1676. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1677. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1678. return;
  1679. }
  1680. }
  1681. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1682. {
  1683. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1684. entity.PlactTime = tradecell.pay_time;
  1685. entity.AddUserId = userid;
  1686. entity.FileName = tradecell.seller_memo;
  1687. entity.Supplier = 24;
  1688. entity.CreateTime = DateTime.Now;
  1689. entity.Did = tradecell.ctid;
  1690. entity.tid = tradecell.tid;
  1691. entity.splitTag = tradecell.SplitTag;
  1692. entity.CurState = "未完成";
  1693. entity.Create();
  1694. }
  1695. public void get_erp_offlinelist()
  1696. {
  1697. DataStruct dStruct = GetPostStruct();
  1698. List<string> lw = new List<string>();
  1699. string tid = GetPostString("ctid");
  1700. string date1 = GetPostString("date1");
  1701. string date2 = GetPostString("date2");
  1702. if (tid.Length > 0 || date1.Length > 0)
  1703. {
  1704. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1705. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1706. if (dw.Length > 0) lw.Add(dw);
  1707. }
  1708. else
  1709. {
  1710. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1711. }
  1712. string shopname = GetPostString("shopname");
  1713. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1714. string buyernick = GetPostString("buyer_nick");
  1715. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1716. string customer = GetPostString("customer");
  1717. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1718. string design = GetPostString("design");
  1719. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1720. string orderState = GetPostString("orderState");
  1721. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1722. string address = GetPostString("address");
  1723. 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));
  1724. string sellermemo = GetPostString("seller_memo");
  1725. if (sellermemo.Length > 0)
  1726. {
  1727. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1728. }
  1729. string price1 = GetPostString("price1");
  1730. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1731. string price2 = GetPostString("price2");
  1732. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1733. //if (PKey != "admin")
  1734. //{
  1735. // string usershop = CurrentUser.User.pemShop;
  1736. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1737. //}
  1738. //if (ex_psize > 0)
  1739. //{
  1740. dStruct.Order = "pay_time desc";
  1741. //}
  1742. //else
  1743. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1744. lw.Add(string.Format("IsOffLineOrder=1"));
  1745. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1746. DataTable dt = null;
  1747. dt = WebCache.GetData("view_erptradecell", dStruct);
  1748. writeGridDataTableJson(dStruct.TotalCount, dt);
  1749. }
  1750. public void get_erp_returncashrecord()
  1751. {
  1752. DataStruct dStruct = GetPostStruct();
  1753. List<string> lw = new List<string>();
  1754. string tid = GetPostString("ctid");
  1755. if (tid.Length > 0)
  1756. {
  1757. lw.Add(string.Format("tid like '%{0}%'", tid));
  1758. dStruct.Order = "id desc";
  1759. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1760. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1761. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1762. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1763. return;
  1764. }
  1765. returnErrorMsg("id数据错误!");
  1766. }
  1767. public void ins_erp_returncashrecord()
  1768. {
  1769. if (UrlPostParmsCheck("tid"))
  1770. {
  1771. string tid = GetPostString("tid");
  1772. string retype = GetPostString("type");
  1773. StringBuilder sql = new StringBuilder();
  1774. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1775. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1776. if (dt.Rows.Count > 0)
  1777. {
  1778. returnErrorMsg("相同返现类型记录已存在");
  1779. return;
  1780. }
  1781. CeErpReturnCash entity = new CeErpReturnCash();
  1782. entity.tid = tid;
  1783. entity.seller_nick = GetPostString("seller_nick");
  1784. string pment = GetPostString("payment");
  1785. if (pment.Length > 0)
  1786. {
  1787. entity.payment = Convert.ToDouble(pment);
  1788. }
  1789. entity.buyer_nick = GetPostString("buyer_nick");
  1790. entity.cashstate = 0;
  1791. entity.rtype = retype;
  1792. string rPrice = GetPostString("returnprice");
  1793. if (rPrice.Length > 0)
  1794. {
  1795. entity.returnprice = Convert.ToDouble(rPrice);
  1796. }
  1797. entity.created = DateTime.Now;
  1798. entity.con = GetPostString("con");
  1799. entity.img = GetPostString("img");
  1800. entity.applyuserid = CurrentUser.UserID;
  1801. entity.Create();
  1802. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1803. returnSuccessMsg("操作成功!");
  1804. return;
  1805. }
  1806. }
  1807. public void set_erp_predelivery()
  1808. {
  1809. if (UrlPostParmsCheck("ctid"))
  1810. {
  1811. string eid = GetPostString("ctid");
  1812. CeErpTradeCell entity = null;
  1813. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1814. if (entity != null)
  1815. {
  1816. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1817. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1818. //{
  1819. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1820. // return;
  1821. //}
  1822. entity.IsPreDelivery = 1;
  1823. entity.Update();
  1824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1825. returnSuccessMsg("预发货成功!");
  1826. return;
  1827. //string shop = GetPostString("seller_nick");
  1828. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1829. //string comName = GetPostString("comName");
  1830. //string comCode = GetPostString("comCode");
  1831. //string outSid = GetPostString("outSid");//运单号
  1832. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1833. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1834. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1835. //string apires = "";
  1836. //if (deliveryType == "虚拟发货")
  1837. //{
  1838. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1839. //}
  1840. //else
  1841. //{
  1842. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1843. //}
  1844. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1845. ////{
  1846. //if (apires.IndexOf("发货成功") != -1)
  1847. //{
  1848. // if (deliveryType != "虚拟发货")
  1849. // {
  1850. // //还要插入快递信息到 快递信息表
  1851. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1852. // exinfo.tid = eid;
  1853. // exinfo.out_sid = outSid;
  1854. // exinfo.company_code = comCode;
  1855. // exinfo.company_name = comName;
  1856. // exinfo.delivery_memo = deliveryMemo;
  1857. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1858. // exinfo.deliveryType = deliveryType;
  1859. // exinfo.Create();
  1860. // }
  1861. // returnSuccessMsg("发货成功!");
  1862. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1863. //}
  1864. //else
  1865. //{
  1866. // returnErrorMsg("淘宝发货失败!!");
  1867. //}
  1868. //return;
  1869. }
  1870. returnErrorMsg("找不到订单记录");
  1871. }
  1872. }
  1873. public void get_erp_unusuallist()
  1874. {
  1875. DataStruct dStruct = GetPostStruct();
  1876. List<string> lw = new List<string>();
  1877. string tid = GetPostString("ctid");
  1878. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1879. string shopname = GetPostString("shopname");
  1880. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1881. string buyernick = GetPostString("buyer_nick");
  1882. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1883. string ResponsibleMan = GetPostString("responsible");
  1884. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1885. string date1 = GetPostString("date1");
  1886. string date2 = GetPostString("date2");
  1887. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1888. if (dw.Length > 0) lw.Add(dw);
  1889. string price1 = GetPostString("price1");
  1890. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1891. string price2 = GetPostString("price2");
  1892. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1893. string orderState = GetPostString("orderState");
  1894. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1895. string sellermemo = GetPostString("seller_memo");
  1896. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1897. lw.Add(string.Format("UnusualTag > 0"));
  1898. lw.Add(string.Format("IsRefund<={0}", 1));
  1899. dStruct.Order = "pay_time desc";
  1900. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1901. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1902. writeGridDataTableJson(dStruct.TotalCount, dt);
  1903. }
  1904. public void set_erp_unusualtonomal()
  1905. {
  1906. if (UrlPostParmsCheck("ctid"))
  1907. {
  1908. string eid = GetPostString("ctid");
  1909. CeErpTradeCell entity = null;
  1910. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1911. if (entity != null)
  1912. {
  1913. entity.UnusualTag = -1;
  1914. entity.Update();
  1915. returnSuccessMsg("忽略成功!");
  1916. return;
  1917. }
  1918. returnErrorMsg("找不到记录");
  1919. }
  1920. }
  1921. public void ins_erp_unusualreason()
  1922. {
  1923. if (UrlPostParmsCheck("ctid"))
  1924. {
  1925. string eid = GetPostString("ctid");
  1926. CeErpTradeCell entity = null;
  1927. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1928. if (entity != null)
  1929. {
  1930. entity.MemoOpt = 4;
  1931. entity.UnusualCon = GetPostString("con");
  1932. entity.Update();
  1933. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1934. if (trade != null)
  1935. {
  1936. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1937. }
  1938. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1939. returnSuccessMsg("操作成功!");
  1940. return;
  1941. }
  1942. returnErrorMsg("找不到记录");
  1943. }
  1944. }
  1945. public void upd_erp_sampleorder()
  1946. {
  1947. if (UrlPostParmsCheck("ctid"))
  1948. {
  1949. string eid = GetPostString("ctid");
  1950. string[] eArr = eid.Split(',');
  1951. if (eArr.Length > 1)
  1952. {
  1953. List<string> eLst = new List<string>();
  1954. for (int i = 0; i < eArr.Length; i++)
  1955. {
  1956. eLst.Add("'" + eArr[i] + "'");
  1957. }
  1958. eid = string.Join(",", eLst.ToArray());
  1959. }
  1960. else
  1961. {
  1962. eid = "'" + eid + "'";
  1963. }
  1964. StringBuilder sql = new StringBuilder();
  1965. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1967. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1968. if (dt.Rows.Count > 0)
  1969. {
  1970. string errmsg = "";
  1971. foreach (DataRow dr in dt.Rows)
  1972. {
  1973. StringBuilder sqlsb = new StringBuilder();
  1974. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1975. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1976. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1977. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1978. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1979. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1980. {
  1981. continue;
  1982. }
  1983. else
  1984. {
  1985. string emsg = commonHelper.KeepChinese(apires);
  1986. errmsg += emsg;
  1987. }
  1988. }
  1989. if (errmsg.Length > 0)
  1990. {
  1991. returnErrorMsg(errmsg);
  1992. return;
  1993. }
  1994. returnSuccessMsg("操作成功");
  1995. return;
  1996. }
  1997. returnErrorMsg("找不到记录");
  1998. }
  1999. }
  2000. public void upd_erp_transcustomer()
  2001. {
  2002. if (UrlPostParmsCheck("ctid"))
  2003. {
  2004. string eid = GetPostString("ctid");
  2005. int userid = GetPostInt("CustomerUserId");
  2006. CeErpTradeCell entity = null;
  2007. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2008. if (entity != null)
  2009. {
  2010. //string[] mlist = entity.seller_memo.Split('-');
  2011. //string sql = "select * from view_erpuser where id=" + userid;
  2012. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2013. //if (dt != null && dt.Rows.Count > 0)
  2014. //{
  2015. // string nmemo = "";
  2016. // for(int i = 0; i < mlist.Length - 1; i++)
  2017. // {
  2018. // nmemo += mlist[i];
  2019. // nmemo += "-";
  2020. // }
  2021. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2022. // entity.seller_memo = nmemo;
  2023. //}
  2024. entity.CustomerUserId = userid;
  2025. entity.Update();
  2026. returnSuccessMsg("操作成功!");
  2027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2028. return;
  2029. }
  2030. returnErrorMsg("找不到记录");
  2031. }
  2032. }
  2033. public void upd_erp_transdesigner()
  2034. {
  2035. if (UrlPostParmsCheck("ctid"))
  2036. {
  2037. string eids = GetPostString("ctid");
  2038. string[] ctidList = eids.Split(',');
  2039. int userid = GetPostInt("DesignUserId");
  2040. foreach (string ctid in ctidList)
  2041. {
  2042. CeErpTradeCell entity = null;
  2043. CeErpDesignerBill entitys = null;
  2044. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2045. entitys = CeErpDesignerBill.GetByTid(ctid);
  2046. if (entity != null)
  2047. {
  2048. if (entity.OrderState > 4)
  2049. {
  2050. continue;
  2051. }
  2052. //存在退款不能流转
  2053. if (entity.IsRefund > 0)
  2054. {
  2055. continue;
  2056. }
  2057. entity.DesignUserId = userid;
  2058. entity.WaitDesignTime = DateTime.Now;
  2059. entity.Update();
  2060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2061. }
  2062. }
  2063. returnSuccessMsg("操作成功!");
  2064. }
  2065. }
  2066. public void upd_erp_distributedesigner()
  2067. {
  2068. if (UrlPostParmsCheck("ctid"))
  2069. {
  2070. string eid = GetPostString("ctid");
  2071. int userid = GetPostInt("DesignUserId");
  2072. string[] idlist = eid.Split(',');
  2073. if (idlist.Length <= 0)
  2074. {
  2075. returnErrorMsg("订单不能为空");
  2076. return;
  2077. }
  2078. foreach (string ctid in idlist)
  2079. {
  2080. CeErpTradeCell entity = null;
  2081. CeErpDesignerBill entitys = null;
  2082. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2083. else continue;
  2084. if (entity != null)
  2085. {
  2086. if (userid == 2125 || userid == 3542)
  2087. { }
  2088. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2089. {
  2090. returnErrorMsg("金额错误的订单无法指派");
  2091. return;
  2092. }
  2093. if (entity.OrderState >= 5)
  2094. {
  2095. returnErrorMsg("已经设计完成无法指派");
  2096. return;
  2097. }
  2098. if (entity.OrderState == -1)
  2099. {
  2100. returnErrorMsg("审核中的订单无法指派");
  2101. return;
  2102. }
  2103. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2104. {
  2105. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2106. return;
  2107. }
  2108. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2109. {
  2110. returnErrorMsg("指派设计共创无法再次指派!");
  2111. return;
  2112. }
  2113. entity.OrderState = 3;
  2114. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2115. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2116. {
  2117. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2118. entity.SupplierId = suid;
  2119. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2120. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2121. }
  2122. if (userid == 2125 && entity.seller_memo != "")
  2123. {
  2124. apiDesign.API_GetPrintData_CreateOrder(entity);
  2125. }
  2126. if (userid == 3542 && entity.seller_memo != "")
  2127. {
  2128. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2129. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2130. if (response.msg != "设计共创:成功")
  2131. {
  2132. returnErrorMsg(response.msg);
  2133. return;
  2134. }
  2135. entity.DispatchSort = 2;
  2136. entity.OrderState = 3;
  2137. }
  2138. entity.DesignUserId = userid;
  2139. entity.WaitDesignTime = DateTime.Now;
  2140. entity.Update();
  2141. string name = commonHelper.getUserNameById(userid);
  2142. commonHelper.UpdateRelationOrder(entity.ctid);
  2143. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2144. }
  2145. }
  2146. returnSuccessMsg("操作成功!");
  2147. return;
  2148. }
  2149. }
  2150. public void get_erp_myorderlist()
  2151. {
  2152. DataStruct dStruct = GetPostStruct();
  2153. List<string> lw = new List<string>();
  2154. string tid = GetPostString("ctid");
  2155. if (tid.Length > 0)
  2156. {
  2157. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2158. }
  2159. else
  2160. {
  2161. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2162. }
  2163. //12-1 修改
  2164. string urgent = GetPostString("urgent");
  2165. string back = GetPostString("back");
  2166. string offlineSearch = GetPostString("offlineSearch");
  2167. if (!string.IsNullOrWhiteSpace(urgent))
  2168. {
  2169. if (urgent.Equals("true"))
  2170. {
  2171. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2172. }
  2173. }
  2174. if (!string.IsNullOrWhiteSpace(back))
  2175. {
  2176. if (back.Equals("true"))
  2177. {
  2178. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2179. }
  2180. }
  2181. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2182. {
  2183. if (offlineSearch.Equals("true"))
  2184. {
  2185. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2186. }
  2187. }
  2188. //end
  2189. string shopname = GetPostString("shopname");
  2190. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2191. string buyernick = GetPostString("buyer_nick");
  2192. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2193. string design = GetPostString("design");
  2194. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2195. string orderState = GetPostString("orderState");
  2196. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2197. string sellermemo = GetPostString("seller_memo");
  2198. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2199. string date1 = GetPostString("date1");
  2200. string date2 = GetPostString("date2");
  2201. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2202. if (dw.Length > 0) lw.Add(dw);
  2203. string price1 = GetPostString("price1");
  2204. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2205. string price2 = GetPostString("price2");
  2206. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2207. string urgency = GetPostString("urgency");
  2208. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2209. string after = GetPostString("after");
  2210. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2211. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2212. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2213. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2215. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2216. writeGridDataTableJson(dStruct.TotalCount, dt);
  2217. }
  2218. public void get_erp_myreturnorderlist()
  2219. {
  2220. DataStruct dStruct = GetPostStruct();
  2221. List<string> lw = new List<string>();
  2222. string tid = GetPostString("ctid");
  2223. if (tid.Length > 0)
  2224. {
  2225. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2226. }
  2227. else
  2228. {
  2229. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2230. }
  2231. string shopname = GetPostString("shopname");
  2232. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2233. string buyernick = GetPostString("buyer_nick");
  2234. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2235. string design = GetPostString("design");
  2236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2237. string orderState = GetPostString("orderState");
  2238. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2239. string sellermemo = GetPostString("seller_memo");
  2240. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2241. string date1 = GetPostString("date1");
  2242. string date2 = GetPostString("date2");
  2243. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2244. if (dw.Length > 0) lw.Add(dw);
  2245. string price1 = GetPostString("price1");
  2246. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2247. string price2 = GetPostString("price2");
  2248. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2249. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2250. {
  2251. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2252. }
  2253. else
  2254. {
  2255. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2256. }
  2257. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2258. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2259. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2260. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2261. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2262. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2263. if (dt != null && dt.Rows.Count > 0)
  2264. {
  2265. foreach (DataRow dr in dt.Rows)
  2266. {
  2267. try
  2268. {
  2269. // 对象操作
  2270. if (dStruct.PageSize != 100000)
  2271. {
  2272. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2273. dr["gongchuang"] = response.code;
  2274. }
  2275. }
  2276. catch (NullReferenceException ex)
  2277. {
  2278. // 处理空引用异常
  2279. }
  2280. }
  2281. }
  2282. writeGridDataTableJson(dStruct.TotalCount, dt);
  2283. }
  2284. public void get_erp_myorderlist_pregather()
  2285. {
  2286. string date1 = GetPostString("date1");
  2287. string date2 = GetPostString("date2");
  2288. int userId = CurrentUser.UserID; //客服id
  2289. string orderWhere = "";
  2290. List<string> lw = new List<string>();
  2291. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2292. if (dw.Length > 0) lw.Add(dw);
  2293. lw.Add(string.Format("CustomerUserId={0}", userId));
  2294. lw.Add(string.Format("OrderState<9"));
  2295. orderWhere = string.Join(" and ", lw.ToArray());
  2296. string orderWhere2 = "";
  2297. List<string> lw2 = new List<string>();
  2298. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2299. if (dw2.Length > 0) lw2.Add(dw2);
  2300. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2301. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2302. string sql = string.Format("select *" +
  2303. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2304. "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 " +
  2305. "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 " +
  2306. "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");
  2307. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2308. //writeGridDataTableJson(dt.Rows.Count, dt);
  2309. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2310. }
  2311. public void upd_erp_publishorder()
  2312. {
  2313. if (UrlPostParmsCheck("ctid"))
  2314. {
  2315. string eid = GetPostString("ctid");
  2316. CeErpTradeCell entity = null;
  2317. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2318. if (entity != null)
  2319. {
  2320. entity.OrderState = 0; //发布后,变为待抢单
  2321. entity.Update();
  2322. commonHelper.UpdateRelationOrder(entity.ctid);
  2323. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2324. returnSuccessMsg("发布成功!");
  2325. return;
  2326. }
  2327. returnErrorMsg("找不到记录");
  2328. }
  2329. }
  2330. public void get_erp_my_tiporder()
  2331. {
  2332. StringBuilder sql = new StringBuilder();
  2333. int userId = 0;
  2334. if (CurrentUser != null) userId = CurrentUser.UserID;
  2335. string posCode = CurrentUser.UserPost.Post.Code;
  2336. string isTipedAfterSaleVerify = GetPostString("af");
  2337. DataTable dt = new DataTable();
  2338. if (posCode != "Supplier")
  2339. {
  2340. if (posCode == "CustomerService" || posCode == "Director")
  2341. {
  2342. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2343. }
  2344. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2345. {
  2346. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2347. }
  2348. else
  2349. {
  2350. string teamIds = CurrentUser.User.TeamIds;
  2351. if (teamIds == "")
  2352. {
  2353. teamIds = "0";
  2354. }
  2355. 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);
  2356. }
  2357. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2358. }
  2359. if (dt.Rows.Count <= 0)
  2360. {
  2361. string key = "aftersale_order_" + userId;
  2362. if (RedisHelper.HasKey(key))
  2363. {
  2364. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2365. dt.Columns.Add("ctid", typeof(string));
  2366. dt.Columns.Add("IsReadTag", typeof(int));
  2367. foreach (var i in list)
  2368. {
  2369. DataRow data = dt.NewRow();
  2370. data["ctid"] = i;
  2371. data["IsReadTag"] = 4;
  2372. dt.Rows.Add(data);
  2373. }
  2374. RedisHelper.StringDelete(key);
  2375. }
  2376. }
  2377. if (dt.Rows.Count <= 0)
  2378. {
  2379. sql = new StringBuilder();
  2380. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and IsFlow = 0 and IsSup = 0 ", userId);
  2381. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2382. }
  2383. if (posCode == "Supplier")
  2384. {
  2385. string ids = CurrentUser.User.pemVend;
  2386. if (ids != null && ids.Length > 0)
  2387. {
  2388. string[] ids_list = ids.Split(',');
  2389. foreach (var item in ids_list)
  2390. {
  2391. string key = "return_order_" + item;
  2392. if (RedisHelper.HasKey(key))
  2393. {
  2394. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2395. dt.Columns.Add("ctid", typeof(string));
  2396. dt.Columns.Add("IsReadTag", typeof(int));
  2397. foreach (var i in list)
  2398. {
  2399. DataRow data = dt.NewRow();
  2400. data["ctid"] = i;
  2401. data["IsReadTag"] = 1;
  2402. dt.Rows.Add(data);
  2403. }
  2404. RedisHelper.StringDelete(key);
  2405. }
  2406. }
  2407. }
  2408. if (dt.Rows.Count <= 0)
  2409. {
  2410. sql = new StringBuilder();
  2411. 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);
  2412. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2413. }
  2414. }
  2415. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2416. }
  2417. public void reset_erp_tiporder()
  2418. {
  2419. string ids = GetPostString("ids");
  2420. string[] ctidList = ids.Split(',');
  2421. foreach (string ctid in ctidList)
  2422. {
  2423. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2424. if (enty != null)
  2425. {
  2426. enty.IsReadTag = 0;
  2427. enty.Update();
  2428. }
  2429. }
  2430. returnSuccessMsg("成功!");
  2431. return;
  2432. }
  2433. public void get_erp_designlist()
  2434. {
  2435. DataStruct dStruct = GetPostStruct();
  2436. List<string> lw = new List<string>();
  2437. string tid = GetPostString("ctid");
  2438. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2439. string shopname = GetPostString("shopname");
  2440. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2441. string buyernick = GetPostString("buyer_nick");
  2442. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2443. string customer = GetPostString("customer");
  2444. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2445. string design = GetPostString("design");
  2446. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2447. string orderState = GetPostString("orderState");
  2448. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2449. lw.Add(string.Format("OrderState<6"));
  2450. string address = GetPostString("address");
  2451. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2452. string sellermemo = GetPostString("seller_memo");
  2453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2454. string date1 = GetPostString("date1");
  2455. string date2 = GetPostString("date2");
  2456. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2457. if (dw.Length > 0) lw.Add(dw);
  2458. string apdate1 = GetPostString("apdate1");
  2459. string apdate2 = GetPostString("apdate2");
  2460. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2461. if (dwap.Length > 0) lw.Add(dwap);
  2462. string price1 = GetPostString("price1");
  2463. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2464. string price2 = GetPostString("price2");
  2465. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2466. string designTime = GetPostString("designtime");
  2467. if (designTime.Length > 0)
  2468. {
  2469. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2470. }
  2471. string usershop = CurrentUser.User.pemShop;
  2472. if (usershop.Length > 0)
  2473. {
  2474. lw.Add(string.Format("shopId in ({0})", usershop));
  2475. }
  2476. int myOrgid = CurrentUser.UserPost.OrgID;
  2477. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2478. if (myOrgCode.IndexOf("Designer") != -1)
  2479. {
  2480. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2481. {
  2482. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2483. }
  2484. else
  2485. {
  2486. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2487. }
  2488. }
  2489. else
  2490. {
  2491. string orgId = GetPostString("designerhd");
  2492. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2493. }
  2494. if (tid.Length > 0 || buyernick.Length > 0)
  2495. {
  2496. lw.Add(string.Format("OrderState >= 3"));
  2497. }
  2498. else
  2499. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2500. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2501. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2503. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2504. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2505. if (dt != null && dt.Rows.Count > 0)
  2506. {
  2507. foreach (DataRow dr in dt.Rows)
  2508. {
  2509. try
  2510. {
  2511. // 对象操作
  2512. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2513. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2514. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2515. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2516. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2517. if (dStruct.PageSize != 100000)
  2518. {
  2519. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2520. dr["gongchuang"] = response.code;
  2521. }
  2522. }
  2523. catch (NullReferenceException ex)
  2524. {
  2525. }
  2526. }
  2527. }
  2528. writeGridDataTableJson(dStruct.TotalCount, dt);
  2529. }
  2530. public void get_erp_mydesignlist()
  2531. {
  2532. DataStruct dStruct = GetPostStruct();
  2533. List<string> lw = new List<string>();
  2534. string tid = GetPostString("ctid");
  2535. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2536. string shopname = GetPostString("shopname");
  2537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2538. string buyernick = GetPostString("buyer_nick");
  2539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2540. string customer = GetPostString("customer");
  2541. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2542. string orderState = GetPostString("orderState");
  2543. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2544. //lw.Add(string.Format("OrderState<6"));
  2545. string date1 = GetPostString("date1");
  2546. string date2 = GetPostString("date2");
  2547. string dw = GetDateWhere("pay_time", date1, date2);
  2548. if (dw.Length > 0) lw.Add(dw);
  2549. string apdate1 = GetPostString("apdate1");
  2550. string apdate2 = GetPostString("apdate2");
  2551. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2552. if (dwap.Length > 0) lw.Add(dwap);
  2553. string price1 = GetPostString("price1");
  2554. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2555. string price2 = GetPostString("price2");
  2556. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2557. string olddownload = GetPostString("olddown");
  2558. if (olddownload == "1")
  2559. {
  2560. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2561. }
  2562. else if (olddownload == "2")
  2563. {
  2564. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2565. }
  2566. string sellermemo = GetPostString("seller_memo");
  2567. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2568. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2569. if (CurrentUser.User.TeamIds.Length > 0)
  2570. {
  2571. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2572. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2573. else
  2574. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2575. }
  2576. else
  2577. {
  2578. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2579. }
  2580. if (tid.Length <= 0)
  2581. {
  2582. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2583. }
  2584. lw.Add(string.Format("IsReturn!=3"));
  2585. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2586. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2587. string teamids = CurrentUser.User.TeamIds.ToString();
  2588. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2589. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2590. if (dt != null && dt.Rows.Count > 0)
  2591. {
  2592. foreach (DataRow dr in dt.Rows)
  2593. {
  2594. try
  2595. {
  2596. // 对象操作
  2597. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2598. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2599. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2600. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2601. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2602. if (dStruct.PageSize != 100000)
  2603. {
  2604. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2605. dr["gongchuang"] = response.code;
  2606. }
  2607. }
  2608. catch (NullReferenceException ex)
  2609. {
  2610. }
  2611. }
  2612. }
  2613. writeGridDataTableJson(dStruct.TotalCount, dt);
  2614. }
  2615. public void set_erp_startdesign()
  2616. {
  2617. if (UrlPostParmsCheck("ctid"))
  2618. {
  2619. string eid = GetPostString("ctid");
  2620. CeErpTradeCell entity = null;
  2621. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2622. if (entity != null)
  2623. {
  2624. if (entity.OrderState != 3)
  2625. {
  2626. returnErrorMsg("请刷新,订单已经设计了");
  2627. return;
  2628. }
  2629. entity.StartDesignTime = DateTime.Now;
  2630. entity.OrderState = 4;
  2631. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2632. {
  2633. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2634. entity.SupplierId = suid;
  2635. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2636. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2637. }
  2638. //entity.MakeSupplier = suname;
  2639. entity.Update();
  2640. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2642. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2643. commonHelper.getCytPrice(entity);
  2644. returnSuccessMsg("操作成功!");
  2645. return;
  2646. }
  2647. returnErrorMsg("找不到记录");
  2648. }
  2649. }
  2650. public void ins_erp_designselfmemo()
  2651. {
  2652. if (UrlPostParmsCheck("ctid"))
  2653. {
  2654. string eid = GetPostString("ctid");
  2655. string con = GetPostString("con");
  2656. CeErpTradeCell entity = null;
  2657. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2658. if (entity != null)
  2659. {
  2660. entity.DesignSelfMemo = con;
  2661. entity.Update();
  2662. returnSuccessMsg("操作成功!");
  2663. return;
  2664. }
  2665. returnErrorMsg("找不到记录");
  2666. }
  2667. }
  2668. public void ins_erp_designprice()
  2669. {
  2670. if (UrlPostParmsCheck("ctid"))
  2671. {
  2672. string eid = GetPostString("ctid");
  2673. int uid = CurrentUser.UserID;
  2674. string userName = CurrentUser.UserName;
  2675. CeErpTradeCell entity = null;
  2676. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2677. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2678. if (entitys == null)
  2679. {
  2680. entitys = new CeErpDesignerBill();
  2681. }
  2682. if (entity != null)
  2683. {
  2684. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2685. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2686. entity.StartDesignTime = DateTime.Now;
  2687. entity.OrderState = 4;
  2688. string suname = "";
  2689. if (entity.SupplierId == 0)
  2690. {
  2691. int sid = commonHelper.autoDistributeToSupplier(entity);
  2692. entity.SupplierId = sid;
  2693. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2694. }
  2695. entity.Update();
  2696. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2697. if (ceErpUserPost != null)
  2698. {
  2699. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2700. if (ceErpPost != null)
  2701. {
  2702. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2703. {
  2704. entitys.tid = entity.ctid;
  2705. entitys.oid = entity.tid;
  2706. entitys.uid = uid;
  2707. entitys.userName = userName;
  2708. entitys.designerType = 1;
  2709. entitys.designerTypeText = "内部设计师";
  2710. entitys.price = Convert.ToDouble(GetPostString("price"));
  2711. entitys.designNum = GetPostInt("designNum");
  2712. entitys.modifyNum = GetPostInt("modifyNum");
  2713. entitys.designSize = GetPostString("designSize");
  2714. entitys.modifySize = GetPostString("modifySize");
  2715. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2716. {
  2717. entitys.create_time = DateTime.Now;
  2718. entitys.create_u_id = uid;
  2719. entitys.create_u_name = userName;
  2720. entitys.Save();
  2721. }
  2722. else
  2723. {
  2724. entitys.update_time = DateTime.Now;
  2725. entitys.update_u_id = uid;
  2726. entitys.update_u_name = userName;
  2727. entitys.Update();
  2728. }
  2729. }
  2730. }
  2731. }
  2732. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2733. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2734. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2735. if (suname != "")
  2736. {
  2737. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2738. }
  2739. commonHelper.getCytPrice(entity);
  2740. returnSuccessMsg("操作成功!");
  2741. return;
  2742. }
  2743. returnErrorMsg("找不到记录");
  2744. }
  2745. }
  2746. public void upload_erp_filecomplete()
  2747. {
  2748. if (UrlPostParmsCheck("ctid"))
  2749. {
  2750. string eid = GetPostString("ctid");
  2751. CeErpTradeCell entity = null;
  2752. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2753. if (entity != null)
  2754. {
  2755. entity.OrderState = 5; //设计完成
  2756. entity.Update();
  2757. returnSuccessMsg(eid + "上传成功,设计完成!");
  2758. return;
  2759. }
  2760. returnErrorMsg("找不到订单记录");
  2761. }
  2762. }
  2763. public void get_erp_designovertimelist()
  2764. {
  2765. DataStruct dStruct = GetPostStruct();
  2766. List<string> lw = new List<string>();
  2767. string tid = GetPostString("ctid");
  2768. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2769. string shopname = GetPostString("shopname");
  2770. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2771. string buyernick = GetPostString("buyer_nick");
  2772. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2773. string ResponsibleMan = GetPostString("responsible");
  2774. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2775. string date1 = GetPostString("date1");
  2776. string date2 = GetPostString("date2");
  2777. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2778. if (dw.Length > 0) lw.Add(dw);
  2779. string price1 = GetPostString("price1");
  2780. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2781. string price2 = GetPostString("price2");
  2782. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2783. string orderState = GetPostString("orderState");
  2784. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2785. string sellermemo = GetPostString("seller_memo");
  2786. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2787. lw.Add(string.Format("UnusualTag=3"));
  2788. lw.Add(string.Format("IsRefund<={0}", 1));
  2789. dStruct.Order = "WaitDesignTime desc";
  2790. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2791. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2792. writeGridDataTableJson(dStruct.TotalCount, dt);
  2793. }
  2794. //设计管理 获取抢单大厅列表
  2795. public void get_erp_grabinglist()
  2796. {
  2797. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2798. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2799. bool oldOrder = false;
  2800. if (org != null)
  2801. {
  2802. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2803. }
  2804. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2805. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2807. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2808. //先处理订单数据
  2809. if (dt.Rows.Count > 0)
  2810. {
  2811. Dictionary<string, int> design = null;
  2812. int count = 0;
  2813. foreach (DataRow row in dt.Rows)
  2814. {
  2815. if (map.ContainsKey(row["ShopId"].ToString()))
  2816. {
  2817. map.TryGetValue(row["ShopId"].ToString(), out design);
  2818. }
  2819. else
  2820. {
  2821. design = new Dictionary<string, int>();
  2822. }
  2823. if (design.ContainsKey(row["ProductId"].ToString()))
  2824. {
  2825. design.TryGetValue(row["ProductId"].ToString(), out count);
  2826. }
  2827. count++;
  2828. design[row["ProductId"].ToString()] = count;
  2829. map[row["ShopId"].ToString()] = design;
  2830. }
  2831. }
  2832. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2833. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2834. //把店铺排序和技能排序分类
  2835. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2836. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2837. if (design_dt.Rows.Count > 0)
  2838. {
  2839. Dictionary<string, string> design = null;
  2840. List<string> shopIds = null;
  2841. foreach (DataRow row in design_dt.Rows)
  2842. {
  2843. if ("0".Equals(row["designId"].ToString()))
  2844. {
  2845. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2846. {
  2847. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2848. }
  2849. else
  2850. {
  2851. shopIds = new List<string>();
  2852. }
  2853. shopIds.Add(row["shopId"].ToString());
  2854. shop_orders[row["orders"].ToString()] = shopIds;
  2855. }
  2856. else
  2857. {
  2858. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2859. {
  2860. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2861. }
  2862. else
  2863. {
  2864. design = new Dictionary<string, string>();
  2865. }
  2866. design[row["orders"].ToString()] = row["designId"].ToString();
  2867. design_orders[row["shopId"].ToString()] = design;
  2868. }
  2869. }
  2870. //处理成key value后根据key排序
  2871. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2872. foreach (List<string> val in shop_orders.Values)
  2873. {
  2874. if (val != null)
  2875. {
  2876. foreach (string key in val)
  2877. {
  2878. if (design_orders.ContainsKey(key.ToString()))
  2879. {
  2880. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2881. }
  2882. }
  2883. }
  2884. }
  2885. }
  2886. //校验哪个优先级有订单
  2887. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2888. foreach (string key in shop_orders.Keys)
  2889. {
  2890. List<string> ids = null;
  2891. shop_orders.TryGetValue(key, out ids);
  2892. //id为shopid
  2893. foreach (string id in ids)
  2894. {
  2895. Dictionary<string, int> list = null;
  2896. Dictionary<string, string> desing = null;
  2897. map.TryGetValue(id, out list);
  2898. design_orders.TryGetValue(id, out desing);
  2899. if (list != null && desing != null)
  2900. {
  2901. foreach (var item in desing)
  2902. {
  2903. int count = 0;
  2904. if (list.ContainsKey(item.Value))
  2905. {
  2906. list.TryGetValue(item.Value, out count);
  2907. if (count > 0)
  2908. {
  2909. designIds[id] = item.Value;
  2910. break;
  2911. }
  2912. }
  2913. }
  2914. }
  2915. }
  2916. if (designIds.Count > 0)
  2917. {
  2918. break;
  2919. }
  2920. }
  2921. DataTable table = new DataTable();
  2922. table.Columns.Add("tid", typeof(string));
  2923. table.Columns.Add("ctid", typeof(string));
  2924. table.Columns.Add("seller_nick", typeof(string));
  2925. table.Columns.Add("productName", typeof(string));
  2926. table.Columns.Add("pay_time", typeof(string));
  2927. table.Columns.Add("seller_memo", typeof(string));
  2928. if (designIds.Count > 0)
  2929. {
  2930. string shopId = "";
  2931. string productId = "";
  2932. foreach (var designInfo in designIds)
  2933. {
  2934. shopId = designInfo.Key;
  2935. productId = designInfo.Value;
  2936. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2937. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2938. if (dt.Rows.Count > 0)
  2939. {
  2940. foreach (DataRow row in dt.Rows)
  2941. {
  2942. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2943. {
  2944. DataRow data = table.NewRow();
  2945. data["ctid"] = row["ctid"].ToString();
  2946. data["tid"] = row["tid"].ToString();
  2947. data["seller_nick"] = ceErpShop.ShopName;
  2948. data["pay_time"] = row["pay_time"].ToString();
  2949. data["seller_memo"] = row["seller_memo"].ToString();
  2950. data["productName"] = ceErpProduct.PType;
  2951. table.Rows.Add(data);
  2952. }
  2953. }
  2954. }
  2955. }
  2956. }
  2957. writeGridDataTableJson(table.Rows.Count, table);
  2958. }
  2959. private object rushLockObject = new object();
  2960. public void set_erp_grabingorder()
  2961. {
  2962. if (UrlPostParmsCheck("ctid"))
  2963. {
  2964. int total = CurrentUser.User.Person.Total;
  2965. int userId = CurrentUser.User.ID;
  2966. int noFinish = CurrentUser.User.Person.NoFinish;
  2967. int finalization = CurrentUser.User.Person.Finalization;
  2968. string eids = GetPostString("ctid");
  2969. string key = "RushKey_" + userId;
  2970. int count = 0;
  2971. if (erpRedis.RedisHelper.KeyExists(key))
  2972. {
  2973. string redisCount = erpRedis.RedisHelper.StringGet(key);
  2974. if (redisCount != null)
  2975. {
  2976. count = Convert.ToInt32(redisCount);
  2977. }
  2978. }
  2979. if (count >= total)
  2980. {
  2981. returnErrorMsg("半小时内已经抢" + total + "单");
  2982. return;
  2983. }
  2984. string[] ctidlist = eids.Split(',');
  2985. if (count + ctidlist.Length > total)
  2986. {
  2987. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  2988. return;
  2989. }
  2990. int itag = 0;
  2991. lock (rushLockObject)
  2992. {
  2993. if (ctidlist.Length > 0)
  2994. {
  2995. string[] dtList = new string[ctidlist.Length];
  2996. for (int i = 0; i < ctidlist.Length; i++)
  2997. {
  2998. dtList[i] = "'" + ctidlist[i] + "'";
  2999. }
  3000. 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"));
  3001. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3002. if (dt_user.Rows.Count > 0)
  3003. {
  3004. int doing = 0;//未定稿
  3005. int finish = 0;//已完成
  3006. foreach (DataRow dr in dt_user.Rows)
  3007. {
  3008. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3009. {
  3010. doing++;
  3011. }
  3012. else
  3013. {
  3014. finish++;
  3015. }
  3016. }
  3017. if (doing >= noFinish)
  3018. {
  3019. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3020. return;
  3021. }
  3022. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3023. {
  3024. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3025. return;
  3026. }
  3027. }
  3028. //校验选择单子状态
  3029. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3030. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3031. if (dt.Rows.Count > 0)
  3032. {
  3033. List<string> list = new List<string>();
  3034. foreach (DataRow dr in dt.Rows)
  3035. {
  3036. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3037. {
  3038. list.Add(dr["ctid"].ToString());
  3039. }
  3040. }
  3041. if (list.Count > 0)
  3042. {
  3043. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3044. return;
  3045. }
  3046. }
  3047. foreach (string ctid in ctidlist)
  3048. {
  3049. CeErpTradeCell entity = null;
  3050. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3051. if (entity != null)
  3052. {
  3053. entity.OrderState = 3;
  3054. entity.DesignUserId = CurrentUser.UserID;
  3055. entity.WaitDesignTime = DateTime.Now;
  3056. entity.StartDesignTime = DateTime.Now;
  3057. entity.Update();
  3058. commonHelper.UpdateRelationOrder(entity.ctid);
  3059. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3061. itag++;
  3062. }
  3063. }
  3064. }
  3065. }
  3066. count += ctidlist.Length;
  3067. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3068. if (itag == 0)
  3069. returnErrorMsg("没有找到相关订单");
  3070. else
  3071. returnSuccessMsg("抢单成功!");
  3072. return;
  3073. }
  3074. }
  3075. public void get_erp_waitorderlist()
  3076. {
  3077. DataStruct dStruct = GetPostStruct();
  3078. List<string> lw = new List<string>();
  3079. string tid = GetPostString("ctid");
  3080. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3081. string shopname = GetPostString("shopname");
  3082. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3083. string buyernick = GetPostString("buyer_nick");
  3084. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3085. string customer = GetPostString("customer");
  3086. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3087. string design = GetPostString("design");
  3088. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3089. string orderState = GetPostString("orderState");
  3090. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3091. string supplier = GetPostString("supplier");
  3092. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3093. string sellermemo = GetPostString("seller_memo");
  3094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3095. string otherMemo = GetPostString("otherMemo");
  3096. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3097. string address = GetPostString("address");
  3098. 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));
  3099. string date1 = GetPostString("date1");
  3100. string date2 = GetPostString("date2");
  3101. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3102. if (dw.Length > 0) lw.Add(dw);
  3103. string price1 = GetPostString("price1");
  3104. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3105. string price2 = GetPostString("price2");
  3106. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3107. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3108. lw.Add(string.Format("IsSample != 2 "));
  3109. lw.Add(string.Format("OrderState = 5 "));
  3110. lw.Add(string.Format("IsRefund<={0}", 1));
  3111. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3112. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3113. string pagesize = GetPostString("pagesize");
  3114. if (pagesize != null)
  3115. {
  3116. dStruct.PageSize = 200;
  3117. }
  3118. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3119. foreach (DataRow dr in dt.Rows)
  3120. {
  3121. 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();
  3122. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3123. {
  3124. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3125. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3126. entity.SupplierId = suid;
  3127. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3128. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3129. entity.Update();
  3130. }
  3131. }
  3132. writeGridDataTableJson(dStruct.TotalCount, dt);
  3133. }
  3134. public void get_erp_supplierwaitorderlist()
  3135. {
  3136. DataStruct dStruct = GetPostStruct();
  3137. List<string> lw = new List<string>();
  3138. string tid = GetPostString("ctid");
  3139. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3140. string shopname = GetPostString("shopname");
  3141. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3142. string sellermemo = GetPostString("seller_memo");
  3143. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3144. string date1 = GetPostString("date1");
  3145. string date2 = GetPostString("date2");
  3146. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3147. if (dw.Length > 0) lw.Add(dw);
  3148. lw.Add(string.Format("OrderState = 5 "));
  3149. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3150. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3151. {
  3152. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3153. }
  3154. string supplier = GetPostString("supplier");
  3155. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3156. {
  3157. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3158. }
  3159. lw.Add(string.Format("IsRefund<={0}", 1));
  3160. dStruct.Order = "FinishDesignTime desc";
  3161. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3162. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3163. if (dt != null)
  3164. {
  3165. foreach (DataRow dr in dt.Rows)
  3166. {
  3167. 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();
  3168. }
  3169. }
  3170. writeGridDataTableJson(dStruct.TotalCount, dt);
  3171. }
  3172. public void upd_erp_verifytosupplier()
  3173. {
  3174. if (UrlPostParmsCheck("ctid"))
  3175. {
  3176. string eids = GetPostString("ctid");
  3177. CeErpTradeCell entity = null;
  3178. string[] eidsList = eids.Split(',');
  3179. if (eidsList.Length <= 0)
  3180. {
  3181. returnErrorMsg("订单号不能空");
  3182. return;
  3183. }
  3184. List<string> tLst = new List<string>();
  3185. foreach (string ctidstr in eidsList)
  3186. {
  3187. tLst.Add("'" + ctidstr + "'");
  3188. CeErpDataSendOrderInfo.createObject(ctidstr);
  3189. }
  3190. string needtids = string.Join(",", tLst.ToArray());
  3191. StringBuilder sql = new StringBuilder();
  3192. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3193. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3194. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3195. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3196. returnSuccessMsg("操作成功!");
  3197. return;
  3198. /**foreach (string ctidstr in eidsList)
  3199. {
  3200. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3201. if (entity != null)
  3202. {
  3203. if (entity.SupplierId == 0)
  3204. {
  3205. continue;
  3206. }
  3207. entity.IsVerifyToSupplier = true;
  3208. if (entity.IsReturn == 1) //1是供应商打回
  3209. {
  3210. entity.IsReturn = 0;
  3211. }
  3212. entity.FinishPlaceTime = DateTime.Now;
  3213. entity.PlaceUserId = CurrentUser.UserID;
  3214. entity.Update();
  3215. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3216. }
  3217. }
  3218. returnSuccessMsg("操作成功!");
  3219. return;**/
  3220. }
  3221. }
  3222. public void upd_erp_supplierback()
  3223. {
  3224. if (UrlPostParmsCheck("ctid"))
  3225. {
  3226. string eid = GetPostString("ctid");
  3227. string reason = GetPostString("returnreason");
  3228. CeErpTradeCell entity = null;
  3229. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3230. if (entity != null)
  3231. {
  3232. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3233. {
  3234. string key = "return_order_" + entity.SupplierId;
  3235. List<string> list = new List<string>();
  3236. if (RedisHelper.HasKey(key))
  3237. {
  3238. object data = RedisHelper.StringGet(key);
  3239. list = Convert.ToString(data).Split(',').ToList();
  3240. }
  3241. list.Add(eid);
  3242. RedisHelper.StringSet(key, string.Join(",", list));
  3243. }
  3244. entity.IsVerifyToSupplier = false;
  3245. entity.IsReturn = 1;
  3246. entity.ReturnTime = DateTime.Now;
  3247. entity.ReturnReason = reason;
  3248. if (entity.OrderState == 6)
  3249. {
  3250. entity.OrderState = 5;
  3251. }
  3252. entity.Update();
  3253. CeErpSukuraData.createInfo(entity.ctid, 5);
  3254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3255. returnSuccessMsg("操作成功!");
  3256. return;
  3257. }
  3258. returnErrorMsg("找不到订单记录");
  3259. }
  3260. }
  3261. public void upd_erp_toaftersaleorder()
  3262. {
  3263. if (UrlPostParmsCheck("ctid"))
  3264. {
  3265. string eid = GetPostString("ctid");
  3266. string reason = GetPostString("returnreason");
  3267. CeErpTradeCell entity = null;
  3268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3269. if (entity != null)
  3270. {
  3271. if (entity.isAfterSaleOrder != 1)
  3272. {
  3273. returnErrorMsg("带S的售后单才能打回给售后");
  3274. return;
  3275. }
  3276. if (entity.OrderState >= 5)
  3277. {
  3278. returnErrorMsg("已经设计完成了不能打回给售后");
  3279. return;
  3280. }
  3281. entity.OrderState = 0;
  3282. entity.IsReturn = 3;
  3283. entity.ReturnTime = DateTime.Now;
  3284. entity.ReturnReason = reason;
  3285. entity.Update();
  3286. CeErpSukuraData.createInfo(entity.ctid, 5);
  3287. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3288. returnSuccessMsg("操作成功!");
  3289. return;
  3290. }
  3291. returnErrorMsg("找不到订单记录");
  3292. }
  3293. }
  3294. public void upd_erp_aftersaletodesign()
  3295. {
  3296. if (UrlPostParmsCheck("ctid"))
  3297. {
  3298. string eid = GetPostString("ctid");
  3299. CeErpTradeCell entity = null;
  3300. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3301. if (entity != null)
  3302. {
  3303. entity.OrderState = 3;
  3304. entity.IsReturn = 0;
  3305. entity.Update();
  3306. CeErpSukuraData.createInfo(entity.ctid, 5);
  3307. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3308. returnSuccessMsg("操作成功!");
  3309. return;
  3310. }
  3311. returnErrorMsg("找不到订单记录");
  3312. }
  3313. }
  3314. public void assign_erp_supplier()
  3315. {
  3316. if (UrlPostParmsCheck("ctid"))
  3317. {
  3318. string eids = GetPostString("ctid");
  3319. int sid = GetPostInt("SupplierName");
  3320. string fromTag = GetPostString("tag");
  3321. string[] eidList = eids.Split(',');
  3322. if (eidList.Length <= 0)
  3323. {
  3324. returnErrorMsg("指派不能为空");
  3325. return;
  3326. }
  3327. string errMsg = "";
  3328. string suname = commonHelper.getSupplierNameById(sid);
  3329. foreach (string ctid in eidList)
  3330. {
  3331. CeErpTradeCell entity = null;
  3332. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3333. if (entity != null)
  3334. {
  3335. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3336. {
  3337. errMsg += (ctid + "指派失败!!!");
  3338. continue;
  3339. }
  3340. entity.SupplierId = sid;
  3341. entity.Update();
  3342. commonHelper.UpdateRelationOrder(entity.ctid);
  3343. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3344. if (entity.OrderState >= 6)
  3345. {
  3346. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3347. //{
  3348. // string msl = entity.MakeSupplier;
  3349. // string[] mslist = msl.Split(',');
  3350. // 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);
  3351. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3352. //}
  3353. //else
  3354. //{
  3355. StringBuilder sql = new StringBuilder();
  3356. 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);
  3357. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3358. //}
  3359. }
  3360. }
  3361. else
  3362. {
  3363. continue;
  3364. }
  3365. }
  3366. if (errMsg.Length > 0)
  3367. {
  3368. returnErrorMsg(errMsg);
  3369. return;
  3370. }
  3371. returnSuccessMsg("操作成功!");
  3372. return;
  3373. }
  3374. }
  3375. public void assign_erp_makesupplier()
  3376. {
  3377. if (UrlPostParmsCheck("ctid"))
  3378. {
  3379. string eids = GetPostString("ctid");
  3380. string sname = GetPostString("SupplierName");
  3381. string[] eidList = eids.Split(',');
  3382. if (eidList.Length <= 0)
  3383. {
  3384. returnErrorMsg("指派不能为空");
  3385. return;
  3386. }
  3387. List<string> tLst = new List<string>();
  3388. foreach (string ctid in eidList)
  3389. {
  3390. CeErpTradeCell entity = null;
  3391. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3392. if (entity != null)
  3393. {
  3394. entity.MakeSupplier = sname;
  3395. entity.Update();
  3396. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3397. tLst.Add("'" + ctid + "'");
  3398. }
  3399. else
  3400. {
  3401. continue;
  3402. }
  3403. }
  3404. string ctids = string.Join(",", tLst.ToArray());
  3405. StringBuilder sql2 = new StringBuilder();
  3406. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3407. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3408. returnSuccessMsg("操作成功!");
  3409. return;
  3410. }
  3411. }
  3412. public void ins_erp_returnreason()
  3413. {
  3414. if (UrlPostParmsCheck("ctid"))
  3415. {
  3416. string eid = GetPostString("ctid");
  3417. CeErpTradeCell entity = null;
  3418. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3419. string userpost = CurrentUser.UserPost.Post.Code;
  3420. if (entity != null)
  3421. {
  3422. bool isPlace = false;
  3423. if (entity.OrderState > 6)
  3424. {
  3425. returnErrorMsg("已发货无法打回!");
  3426. return;
  3427. }
  3428. if (entity.OrderState == 6)
  3429. {
  3430. isPlace = true;
  3431. }
  3432. bool isNeedUpdateCell2 = false;
  3433. if (entity.OrderState >= 6)
  3434. {
  3435. isNeedUpdateCell2 = true;
  3436. }
  3437. int returnTag = 2;
  3438. if (userpost == "Supplier")
  3439. {
  3440. returnTag = 1;
  3441. }
  3442. if (entity.IsXianHuo == 0)
  3443. {
  3444. if (returnTag == 2)
  3445. {
  3446. int toType = GetPostInt("totype");
  3447. if (toType == 1)
  3448. {
  3449. entity.OrderState = 0;
  3450. entity.ReturnUserType = 1;
  3451. string clearman = GetPostString("clearman");
  3452. if (!string.IsNullOrEmpty(clearman))
  3453. {
  3454. entity.DesignUserId = 0;
  3455. }
  3456. }
  3457. else
  3458. {
  3459. entity.OrderState = 3;
  3460. entity.ReturnUserType = 2;
  3461. }
  3462. entity.IsReadTag = 1;
  3463. }
  3464. else if (returnTag == 1)
  3465. {
  3466. entity.OrderState = 5;
  3467. }
  3468. entity.IsVerifyToSupplier = false;
  3469. }
  3470. if (entity.IsXianHuo == 1)
  3471. {
  3472. entity.OrderState = 5;
  3473. }
  3474. entity.UnusualTag = 0;
  3475. entity.UnusualTime = null;
  3476. entity.UnusualCon = "";
  3477. entity.IsReturn = returnTag;
  3478. entity.ReturnTime = DateTime.Now;
  3479. entity.ReturnReason = GetPostString("returnreason");
  3480. entity.Update();
  3481. if (entity.OrderState == 3)
  3482. {
  3483. ApiVo apiVo = new ApiVo();
  3484. apiVo.orderNumber = entity.ctid;
  3485. apiVo.actionName = "rebutDesign";
  3486. apiVo.orderRemarks = entity.ReturnReason;
  3487. designHelper.API_WorkCore(apiVo);//rebutDesign
  3488. }
  3489. CeErpSukuraData.createInfo(entity.ctid, 5);
  3490. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3491. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3492. if (isPlace)
  3493. {
  3494. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3495. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3496. if (dth != null && dth.Rows.Count > 0)
  3497. {
  3498. dataSendOrderBean dataSendOrderBean = null;
  3499. foreach (DataRow item in dth.Rows)
  3500. {
  3501. try
  3502. {
  3503. dataSendOrderBean = new dataSendOrderBean();
  3504. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3505. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3506. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3507. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3508. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3509. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3510. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3511. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3512. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3513. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3514. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3515. dataSendOrderBean.Radio1723534706288 = "打回";
  3516. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3517. if (result != null)
  3518. {
  3519. if ("0".Equals(result.errcode))
  3520. {
  3521. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3522. }
  3523. else
  3524. {
  3525. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3526. }
  3527. }
  3528. }
  3529. catch (Exception ex)
  3530. {
  3531. }
  3532. }
  3533. }
  3534. }
  3535. if (isNeedUpdateCell2)
  3536. {
  3537. if (entity.MakeSupplier.IndexOf(",") != -1)
  3538. {
  3539. StringBuilder sql2 = new StringBuilder();
  3540. 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);
  3541. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3542. }
  3543. else
  3544. {
  3545. StringBuilder sql2 = new StringBuilder();
  3546. 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);
  3547. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3548. }
  3549. }
  3550. returnSuccessMsg("操作成功!");
  3551. return;
  3552. }
  3553. returnErrorMsg("找不到订单记录");
  3554. }
  3555. }
  3556. public void cyt_erp_returnreason()
  3557. {
  3558. if (UrlPostParmsCheck("ctid"))
  3559. {
  3560. string eid = GetPostString("ctid");
  3561. CeErpTradeCell entity = null;
  3562. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3563. string userpost = CurrentUser.UserPost.Post.Code;
  3564. if (entity != null)
  3565. {
  3566. if (entity.OrderState > 6)
  3567. {
  3568. returnErrorMsg("已发货无法打回!");
  3569. return;
  3570. }
  3571. JObject jsonObject = new JObject
  3572. {
  3573. { "Userid", "77886" },
  3574. { "Pwd", "lt666888" },
  3575. { "LTOrderId",eid }
  3576. };
  3577. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3578. JObject jsonObjects = JObject.Parse(response);
  3579. string msg = (string)jsonObjects["msg"];
  3580. if (msg != "取消成功")
  3581. {
  3582. returnErrorMsg(msg);
  3583. return;
  3584. }
  3585. bool isNeedUpdateCell2 = false;
  3586. if (entity.OrderState >= 6)
  3587. {
  3588. isNeedUpdateCell2 = true;
  3589. }
  3590. int returnTag = 2;
  3591. if (userpost == "Supplier")
  3592. {
  3593. returnTag = 1;
  3594. }
  3595. if (entity.IsXianHuo == 0)
  3596. {
  3597. if (returnTag == 2)
  3598. {
  3599. int toType = GetPostInt("totype");
  3600. if (toType == 1)
  3601. {
  3602. entity.OrderState = 0;
  3603. entity.ReturnUserType = 1;
  3604. }
  3605. else
  3606. {
  3607. entity.OrderState = 4;
  3608. entity.ReturnUserType = 2;
  3609. }
  3610. entity.IsReadTag = 1;
  3611. }
  3612. else if (returnTag == 1)
  3613. {
  3614. entity.OrderState = 5;
  3615. }
  3616. entity.IsVerifyToSupplier = false;
  3617. }
  3618. entity.UnusualTag = 0;
  3619. entity.UnusualTime = null;
  3620. entity.UnusualCon = "";
  3621. entity.IsReturn = returnTag;
  3622. entity.ReturnTime = DateTime.Now;
  3623. entity.ReturnReason = GetPostString("returnreason");
  3624. entity.Update();
  3625. if (entity.OrderState == 4)
  3626. {
  3627. ApiVo apiVo = new ApiVo();
  3628. apiVo.orderNumber = entity.ctid;
  3629. apiVo.actionName = "rebutDesign";
  3630. apiVo.orderRemarks = entity.ReturnReason;
  3631. designHelper.API_WorkCore(apiVo);//rebutDesign
  3632. }
  3633. CeErpSukuraData.createInfo(entity.ctid, 5);
  3634. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3635. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3636. if (isNeedUpdateCell2)
  3637. {
  3638. if (entity.MakeSupplier.IndexOf(",") != -1)
  3639. {
  3640. StringBuilder sql2 = new StringBuilder();
  3641. 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);
  3642. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3643. }
  3644. else
  3645. {
  3646. StringBuilder sql2 = new StringBuilder();
  3647. 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);
  3648. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3649. }
  3650. }
  3651. returnSuccessMsg("操作成功!");
  3652. return;
  3653. }
  3654. returnErrorMsg("找不到订单记录");
  3655. }
  3656. }
  3657. public void upd_erp_xianhuoreturntag()
  3658. {
  3659. if (UrlPostParmsCheck("ctid"))
  3660. {
  3661. string eids = GetPostString("ctid");
  3662. string[] ctids = eids.Split(',');
  3663. foreach (string ctid in ctids)
  3664. {
  3665. CeErpTradeCell entity = null;
  3666. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3667. if (entity != null)
  3668. {
  3669. entity.IsReturn = 0;
  3670. entity.Update();
  3671. CeErpSukuraData.createInfo(entity.ctid, 5);
  3672. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3673. }
  3674. }
  3675. returnSuccessMsg("操作成功!");
  3676. return;
  3677. }
  3678. }
  3679. public void get_erp_waitdeliverylist()
  3680. {
  3681. DataStruct dStruct = GetPostStruct();
  3682. List<string> lw = new List<string>();
  3683. string tid = GetPostString("ctid");
  3684. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3685. string shopname = GetPostString("shopname");
  3686. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3687. string buyernick = GetPostString("buyer_nick");
  3688. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3689. //if (tid.Length == 0 && buyernick.Length == 0)
  3690. //{
  3691. // lw.Add(string.Format("IsRefund<={0}", 1));
  3692. //}
  3693. string customer = GetPostString("customer");
  3694. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3695. string design = GetPostString("design");
  3696. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3697. string orderState = GetPostString("orderState");
  3698. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3699. string address = GetPostString("address");
  3700. 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));
  3701. string sellermemo = GetPostString("seller_memo");
  3702. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3703. string supplier = GetPostString("supplier");
  3704. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3705. string OrderArea = GetPostString("order_area");
  3706. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3707. string placedate1 = GetPostString("placedate1");
  3708. string placedate2 = GetPostString("placedate2");
  3709. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3710. if (fdw.Length > 0) lw.Add(fdw);
  3711. string price1 = GetPostString("price1");
  3712. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3713. string price2 = GetPostString("price2");
  3714. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3715. string unusualCon = GetPostString("unusualcon");
  3716. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3717. string otherMemo = GetPostString("otherMemo");
  3718. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3719. string posTag = CurrentUser.UserPost.Post.Code;
  3720. if (posTag == "Supplier")
  3721. {
  3722. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3723. }
  3724. lw.Add(string.Format("OrderState = 6 "));
  3725. lw.Add(string.Format("type != 'PDD' "));
  3726. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3727. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3728. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3729. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3730. writeGridDataTableJson(dStruct.TotalCount, dt);
  3731. }
  3732. public void get_erp_pddderiving()
  3733. {
  3734. DataStruct dStruct = GetPostStruct();
  3735. List<string> lw = new List<string>();
  3736. string tid = GetPostString("ctid");
  3737. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3738. string shopname = GetPostString("shopname");
  3739. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3740. string buyernick = GetPostString("buyer_nick");
  3741. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3742. //if (tid.Length == 0 && buyernick.Length == 0)
  3743. //{
  3744. // lw.Add(string.Format("IsRefund<={0}", 1));
  3745. //}
  3746. string customer = GetPostString("customer");
  3747. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3748. string design = GetPostString("design");
  3749. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3750. string orderState = GetPostString("orderState");
  3751. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3752. string address = GetPostString("address");
  3753. 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));
  3754. string sellermemo = GetPostString("seller_memo");
  3755. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3756. string supplier = GetPostString("supplier");
  3757. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3758. string OrderArea = GetPostString("order_area");
  3759. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3760. string placedate1 = GetPostString("placedate1");
  3761. string placedate2 = GetPostString("placedate2");
  3762. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3763. if (fdw.Length > 0) lw.Add(fdw);
  3764. string price1 = GetPostString("price1");
  3765. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3766. string price2 = GetPostString("price2");
  3767. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3768. string unusualCon = GetPostString("unusualcon");
  3769. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3770. string posTag = CurrentUser.UserPost.Post.Code;
  3771. if (posTag == "Supplier")
  3772. {
  3773. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3774. }
  3775. lw.Add(string.Format("OrderState = 6 "));
  3776. lw.Add(string.Format("type = 'PDD' "));
  3777. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3778. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3779. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3780. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3781. writeGridDataTableJson(dStruct.TotalCount, dt);
  3782. }
  3783. public void get_erp_jdderiving()
  3784. {
  3785. DataStruct dStruct = GetPostStruct();
  3786. List<string> lw = new List<string>();
  3787. string tid = GetPostString("ctid");
  3788. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3789. string shopname = GetPostString("shopname");
  3790. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3791. string buyernick = GetPostString("buyer_nick");
  3792. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3793. //if (tid.Length == 0 && buyernick.Length == 0)
  3794. //{
  3795. // lw.Add(string.Format("IsRefund<={0}", 1));
  3796. //}
  3797. string customer = GetPostString("customer");
  3798. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3799. string design = GetPostString("design");
  3800. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3801. string orderState = GetPostString("orderState");
  3802. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3803. string address = GetPostString("address");
  3804. 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));
  3805. string sellermemo = GetPostString("seller_memo");
  3806. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3807. string supplier = GetPostString("supplier");
  3808. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3809. string OrderArea = GetPostString("order_area");
  3810. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3811. string placedate1 = GetPostString("placedate1");
  3812. string placedate2 = GetPostString("placedate2");
  3813. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3814. if (fdw.Length > 0) lw.Add(fdw);
  3815. string price1 = GetPostString("price1");
  3816. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3817. string price2 = GetPostString("price2");
  3818. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3819. string unusualCon = GetPostString("unusualcon");
  3820. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3821. string posTag = CurrentUser.UserPost.Post.Code;
  3822. if (posTag == "Supplier")
  3823. {
  3824. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3825. }
  3826. lw.Add(string.Format("OrderState = 6 "));
  3827. lw.Add(string.Format("type = 'JD' "));
  3828. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3829. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3830. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3831. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3832. writeGridDataTableJson(dStruct.TotalCount, dt);
  3833. }
  3834. public void get_erp_demoorderlist()
  3835. {
  3836. DataStruct dStruct = GetPostStruct();
  3837. List<string> lw = new List<string>();
  3838. string tid = GetPostString("ctid");
  3839. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3840. string shopname = GetPostString("shopname");
  3841. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3842. string buyernick = GetPostString("buyer_nick");
  3843. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3844. string customer = GetPostString("customer");
  3845. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3846. string design = GetPostString("design");
  3847. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3848. string orderState = GetPostString("orderState");
  3849. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3850. string address = GetPostString("address");
  3851. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3852. string sellermemo = GetPostString("seller_memo");
  3853. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3854. string supplier = GetPostString("supplier");
  3855. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3856. string OrderArea = GetPostString("order_area");
  3857. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3858. string date1 = GetPostString("date1");
  3859. string date2 = GetPostString("date2");
  3860. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3861. if (dw.Length > 0) lw.Add(dw);
  3862. string price1 = GetPostString("price1");
  3863. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3864. string price2 = GetPostString("price2");
  3865. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3866. string posTag = CurrentUser.UserPost.Post.Code;
  3867. if (posTag == "Supplier")
  3868. {
  3869. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3870. }
  3871. //lw.Add(string.Format("OrderState = 6 "));
  3872. lw.Add(string.Format("IsSample={0}", 3));
  3873. lw.Add(string.Format("IsRefund<={0}", 1));
  3874. dStruct.Order = "pay_time desc";
  3875. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3876. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3877. writeGridDataTableJson(dStruct.TotalCount, dt);
  3878. }
  3879. public void save_erp_checkmemo()
  3880. {
  3881. if (UrlPostParmsCheck("ctid"))
  3882. {
  3883. string ctid = GetPostString("ctid");
  3884. CeErpTradeCell entity = null;
  3885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3886. if (entity != null)
  3887. {
  3888. entity.CheckMemo = GetPostString("CheckMemo");
  3889. entity.Update();
  3890. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3891. if (trade != null)
  3892. {
  3893. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3894. }
  3895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3896. returnSuccessMsg("保存成功!");
  3897. return;
  3898. }
  3899. returnErrorMsg("找不到记录");
  3900. }
  3901. }
  3902. public void get_erp_returnlist()
  3903. {
  3904. DataStruct dStruct = GetPostStruct();
  3905. List<string> lw = new List<string>();
  3906. string tid = GetPostString("ctid");
  3907. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3908. string shopname = GetPostString("shopname");
  3909. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3910. string buyernick = GetPostString("buyer_nick");
  3911. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3912. string customer = GetPostString("customer");
  3913. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3914. string design = GetPostString("design");
  3915. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3916. string orderState = GetPostString("orderState");
  3917. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3918. string address = GetPostString("address");
  3919. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3920. string sellermemo = GetPostString("seller_memo");
  3921. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3922. string supplier = GetPostString("supplier");
  3923. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3924. string date1 = GetPostString("date1");
  3925. string date2 = GetPostString("date2");
  3926. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3927. if (dw.Length > 0) lw.Add(dw);
  3928. string bdate1 = GetPostString("backdate1");
  3929. string bdate2 = GetPostString("backdate2");
  3930. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3931. if (dw_back.Length > 0) lw.Add(dw_back);
  3932. string price1 = GetPostString("price1");
  3933. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3934. string price2 = GetPostString("price2");
  3935. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3936. lw.Add(string.Format("IsReturn>0"));
  3937. lw.Add(string.Format("IsXianHuo=0"));
  3938. lw.Add(string.Format("IsReturn!=3"));
  3939. string backtype = GetPostString("backtype");
  3940. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3941. dStruct.Order = "FinishDesignTime desc";
  3942. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3943. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3944. writeGridDataTableJson(dStruct.TotalCount, dt);
  3945. }
  3946. public void get_erp_today_sumreturn()
  3947. {
  3948. DataStruct dStruct = GetPostStruct();
  3949. List<string> lw = new List<string>();
  3950. string bdate1 = GetPostString("returnTimeS");
  3951. string bdate2 = GetPostString("returnTimeE");
  3952. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3953. if (dw_back.Length > 0) lw.Add(dw_back);
  3954. lw.Add(string.Format("IsReturn=0"));
  3955. lw.Add(string.Format("IsXianHuo=0"));
  3956. string mainWhere = string.Join(" and ", lw.ToArray());
  3957. string sql = "";
  3958. if (dw_back.Length > 0)
  3959. {
  3960. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  3961. }
  3962. else
  3963. {
  3964. 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 + "'";
  3965. }
  3966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3967. decimal total = 0, today_finish = 0;
  3968. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  3969. {
  3970. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  3971. }
  3972. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  3973. {
  3974. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  3975. }
  3976. var res = new
  3977. {
  3978. data = total,
  3979. data1 = today_finish,
  3980. };
  3981. string ro_jsond = JsonConvert.SerializeObject(res);
  3982. returnSuccess(ro_jsond);
  3983. return;
  3984. }
  3985. public void get_erp_allreturnlist()
  3986. {
  3987. DataStruct dStruct = GetPostStruct();
  3988. List<string> lw = new List<string>();
  3989. string tid = GetPostString("ctid");
  3990. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3991. string shopname = GetPostString("shopname");
  3992. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3993. string buyernick = GetPostString("buyer_nick");
  3994. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3995. string customer = GetPostString("customer");
  3996. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3997. string design = GetPostString("design");
  3998. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3999. string orderState = GetPostString("orderState");
  4000. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4001. string address = GetPostString("address");
  4002. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4003. string sellermemo = GetPostString("seller_memo");
  4004. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4005. string supplier = GetPostString("supplier");
  4006. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4007. string date1 = GetPostString("date1");
  4008. string date2 = GetPostString("date2");
  4009. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4010. if (dw.Length > 0) lw.Add(dw);
  4011. string bdate1 = GetPostString("backdate1");
  4012. string bdate2 = GetPostString("backdate2");
  4013. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4014. if (dw_back.Length > 0) lw.Add(dw_back);
  4015. string price1 = GetPostString("price1");
  4016. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4017. string price2 = GetPostString("price2");
  4018. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4019. string backreason = GetPostString("backreason");
  4020. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4021. lw.Add(string.Format("IsXianHuo=0"));
  4022. lw.Add(string.Format("ReturnTime != ''"));
  4023. string backtype = GetPostString("backtype");
  4024. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4025. dStruct.Order = "FinishDesignTime desc";
  4026. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4027. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4028. writeGridDataTableJson(dStruct.TotalCount, dt);
  4029. }
  4030. public void get_erp_aftersalereturnlist()
  4031. {
  4032. DataStruct dStruct = GetPostStruct();
  4033. List<string> lw = new List<string>();
  4034. string tid = GetPostString("ctid");
  4035. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4036. string shopname = GetPostString("shopname");
  4037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4038. string buyernick = GetPostString("buyer_nick");
  4039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4040. string customer = GetPostString("customer");
  4041. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4042. string design = GetPostString("design");
  4043. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4044. string orderState = GetPostString("orderState");
  4045. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4046. string address = GetPostString("address");
  4047. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4048. string sellermemo = GetPostString("seller_memo");
  4049. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4050. string supplier = GetPostString("supplier");
  4051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4052. string date1 = GetPostString("date1");
  4053. string date2 = GetPostString("date2");
  4054. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4055. if (dw.Length > 0) lw.Add(dw);
  4056. string bdate1 = GetPostString("backdate1");
  4057. string bdate2 = GetPostString("backdate2");
  4058. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4059. if (dw_back.Length > 0) lw.Add(dw_back);
  4060. string price1 = GetPostString("price1");
  4061. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4062. string price2 = GetPostString("price2");
  4063. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4064. lw.Add(string.Format("IsReturn=3"));
  4065. string backtype = GetPostString("backtype");
  4066. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4067. string backreason = GetPostString("backreason");
  4068. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4069. dStruct.Order = "ReturnTime desc";
  4070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4071. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4072. writeGridDataTableJson(dStruct.TotalCount, dt);
  4073. }
  4074. public void get_erp_xianhuoreturnlist()
  4075. {
  4076. DataStruct dStruct = GetPostStruct();
  4077. List<string> lw = new List<string>();
  4078. string tid = GetPostString("ctid");
  4079. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4080. string shopname = GetPostString("shopname");
  4081. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4082. string buyernick = GetPostString("buyer_nick");
  4083. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4084. string customer = GetPostString("customer");
  4085. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4086. string design = GetPostString("design");
  4087. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4088. string orderState = GetPostString("orderState");
  4089. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4090. string address = GetPostString("address");
  4091. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4092. string sellermemo = GetPostString("seller_memo");
  4093. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4094. string supplier = GetPostString("supplier");
  4095. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4096. string OrderArea = GetPostString("order_area");
  4097. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4098. string date1 = GetPostString("date1");
  4099. string date2 = GetPostString("date2");
  4100. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4101. if (dw.Length > 0) lw.Add(dw);
  4102. string price1 = GetPostString("price1");
  4103. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4104. string price2 = GetPostString("price2");
  4105. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4106. string posTag = CurrentUser.UserPost.Post.Code;
  4107. if (posTag == "Supplier")
  4108. {
  4109. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4110. }
  4111. lw.Add(string.Format("OrderState=6 "));
  4112. lw.Add(string.Format("IsXianHuo=1 "));
  4113. lw.Add(string.Format("IsReturn>0 "));
  4114. lw.Add(string.Format("IsReturn!=3"));
  4115. lw.Add(string.Format("IsRefund<={0}", 1));
  4116. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4117. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4118. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4119. writeGridDataTableJson(dStruct.TotalCount, dt);
  4120. }
  4121. public void set_erp_orderdelivery()
  4122. {
  4123. if (UrlPostParmsCheck("ctid"))
  4124. {
  4125. string eid = GetPostString("ctid");
  4126. CeErpTradeCell entity = null;
  4127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4128. if (entity != null)
  4129. {
  4130. if (entity.OrderState >= 7)
  4131. {
  4132. returnErrorMsg("此单已发货,无需重复发货");
  4133. return;
  4134. }
  4135. if (entity.OrderState != 6)
  4136. {
  4137. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4138. return;
  4139. }
  4140. string shop = GetPostString("seller_nick");
  4141. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4142. string comName = GetPostString("comName");
  4143. string comCode = GetPostString("comCode");
  4144. string outSid = GetPostString("outSid");
  4145. string deliveryType = GetPostString("deliveryType");
  4146. string deliveryMemo = GetPostString("deliveryMemo");
  4147. outSid = outSid.Trim();
  4148. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4149. if (mainEn == null)
  4150. {
  4151. returnErrorMsg("找不到原始订单记录");
  4152. return;
  4153. }
  4154. bool isInitOrderDeliv = false;
  4155. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4156. {
  4157. isInitOrderDeliv = true;
  4158. }
  4159. string apires = "";
  4160. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4161. 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)
  4162. {
  4163. apires = "发货成功true";
  4164. }
  4165. else
  4166. {
  4167. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4168. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4169. }
  4170. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4171. {
  4172. entity.OrderState = 7;//发货后订单已发货
  4173. entity.OutSid = outSid;
  4174. entity.MemoOpt = 0;
  4175. entity.Update();
  4176. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4177. commonHelper.UpdateRelationOrder(entity.ctid);
  4178. //还要插入快递信息到 快递信息表
  4179. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4180. exinfo.tid = eid;
  4181. exinfo.out_sid = outSid;
  4182. exinfo.company_code = comCode;
  4183. exinfo.company_name = comName;
  4184. exinfo.delivery_memo = deliveryMemo;
  4185. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4186. exinfo.deliveryType = deliveryType;
  4187. exinfo.Create();
  4188. returnSuccessMsg("发货操作成功!");
  4189. commonHelper.UpdateRelationOrder(entity.ctid);
  4190. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4191. CeErpSukuraData.createInfo(entity.ctid, 4);
  4192. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4194. }
  4195. else
  4196. {
  4197. string errmsg = commonHelper.KeepChinese(apires);
  4198. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4199. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4200. }
  4201. return;
  4202. }
  4203. returnErrorMsg("找不到订单记录");
  4204. }
  4205. }
  4206. public void set_erp_multidelivery()
  4207. {
  4208. string eids = GetPostString("tids");
  4209. string[] eidList = eids.Split(',');
  4210. if (eidList.Length <= 0)
  4211. {
  4212. returnErrorMsg("发货不能为空");
  4213. return;
  4214. }
  4215. foreach (string ctid in eidList)
  4216. {
  4217. if (ctid.Length <= 0) continue;
  4218. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4219. if (expInfo != null)
  4220. {
  4221. StringBuilder sql = new StringBuilder();
  4222. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4223. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4224. if (dt.Rows.Count > 0)
  4225. {
  4226. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4227. {
  4228. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4229. expInfo.state = "异常";
  4230. expInfo.isMultiDelivery = 1;
  4231. expInfo.Update();
  4232. continue;
  4233. }
  4234. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4235. {
  4236. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4237. expInfo.state = "异常";
  4238. expInfo.Update();
  4239. continue;
  4240. }
  4241. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4242. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4243. bool isInitOrderDeliv = false;
  4244. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4245. {
  4246. isInitOrderDeliv = true;
  4247. expInfo.isMultiDelivery = 1;
  4248. }
  4249. if (ctid.IndexOf("N") != -1)
  4250. {
  4251. StringBuilder sqlbucha = new StringBuilder();
  4252. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4253. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4254. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4255. commonHelper.UpdateRelationOrder(ctid);
  4256. expInfo.delivery_memo = "发货成功";
  4257. expInfo.state = "发货成功";
  4258. expInfo.isMultiDelivery = 1;
  4259. expInfo.Update();
  4260. }
  4261. else
  4262. {
  4263. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4264. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4265. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4266. {
  4267. expInfo.delivery_memo = "发货成功";
  4268. expInfo.state = "发货成功";
  4269. expInfo.isMultiDelivery = 1;
  4270. expInfo.Update();
  4271. commonHelper.UpdateRelationOrder(ctid);
  4272. CeErpSukuraData.createInfo(ctid, 4);
  4273. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4274. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4275. }
  4276. else
  4277. {
  4278. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4279. expInfo.state = "异常";
  4280. expInfo.Update();
  4281. }
  4282. }
  4283. }
  4284. }
  4285. }
  4286. returnSuccessMsg("操作完成");
  4287. }
  4288. public void reset_erp_memoopt()
  4289. {
  4290. if (UrlPostParmsCheck("ctid"))
  4291. {
  4292. string eid = GetPostString("ctid");
  4293. CeErpTradeCell entity = null;
  4294. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4295. if (entity != null)
  4296. {
  4297. string stropt = "";
  4298. if (entity.MemoOpt == 1)
  4299. {
  4300. stropt = "“改稿”";
  4301. }
  4302. else if (entity.MemoOpt == 2)
  4303. {
  4304. stropt = "“定稿”";
  4305. }
  4306. else if (entity.MemoOpt == 3)
  4307. {
  4308. stropt = "“完成查货”";
  4309. CeErpSukuraData.createInfo(entity.ctid, 6);
  4310. }
  4311. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4312. entity.MemoOpt = 0;
  4313. entity.Update();
  4314. returnSuccessMsg("操作成功!");
  4315. return;
  4316. }
  4317. returnErrorMsg("找不到记录");
  4318. }
  4319. }
  4320. public void get_erp_deliveryunusual()
  4321. {
  4322. DataStruct dStruct = GetPostStruct();
  4323. List<string> lw = new List<string>();
  4324. string tid = GetPostString("ctid");
  4325. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4326. string shopname = GetPostString("shopname");
  4327. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4328. string buyernick = GetPostString("buyer_nick");
  4329. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4330. string customer = GetPostString("customer");
  4331. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4332. string design = GetPostString("design");
  4333. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4334. string sellermemo = GetPostString("seller_memo");
  4335. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4336. string supplier = GetPostString("supplier");
  4337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4338. string date1 = GetPostString("date1");
  4339. string date2 = GetPostString("date2");
  4340. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4341. if (dw.Length > 0) lw.Add(dw);
  4342. string placedate1 = GetPostString("placedate1");
  4343. string placedate2 = GetPostString("placedate2");
  4344. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4345. if (dw_place.Length > 0) lw.Add(dw_place);
  4346. string price1 = GetPostString("price1");
  4347. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4348. string price2 = GetPostString("price2");
  4349. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4350. string unusualCon = GetPostString("unusualcon");
  4351. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4352. string posTag = CurrentUser.UserPost.Post.Code;
  4353. if (posTag == "Supplier")
  4354. {
  4355. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4356. }
  4357. lw.Add(string.Format("OrderState = 6"));
  4358. lw.Add(string.Format("UnusualTag = 5"));
  4359. lw.Add(string.Format("IsRefund<={0}", 1));
  4360. dStruct.Order = "FinishPlaceTime desc";
  4361. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4362. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4363. writeGridDataTableJson(dStruct.TotalCount, dt);
  4364. }
  4365. public void get_erp_deliveryedlist()
  4366. {
  4367. DataStruct dStruct = GetPostStruct();
  4368. List<string> lw = new List<string>();
  4369. string tid = GetPostString("ctid");
  4370. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4371. string shopname = GetPostString("shopname");
  4372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4373. string buyernick = GetPostString("buyer_nick");
  4374. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4375. string customer = GetPostString("customer");
  4376. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4377. string design = GetPostString("design");
  4378. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4379. string sellermemo = GetPostString("seller_memo");
  4380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4381. string logistics = GetPostString("logistics");
  4382. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4383. string date1 = GetPostString("date1");
  4384. string date2 = GetPostString("date2");
  4385. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4386. //if (dw.Length > 0) lw.Add(dw);
  4387. string placedate1 = GetPostString("placedate1");
  4388. string placedate2 = GetPostString("placedate2");
  4389. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4390. if (fdw.Length > 0) lw.Add(fdw);
  4391. string devdate1 = GetPostString("deliverydate1");
  4392. string devdate2 = GetPostString("deliverydate2");
  4393. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4394. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4395. string price1 = GetPostString("price1");
  4396. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4397. string price2 = GetPostString("price2");
  4398. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4399. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4400. {
  4401. if (tid.Length > 0)
  4402. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4403. if (buyernick.Length > 0)
  4404. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4405. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4406. if (dw.Length > 0) lw.Add(dw);
  4407. }
  4408. else
  4409. {
  4410. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4411. }
  4412. string posTag = CurrentUser.UserPost.Post.Code;
  4413. if (posTag == "Supplier")
  4414. {
  4415. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4416. }
  4417. else
  4418. {
  4419. string supplier = GetPostString("supplier");
  4420. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4421. }
  4422. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4423. lw.Add(string.Format("IsRefund!={0}", 2));
  4424. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4425. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4426. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4427. if (dt != null)
  4428. {
  4429. foreach (DataRow dr in dt.Rows)
  4430. {
  4431. 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();
  4432. }
  4433. }
  4434. writeGridDataTableJson(dStruct.TotalCount, dt);
  4435. }
  4436. public void get_erp_pdddeliveryed()
  4437. {
  4438. DataStruct dStruct = GetPostStruct();
  4439. List<string> lw = new List<string>();
  4440. string tid = GetPostString("ctid");
  4441. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4442. string shopname = GetPostString("shopname");
  4443. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4444. string buyernick = GetPostString("buyer_nick");
  4445. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4446. string customer = GetPostString("customer");
  4447. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4448. string design = GetPostString("design");
  4449. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4450. string sellermemo = GetPostString("seller_memo");
  4451. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4452. string logistics = GetPostString("logistics");
  4453. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4454. string date1 = GetPostString("date1");
  4455. string date2 = GetPostString("date2");
  4456. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4457. //if (dw.Length > 0) lw.Add(dw);
  4458. string placedate1 = GetPostString("placedate1");
  4459. string placedate2 = GetPostString("placedate2");
  4460. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4461. if (fdw.Length > 0) lw.Add(fdw);
  4462. string devdate1 = GetPostString("deliverydate1");
  4463. string devdate2 = GetPostString("deliverydate2");
  4464. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4465. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4466. string price1 = GetPostString("price1");
  4467. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4468. string price2 = GetPostString("price2");
  4469. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4470. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4471. {
  4472. if (tid.Length > 0)
  4473. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4474. if (buyernick.Length > 0)
  4475. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4476. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4477. if (dw.Length > 0) lw.Add(dw);
  4478. }
  4479. else
  4480. {
  4481. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4482. }
  4483. string posTag = CurrentUser.UserPost.Post.Code;
  4484. if (posTag == "Supplier")
  4485. {
  4486. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4487. }
  4488. else
  4489. {
  4490. string supplier = GetPostString("supplier");
  4491. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4492. }
  4493. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4494. lw.Add(string.Format("type = 'PDD' "));
  4495. lw.Add(string.Format("IsRefund!={0}", 2));
  4496. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4497. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4498. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4499. foreach (DataRow dr in dt.Rows)
  4500. {
  4501. 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();
  4502. }
  4503. writeGridDataTableJson(dStruct.TotalCount, dt);
  4504. }
  4505. public void get_erp_jddeliveryed()
  4506. {
  4507. DataStruct dStruct = GetPostStruct();
  4508. List<string> lw = new List<string>();
  4509. string tid = GetPostString("ctid");
  4510. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4511. string shopname = GetPostString("shopname");
  4512. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4513. string buyernick = GetPostString("buyer_nick");
  4514. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4515. string customer = GetPostString("customer");
  4516. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4517. string design = GetPostString("design");
  4518. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4519. string sellermemo = GetPostString("seller_memo");
  4520. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4521. string date1 = GetPostString("date1");
  4522. string date2 = GetPostString("date2");
  4523. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4524. //if (dw.Length > 0) lw.Add(dw);
  4525. string placedate1 = GetPostString("placedate1");
  4526. string placedate2 = GetPostString("placedate2");
  4527. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4528. if (fdw.Length > 0) lw.Add(fdw);
  4529. string devdate1 = GetPostString("deliverydate1");
  4530. string devdate2 = GetPostString("deliverydate2");
  4531. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4532. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4533. string price1 = GetPostString("price1");
  4534. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4535. string price2 = GetPostString("price2");
  4536. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4537. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4538. {
  4539. if (tid.Length > 0)
  4540. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4541. if (buyernick.Length > 0)
  4542. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4543. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4544. if (dw.Length > 0) lw.Add(dw);
  4545. }
  4546. else
  4547. {
  4548. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4549. }
  4550. string posTag = CurrentUser.UserPost.Post.Code;
  4551. if (posTag == "Supplier")
  4552. {
  4553. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4554. }
  4555. else
  4556. {
  4557. string supplier = GetPostString("supplier");
  4558. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4559. }
  4560. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4561. lw.Add(string.Format("type = 'JD' "));
  4562. lw.Add(string.Format("IsRefund!={0}", 2));
  4563. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4564. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4565. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4566. foreach (DataRow dr in dt.Rows)
  4567. {
  4568. 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();
  4569. }
  4570. writeGridDataTableJson(dStruct.TotalCount, dt);
  4571. }
  4572. public void get_erp_allplacelist()
  4573. {
  4574. DataStruct dStruct = GetPostStruct();
  4575. List<string> lw = new List<string>();
  4576. string tid = GetPostString("ctid");
  4577. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4578. string shopname = GetPostString("shopname");
  4579. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4580. string buyernick = GetPostString("buyer_nick");
  4581. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4582. string customer = GetPostString("customer");
  4583. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4584. string design = GetPostString("design");
  4585. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4586. string sellermemo = GetPostString("seller_memo");
  4587. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4588. string supplier = GetPostString("supplier");
  4589. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4590. string date1 = GetPostString("date1");
  4591. string date2 = GetPostString("date2");
  4592. string pldate1 = GetPostString("placedate1");
  4593. string pldate2 = GetPostString("placedate2");
  4594. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4595. //if (dw.Length > 0) lw.Add(dw);
  4596. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4597. {
  4598. if (tid.Length > 0)
  4599. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4600. if (buyernick.Length > 0)
  4601. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4602. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4603. if (dw.Length > 0) lw.Add(dw);
  4604. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4605. if (dw_place.Length > 0) lw.Add(dw_place);
  4606. }
  4607. else
  4608. {
  4609. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4610. {
  4611. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4612. }
  4613. }
  4614. string price1 = GetPostString("price1");
  4615. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4616. string price2 = GetPostString("price2");
  4617. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4618. string posTag = CurrentUser.UserPost.Post.Code;
  4619. if (posTag == "Supplier")
  4620. {
  4621. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4622. }
  4623. lw.Add(string.Format("OrderState >= 6"));
  4624. lw.Add(string.Format("IsSample != 2 "));
  4625. lw.Add(string.Format("isDianziOrder = 0 "));
  4626. //lw.Add(string.Format("IsRefund<={0}", 1));
  4627. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4628. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4629. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4630. foreach (DataRow dr in dt.Rows)
  4631. {
  4632. 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();
  4633. }
  4634. writeGridDataTableJson(dStruct.TotalCount, dt);
  4635. }
  4636. public void get_erp_financeallplacelist()
  4637. {
  4638. DataStruct dStruct = GetPostStruct();
  4639. List<string> lw = new List<string>();
  4640. string tid = GetPostString("ctid");
  4641. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4642. string shopname = GetPostString("shopname");
  4643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4644. string buyernick = GetPostString("buyer_nick");
  4645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4646. string customer = GetPostString("customer");
  4647. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4648. string design = GetPostString("design");
  4649. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4650. string sellermemo = GetPostString("seller_memo");
  4651. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4652. string supplier = GetPostString("supplier");
  4653. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4654. string date1 = GetPostString("date1");
  4655. string date2 = GetPostString("date2");
  4656. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4657. if (dw.Length > 0) lw.Add(dw);
  4658. string pldate1 = GetPostString("placedate1");
  4659. string pldate2 = GetPostString("placedate2");
  4660. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4661. if (dw_place.Length > 0) lw.Add(dw_place);
  4662. string price1 = GetPostString("price1");
  4663. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4664. string price2 = GetPostString("price2");
  4665. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4666. string posTag = CurrentUser.UserPost.Post.Code;
  4667. if (posTag == "Supplier")
  4668. {
  4669. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4670. }
  4671. //lw.Add(string.Format("OrderState >= 6"));
  4672. lw.Add(string.Format("IsSample != 2 "));
  4673. lw.Add(string.Format("isDianziOrder = 0 "));
  4674. //lw.Add(string.Format("IsRefund<={0}", 1));
  4675. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4676. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4677. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4678. foreach (DataRow dr in dt.Rows)
  4679. {
  4680. 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();
  4681. }
  4682. writeGridDataTableJson(dStruct.TotalCount, dt);
  4683. }
  4684. public void get_erp_expresslist()
  4685. {
  4686. int listtype = GetInt("ltype");
  4687. DataStruct dStruct = GetPostStruct();
  4688. List<string> lw = new List<string>();
  4689. string tid = GetPostString("tid");
  4690. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4691. string outsid = GetPostString("out_sid");
  4692. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4693. string importer = GetPostString("ImportUserName");
  4694. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4695. string file = GetPostString("import_file");
  4696. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4697. string printman = GetPostString("printman");
  4698. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4699. string date1 = GetPostString("date1");
  4700. string date2 = GetPostString("date2");
  4701. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4702. if (dw.Length > 0) lw.Add(dw);
  4703. string fdate1 = GetPostString("finishdate1");
  4704. string fdate2 = GetPostString("finishdate2");
  4705. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4706. if (fdw.Length > 0) lw.Add(fdw);
  4707. if (listtype == 1)
  4708. {
  4709. lw.Add(string.Format("importUserId !=0"));
  4710. }
  4711. string posTag = CurrentUser.UserPost.Post.Code;
  4712. if (posTag == "Supplier")
  4713. {
  4714. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4715. }
  4716. if (dStruct.PageSize != 100000)
  4717. {
  4718. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4719. }
  4720. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4721. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4722. writeGridDataTableJson(dStruct.TotalCount, dt);
  4723. }
  4724. public void set_erp_buchaorderdelivery()
  4725. {
  4726. if (UrlPostParmsCheck("ctid"))
  4727. {
  4728. string eid = GetPostString("ctid");
  4729. CeErpTradeCell entity = null;
  4730. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4731. if (entity != null)
  4732. {
  4733. if (entity.IsSample != 2)
  4734. {
  4735. returnErrorMsg("补差价单才能标记为已发货");
  4736. return;
  4737. }
  4738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4739. entity.OrderState = 7;
  4740. entity.Update();
  4741. returnSuccessMsg("操作成功!");
  4742. return;
  4743. }
  4744. returnErrorMsg("找不到记录");
  4745. }
  4746. }
  4747. public void get_stdtemplates()
  4748. {
  4749. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4750. //string res = taobaoHelper.test();
  4751. string res = apiHelper.API_PrintTemplate();
  4752. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4753. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4754. {
  4755. int sidx = res.IndexOf("error_code");
  4756. int eidx = res.IndexOf("success");
  4757. string msg = res.Substring(sidx, eidx - sidx);
  4758. returnErrorMsg(msg);
  4759. return;
  4760. }
  4761. if (res.Length <= 0)
  4762. {
  4763. returnErrorMsg("模板数据为空!");
  4764. return;
  4765. }
  4766. ReturnSuccess(res);
  4767. }
  4768. public void cancel_print_order()
  4769. {
  4770. if (UrlPostParmsCheck("ctid"))
  4771. {
  4772. string ctid = GetPostString("ctid");
  4773. CeErpTradeCell entity = null;
  4774. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4775. if (entity != null)
  4776. {
  4777. string res = "";
  4778. string code = entity.LastBillWaybillCode;
  4779. if (code == "")
  4780. {
  4781. code = entity.OutSid;
  4782. }
  4783. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4784. XLog.SaveLog(0, "取消面单" + res);
  4785. }
  4786. }
  4787. }
  4788. public void set_erp_printwaybill()
  4789. {
  4790. if (UrlPostParmsCheck("ctid"))
  4791. {
  4792. string ctid = GetPostString("ctid");
  4793. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4794. string cpName = GetPostString("cpname");
  4795. string isTogether = GetPostString("together");
  4796. //var res_obj = new
  4797. //{
  4798. // restype = 1,
  4799. // 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\"}"
  4800. //};
  4801. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4802. //ReturnSuccess(ro_json);
  4803. //return;
  4804. bool isUseLastWayBillCode = false;
  4805. CeErpTradeCell entity = null;
  4806. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4807. if (entity != null)
  4808. {
  4809. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4810. {
  4811. isUseLastWayBillCode = true;
  4812. }
  4813. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4814. {
  4815. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4816. return;
  4817. }
  4818. }
  4819. string res = "";
  4820. Api_waybill_code_response_Obj fullObj = null;
  4821. string pData_str = "";
  4822. string curUseWayBillCode = "";
  4823. if (isUseLastWayBillCode == false)
  4824. {
  4825. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4826. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4827. if (res.IndexOf("failure") != -1)
  4828. {
  4829. //int idx = res.IndexOf("sub_message");
  4830. //int idx2 = res.IndexOf("flag");
  4831. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4832. string errMsgNeed = commonHelper.KeepChinese(res);
  4833. var res_objd = new
  4834. {
  4835. restype = 0,
  4836. data = "获取面单失败" + errMsgNeed
  4837. };
  4838. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4839. returnSuccess(ro_jsond);
  4840. if (res.IndexOf("停发") != -1)
  4841. {
  4842. entity.UnusualCon = "物流停发";
  4843. entity.Update();
  4844. }
  4845. //returnErrorMsg("获取面单失败,"+emsg);
  4846. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4847. return;
  4848. }
  4849. else if (res.IndexOf("errorMsg") != -1)
  4850. {
  4851. //int idx = res.IndexOf("errorMsg");
  4852. //int idx2 = res.IndexOf("}]}");
  4853. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4854. string errMsgNeed = commonHelper.KeepChinese(res);
  4855. var res_objf = new
  4856. {
  4857. restype = 0,
  4858. data = "获取面单失败2" + errMsgNeed
  4859. };
  4860. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4861. if (res.IndexOf("停发") != -1)
  4862. {
  4863. entity.UnusualCon = "物流停发";
  4864. entity.Update();
  4865. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4866. if (trade != null)
  4867. {
  4868. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4869. }
  4870. }
  4871. returnSuccess(ro_jsonf);
  4872. //returnErrorMsg("获取面单失败," + emsg);
  4873. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4874. return;
  4875. }
  4876. try
  4877. {
  4878. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4879. //res = res.Replace(" ", "");
  4880. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4881. }
  4882. catch (Exception ex)
  4883. {
  4884. XLog.SaveLog(0, "生成fullObj" + res);
  4885. var res_objf = new
  4886. {
  4887. restype = 0,
  4888. data = "生成fullObj发生错误" + ex.Message
  4889. };
  4890. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4891. returnSuccess(ro_jsonf);
  4892. return;
  4893. }
  4894. if (fullObj.response.data.content.Count > 0)
  4895. {
  4896. ContentItem codeObj = fullObj.response.data.content[0];
  4897. if (cpCode.IndexOf("SFFQ-") != -1)
  4898. {
  4899. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4900. }
  4901. else
  4902. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4903. curUseWayBillCode = codeObj.waybillCode;
  4904. }
  4905. else
  4906. {
  4907. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4908. var res_objf = new
  4909. {
  4910. restype = 0,
  4911. data = "生成fullObj找不到快递单号waybillCode"
  4912. };
  4913. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4914. returnSuccess(ro_jsonf);
  4915. return;
  4916. }
  4917. }
  4918. else
  4919. {
  4920. //使用上次打印的快递单号
  4921. if (cpCode == "SFFQ-LY")
  4922. {
  4923. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4924. }
  4925. else
  4926. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4927. curUseWayBillCode = entity.LastBillWaybillCode;
  4928. }
  4929. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4930. {
  4931. var res_obje = new
  4932. {
  4933. restype = 0,
  4934. data = "获取加密打印数据失败"
  4935. };
  4936. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4937. returnSuccess(ro_jsone);
  4938. entity.LastBillCpCode = cpCode;
  4939. entity.LastBillWaybillCode = curUseWayBillCode;
  4940. entity.Update();
  4941. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4942. //returnErrorMsg("获取加密打印数据失败");
  4943. return;
  4944. }
  4945. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4946. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4947. string btnType = "";
  4948. if (entity != null)
  4949. {
  4950. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4951. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4952. //cpcode是 YTO-CAINIAO
  4953. //string comCode = cpCode.Split('-')[0].ToString();
  4954. string apires = "";
  4955. if (ctid.IndexOf("N") != -1)
  4956. {
  4957. apires = "发货成功";
  4958. }
  4959. else
  4960. {
  4961. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4962. }
  4963. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  4964. //打单后发货
  4965. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  4966. {
  4967. try
  4968. {
  4969. btnType = "待发货";
  4970. entity.OutSid = curUseWayBillCode;
  4971. entity.OrderState = 7;
  4972. entity.IsUrgency = false;
  4973. entity.LastBillCpCode = "";
  4974. entity.LastBillWaybillCode = "";
  4975. entity.FinishDeliveryTime = DateTime.Now;
  4976. entity.IsReturn = 0;
  4977. entity.MemoOpt = 0;
  4978. entity.Update();
  4979. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  4980. //还要插入快递信息到 快递信息表
  4981. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4982. exinfo.tid = entity.ctid;
  4983. exinfo.out_sid = entity.OutSid;
  4984. exinfo.company_code = cpCode;
  4985. exinfo.company_name = cpName;
  4986. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4987. exinfo.deliveryType = "发货成功";
  4988. exinfo.print_time = DateTime.Now;
  4989. exinfo.printUser = CurrentUser.UserName;
  4990. exinfo.Create();
  4991. commonHelper.UpdateRelationOrder(entity.ctid);
  4992. CeErpSukuraData.createInfo(ctid, 4);
  4993. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4994. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  4995. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4996. if (isTogether == "1")
  4997. {
  4998. StringBuilder sqlsb = new StringBuilder();
  4999. 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);
  5000. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5001. }
  5002. }
  5003. catch (Exception ex)
  5004. {
  5005. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5006. }
  5007. }
  5008. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5009. {
  5010. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5011. if (entity.OrderState == 6)
  5012. {
  5013. entity.OrderState = 7;
  5014. }
  5015. entity.FinishDeliveryTime = DateTime.Now;
  5016. btnType = "已发货";
  5017. entity.Update();
  5018. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5019. exinfo.tid = entity.ctid;
  5020. exinfo.out_sid = entity.OutSid;
  5021. exinfo.company_code = cpCode;
  5022. exinfo.company_name = cpName;
  5023. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5024. exinfo.deliveryType = "发货成功";
  5025. exinfo.print_time = DateTime.Now;
  5026. exinfo.printUser = CurrentUser.UserName;
  5027. exinfo.Create();
  5028. commonHelper.UpdateRelationOrder(entity.ctid);
  5029. CeErpSukuraData.createInfo(entity.ctid, 4);
  5030. if (isTogether == "1")
  5031. {
  5032. StringBuilder sqlsb = new StringBuilder();
  5033. 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);
  5034. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5035. }
  5036. //不处理
  5037. }
  5038. else
  5039. {
  5040. entity.LastBillCpCode = cpCode;
  5041. entity.LastBillWaybillCode = curUseWayBillCode;
  5042. entity.Update();
  5043. string errmsg = commonHelper.KeepChinese(apires);
  5044. var res_objz = new
  5045. {
  5046. restype = 0,
  5047. data = "打单后发货失败"
  5048. };
  5049. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5050. returnSuccess(ro_jsonz);
  5051. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5052. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5053. return;
  5054. }
  5055. }
  5056. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5057. var res_obj = new
  5058. {
  5059. restype = 1,
  5060. data = pData_str
  5061. };
  5062. string ro_json = JsonConvert.SerializeObject(res_obj);
  5063. ReturnSuccess(ro_json);
  5064. return;
  5065. }
  5066. }
  5067. private string GetUTF8String(byte[] vs)
  5068. {
  5069. throw new NotImplementedException();
  5070. }
  5071. public void set_erp_printwaybill_cn()
  5072. {
  5073. if (UrlPostParmsCheck("ctid"))
  5074. {
  5075. string ctid = GetPostString("ctid");
  5076. string cpCode = GetPostString("cpcode");
  5077. string cpName = GetPostString("cpname");
  5078. string tempUrl = GetPostString("tempurl");
  5079. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5080. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5081. //string res = taobaoHelper.test();
  5082. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5083. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5084. {
  5085. int sidx = res.IndexOf("errorMsg");
  5086. int eidx = res.IndexOf("}");
  5087. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5088. var res_objzxx = new
  5089. {
  5090. restype = 0,
  5091. data = msg
  5092. };
  5093. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5094. returnSuccess(ro_jsonzxx);
  5095. //returnErrorMsg(msg);
  5096. return;
  5097. }
  5098. int idx = res.IndexOf("waybillCode");
  5099. int idx2 = res.IndexOf("printData");
  5100. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5101. string eid = GetPostString("ctid");
  5102. CeErpTradeCell entity = null;
  5103. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5104. if (entity != null)
  5105. {
  5106. string osid = entity.OutSid;
  5107. entity.OutSid = osid + "," + outsid;
  5108. entity.FinishDeliveryTime = DateTime.Now;
  5109. entity.OrderState = 7;
  5110. entity.IsReturn = 0;
  5111. entity.Update();
  5112. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5113. exinfo.tid = entity.ctid;
  5114. exinfo.out_sid = outsid;
  5115. exinfo.company_code = cpCode;
  5116. exinfo.company_name = cpName;
  5117. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5118. exinfo.deliveryType = "发货成功";
  5119. exinfo.print_time = DateTime.Now;
  5120. exinfo.printUser = CurrentUser.UserName;
  5121. exinfo.Create();
  5122. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5123. }
  5124. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5125. var res_objz = new
  5126. {
  5127. restype = 1,
  5128. data = res
  5129. };
  5130. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5131. returnSuccess(ro_jsonz);
  5132. //ReturnSuccess(res);
  5133. }
  5134. }
  5135. ////打单,打印面单 获取面单号
  5136. //public void set_erp_printwaybill()
  5137. //{
  5138. // if (UrlPostParmsCheck("ctid"))
  5139. // {
  5140. // string ctid = GetPostString("ctid");
  5141. // string cpCode = GetPostString("cpcode");
  5142. // string tempUrl = GetPostString("tempurl");
  5143. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5144. // //string res = taobaoHelper.test();
  5145. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5146. // if (res.IndexOf("error_response") != -1)
  5147. // {
  5148. // int sidx = res.IndexOf("sub_msg");
  5149. // int eidx = res.IndexOf("request_id");
  5150. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5151. // returnErrorMsg(msg);
  5152. // return;
  5153. // }
  5154. // int idx = res.IndexOf("waybill_code");
  5155. // int idx2 = res.IndexOf("}]}");
  5156. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5157. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5158. // ReturnSuccess(res);
  5159. // }
  5160. //}
  5161. public void cancel_erp_aftersale()
  5162. {
  5163. if (UrlPostParmsCheck("ctid"))
  5164. {
  5165. string eid = GetPostString("ctid");
  5166. CeErpTradeCell entity = null;
  5167. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5168. if (entity != null)
  5169. {
  5170. //有过处理的售后,取消也不能删除 售 字,保留
  5171. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5172. {
  5173. entity.AfterSaleState = 4;
  5174. }
  5175. else
  5176. entity.AfterSaleState = 0;
  5177. entity.Update();
  5178. returnSuccessMsg("操作成功!");
  5179. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5180. return;
  5181. }
  5182. returnErrorMsg("找不到订单记录");
  5183. }
  5184. }
  5185. public void get_erp_aftersalelist()
  5186. {
  5187. DataStruct dStruct = GetPostStruct();
  5188. List<string> lw = new List<string>();
  5189. int st = GetInt("st");
  5190. string tid = GetPostString("ctid");
  5191. if (st == 3)
  5192. {
  5193. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5194. }
  5195. else
  5196. {
  5197. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5198. }
  5199. string shopname = GetPostString("shopname");
  5200. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5201. string buyernick = GetPostString("buyer_nick");
  5202. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5203. string sellermemo = GetPostString("seller_memo");
  5204. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5205. string orderState = GetPostString("orderState");
  5206. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5207. string afterState = GetPostString("afterstate");
  5208. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5209. string date1 = GetPostString("date1");
  5210. string date2 = GetPostString("date2");
  5211. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5212. if (dw.Length > 0) lw.Add(dw);
  5213. string price1 = GetPostString("price1");
  5214. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5215. string price2 = GetPostString("price2");
  5216. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5217. //lw.Add(string.Format("IsRefund!={0}", 1));
  5218. string reason = GetPostString("reason");
  5219. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5220. string method = GetPostString("method");
  5221. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5222. string handler = GetPostString("handler");
  5223. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5224. string handledate1 = GetPostString("handledate1");
  5225. string handledate2 = GetPostString("handledate2");
  5226. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5227. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5228. string finish1 = GetPostString("finishdate1");
  5229. string finish2 = GetPostString("finishdate2");
  5230. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5231. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5232. string afterdate1 = GetPostString("afterdate1");
  5233. string afterdate2 = GetPostString("afterdate2");
  5234. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5235. if (afterDate.Length > 0) lw.Add(afterDate);
  5236. string supplier = GetPostString("supplier");
  5237. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5238. string responsible = GetPostString("responsibleman");
  5239. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5240. string customer = GetPostString("customer");
  5241. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5242. string design = GetPostString("design");
  5243. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5244. string afterMemoType = GetPostString("aftermemotype");
  5245. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5246. string posCode = CurrentUser.UserPost.Post.Code;
  5247. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5248. //{
  5249. // string vstate = GetPostString("vstate");
  5250. // if (vstate.Length > 0)
  5251. // {
  5252. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5253. // }
  5254. // if (posCode == "Supplier")
  5255. // {
  5256. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5257. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5258. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5259. // }
  5260. // else
  5261. // {
  5262. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5263. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5264. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5265. // {
  5266. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5267. // }
  5268. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5269. // {
  5270. // int orgid = CurrentUser.UserPost.OrgID;
  5271. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5272. // }
  5273. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5274. // {
  5275. // string shopid = CurrentUser.User.pemShop;
  5276. // lw.Add(string.Format("shopId in ({0})", shopid));
  5277. // }
  5278. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5279. // //{
  5280. // // int org_id = CurrentUser.UserPost.OrgID;
  5281. // // lw.Add(string.Format("OrgID={0}", org_id));
  5282. // //}
  5283. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5284. // }
  5285. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5286. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5287. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5288. //}
  5289. if (st == 5)
  5290. {
  5291. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5292. {
  5293. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5294. {
  5295. string shopid = CurrentUser.User.pemShop;
  5296. lw.Add(string.Format("shopId in ({0})", shopid));
  5297. }
  5298. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5299. {
  5300. int mrOrgid = CurrentUser.UserPost.OrgID;
  5301. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5302. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5303. }
  5304. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5305. //{
  5306. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5307. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5308. //}
  5309. else
  5310. {
  5311. string userIdStr = "";
  5312. if (posCode == "CustomerService")
  5313. {
  5314. userIdStr = CurrentUser.UserID + "_k";
  5315. }
  5316. else if (posCode == "Designer" || posCode == "wxDesigner")
  5317. {
  5318. userIdStr = CurrentUser.UserID + "_s";
  5319. }
  5320. else if (posCode == "Place")
  5321. {
  5322. userIdStr = CurrentUser.UserID + "_x";
  5323. }
  5324. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5325. }
  5326. }
  5327. string placedate1 = GetPostString("placedate1");
  5328. string placedate2 = GetPostString("placedate2");
  5329. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5330. if (dwplace.Length > 0) lw.Add(dwplace);
  5331. string supState = GetPostString("supState");
  5332. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5333. string searchType = GetPostString("searchType");
  5334. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5335. {
  5336. lw.Add(string.Format("BackNum>1"));
  5337. }
  5338. lw.Add(string.Format("AfterSaleState>0"));
  5339. if (ex_psize > 0)
  5340. {
  5341. if (CurrentUser.UserPost.Post.Code == "Finance")
  5342. dStruct.Order = "pay_time desc";
  5343. else
  5344. dStruct.Order = "HandleTime desc";
  5345. }
  5346. else
  5347. dStruct.Order = "HandleTime desc";
  5348. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5349. DataTable dt = WebCache.GetData("view_test", dStruct);
  5350. writeGridDataTableJson(dStruct.TotalCount, dt);
  5351. }
  5352. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5353. //{
  5354. // lw.Add(string.Format("AfterSaleState=4"));
  5355. // string code = CurrentUser.UserPost.Post.Code;
  5356. // if (code == "CustomerService")
  5357. // {
  5358. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5359. // }
  5360. // else if (code == "Designer" || code == "DesignerMr")
  5361. // {
  5362. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5363. // }
  5364. // else if (code == "Place" || code == "PlaceMr")
  5365. // {
  5366. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5367. // }
  5368. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5369. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5370. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5371. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5372. //}
  5373. //else //处理中的售后,待处理和处理中合并
  5374. //{
  5375. // if (afterState.Length <= 0)
  5376. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  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. }
  5383. public void get_erp_disagreeftersalelist()
  5384. {
  5385. DataStruct dStruct = GetPostStruct();
  5386. List<string> lw = new List<string>();
  5387. int st = 2;
  5388. string tid = GetPostString("ctid");
  5389. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5390. string shopname = GetPostString("shopname");
  5391. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5392. string buyernick = GetPostString("buyer_nick");
  5393. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5394. string sellermemo = GetPostString("seller_memo");
  5395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5396. string orderState = GetPostString("orderState");
  5397. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5398. string afterState = GetPostString("afterstate");
  5399. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5400. string date1 = GetPostString("date1");
  5401. string date2 = GetPostString("date2");
  5402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5403. if (dw.Length > 0) lw.Add(dw);
  5404. string price1 = GetPostString("price1");
  5405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5406. string price2 = GetPostString("price2");
  5407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5408. //lw.Add(string.Format("IsRefund!={0}", 1));
  5409. string reason = GetPostString("reason");
  5410. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5411. string method = GetPostString("method");
  5412. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5413. string handler = GetPostString("handler");
  5414. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5415. string handledate1 = GetPostString("handledate1");
  5416. string handledate2 = GetPostString("handledate2");
  5417. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5418. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5419. string afterdate1 = GetPostString("afterdate1");
  5420. string afterdate2 = GetPostString("afterdate2");
  5421. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5422. if (afterDate.Length > 0) lw.Add(afterDate);
  5423. string supplier = GetPostString("supplier");
  5424. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5425. string responsible = GetPostString("responsibleman");
  5426. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5427. string customer = GetPostString("customer");
  5428. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5429. string design = GetPostString("design");
  5430. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5431. string afterSaleMemo = GetPostString("afterSaleMemo");
  5432. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5433. string afterMemoType = GetPostString("aftermemotype");
  5434. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5435. string aftersakereason = GetPostString("aftersakereason");
  5436. if (aftersakereason.Length > 0)
  5437. {
  5438. if (aftersakereason == "1")
  5439. {
  5440. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5441. }
  5442. if (aftersakereason == "2")
  5443. {
  5444. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5445. }
  5446. }
  5447. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5448. string poscode = CurrentUser.UserPost.Post.Code;
  5449. if (poscode != "SysAdmin")
  5450. {
  5451. string shopid = CurrentUser.User.pemShop;
  5452. lw.Add(string.Format("shopId in ({0})", shopid));
  5453. }
  5454. string searchType = GetPostString("searchType");
  5455. if (searchType == "wait")
  5456. {
  5457. lw.Add(string.Format("HandleTime is null"));
  5458. }
  5459. if (searchType == "handling")
  5460. {
  5461. lw.Add(string.Format("HandleTime is not null "));
  5462. }
  5463. if (searchType == "back" || searchType == "puBack")
  5464. {
  5465. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5466. }
  5467. if (searchType == "reBack")
  5468. {
  5469. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5470. }
  5471. if (searchType == "moreBack")
  5472. {
  5473. lw.Add(string.Format("backNum > 1"));
  5474. }
  5475. lw.Add(string.Format("(AfterSaleState=5)"));
  5476. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5477. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5478. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5479. writeGridDataTableJson(dStruct.TotalCount, dt);
  5480. }
  5481. public void get_erp_handlingaftersalelist()
  5482. {
  5483. DataStruct dStruct = GetPostStruct();
  5484. List<string> lw = new List<string>();
  5485. int st = 2;
  5486. string tid = GetPostString("ctid");
  5487. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5488. string shopname = GetPostString("shopname");
  5489. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5490. string buyernick = GetPostString("buyer_nick");
  5491. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5492. string sellermemo = GetPostString("seller_memo");
  5493. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5494. string orderState = GetPostString("orderState");
  5495. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5496. string afterState = GetPostString("afterstate");
  5497. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5498. string date1 = GetPostString("date1");
  5499. string date2 = GetPostString("date2");
  5500. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5501. if (dw.Length > 0) lw.Add(dw);
  5502. string price1 = GetPostString("price1");
  5503. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5504. string price2 = GetPostString("price2");
  5505. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5506. //lw.Add(string.Format("IsRefund!={0}", 1));
  5507. string reason = GetPostString("reason");
  5508. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5509. string method = GetPostString("method");
  5510. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5511. string handler = GetPostString("handler");
  5512. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5513. string handledate1 = GetPostString("handledate1");
  5514. string handledate2 = GetPostString("handledate2");
  5515. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5516. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5517. string afterdate1 = GetPostString("afterdate1");
  5518. string afterdate2 = GetPostString("afterdate2");
  5519. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5520. if (afterDate.Length > 0) lw.Add(afterDate);
  5521. string supplier = GetPostString("supplier");
  5522. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5523. string responsible = GetPostString("responsibleman");
  5524. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5525. string customer = GetPostString("customer");
  5526. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5527. string design = GetPostString("design");
  5528. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5529. string afterSaleMemo = GetPostString("afterSaleMemo");
  5530. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5531. string afterMemoType = GetPostString("aftermemotype");
  5532. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5533. string afterresult = GetPostString("afterresult");
  5534. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5535. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5536. string poscode = CurrentUser.UserPost.Post.Code;
  5537. if (poscode != "SysAdmin")
  5538. {
  5539. string shopid = CurrentUser.User.pemShop;
  5540. lw.Add(string.Format("shopId in ({0})", shopid));
  5541. }
  5542. string searchType = GetPostString("searchType");
  5543. if (searchType == "wait")
  5544. {
  5545. lw.Add(string.Format("HandleTime is null"));
  5546. }
  5547. if (searchType == "documentary")
  5548. {
  5549. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5550. }
  5551. if (searchType == "handling")
  5552. {
  5553. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5554. }
  5555. if (searchType == "back" || searchType == "puBack")
  5556. {
  5557. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5558. }
  5559. if (searchType == "reBack")
  5560. {
  5561. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5562. }
  5563. if (afterState.Length <= 0)
  5564. {
  5565. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5566. }
  5567. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5568. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5569. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5570. writeGridDataTableJson(dStruct.TotalCount, dt);
  5571. }
  5572. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5573. //public void get_erp_back_handlingaftersalelist()
  5574. //{
  5575. // DataStruct dStruct = GetPostStruct();
  5576. // List<string> lw = new List<string>();
  5577. // string tid = GetPostString("ctid");
  5578. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5579. // string shopname = GetPostString("shopname");
  5580. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5581. // string buyernick = GetPostString("buyer_nick");
  5582. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5583. // string sellermemo = GetPostString("seller_memo");
  5584. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5585. // string orderState = GetPostString("orderState");
  5586. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5587. // string afterState = GetPostString("afterstate");
  5588. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5589. // string date1 = GetPostString("date1");
  5590. // string date2 = GetPostString("date2");
  5591. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5592. // if (dw.Length > 0) lw.Add(dw);
  5593. // string price1 = GetPostString("price1");
  5594. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5595. // string price2 = GetPostString("price2");
  5596. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5597. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5598. // string reason = GetPostString("reason");
  5599. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5600. // string method = GetPostString("method");
  5601. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5602. // string handler = GetPostString("handler");
  5603. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5604. // string handledate1 = GetPostString("handledate1");
  5605. // string handledate2 = GetPostString("handledate2");
  5606. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5607. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5608. // string afterdate1 = GetPostString("afterdate1");
  5609. // string afterdate2 = GetPostString("afterdate2");
  5610. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5611. // if (afterDate.Length > 0) lw.Add(afterDate);
  5612. // string supplier = GetPostString("supplier");
  5613. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5614. // string responsible = GetPostString("responsibleman");
  5615. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5616. // string customer = GetPostString("customer");
  5617. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5618. // string design = GetPostString("design");
  5619. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5620. // string afterMemoType = GetPostString("aftermemotype");
  5621. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5622. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5623. // if (afterState.Length <= 0)
  5624. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5625. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5626. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5627. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5628. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5629. //}
  5630. public void get_erp_aftersaleverifylist()
  5631. {
  5632. DataStruct dStruct = GetPostStruct();
  5633. List<string> lw = new List<string>();
  5634. string tid = GetPostString("ctid");
  5635. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5636. string shopname = GetPostString("shopname");
  5637. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5638. string buyernick = GetPostString("buyer_nick");
  5639. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5640. string sellermemo = GetPostString("seller_memo");
  5641. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5642. string orderState = GetPostString("orderState");
  5643. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5644. //lw.Add(string.Format("IsRefund!={0}", 1));
  5645. string reason = GetPostString("reason");
  5646. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5647. string method = GetPostString("method");
  5648. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5649. string handler = GetPostString("handler");
  5650. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5651. string handledate1 = GetPostString("handledate1");
  5652. string handledate2 = GetPostString("handledate2");
  5653. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5654. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5655. string finish1 = GetPostString("finishdate1");
  5656. string finish2 = GetPostString("finishdate2");
  5657. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5658. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5659. string supplier = GetPostString("supplier");
  5660. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5661. string responsible = GetPostString("responsibleman");
  5662. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5663. string posCode = CurrentUser.UserPost.Post.Code;
  5664. string vstate = GetPostString("vstate");
  5665. if (vstate.Length > 0)
  5666. {
  5667. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5668. }
  5669. if (posCode == "Supplier")
  5670. {
  5671. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5672. lw.Add(string.Format("VerifyState = 0"));
  5673. lw.Add("COALESCE(IsSup,0) = 1");
  5674. lw.Add(string.Format("AfterSaleState={0}", 3));
  5675. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5676. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5678. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5679. writeGridDataTableJson(dStruct.TotalCount, dt);
  5680. }
  5681. else if (posCode == "logistics")
  5682. {
  5683. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5684. lw.Add(string.Format("VerifyState = 0"));
  5685. lw.Add("COALESCE(IsFlow,0) = 1");
  5686. lw.Add(string.Format("AfterSaleState={0}", 3));
  5687. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5688. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5689. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5690. writeGridDataTableJson(dStruct.TotalCount, dt);
  5691. }
  5692. else
  5693. {
  5694. lw.Add(string.Format("(AfterSaleState = 3)"));
  5695. string reasonState = GetPostString("reasonState");
  5696. lw.Add("COALESCE(IsSup,0) = 0");
  5697. lw.Add("COALESCE(IsFlow,0) = 0");
  5698. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5699. || posCode == "Summarize" || posCode == "Finance")
  5700. {
  5701. if (reasonState == "2")
  5702. {
  5703. lw.Add("VerifyState = 3");
  5704. }
  5705. else if (reasonState == "1")
  5706. {
  5707. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5708. }
  5709. else
  5710. {
  5711. lw.Add("VerifyState in (0,3)");
  5712. }
  5713. //不加条件,可以看全部
  5714. }
  5715. 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")
  5716. {
  5717. int orgid = CurrentUser.UserPost.OrgID;
  5718. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5719. if (string.IsNullOrEmpty(manageOrgId))
  5720. {
  5721. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5722. }
  5723. else
  5724. {
  5725. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5726. }
  5727. if (reasonState == "1")
  5728. {
  5729. lw.Add("VerifyState = 3");
  5730. }
  5731. else if (reasonState == "2")
  5732. {
  5733. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5734. }
  5735. else
  5736. {
  5737. }
  5738. }
  5739. else
  5740. {
  5741. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5742. }
  5743. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5744. //{
  5745. // int org_id = CurrentUser.UserPost.OrgID;
  5746. // lw.Add(string.Format("OrgID={0}", org_id));
  5747. //}
  5748. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5749. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5750. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5751. writeGridDataTableJson(dStruct.TotalCount, dt);
  5752. }
  5753. }
  5754. public void get_erp_finishaftersalelist()
  5755. {
  5756. DataStruct dStruct = GetPostStruct();
  5757. List<string> lw = new List<string>();
  5758. int st = 4;
  5759. string tid = GetPostString("ctid");
  5760. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5761. string shopname = GetPostString("shopname");
  5762. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5763. //lw.Add(string.Format("IsRefund!={0}", 1));
  5764. string reason = GetPostString("reason");
  5765. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5766. string method = GetPostString("method");
  5767. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5768. string buyernick = GetPostString("buyer_nick");
  5769. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5770. string handler = GetPostString("handler");
  5771. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5772. string handledate1 = GetPostString("handledate1");
  5773. string handledate2 = GetPostString("handledate2");
  5774. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5775. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5776. string finish1 = GetPostString("finishdate1");
  5777. string finish2 = GetPostString("finishdate2");
  5778. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5779. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5780. string supplier = GetPostString("supplier");
  5781. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5782. string responsible = GetPostString("responsibleman");
  5783. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5784. string vstate = GetPostString("vstate");
  5785. if (vstate.Length > 0)
  5786. {
  5787. if ("3".Equals(vstate))
  5788. {
  5789. lw.Add(string.Format("IsTem=1"));
  5790. }
  5791. else
  5792. {
  5793. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5794. }
  5795. }
  5796. lw.Add(string.Format("AfterSaleState=4"));
  5797. string code = CurrentUser.UserPost.Post.Code;
  5798. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5799. {
  5800. //不加条件,可以看全部
  5801. }
  5802. else if (code == "Supplier")
  5803. {
  5804. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5805. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5806. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5807. }
  5808. else if (code == "logistics")
  5809. {
  5810. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5811. lw.Add("COALESCE(IsFlow,0) = 1");
  5812. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5813. }
  5814. 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")
  5815. {
  5816. int orgid = CurrentUser.UserPost.OrgID;
  5817. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5818. if (string.IsNullOrEmpty(manageOrgIds))
  5819. {
  5820. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5821. }
  5822. else
  5823. {
  5824. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5825. }
  5826. }
  5827. else
  5828. {
  5829. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5830. }
  5831. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5832. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5833. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5834. writeGridDataTableJson(dStruct.TotalCount, dt);
  5835. }
  5836. public void handle_erp_aftersale()
  5837. {
  5838. if (UrlPostParmsCheck("ctid"))
  5839. {
  5840. string eid = GetPostString("ctid");
  5841. string responStr = GetPostString("AfterSaleResponsible");
  5842. if (responStr.Length <= 0)
  5843. {
  5844. returnErrorMsg("售后责任人不能为空");
  5845. return;
  5846. }
  5847. bool isDesign = false;
  5848. double designFree = 0.00;
  5849. int responsibleId = 0;
  5850. CeErpTradeCell entity = null;
  5851. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5852. if (entity != null)
  5853. {
  5854. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5855. string afterMethod = GetPostString("AfterSaleMethod");
  5856. if (isNeedNewOrder == 1)
  5857. {
  5858. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5859. bool ishav = true;
  5860. if (newentity == null)
  5861. {
  5862. newentity = entity.Clone() as CeErpTradeCell;
  5863. ishav = false;
  5864. newentity.ctid = "S_" + entity.ctid;
  5865. newentity.OrderState = 0;
  5866. }
  5867. //唯一标识
  5868. newentity.OrderSn = newentity.ctid;
  5869. /* string orderSn = dataHelper.getSaleOrderSn();
  5870. if (orderSn != "")
  5871. {
  5872. newentity.OrderSn = orderSn;
  5873. }*/
  5874. newentity.AfterSaleState = 0;
  5875. newentity.AfterSaleMethod = afterMethod;
  5876. if (!ishav)
  5877. {
  5878. string memo_str = newentity.seller_memo;
  5879. memo_str = memo_str.Replace("(", "(");
  5880. memo_str = memo_str.Replace(")", ")");
  5881. int sIndex = memo_str.IndexOf("(");
  5882. int eIndex = memo_str.IndexOf(")");
  5883. if (sIndex == -1 || eIndex == -1)
  5884. {
  5885. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5886. return;
  5887. }
  5888. string first = memo_str.Substring(0, sIndex + 1);
  5889. string memoCtid = newentity.OrderSn;
  5890. //if (memoCtid.IndexOf("C") != -1)
  5891. //{
  5892. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5893. //if (CIdx.IndexOf("+") != -1)
  5894. //{
  5895. //CIdx = "C" + CIdx.Split('+')[1];
  5896. //}
  5897. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5898. //}
  5899. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5900. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5901. string newMemo = first + memoCtid + last;
  5902. newentity.seller_memo = newMemo;
  5903. newentity.FinishPlaceTime = null;
  5904. newentity.UnusualTag = 0;
  5905. newentity.UnusualCon = "";
  5906. newentity.UnusualTime = null;
  5907. newentity.AfterSaleMemo = "";
  5908. newentity.AfterSaleMethod = afterMethod;
  5909. newentity.AfterSalePreTime = null;
  5910. newentity.AfterSaleReason = "";
  5911. newentity.AfterSaleResponsible = "";
  5912. newentity.AfterSaleState = 0;
  5913. newentity.AfterSaleTime = null;
  5914. newentity.AfterSaleUserId = 0;
  5915. newentity.AfterSaleSupplierState = 0;
  5916. newentity.LastBillWaybillCode = "";
  5917. newentity.LastBillCpCode = "";
  5918. newentity.FinishAfterSaleTime = null;
  5919. newentity.HandleTime = null;
  5920. newentity.IsSF = 0;
  5921. newentity.IsOldCustomer = 0;
  5922. newentity.UrgencyTime = null;
  5923. newentity.ResponsibleUserId = "";
  5924. newentity.IsVerifyToSupplier = false;
  5925. newentity.payment = 0;
  5926. newentity.CheckMemo = "";
  5927. newentity.OutSid = "";
  5928. newentity.CheckOrderTime = null;
  5929. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5930. }
  5931. newentity.isAfterSaleOrder = 1;
  5932. newentity.IsRefund = 0;
  5933. string receiveMobile = GetPostString("receiver_mobile");
  5934. if (receiveMobile.Length > 0)
  5935. {
  5936. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5937. if (trade != null)
  5938. {
  5939. trade.receiver_name = GetPostString("receiver_name");
  5940. trade.receiver_mobile = receiveMobile;
  5941. trade.receiver_state = GetPostString("receiver_state");
  5942. trade.receiver_city = GetPostString("receiver_city");
  5943. trade.receiver_district = GetPostString("receiver_district");
  5944. trade.receiver_address = GetPostString("receiver_address");
  5945. newentity.IsOffLineOrder = 1;
  5946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  5947. }
  5948. }
  5949. string st = GetPostString("ToState");
  5950. if (st.Length > 0)
  5951. {
  5952. if (newentity.OrderState <= 3)
  5953. {
  5954. newentity.WaitDesignTime = DateTime.Now;
  5955. newentity.StartDesignTime = null;
  5956. newentity.FinishDesignTime = null;
  5957. newentity.OrderState = 3;
  5958. if (st == "下单员")
  5959. {
  5960. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  5961. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  5962. {
  5963. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  5964. }
  5965. }
  5966. else
  5967. {
  5968. newentity.WaitDesignTime = DateTime.Now;
  5969. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  5970. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  5971. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  5972. {
  5973. DataRow user = dt1.Rows[0];
  5974. //找主管
  5975. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  5976. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  5977. if (dt != null && dt.Rows.Count > 0)
  5978. {
  5979. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  5980. newentity.DesignUserId = designMr;
  5981. string key = "aftersale_order_" + designMr;
  5982. if (RedisHelper.HasKey(key))
  5983. {
  5984. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5985. list.Add(newentity.ctid);
  5986. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5987. }
  5988. }
  5989. //账号正常
  5990. if (user["State"].ToString() == "0")
  5991. {
  5992. newentity.DesignUserId = entity.DesignUserId;
  5993. string key = "aftersale_order_" + entity.DesignUserId;
  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. }
  6003. }
  6004. if (entity.IsXianHuo == 1)
  6005. {
  6006. newentity.OrderState = 6;
  6007. entity.FinishPlaceTime = DateTime.Now;
  6008. }
  6009. }
  6010. if (ishav)
  6011. {
  6012. newentity.Update();
  6013. }
  6014. else
  6015. {
  6016. newentity.Create();
  6017. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6018. }
  6019. if (st != "下单员")
  6020. {
  6021. designHelper.API_GetPrintData_CreateOrder(newentity);
  6022. }
  6023. }
  6024. //处理售后扩展
  6025. string resIdStr = GetPostString("ResponsibleUserId");
  6026. string refundFees = GetPostString("refundFrees");
  6027. int IsComplain = GetPostInt("isComplain");
  6028. int IsBad = GetPostInt("isBad");
  6029. string IsOriginal = GetPostString("isOriginal");
  6030. double diffResultPrice = GetPostDouble("diffResultPrice");
  6031. string textResult = GetPostString("textResult");
  6032. string supplierResponsible = GetPostString("supplierResponsible");
  6033. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6034. if (ceErpTradeAfterSaleExtend == null)
  6035. {
  6036. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6037. ceErpTradeAfterSaleExtend.tid = eid;
  6038. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6039. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6040. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6041. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6042. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6043. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6044. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6045. ceErpTradeAfterSaleExtend.Create();
  6046. }
  6047. else
  6048. {
  6049. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6050. {
  6051. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6052. }
  6053. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6054. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6055. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6056. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6057. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6058. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6059. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6060. ceErpTradeAfterSaleExtend.Update();
  6061. }
  6062. int gysid = GetPostInt("ResponsibleSupId");
  6063. entity.AfterSaleUserId = CurrentUser.UserID;
  6064. entity.ResponsibleUserId = resIdStr;
  6065. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6066. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6067. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6068. {
  6069. CeErpTradeResponsible.DelByTid(eid, -1);
  6070. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6071. int backNum = 0;
  6072. if (number != null)
  6073. {
  6074. backNum = number.BackNum;
  6075. }
  6076. char[] separator = { ',' };
  6077. string[] sArray = resIdStr.Split(separator);
  6078. string[] refundFreeList = { };
  6079. if (refundFees.Length > 0)
  6080. {
  6081. refundFreeList = refundFees.Split(separator);
  6082. }
  6083. int index = -1;
  6084. foreach (string i in sArray)
  6085. {
  6086. index++;
  6087. if (i.Length <= 0) continue;
  6088. char[] separator2 = { '_' };
  6089. string idstr = i.Split(separator2)[0];
  6090. string idtype = i.Split(separator2)[1];
  6091. double refudFree = 0;
  6092. if (refundFreeList.Length > 0)
  6093. {
  6094. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6095. }
  6096. if (idtype == "s")
  6097. {
  6098. isDesign = true;
  6099. designFree = refudFree;
  6100. }
  6101. int userId = Convert.ToInt32(idstr);
  6102. int isSup = 0;
  6103. if (gysid != 0 && gysid == userId)
  6104. {
  6105. isSup = 1;
  6106. }
  6107. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(eid, userId, isSup, idtype == "w" ? 1 : 0);
  6108. if (ceErpTradeResponsible == null)
  6109. {
  6110. ceErpTradeResponsible = new CeErpTradeResponsible();
  6111. ceErpTradeResponsible.tid = eid;
  6112. ceErpTradeResponsible.VerifyState = 0;
  6113. ceErpTradeResponsible.UserId = userId;
  6114. ceErpTradeResponsible.IsSup = isSup;
  6115. ceErpTradeResponsible.RefundFee = refudFree;
  6116. ceErpTradeResponsible.createdTime = DateTime.Now;
  6117. if (userId == 2125)
  6118. {
  6119. ceErpTradeResponsible.VerifyState = 1;
  6120. }
  6121. if (idtype == "w")
  6122. {
  6123. ceErpTradeResponsible.IsFlow = 1;
  6124. ceErpTradeResponsible.VerifyState = 1;
  6125. if (userId == 101)
  6126. {
  6127. ceErpTradeResponsible.VerifyState = 0;
  6128. }
  6129. }
  6130. ceErpTradeResponsible.Create();
  6131. }
  6132. else
  6133. {
  6134. ceErpTradeResponsible.RefundFee = refudFree;
  6135. ceErpTradeResponsible.VerifyState = 0;
  6136. if (userId == 2125)
  6137. {
  6138. ceErpTradeResponsible.VerifyState = 1;
  6139. }
  6140. if (idtype == "w")
  6141. {
  6142. ceErpTradeResponsible.VerifyState = 1;
  6143. if (userId == 101)
  6144. {
  6145. ceErpTradeResponsible.VerifyState = 0;
  6146. }
  6147. }
  6148. ceErpTradeResponsible.Update();
  6149. }
  6150. if (isDesign)
  6151. {
  6152. responsibleId = ceErpTradeResponsible.ID;
  6153. }
  6154. }
  6155. CeErpTradeResponsible.NumByTid(backNum, eid);
  6156. }
  6157. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6158. if (ceErpTradeCellExtend != null)
  6159. {
  6160. ceErpTradeCellExtend.returnVisit = 0;
  6161. ceErpTradeCellExtend.Update();
  6162. }
  6163. if (entity.HandleTime != null)
  6164. {
  6165. if (entity.AfterSaleState == 1)
  6166. {
  6167. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6168. }
  6169. else
  6170. {
  6171. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6172. }
  6173. }
  6174. else
  6175. {
  6176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6177. entity.HandleTime = DateTime.Now;
  6178. }
  6179. bool isCompale = false;
  6180. if (entity.AfterSaleState == 5)
  6181. {
  6182. isCompale = true;
  6183. entity.AfterSaleState = 3;
  6184. }
  6185. entity.AfterSaleSupplierState = 0;
  6186. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6187. {
  6188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6189. }
  6190. string sImgs = GetPostString("img");
  6191. entity.AfterSaleSupplierImg = sImgs;
  6192. entity.supRefundType = GetPostString("supRefundType");
  6193. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6194. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6195. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6196. entity.AfterSaleMemoType = GetPostString("MemoType");
  6197. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6198. {
  6199. entity.AfterSaleSupplierState = 2;
  6200. }
  6201. string df = GetPostString("DeductFee");
  6202. if (df == "")
  6203. {
  6204. df = "0";
  6205. }
  6206. string rf = GetPostString("RefundFee");
  6207. if (rf == "")
  6208. {
  6209. rf = "0";
  6210. }
  6211. string pm = GetPostString("AfterSalePayment");
  6212. if (pm == "")
  6213. {
  6214. pm = "0";
  6215. }
  6216. entity.AfterSalePayment = Convert.ToDouble(pm);
  6217. entity.DeductFee = Convert.ToDouble(df);
  6218. entity.RefundFee = Convert.ToDouble(rf);
  6219. entity.Update();
  6220. string toState = GetPostString("ToState");
  6221. string original = GetPostString("isOriginal");
  6222. ApiVo apiVo = new ApiVo();
  6223. apiVo.orderNumber = entity.ctid;
  6224. apiVo.actionName = "afterDesign";
  6225. apiVo.orderRemarks = entity.AfterSaleMethod;
  6226. apiVo.reasonRemarks = entity.AfterSaleReason;
  6227. apiVo.isDesign = isDesign;
  6228. apiVo.designFree = designFree;
  6229. apiVo.responsibleId = responsibleId;
  6230. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6231. if (toState == "设计师")
  6232. {
  6233. apiVo.isOriginal = Convert.ToBoolean(original);
  6234. }
  6235. designHelper.API_WorkCore(apiVo);//afterDesign
  6236. CeErpMethod methodSql = new CeErpMethod();
  6237. methodSql.con = entity.AfterSaleMethod;
  6238. methodSql.addTime = DateTime.Now;
  6239. methodSql.Create();
  6240. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6241. CeErpMethod.ExecuteNonQuery(delsql);
  6242. if (isCompale)
  6243. {
  6244. aftersale_data_change(entity.ctid);
  6245. }
  6246. returnSuccessMsg("操作成功!");
  6247. return;
  6248. }
  6249. returnErrorMsg("找不到订单记录");
  6250. }
  6251. }
  6252. public void ins_erp_toresponsible()
  6253. {
  6254. if (UrlPostParmsCheck("ctid"))
  6255. {
  6256. string eid = GetPostString("ctid");
  6257. CeErpTradeCell entity = null;
  6258. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6259. if (entity != null)
  6260. {
  6261. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6262. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6263. {
  6264. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6265. return;
  6266. }
  6267. entity.AfterSalePreTime = DateTime.Now;
  6268. //预完成给售后主管审核客户问题直接完成
  6269. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null)
  6270. {
  6271. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6272. {
  6273. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6274. }
  6275. }
  6276. entity.AfterSaleState = 2;
  6277. entity.Update();
  6278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6279. aftersale_data_change(entity.ctid);
  6280. returnSuccessMsg("操作成功!");
  6281. return;
  6282. }
  6283. returnErrorMsg("找不到订单记录");
  6284. }
  6285. }
  6286. public void cancel_erp_aftersaleanddelnew()
  6287. {
  6288. if (UrlPostParmsCheck("ctid"))
  6289. {
  6290. string eid = GetPostString("ctid");
  6291. CeErpTradeCell entity = null;
  6292. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6293. if (entity != null)
  6294. {
  6295. entity.AfterSaleState = 0;
  6296. entity.AfterSaleReason = "";
  6297. entity.AfterSaleMethod = "";
  6298. entity.AfterSaleMemo = "";
  6299. entity.AfterSaleResponsible = "";
  6300. entity.ResponsibleUserId = "";
  6301. entity.DeductFee = 0;
  6302. entity.RefundFee = 0;
  6303. entity.IsArbitrate = 0;
  6304. CeErpTradeResponsible.DelByTid(eid, -1);
  6305. entity.Update();
  6306. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6307. if (after != null)
  6308. {
  6309. if (after.OrderState < 5)
  6310. CeErpTradeCell.DelByCtid("S_" + eid);
  6311. }
  6312. returnSuccessMsg("操作成功!");
  6313. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6314. return;
  6315. }
  6316. returnErrorMsg("找不到订单记录");
  6317. }
  6318. }
  6319. public void get_erp_aftersale_pregather()
  6320. {
  6321. List<string> lw = new List<string>();
  6322. int st = GetInt("st");
  6323. string tid = GetPostString("ctid");
  6324. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6325. string shopname = GetPostString("shopname");
  6326. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6327. string buyernick = GetPostString("buyer_nick");
  6328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6329. string sellermemo = GetPostString("seller_memo");
  6330. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6331. string orderState = GetPostString("orderState");
  6332. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6333. string reason = GetPostString("reason");
  6334. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6335. string method = GetPostString("method");
  6336. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6337. string handler = GetPostString("handler");
  6338. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6339. string handledate1 = GetPostString("handledate1");
  6340. string handledate2 = GetPostString("handledate2");
  6341. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6342. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6343. string supplier = GetPostString("supplier");
  6344. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6345. string responsible = GetPostString("responsibleman");
  6346. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6347. string customer = GetPostString("customer");
  6348. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6349. string design = GetPostString("design");
  6350. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6351. string afterMemoType = GetPostString("aftermemotype");
  6352. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6353. string afterSaleMemo = GetPostString("afterSaleMemo");
  6354. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6355. string afterresult = GetPostString("afterresult");
  6356. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6357. string poscode = CurrentUser.UserPost.Post.Code;
  6358. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6359. {
  6360. string shopid = CurrentUser.User.pemShop;
  6361. lw.Add(string.Format("shopId in ({0})", shopid));
  6362. }
  6363. var mainwhere = string.Join(" and ", lw.ToArray());
  6364. string ro_json = "";
  6365. string type = GetPostString("gather_type");
  6366. if (poscode == "AfterSale")
  6367. {
  6368. //处理中
  6369. if (type == "Handling")
  6370. {
  6371. 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) : ""));
  6372. DataTable dt = null;
  6373. try
  6374. {
  6375. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6376. }
  6377. catch (Exception e)
  6378. {
  6379. dt = new DataTable();
  6380. }
  6381. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6382. return;
  6383. }
  6384. if (type == "Wait")
  6385. {
  6386. //待处理
  6387. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6388. DataTable dt1 = null;
  6389. try
  6390. {
  6391. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6392. }
  6393. catch (Exception e)
  6394. {
  6395. dt1 = new DataTable();
  6396. }
  6397. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6398. return;
  6399. }
  6400. if (type == "back")
  6401. {
  6402. //打回
  6403. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6404. DataTable dt2 = null;
  6405. try
  6406. {
  6407. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6408. }
  6409. catch (Exception e)
  6410. {
  6411. dt2 = new DataTable();
  6412. }
  6413. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6414. return;
  6415. }
  6416. if (type == "preCompletion")
  6417. {
  6418. //预完成
  6419. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6420. DataTable dt3 = null;
  6421. try
  6422. {
  6423. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6424. }
  6425. catch (Exception e)
  6426. {
  6427. dt3 = new DataTable();
  6428. }
  6429. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6430. return;
  6431. }
  6432. if (type == "documentary")
  6433. {
  6434. //跟单中
  6435. 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) : ""));
  6436. DataTable dt4 = null;
  6437. try
  6438. {
  6439. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6440. }
  6441. catch (Exception e)
  6442. {
  6443. dt4 = new DataTable();
  6444. }
  6445. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6446. return;
  6447. }
  6448. if (type == "reBack")
  6449. {
  6450. //被打回
  6451. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6452. DataTable dt1 = null;
  6453. try
  6454. {
  6455. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6456. }
  6457. catch (Exception e)
  6458. {
  6459. dt1 = new DataTable();
  6460. }
  6461. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6462. return;
  6463. }
  6464. }
  6465. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6466. {
  6467. if (type == "puBack")
  6468. {
  6469. //退回
  6470. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6471. DataTable dt = null;
  6472. try
  6473. {
  6474. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6475. }
  6476. catch (Exception e)
  6477. {
  6478. dt = new DataTable();
  6479. }
  6480. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6481. return;
  6482. }
  6483. if (type == "reBack")
  6484. {
  6485. //打回
  6486. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6487. DataTable dt1 = null;
  6488. try
  6489. {
  6490. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6491. }
  6492. catch (Exception e)
  6493. {
  6494. dt1 = new DataTable();
  6495. }
  6496. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6497. return;
  6498. }
  6499. if (type == "examEd")
  6500. {
  6501. //已审核
  6502. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6503. DataTable dt2 = null;
  6504. try
  6505. {
  6506. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6507. }
  6508. catch (Exception e)
  6509. {
  6510. dt2 = new DataTable();
  6511. }
  6512. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6513. return;
  6514. }
  6515. if (type == "waitExam")
  6516. {
  6517. //待审核
  6518. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6519. DataTable dt3 = null;
  6520. try
  6521. {
  6522. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6523. }
  6524. catch (Exception e)
  6525. {
  6526. dt3 = new DataTable();
  6527. }
  6528. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6529. return;
  6530. }
  6531. if (type == "Handling")
  6532. {
  6533. //处理中
  6534. 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) : ""));
  6535. DataTable dt4 = null;
  6536. try
  6537. {
  6538. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6539. }
  6540. catch (Exception e)
  6541. {
  6542. dt4 = new DataTable();
  6543. }
  6544. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6545. return;
  6546. }
  6547. if (type == "Wait")
  6548. {
  6549. //待处理
  6550. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6551. DataTable dt5 = null;
  6552. try
  6553. {
  6554. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6555. }
  6556. catch (Exception e)
  6557. {
  6558. dt5 = new DataTable();
  6559. }
  6560. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6561. return;
  6562. }
  6563. if (type == "documentary")
  6564. {
  6565. //跟单中
  6566. 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) : ""));
  6567. DataTable dt6 = null;
  6568. try
  6569. {
  6570. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6571. }
  6572. catch (Exception e)
  6573. {
  6574. dt6 = new DataTable();
  6575. }
  6576. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6577. return;
  6578. }
  6579. }
  6580. returnSuccess(ro_json);
  6581. }
  6582. public void end_erp_aftersale()
  6583. {
  6584. if (UrlPostParmsCheck("ctid"))
  6585. {
  6586. string eid = GetPostString("ctid");
  6587. CeErpTradeCell entity = null;
  6588. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6589. if (entity != null)
  6590. {
  6591. string stype = GetPostString("stype");
  6592. string typeStr = stype;
  6593. entity.AfterSaleState = 4;
  6594. entity.FinishAfterSaleTime = DateTime.Now;
  6595. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6596. entity.Update();
  6597. ApiVo apiVo = new ApiVo();
  6598. apiVo.orderNumber = entity.ctid;
  6599. apiVo.actionName = "afterOver";
  6600. designHelper.API_WorkCore(apiVo); //afterOver
  6601. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6602. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6603. CeErpSukuraData.createInfo(entity.ctid, 8);
  6604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6605. returnSuccessMsg("操作成功!");
  6606. return;
  6607. }
  6608. returnErrorMsg("找不到订单记录");
  6609. }
  6610. }
  6611. public void ins_erp_finishaftersale()
  6612. {
  6613. if (UrlPostParmsCheck("id"))
  6614. {
  6615. string eid = GetPostString("id");
  6616. CeErpTradeResponsible entity = null;
  6617. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6618. if (entity != null)
  6619. {
  6620. entity.VerifyState = 1;
  6621. entity.VerifyTime = DateTime.Now;
  6622. entity.Update();
  6623. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6624. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6625. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6626. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6627. if (dt.Rows.Count <= 0)
  6628. {
  6629. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6630. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6631. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6632. CeErpSukuraData.createInfo(entity.tid, 8);
  6633. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6634. {
  6635. CeErpDesignerBill.Del(entity.tid);
  6636. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6637. }
  6638. }
  6639. returnSuccessMsg("操作成功!");
  6640. return;
  6641. }
  6642. returnErrorMsg("找不到订单记录");
  6643. }
  6644. }
  6645. public void upd_erp_arbitrateaftersale()
  6646. {
  6647. if (UrlPostParmsCheck("id"))
  6648. {
  6649. string eid = GetPostString("id");
  6650. CeErpTradeResponsible entity = null;
  6651. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6652. if (entity != null)
  6653. {
  6654. entity.IsArbitrate = 1;
  6655. entity.ArbitradeMemo = GetPostString("reason");
  6656. entity.VerifyState = 2;
  6657. entity.Update();
  6658. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6659. if (tradecell != null)
  6660. {
  6661. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6662. tradecell.IsArbitrate = 1;
  6663. tradecell.Update();
  6664. }
  6665. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6666. returnSuccessMsg("操作成功!");
  6667. return;
  6668. }
  6669. returnErrorMsg("找不到订单记录");
  6670. }
  6671. }
  6672. public void upd_erp_backaftersale()
  6673. {
  6674. if (UrlPostParmsCheck("tid"))
  6675. {
  6676. string eid = GetPostString("tid");
  6677. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6678. int backNum = 0;
  6679. if (number != null)
  6680. {
  6681. backNum = number.BackNum;
  6682. }
  6683. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6684. CeErpTradeCell entity = null;
  6685. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6686. if (entity != null)
  6687. {
  6688. entity.AfterSaleBackReason = GetPostString("backreason");
  6689. entity.AfterSaleState = 1;
  6690. entity.AfterSaleSupplierState = 0;
  6691. entity.Update();
  6692. returnSuccessMsg("操作成功!");
  6693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6694. return;
  6695. }
  6696. returnErrorMsg("找不到订单记录");
  6697. }
  6698. }
  6699. public void get_erp_supplieraftersalelist()
  6700. {
  6701. DataStruct dStruct = GetPostStruct();
  6702. List<string> lw = new List<string>();
  6703. string tid = GetPostString("ctid");
  6704. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6705. string shopname = GetPostString("shopname");
  6706. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6707. string buyernick = GetPostString("buyer_nick");
  6708. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6709. string sellermemo = GetPostString("seller_memo");
  6710. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6711. string orderState = GetPostString("orderState");
  6712. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6713. string afterState = GetPostString("afterstate");
  6714. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6715. string date1 = GetPostString("date1");
  6716. string date2 = GetPostString("date2");
  6717. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6718. if (dw.Length > 0) lw.Add(dw);
  6719. string price1 = GetPostString("price1");
  6720. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6721. string price2 = GetPostString("price2");
  6722. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6723. string reason = GetPostString("reason");
  6724. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6725. string method = GetPostString("method");
  6726. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6727. string handledate1 = GetPostString("handledate1");
  6728. string handledate2 = GetPostString("handledate2");
  6729. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6730. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6731. string handler = GetPostString("handler");
  6732. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6733. string afterdate1 = GetPostString("afterdate1");
  6734. string afterdate2 = GetPostString("afterdate2");
  6735. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6736. if (afterDate.Length > 0) lw.Add(afterDate);
  6737. string customer = GetPostString("customer");
  6738. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6739. string design = GetPostString("design");
  6740. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6741. string afterMemoType = GetPostString("aftermemotype");
  6742. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6743. string vstate = GetPostString("vstate");
  6744. if (vstate.Length > 0)
  6745. {
  6746. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6747. }
  6748. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6749. string supplier = GetPostString("supplier");
  6750. int supid = commonHelper.getSupplierIDByName(supplier);
  6751. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6752. string posCode = CurrentUser.UserPost.Post.Code;
  6753. if (posCode == "Supplier")
  6754. {
  6755. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6756. }
  6757. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6758. {
  6759. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6760. }
  6761. else
  6762. {
  6763. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6764. }
  6765. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6766. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6768. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6769. writeGridDataTableJson(dStruct.TotalCount, dt);
  6770. }
  6771. public void upd_erp_supverifyaftersale()
  6772. {
  6773. if (UrlPostParmsCheck("id"))
  6774. {
  6775. string id = GetPostString("id");
  6776. int st = GetPostInt("afterstate");
  6777. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6778. CeErpTradeCell entity = null;
  6779. if (ceErpTradeResponsible != null)
  6780. {
  6781. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6782. }
  6783. string afmemo = GetPostString("supmemo");
  6784. string image = GetPostString("image");
  6785. if (entity != null)
  6786. {
  6787. entity.AfterSaleSupplierState = st;
  6788. entity.AfterSaleSupplierMemo = afmemo;
  6789. entity.AfterSaleSupplierState = st;
  6790. if (st == 1)
  6791. {
  6792. ceErpTradeResponsible.VerifyState = 1;
  6793. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6794. ceErpTradeResponsible.Update();
  6795. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6796. if (isAll)
  6797. {
  6798. entity.AfterSaleState = 4;
  6799. entity.FinishAfterSaleTime = DateTime.Now;
  6800. }
  6801. }
  6802. else
  6803. {
  6804. CeErpTradeResponsible.dateByTid(entity.ctid);
  6805. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6806. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6807. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6808. if (num <= 1)
  6809. {
  6810. entity.AfterSaleState = 1;
  6811. }
  6812. else
  6813. {
  6814. entity.AfterSaleState = 5;
  6815. }
  6816. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6817. if (ceErpTradeAfterSaleExtend != null)
  6818. {
  6819. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6820. if (entity.AfterSaleState == 1)
  6821. {
  6822. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6823. }
  6824. else
  6825. {
  6826. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6827. }
  6828. ceErpTradeAfterSaleExtend.Update();
  6829. }
  6830. else
  6831. {
  6832. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6833. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6834. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6835. if (entity.AfterSaleState == 1)
  6836. {
  6837. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6838. }
  6839. else
  6840. {
  6841. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6842. }
  6843. ceErpTradeAfterSaleExtend.Create();
  6844. }
  6845. }
  6846. if (entity.AfterSaleState == 4)
  6847. {
  6848. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6849. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6850. {
  6851. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6852. }
  6853. ApiVo apiVo = new ApiVo();
  6854. apiVo.orderNumber = entity.ctid;
  6855. apiVo.actionName = "afterOver";
  6856. designHelper.API_WorkCore(apiVo); //afterOver
  6857. }
  6858. entity.Update();
  6859. returnSuccessMsg("操作成功!");
  6860. CeErpSukuraData.createInfo(entity.ctid, 8);
  6861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6862. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6863. return;
  6864. }
  6865. returnErrorMsg("找不到订单记录");
  6866. }
  6867. }
  6868. public void upd_erp_masteraftersale()
  6869. {
  6870. if (UrlPostParmsCheck("id"))
  6871. {
  6872. string id = GetPostString("id");
  6873. int st = GetPostInt("afterstate");
  6874. string afmemo = GetPostString("supmemo");
  6875. string image = GetPostString("image");
  6876. string textResult = GetPostString("textResult");
  6877. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6878. if (ceErpTradeResponsible != null)
  6879. {
  6880. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6881. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6882. ceErpTradeResponsible.Update();
  6883. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6884. if (entity != null)
  6885. {
  6886. entity.AfterSaleSupplierState = st;
  6887. entity.AfterSaleSupplierMemo = afmemo;
  6888. if (st == 1)
  6889. {
  6890. }
  6891. else
  6892. {
  6893. CeErpTradeResponsible.dateByTid(entity.ctid);
  6894. //退回到售后
  6895. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6896. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6897. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6898. if (num <= 1)
  6899. {
  6900. entity.AfterSaleState = 1;
  6901. }
  6902. else
  6903. {
  6904. entity.AfterSaleState = 5;
  6905. }
  6906. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6907. if (ceErpTradeAfterSaleExtend != null)
  6908. {
  6909. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6910. if (entity.AfterSaleState == 1)
  6911. {
  6912. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6913. }
  6914. else
  6915. {
  6916. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6917. }
  6918. ceErpTradeAfterSaleExtend.Update();
  6919. }
  6920. else
  6921. {
  6922. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6923. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6924. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6925. if (entity.AfterSaleState == 1)
  6926. {
  6927. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6928. }
  6929. else
  6930. {
  6931. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6932. }
  6933. ceErpTradeAfterSaleExtend.Create();
  6934. }
  6935. }
  6936. entity.Update();
  6937. returnSuccessMsg("操作成功!");
  6938. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6939. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6940. return;
  6941. }
  6942. }
  6943. returnErrorMsg("找不到订单记录");
  6944. }
  6945. }
  6946. public void upd_erp_personaftersale()
  6947. {
  6948. if (UrlPostParmsCheck("id"))
  6949. {
  6950. string id = GetPostString("id");
  6951. int st = GetPostInt("afterstate");
  6952. string afmemo = GetPostString("supmemo");
  6953. string image = GetPostString("image");
  6954. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6955. if (ceErpTradeResponsible != null)
  6956. {
  6957. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6958. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6959. ceErpTradeResponsible.Update();
  6960. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6961. if (entity != null)
  6962. {
  6963. entity.AfterSaleSupplierMemo = afmemo;
  6964. entity.AfterSaleSupplierState = st;
  6965. if (st == 1)
  6966. {
  6967. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6968. if (isAll)
  6969. {
  6970. entity.AfterSaleState = 4;
  6971. entity.FinishAfterSaleTime = DateTime.Now;
  6972. }
  6973. }
  6974. else
  6975. {
  6976. CeErpTradeResponsible.dateByTid(entity.ctid);
  6977. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6978. if (ceErpTradeAfterSaleExtend != null)
  6979. {
  6980. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6981. ceErpTradeAfterSaleExtend.Update();
  6982. }
  6983. else
  6984. {
  6985. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6986. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6987. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6988. ceErpTradeAfterSaleExtend.Create();
  6989. }
  6990. //退回到主管
  6991. //entity.AfterSaleState = 2;
  6992. }
  6993. if (entity.AfterSaleState == 4)
  6994. {
  6995. ApiVo apiVo = new ApiVo();
  6996. apiVo.orderNumber = entity.ctid;
  6997. apiVo.actionName = "afterOver";
  6998. designHelper.API_WorkCore(apiVo); //afterOver
  6999. }
  7000. entity.Update();
  7001. returnSuccessMsg("操作成功!");
  7002. CeErpSukuraData.createInfo(entity.ctid, 8);
  7003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7004. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7005. return;
  7006. }
  7007. }
  7008. returnErrorMsg("找不到订单记录");
  7009. }
  7010. }
  7011. public void set_erp_supplierrefundtag()
  7012. {
  7013. if (UrlPostParmsCheck("ctid"))
  7014. {
  7015. string eid = GetPostString("ctid");
  7016. CeErpTradeCell entity = null;
  7017. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7018. if (entity != null)
  7019. {
  7020. entity.IsSupplierRefund = GetPostInt("tag");
  7021. entity.Update();
  7022. returnSuccessMsg("操作成功!");
  7023. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7024. return;
  7025. }
  7026. returnErrorMsg("找不到订单记录");
  7027. }
  7028. }
  7029. public void get_erp_refundlist()
  7030. {
  7031. DataStruct dStruct = GetPostStruct();
  7032. List<string> lw = new List<string>();
  7033. string tid = GetPostString("tid");
  7034. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7035. //string rid = GetPostString("refund_id");
  7036. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7037. string shopname = GetPostString("shopname");
  7038. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7039. string buyernick = GetPostString("buyer_nick");
  7040. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7041. string customer = GetPostString("customer");
  7042. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7043. string design = GetPostString("design");
  7044. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7045. string sellermemo = GetPostString("seller_memo");
  7046. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7047. //string date1 = GetPostString("date1");
  7048. //string date2 = GetPostString("date2");
  7049. //string dateType = GetPostString("dateType");
  7050. //if (dateType.Length > 0)
  7051. //{
  7052. // if (dateType == "1001") dateType = "0";
  7053. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7054. // if (searchDT.Count == 2)
  7055. // {
  7056. // date1 = searchDT[0].ToString();
  7057. // date2 = searchDT[1].ToString();
  7058. // }
  7059. //}
  7060. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7061. //if (dw.Length > 0) lw.Add(dw);
  7062. string redate1 = GetPostString("refunddate1");
  7063. string redate2 = GetPostString("refunddate2");
  7064. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7065. if (dwdate.Length > 0) lw.Add(dwdate);
  7066. string price1 = GetPostString("price1");
  7067. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7068. string price2 = GetPostString("price2");
  7069. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7070. string ispartrefund = GetPostString("ispartrefund");
  7071. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7072. string refundState = GetPostString("refundvstate");
  7073. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7074. int st = GetInt("st");
  7075. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7076. {
  7077. string responsible = GetPostString("responsibleman");
  7078. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7079. lw.Add(string.Format("RefundState>={0}", st));
  7080. string code = CurrentUser.UserPost.Post.Code;
  7081. if (code == "CustomerService")
  7082. {
  7083. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7084. }
  7085. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7086. {
  7087. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7088. }
  7089. else if (code == "Place" || code == "PlaceMr")
  7090. {
  7091. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7092. }
  7093. dStruct.Order = "RefundState asc,created desc";
  7094. }
  7095. else if (st == 10)
  7096. {
  7097. string responsible = GetPostString("responsibleman");
  7098. if (responsible == "空白")
  7099. {
  7100. lw.Add(string.Format("ResponsibleUserName = ''"));
  7101. }
  7102. else if (responsible.Length > 0)
  7103. {
  7104. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7105. }
  7106. lw.Add(string.Format("RefundState>=0"));
  7107. dStruct.Order = "created desc";
  7108. }
  7109. else
  7110. {
  7111. string responsible = GetPostString("responsibleman");
  7112. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7113. lw.Add(string.Format("RefundState={0}", st));
  7114. dStruct.Order = "created desc";
  7115. }
  7116. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7117. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7118. dt.Columns.Add("refund_fees");
  7119. foreach (DataRow dr in dt.Rows)
  7120. {
  7121. String status = dr["status"].ToString();
  7122. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7123. {
  7124. dr["refund_fees"] = dr["refund_fee"];
  7125. }
  7126. else
  7127. {
  7128. dr["refund_fees"] = "0.0";
  7129. }
  7130. }
  7131. writeGridDataTableJson(dStruct.TotalCount, dt);
  7132. }
  7133. public void handle_erp_refundtag()
  7134. {
  7135. if (UrlPostParmsCheck("refund_id"))
  7136. {
  7137. string eid = GetPostString("refund_id");
  7138. string respMan = GetPostString("ResponsibleName");
  7139. if (respMan.Length <= 0)
  7140. {
  7141. returnErrorMsg("责任人不能为空");
  7142. return;
  7143. }
  7144. CeErpTradeRefund entity = null;
  7145. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7146. if (entity != null)
  7147. {
  7148. entity.ResponsibleUserName = respMan;
  7149. string userid = GetPostString("ResponsibleUserId");
  7150. if (userid.Length > 0)
  7151. {
  7152. entity.ResponsibleUserId = userid;
  7153. }
  7154. entity.Memo = GetPostString("Memo");
  7155. if (respMan.IndexOf("客服") != -1 ||
  7156. respMan.IndexOf("设计师") != -1 ||
  7157. respMan.IndexOf("下单员") != -1)
  7158. {
  7159. entity.RefundState = 2;
  7160. }
  7161. else
  7162. {
  7163. entity.RefundState = 3;
  7164. }
  7165. entity.modified = DateTime.Now;
  7166. entity.Update();
  7167. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7168. returnSuccessMsg("操作成功!");
  7169. return;
  7170. }
  7171. returnErrorMsg("找不到订单记录");
  7172. }
  7173. }
  7174. public void upd_erp_refundverify()
  7175. {
  7176. if (UrlPostParmsCheck("refund_id"))
  7177. {
  7178. string eid = GetPostString("refund_id");
  7179. CeErpTradeRefund entity = null;
  7180. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7181. if (entity != null)
  7182. {
  7183. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7184. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7185. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7186. {
  7187. entity.RefundState = 2;
  7188. }
  7189. else
  7190. {
  7191. entity.RefundState = 3;
  7192. }
  7193. entity.Update();
  7194. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7195. returnSuccessMsg("操作成功!");
  7196. return;
  7197. }
  7198. returnErrorMsg("找不到订单记录");
  7199. }
  7200. }
  7201. public void upd_erp_refundapprove()
  7202. {
  7203. if (UrlPostParmsCheck("refund_id"))
  7204. {
  7205. string eid = GetPostString("refund_id");
  7206. CeErpTradeRefund entity = null;
  7207. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7208. if (entity != null)
  7209. {
  7210. int apr = GetPostInt("approve");
  7211. if (apr == 0)
  7212. {
  7213. entity.RefundState = 1;
  7214. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7215. }
  7216. else if (apr == 1)
  7217. {
  7218. entity.RefundState = 3;
  7219. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7220. }
  7221. entity.modified = DateTime.Now;
  7222. entity.Update();
  7223. returnSuccessMsg("操作成功!");
  7224. return;
  7225. }
  7226. returnErrorMsg("找不到订单记录");
  7227. }
  7228. }
  7229. public void get_erp_billlist()
  7230. {
  7231. DataStruct dStruct = GetPostStruct();
  7232. List<string> lw = new List<string>();
  7233. string title = GetPostString("title");
  7234. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7235. string tid = GetPostString("tid");
  7236. string tids = GetPostString("tids");
  7237. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7238. if (tids.Length > 0)
  7239. {
  7240. tids = "'" + tids + "'";
  7241. tids = tids.Replace(",", "','");
  7242. lw.Add(string.Format("tid in ({0})", tids));
  7243. }
  7244. string shopname = GetPostString("shopname");
  7245. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7246. string buyernick = GetPostString("buyer_nick");
  7247. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7248. string customer = GetPostString("customer");
  7249. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7250. string date1 = GetPostString("date1");
  7251. string date2 = GetPostString("date2");
  7252. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7253. if (dw.Length > 0) lw.Add(dw);
  7254. string price1 = GetPostString("price1");
  7255. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7256. string price2 = GetPostString("price2");
  7257. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7258. string returndate1 = GetPostString("returndate1");
  7259. string returndate2 = GetPostString("returndate2");
  7260. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7261. if (dw1.Length > 0) lw.Add(dw1);
  7262. string billtype = GetPostString("billtype");
  7263. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7264. string billstate = GetPostString("billstate");
  7265. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7266. string usershop = CurrentUser.User.pemShop;
  7267. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7268. dStruct.Order = "createTime desc";
  7269. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7270. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7271. //foreach (DataRow dr in dt.Rows)
  7272. //{
  7273. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7274. //}
  7275. writeGridDataTableJson(dStruct.TotalCount, dt);
  7276. }
  7277. public void modify_erp_billinfo()
  7278. {
  7279. if (UrlPostParmsCheck("ID"))
  7280. {
  7281. string eid = GetPostString("ID");
  7282. CeErpBill bill_entity = null;
  7283. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7284. if (bill_entity != null)
  7285. {
  7286. bill_entity.tid = GetPostString("tid");
  7287. bill_entity.title = GetPostString("title");
  7288. bill_entity.tax = GetPostString("tax");
  7289. bill_entity.bank = GetPostString("bank");
  7290. bill_entity.bankac = GetPostString("bankac");
  7291. bill_entity.address = GetPostString("address");
  7292. bill_entity.phone = GetPostString("phone");
  7293. bill_entity.price = GetPostString("price");
  7294. bill_entity.productId = GetPostInt("ProductName");
  7295. bill_entity.num = GetPostInt("num");
  7296. bill_entity.unit = GetPostString("unit");
  7297. bill_entity.type = GetPostString("type");
  7298. bill_entity.sendType = GetPostString("SendType");
  7299. bill_entity.email = GetPostString("email");
  7300. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7301. bill_entity.shopName = GetPostString("ShopName");
  7302. bill_entity.applymemo = GetPostString("applymemo");
  7303. bill_entity.modifyTime = DateTime.Now;
  7304. bill_entity.createTime = DateTime.Now;
  7305. bill_entity.state = 0;
  7306. bill_entity.Update();
  7307. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7308. returnSuccessMsg("发票修改成功!");
  7309. return;
  7310. }
  7311. returnErrorMsg("找不到对应记录");
  7312. }
  7313. }
  7314. public void set_erp_invoicing()
  7315. {
  7316. if (UrlPostParmsCheck("id"))
  7317. {
  7318. try
  7319. {
  7320. string eid = GetPostString("id");
  7321. CeErpBill bill_entity = null;
  7322. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7323. if (bill_entity != null)
  7324. {
  7325. int ComId = GetPostInt("ComId");
  7326. //string memo = GetPostString("Memo");
  7327. int allInfo = GetPostInt("allinfo");
  7328. string clert = CurrentUser.User.Name;
  7329. //string detailValue = GetPostString("detailvalue");
  7330. string billId = bill_entity.billOrderId;
  7331. string[] billIdList = billId.Split(',');
  7332. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7333. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7334. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7335. {
  7336. billCount += 1;
  7337. }
  7338. if (billId.Length <= 0 || billIdList.Length != billCount)
  7339. {
  7340. bill_entity.billOrderId = "";
  7341. string prebill = "ltb";
  7342. for (int idx = 1; idx <= billCount; idx++)
  7343. {
  7344. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7345. string billoid = prebill + idx + dtstr;
  7346. bill_entity.billOrderId += billoid;
  7347. if (idx < billCount)
  7348. {
  7349. bill_entity.billOrderId += ",";
  7350. }
  7351. }
  7352. }
  7353. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7354. if (bill_entity.state == 5)
  7355. {
  7356. string errMsg = bill_entity.failerror;
  7357. string[] errlist = errMsg.Split('|');
  7358. string[] errTags = new string[errlist.Length];
  7359. for (int itag = 0; itag < errlist.Length; itag++)
  7360. {
  7361. if (errlist[itag].Length <= 0) continue;
  7362. errTags[itag] = errlist[itag].Split('&')[0];
  7363. }
  7364. for (int iii = 0; iii < errTags.Length; iii++)
  7365. {
  7366. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7367. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7368. if (billOrderList.Length >= erroBillOrderTag)
  7369. {
  7370. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7371. if (needModifyBillId.Length <= 19)
  7372. {
  7373. needModifyBillId = needModifyBillId + "1";
  7374. }
  7375. else
  7376. {
  7377. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7378. last = last + 1;
  7379. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7380. }
  7381. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7382. }
  7383. }
  7384. }
  7385. bool isHaveBillSucces = false;
  7386. string totalRes = "";
  7387. bill_entity.failerror = "";
  7388. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7389. {
  7390. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7391. totalRes += res;
  7392. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7393. {
  7394. isHaveBillSucces = true;
  7395. bill_entity.comId = ComId;
  7396. bill_entity.state = 1;
  7397. bill_entity.executeTime = DateTime.Now;
  7398. bill_entity.executeUser = clert;
  7399. }
  7400. else
  7401. {
  7402. bill_entity.state = 5;
  7403. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7404. }
  7405. }
  7406. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7407. bill_entity.Update();
  7408. if (isHaveBillSucces)
  7409. {
  7410. StringBuilder sql = new StringBuilder();
  7411. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7412. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7413. }
  7414. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7415. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7416. {
  7417. returnErrorMsg("开票失败");
  7418. }
  7419. else
  7420. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7421. return;
  7422. }
  7423. returnErrorMsg("找不到对应记录");
  7424. }
  7425. catch (Exception ex)
  7426. {
  7427. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7428. returnErrorMsg("操作失败");
  7429. }
  7430. }
  7431. }
  7432. public void get_erp_invoicing_back()
  7433. {
  7434. if (UrlPostParmsCheck("id"))
  7435. {
  7436. try
  7437. {
  7438. string id = GetPostString("id");
  7439. CeErpBill entiy = CeErpBill.Get(id);
  7440. if (entiy != null)
  7441. {
  7442. if (entiy.state == 0)
  7443. {
  7444. returnErrorMsg("发票还未开具");
  7445. return;
  7446. }
  7447. string[] billOrderList = entiy.billOrderId.Split(',');
  7448. int iTag = 0;
  7449. entiy.fplsh = "";
  7450. entiy.fpdm = "";
  7451. entiy.fphm = "";
  7452. foreach (string billOrderId in billOrderList)
  7453. {
  7454. iTag++;
  7455. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7456. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7457. {
  7458. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7459. try
  7460. {
  7461. Invoicing_get_response_Obj iObj = null;
  7462. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7463. if (iObj != null)
  7464. {
  7465. entiy.state = 2;
  7466. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7467. entiy.fpdm += iObj.list[0].c_fpdm;
  7468. entiy.fphm += iObj.list[0].c_fphm;
  7469. if (iTag < billOrderList.Length)
  7470. {
  7471. entiy.fplsh += ",";
  7472. entiy.fpdm += ",";
  7473. entiy.fphm += ",";
  7474. }
  7475. entiy.Update();
  7476. }
  7477. StringBuilder sql = new StringBuilder();
  7478. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7479. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7480. returnSuccessMsg("开票成功");
  7481. }
  7482. catch (Exception ex)
  7483. {
  7484. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7485. }
  7486. return;
  7487. }
  7488. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7489. {
  7490. var res_obj = new
  7491. {
  7492. data = "开票中"
  7493. };
  7494. string ro_json = JsonConvert.SerializeObject(res_obj);
  7495. returnSuccess(ro_json);
  7496. return;
  7497. }
  7498. else
  7499. {
  7500. int eidx = res.IndexOf("c_resultmsg");
  7501. int lidx = res.IndexOf("c_status");
  7502. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7503. entiy.state = 5;
  7504. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7505. entiy.Update();
  7506. returnErrorMsg("开票失败");
  7507. return;
  7508. }
  7509. }
  7510. }
  7511. }
  7512. catch (Exception ex)
  7513. {
  7514. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7515. }
  7516. return;
  7517. }
  7518. }
  7519. public void get_erp_invoicing()
  7520. {
  7521. if (UrlPostParmsCheck("id"))
  7522. {
  7523. try
  7524. {
  7525. string id = GetPostString("id");
  7526. CeErpBill entiy = CeErpBill.Get(id);
  7527. if (entiy != null)
  7528. {
  7529. if (entiy.state == 0)
  7530. {
  7531. returnErrorMsg("发票还未开具");
  7532. return;
  7533. }
  7534. if (entiy.sendType == "纸质发票")
  7535. {
  7536. if (entiy.img.Length <= 0)
  7537. {
  7538. returnErrorMsg("查无纸质发票");
  7539. return;
  7540. }
  7541. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7542. returnSuccess(returnres);
  7543. return;
  7544. }
  7545. string[] billOrderList = entiy.billOrderId.Split(',');
  7546. int iTag = 0;
  7547. string fpUrl = "";
  7548. entiy.fplsh = "";
  7549. entiy.fpdm = "";
  7550. entiy.fphm = "";
  7551. foreach (string billOrderId in billOrderList)
  7552. {
  7553. iTag++;
  7554. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7555. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7556. {
  7557. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7558. Invoicing_get_response_Obj iObj = null;
  7559. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7560. if (iObj != null)
  7561. {
  7562. //entiy.state = 2;
  7563. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7564. entiy.fpdm += iObj.list[0].c_fpdm;
  7565. entiy.fphm += iObj.list[0].c_fphm;
  7566. if (iTag < billOrderList.Length)
  7567. {
  7568. entiy.fplsh += ",";
  7569. entiy.fpdm += ",";
  7570. entiy.fphm += ",";
  7571. }
  7572. entiy.Update();
  7573. fpUrl += iObj.list[0].c_url + ",";
  7574. }
  7575. //returnSuccess(res);
  7576. StringBuilder sql = new StringBuilder();
  7577. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7578. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7579. }
  7580. else
  7581. {
  7582. int eidx = res.IndexOf("c_resultmsg");
  7583. //int lidx = res.IndexOf("c_status");
  7584. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7585. //开票失败
  7586. entiy.state = 5;
  7587. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7588. entiy.Update();
  7589. returnErrorMsg("开票失败");
  7590. return;
  7591. }
  7592. }
  7593. var returnObj = new
  7594. {
  7595. data = fpUrl
  7596. };
  7597. string ro_json = JsonConvert.SerializeObject(returnObj);
  7598. returnSuccess(ro_json);
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7604. }
  7605. return;
  7606. }
  7607. }
  7608. public void save_erp_billimg()
  7609. {
  7610. if (UrlPostParmsCheck("id"))
  7611. {
  7612. string eid = GetPostString("id");
  7613. CeErpBill bill_entity = null;
  7614. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7615. if (bill_entity != null)
  7616. {
  7617. bill_entity.img = GetPostString("img");
  7618. bill_entity.executeTime = DateTime.Now;
  7619. bill_entity.state = 2;
  7620. bill_entity.Update();
  7621. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7622. returnSuccessMsg("保存成功");
  7623. }
  7624. return;
  7625. }
  7626. }
  7627. public void upd_erp_billreturnback()
  7628. {
  7629. if (UrlPostParmsCheck("id"))
  7630. {
  7631. int eid = GetPostInt("id");
  7632. CeErpBill bill_entity = null;
  7633. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7634. if (bill_entity != null)
  7635. {
  7636. bill_entity.state = 3;
  7637. bill_entity.returnReason = GetPostString("reason");
  7638. bill_entity.Update();
  7639. returnSuccessMsg("驳回成功!");
  7640. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7641. }
  7642. return;
  7643. }
  7644. }
  7645. public void cancel_erp_bill()
  7646. {
  7647. if (UrlPostParmsCheck("id"))
  7648. {
  7649. int eid = GetPostInt("id");
  7650. int detailValue = GetPostInt("detailvalue");
  7651. CeErpBill bill_entity = null;
  7652. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7653. string cres = "";
  7654. string gres = "";
  7655. if (bill_entity != null)
  7656. {
  7657. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7658. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7659. {
  7660. int iTag = 0;
  7661. bill_entity.fplsh = "";
  7662. bill_entity.fpdm = "";
  7663. bill_entity.fphm = "";
  7664. foreach (string billOrderId in billOrderList)
  7665. {
  7666. iTag++;
  7667. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7668. if (gres.IndexOf("success") != -1)
  7669. {
  7670. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7671. Invoicing_get_response_Obj iObj = null;
  7672. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7673. if (iObj != null)
  7674. {
  7675. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7676. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7677. bill_entity.fphm += iObj.list[0].c_fphm;
  7678. if (iTag < billOrderList.Length)
  7679. {
  7680. bill_entity.fplsh += ",";
  7681. bill_entity.fpdm += ",";
  7682. bill_entity.fphm += ",";
  7683. }
  7684. bill_entity.Update();
  7685. }
  7686. }
  7687. else
  7688. {
  7689. returnErrorMsg(gres);
  7690. return;
  7691. }
  7692. }
  7693. }
  7694. if (bill_entity.sendType == "纸质发票")
  7695. {
  7696. //作废
  7697. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7698. //if (DateTime.Now.Month == extime.Month)
  7699. //{
  7700. //cres = taobaoHelper.cancel_invoicing(eid);
  7701. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7702. //{
  7703. bill_entity.state = 4;//已作废
  7704. bill_entity.Update();
  7705. returnSuccessMsg("发票已作废");
  7706. return;
  7707. //}
  7708. //else
  7709. //{
  7710. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7711. // bill_entity.Update();
  7712. // returnErrorMsg(cres);
  7713. // return;
  7714. //}
  7715. //}
  7716. //else
  7717. //{
  7718. // returnErrorMsg("纸质发票只能作废本月的发票");
  7719. // return;
  7720. //}
  7721. }
  7722. //红冲
  7723. int redTag = 0;
  7724. string[] fpdmList = bill_entity.fpdm.Split(',');
  7725. string[] fphmList = bill_entity.fphm.Split(',');
  7726. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7727. {
  7728. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7729. return;
  7730. }
  7731. foreach (string billOrderId in billOrderList)
  7732. {
  7733. redTag++;
  7734. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7735. cres += onecres;
  7736. cres += ",";
  7737. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7738. {
  7739. bill_entity.state = 4;//已作废
  7740. //bill_entity.Update();
  7741. //returnSuccessMsg("发票已红冲");
  7742. }
  7743. else if (onecres.IndexOf("重复冲红") != -1)
  7744. {
  7745. bill_entity.state = 4;//已作废
  7746. //bill_entity.Update();
  7747. //returnSuccessMsg("发票已红冲");
  7748. }
  7749. else
  7750. {
  7751. string errmsg = commonHelper.KeepChinese(onecres);
  7752. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7753. }
  7754. }
  7755. bill_entity.Update();
  7756. if (cres.IndexOf("失败") != -1)
  7757. returnErrorMsg("红冲失败");
  7758. else
  7759. returnSuccessMsg("发票已红冲");
  7760. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7761. return;
  7762. }
  7763. return;
  7764. }
  7765. }
  7766. public void del_erp_billorder()
  7767. {
  7768. if (UrlPostParmsCheck("id"))
  7769. {
  7770. string eid = GetPostString("id");
  7771. CeErpBill.Del(eid);
  7772. CeErpBill bill = CeErpBill.Get(eid);
  7773. if (bill != null)
  7774. {
  7775. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7776. }
  7777. returnSuccessMsg("删除成功");
  7778. }
  7779. }
  7780. public void finish_erp_bill()
  7781. {
  7782. if (UrlPostParmsCheck("ids"))
  7783. {
  7784. string eids = GetPostString("ids");
  7785. string[] list = eids.Split(',');
  7786. foreach (string eid in list)
  7787. {
  7788. CeErpBill bill = CeErpBill.Get(eid);
  7789. if (bill != null)
  7790. {
  7791. bill.state = 2;
  7792. bill.Update();
  7793. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7794. }
  7795. }
  7796. returnSuccessMsg("操作成功");
  7797. }
  7798. }
  7799. public void get_erp_returncash()
  7800. {
  7801. DataStruct dStruct = GetPostStruct();
  7802. List<string> lw = new List<string>();
  7803. string tid = GetPostString("tid");
  7804. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7805. string shopname = GetPostString("shopname");
  7806. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7807. string buyernick = GetPostString("buyer_nick");
  7808. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7809. string customer = GetPostString("customer");
  7810. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7811. string returndate1 = GetPostString("returndate1");
  7812. string returndate2 = GetPostString("returndate2");
  7813. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7814. if (dw.Length > 0) lw.Add(dw);
  7815. string finishDate1 = GetPostString("finishdate1");
  7816. string finishDate2 = GetPostString("finishdate2");
  7817. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7818. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7819. string returntype = GetPostString("returntype");
  7820. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7821. string returnvstate = GetPostString("returnvstate");
  7822. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7823. dStruct.Order = "created desc";
  7824. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7825. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7826. writeGridDataTableJson(dStruct.TotalCount, dt);
  7827. }
  7828. public void get_erp_staygoods()
  7829. {
  7830. DataStruct dStruct = GetPostStruct();
  7831. List<string> lw = new List<string>();
  7832. string tid = GetPostString("tid");
  7833. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7834. string shopname = GetPostString("shopname");
  7835. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7836. string wangwang = GetPostString("wangwang");
  7837. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7838. string customer = GetPostString("customer");
  7839. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7840. string returndate1 = GetPostString("returndate1");
  7841. string returndate2 = GetPostString("returndate2");
  7842. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7843. if (dw.Length > 0) lw.Add(dw);
  7844. string finishDate1 = GetPostString("finishdate1");
  7845. string finishDate2 = GetPostString("finishdate2");
  7846. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7847. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7848. string returnvstate = GetPostString("returnvstate");
  7849. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7850. string persuadetype = GetPostString("persuadetype");
  7851. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7852. string customerOrg = GetPostString("customerOrg");
  7853. if (customerOrg.Length > 0)
  7854. {
  7855. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7856. }
  7857. dStruct.Order = "creata_time desc";
  7858. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7859. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7860. writeGridDataTableJson(dStruct.TotalCount, dt);
  7861. }
  7862. public void upd_erp_staygoods()
  7863. {
  7864. if (UrlPostParmsCheck("id"))
  7865. {
  7866. int eid = GetPostInt("id");
  7867. CeErpStayGoods entity = null;
  7868. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7869. if (entity != null)
  7870. {
  7871. entity.audit_type = 1;
  7872. entity.audit_time = DateTime.Now;
  7873. entity.audit_u_id = CurrentUser.UserID;
  7874. entity.audit_u_name = CurrentUser.UserName;
  7875. entity.Update();
  7876. returnSuccessMsg("审核成功!");
  7877. return;
  7878. }
  7879. returnErrorMsg("找不到订单记录");
  7880. }
  7881. }
  7882. public void upd_erp_stayGoodsback()
  7883. {
  7884. if (UrlPostParmsCheck("id"))
  7885. {
  7886. int eid = GetPostInt("id");
  7887. CeErpStayGoods entity = null;
  7888. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7889. if (entity != null)
  7890. {
  7891. entity.audit_text = GetPostString("reason");
  7892. entity.audit_type = 2;
  7893. entity.audit_time = DateTime.Now;
  7894. entity.audit_u_id = CurrentUser.UserID;
  7895. entity.audit_u_name = CurrentUser.UserName;
  7896. entity.Update();
  7897. returnSuccessMsg("退回成功!");
  7898. return;
  7899. }
  7900. returnErrorMsg("找不到订单记录");
  7901. }
  7902. }
  7903. public void upd_erp_returncashverify()
  7904. {
  7905. if (UrlPostParmsCheck("ID"))
  7906. {
  7907. int eid = GetPostInt("ID");
  7908. CeErpReturnCash entity = null;
  7909. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7910. if (entity != null)
  7911. {
  7912. entity.cashstate = 1;
  7913. entity.verifytime = DateTime.Now;
  7914. entity.verifyuserid = CurrentUser.UserID;
  7915. entity.Update();
  7916. returnSuccessMsg("审核成功!");
  7917. return;
  7918. }
  7919. returnErrorMsg("找不到订单记录");
  7920. }
  7921. }
  7922. public void upd_all_erp_returncashverify()
  7923. {
  7924. if (UrlPostParmsCheck("ID"))
  7925. {
  7926. String[] list = GetPostString("ID").Split(',');
  7927. CeErpReturnCash entity = null;
  7928. for (int i = 0; i < list.Length; i++)
  7929. {
  7930. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  7931. if (entity != null)
  7932. {
  7933. if (entity.cashstate == 1)
  7934. {
  7935. returnErrorMsg("已审核过的订单不需要在审核!");
  7936. return;
  7937. }
  7938. entity.cashstate = 1;
  7939. entity.verifytime = DateTime.Now;
  7940. entity.verifyuserid = CurrentUser.UserID;
  7941. entity.Update();
  7942. }
  7943. }
  7944. returnSuccessMsg("审核成功!");
  7945. return;
  7946. }
  7947. }
  7948. public void upd_erp_returncashback()
  7949. {
  7950. if (UrlPostParmsCheck("ID"))
  7951. {
  7952. int eid = GetPostInt("ID");
  7953. CeErpReturnCash entity = null;
  7954. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7955. if (entity != null)
  7956. {
  7957. entity.backreason = GetPostString("reason");
  7958. entity.cashstate = 2;
  7959. entity.verifytime = DateTime.Now;
  7960. entity.verifyuserid = CurrentUser.UserID;
  7961. entity.Update();
  7962. returnSuccessMsg("退回成功!");
  7963. return;
  7964. }
  7965. returnErrorMsg("找不到订单记录");
  7966. }
  7967. }
  7968. public void upd_erp_returnprice()
  7969. {
  7970. if (UrlPostParmsCheck("ID"))
  7971. {
  7972. int eid = GetPostInt("ID");
  7973. CeErpReturnCash entity = null;
  7974. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7975. if (entity != null)
  7976. {
  7977. if (entity.cashstate == 1)
  7978. {
  7979. returnErrorMsg("审核通过了不能改");
  7980. return;
  7981. }
  7982. entity.returnprice = GetPostDouble("returnprice");
  7983. entity.Update();
  7984. returnSuccessMsg("修改成功!");
  7985. return;
  7986. }
  7987. returnErrorMsg("找不到订单记录");
  7988. }
  7989. }
  7990. public void del_erp_returncash()
  7991. {
  7992. if (UrlPostParmsCheck("ID"))
  7993. {
  7994. int eid = GetPostInt("ID");
  7995. CeErpReturnCash.Del(eid);
  7996. returnSuccessMsg("操作成功");
  7997. return;
  7998. }
  7999. }
  8000. public void test_for_do_sql()
  8001. {
  8002. string sql = GetPostString("sqlstr");
  8003. if (sql.Length > 0)
  8004. {
  8005. try
  8006. {
  8007. DbHelper.DbConn.ExecuteNonQuery(sql);
  8008. var res_obj = new
  8009. {
  8010. data = "成功",
  8011. };
  8012. string ro_json = JsonConvert.SerializeObject(res_obj);
  8013. returnSuccess(ro_json);
  8014. }
  8015. catch (Exception ex)
  8016. {
  8017. var res_obj = new
  8018. {
  8019. data = ex.Message,
  8020. };
  8021. string ro_json = JsonConvert.SerializeObject(res_obj);
  8022. returnSuccess(ro_json);
  8023. }
  8024. }
  8025. }
  8026. public void get_user_info()
  8027. {
  8028. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8029. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8030. }
  8031. public void get_total_data()
  8032. {
  8033. int userId = CurrentUser.UserID;
  8034. string sql = "";
  8035. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8036. {
  8037. 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);
  8038. }
  8039. else
  8040. {
  8041. 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 " +
  8042. "(select ID from CE_ErpUser where ID = {0}) d " +
  8043. "left join " +
  8044. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8045. ") a on d.ID = a.id left join " +
  8046. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8047. ") b on a.id = b.id1 left join" +
  8048. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8049. ") c on a.id = c.id2;", userId);
  8050. }
  8051. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8052. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8053. }
  8054. public void get_date_area_total_data2()
  8055. {
  8056. int userId = CurrentUser.UserID;
  8057. string date_type = GetPostString("timetype");
  8058. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8059. string sql = "";
  8060. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8061. {
  8062. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8063. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8064. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8065. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8066. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8067. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8068. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8069. ") a on e.ID = a.id left join " +
  8070. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8071. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8072. ") b on a.id = b.id1 " +
  8073. "left join " +
  8074. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8075. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8076. ") c on a.id = c.id2 " +
  8077. "left join " +
  8078. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8079. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8080. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8081. }
  8082. else
  8083. {
  8084. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8085. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8086. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8087. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8088. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8089. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8090. ") a on e.ID = a.id left join " +
  8091. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8092. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8093. ") c on a.id = c.id2 " +
  8094. "left join " +
  8095. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8096. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8097. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8098. }
  8099. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8100. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8101. }
  8102. public void get_date_area_total_data()
  8103. {
  8104. int userId = CurrentUser.UserID;
  8105. string date_type = GetPostString("timetype");
  8106. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8107. string date1 = searchDT[0].ToString();
  8108. string date2 = searchDT[1].ToString();
  8109. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8110. {
  8111. SqlParameter[] sqlParameter ={
  8112. new SqlParameter("@userId", SqlDbType.Int,4),
  8113. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8114. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8115. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8116. };
  8117. sqlParameter[0].Value = userId;
  8118. sqlParameter[1].Value = date1;
  8119. sqlParameter[2].Value = date2;
  8120. sqlParameter[3].Direction = ParameterDirection.Output;
  8121. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8122. string res = sqlParameter[3].Value.ToString();
  8123. var res_obj = new
  8124. {
  8125. data = res
  8126. };
  8127. string ro_json = JsonConvert.SerializeObject(res_obj);
  8128. returnSuccess(ro_json);
  8129. }
  8130. else
  8131. {
  8132. SqlParameter[] sqlParameter ={
  8133. new SqlParameter("@userId", SqlDbType.Int,4),
  8134. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8135. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8136. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8137. };
  8138. sqlParameter[0].Value = userId;
  8139. sqlParameter[1].Value = date1;
  8140. sqlParameter[2].Value = date2;
  8141. sqlParameter[3].Direction = ParameterDirection.Output;
  8142. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8143. string res = sqlParameter[3].Value.ToString();
  8144. var res_obj = new
  8145. {
  8146. data = res
  8147. };
  8148. string ro_json = JsonConvert.SerializeObject(res_obj);
  8149. returnSuccess(ro_json);
  8150. }
  8151. //writeGridDataViewJson(dt.Rows.Count, dv);
  8152. }
  8153. public void get_order_list()
  8154. {
  8155. string strFields = GetPostString("paraFields");
  8156. string strOrder = GetPostString("paraOrder");
  8157. string strWhere = GetPostString("paraWhere");
  8158. string strPageSize = GetPostString("paraPageSize");
  8159. DataStruct dStruct = GetPostStruct();
  8160. dStruct.PageSize = int.Parse(strPageSize);
  8161. dStruct.Fileds = strFields;
  8162. dStruct.Order = strOrder;
  8163. dStruct.MainWhere = strWhere;
  8164. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8165. writeGridDataTableJson(dStruct.TotalCount, dt);
  8166. }
  8167. ////获取待开始订单列表
  8168. //public void get_wait_design_order_list()
  8169. //{
  8170. // string date_type = GetPostString("date_type");
  8171. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8172. // DataStruct dStruct = GetPostStruct();
  8173. // dStruct.PageSize = 1000;
  8174. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8175. // List<string> lw = new List<string>();
  8176. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8177. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8178. // dStruct.Order = "WaitDesignTime asc";
  8179. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8180. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8181. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8182. //}
  8183. //获取完成单量排名
  8184. public void get_finish_order_count_ranking()
  8185. {
  8186. /* string date_type = GetPostString("date_type");
  8187. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8188. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8189. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8190. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8191. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8192. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8193. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8194. writeGridDataTableJson(0, new DataTable());
  8195. }
  8196. public void get_finish_order_amount_ranking()
  8197. {
  8198. /*string date_type = GetPostString("date_type");
  8199. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8200. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8201. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8202. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8203. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8204. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8205. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8206. writeGridDataTableJson(0, new DataTable());
  8207. }
  8208. public void get_finish_refund_count_ranking()
  8209. {
  8210. string date_type = GetPostString("date_type");
  8211. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8212. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8213. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8214. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8215. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8216. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8217. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8218. writeGridDataTableJson(dt.Rows.Count, dt);
  8219. }
  8220. public void get_finish_refund_amount_ranking()
  8221. {
  8222. string date_type = GetPostString("date_type");
  8223. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8224. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8225. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8226. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8227. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8228. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8229. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8230. writeGridDataTableJson(dt.Rows.Count, dt);
  8231. }
  8232. public void set_erp_finishorder_director()
  8233. {
  8234. if (UrlPostParmsCheck("ctid"))
  8235. {
  8236. string eid = GetPostString("ctid");
  8237. CeErpTradeCell entity = null;
  8238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8239. if (entity != null)
  8240. {
  8241. entity.OrderState = 8;
  8242. entity.Update();
  8243. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8244. returnSuccessMsg("操作成功!");
  8245. return;
  8246. }
  8247. returnErrorMsg("找不到记录");
  8248. }
  8249. }
  8250. public void get_erp_placeregistlist()
  8251. {
  8252. DataStruct dStruct = GetPostStruct();
  8253. List<string> lw = new List<string>();
  8254. string outsid = GetPostString("outsid");
  8255. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8256. string memo = GetPostString("memo");
  8257. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8258. string filename = GetPostString("filename");
  8259. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8260. string islate = GetPostString("islate");
  8261. if (islate.Length > 0)
  8262. {
  8263. if (islate == "1")
  8264. lw.Add(string.Format("OutLate>0"));
  8265. else
  8266. lw.Add(string.Format("OutLate=0"));
  8267. }
  8268. string placedate1 = GetPostString("placedate1");
  8269. string placedate2 = GetPostString("placedate2");
  8270. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8271. if (dw.Length > 0) lw.Add(dw);
  8272. string deliveryDate1 = GetPostString("deliverydate1");
  8273. string deliveryDate2 = GetPostString("deliverydate2");
  8274. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8275. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8276. dStruct.Order = "ID desc";
  8277. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8278. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8279. writeGridDataTableJson(dStruct.TotalCount, dt);
  8280. }
  8281. public void ins_erp_placeregist()
  8282. {
  8283. if (UrlPostParmsCheck("id"))
  8284. {
  8285. string eid = GetPostString("id");
  8286. CeErpPlaceRegister entity = null;
  8287. if (eid == "0")//新增
  8288. {
  8289. entity = new CeErpPlaceRegister();
  8290. string xdTime = GetPostString("placeTime");
  8291. if (xdTime.Length > 0)
  8292. {
  8293. entity.PlactTime = Convert.ToDateTime(xdTime);
  8294. }
  8295. string fhTime = GetPostString("deliveryTime");
  8296. if (fhTime.Length > 0)
  8297. {
  8298. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8299. }
  8300. string preTime = GetPostString("preOutTime");
  8301. if (preTime.Length > 0)
  8302. {
  8303. entity.PreOutTime = Convert.ToDateTime(preTime);
  8304. }
  8305. entity.DeliveryCount = GetPostInt("deliveryCount");
  8306. entity.ReceiveCount = GetPostInt("receiveCount");
  8307. entity.OutSid = GetPostString("outSid");
  8308. entity.FileName = GetPostString("fileName");
  8309. entity.Memo = GetPostString("memo");
  8310. entity.AddUserId = CurrentUser.UserID;
  8311. entity.CreateTime = DateTime.Now;
  8312. entity.Img = GetPostString("img");
  8313. entity.Supplier = GetPostInt("supplier");
  8314. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8315. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8316. {
  8317. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8318. DateTime dt2 = (DateTime)entity.PreOutTime;
  8319. TimeSpan span = dt1.Subtract(dt2);
  8320. if (span.Days > 0)
  8321. {
  8322. entity.OutLate = span.Days;
  8323. }
  8324. }
  8325. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8326. entity.Create();
  8327. returnSuccessMsg("添加成功!");
  8328. return;
  8329. }
  8330. else //修改
  8331. {
  8332. entity = CeErpPlaceRegister.Get(eid);
  8333. if (entity != null)
  8334. {
  8335. string xdTime = GetPostString("placeTime");
  8336. if (xdTime.Length > 0)
  8337. {
  8338. entity.PlactTime = Convert.ToDateTime(xdTime);
  8339. }
  8340. string fhTime = GetPostString("deliveryTime");
  8341. if (fhTime.Length > 0)
  8342. {
  8343. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8344. }
  8345. string preTime = GetPostString("preOutTime");
  8346. if (preTime.Length > 0)
  8347. {
  8348. entity.PreOutTime = Convert.ToDateTime(preTime);
  8349. }
  8350. entity.DeliveryCount = GetPostInt("deliveryCount");
  8351. entity.ReceiveCount = GetPostInt("receiveCount");
  8352. if (entity.DeliveryCount == entity.ReceiveCount)
  8353. {
  8354. entity.CurState = "已完成";
  8355. }
  8356. else
  8357. {
  8358. entity.CurState = "未完成";
  8359. }
  8360. entity.OutSid = GetPostString("outSid");
  8361. entity.FileName = GetPostString("fileName");
  8362. entity.Memo = GetPostString("memo");
  8363. entity.Img = GetPostString("img");
  8364. entity.Supplier = GetPostInt("supplier");
  8365. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8366. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8367. {
  8368. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8369. DateTime dt2 = (DateTime)entity.PreOutTime;
  8370. TimeSpan span = dt1.Subtract(dt2);
  8371. if (span.Days > 0)
  8372. {
  8373. entity.OutLate = span.Days;
  8374. }
  8375. }
  8376. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8377. entity.Update();
  8378. returnSuccessMsg("修改成功");
  8379. return;
  8380. }
  8381. returnErrorMsg("找不到对应的记录");
  8382. return;
  8383. }
  8384. }
  8385. returnErrorMsg("缺少必要参数");
  8386. }
  8387. public void del_erp_placeregist()
  8388. {
  8389. string eid = GetPostString("id");
  8390. CeErpPlaceRegister.Del(eid);
  8391. returnSuccessMsg("删除成功!");
  8392. return;
  8393. }
  8394. public void ins_erp_placeregistbyorder()
  8395. {
  8396. string ctid = GetPostString("ctid");
  8397. if (ctid.Length > 0)
  8398. {
  8399. StringBuilder sql = new StringBuilder();
  8400. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8402. if (dt.Rows.Count > 0)
  8403. {
  8404. foreach (DataRow dr in dt.Rows)
  8405. {
  8406. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8407. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8408. entity.AddUserId = CurrentUser.UserID;
  8409. entity.tid = dr["tid"].ToString();
  8410. entity.Did = Convert.ToString(dr["ctid"]);
  8411. entity.splitTag = dr["SplitTag"].ToString();
  8412. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8413. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8414. if (pre_ctid.Length > 0)
  8415. {
  8416. sellmemo = sellmemo.Replace(pre_ctid, "");
  8417. }
  8418. sellmemo = sellmemo.Replace("[", "");
  8419. sellmemo = sellmemo.Replace("]", "");
  8420. entity.FileName = sellmemo;
  8421. string count = dr["ProductCount"].ToString();
  8422. int usecount = commonHelper.getIntCountFromString(count);
  8423. entity.DeliveryCount = usecount;
  8424. entity.CurState = "未完成";
  8425. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8426. {
  8427. entity.Supplier = 24;//dl手提袋定制
  8428. }
  8429. else
  8430. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8431. entity.CreateTime = DateTime.Now;
  8432. entity.Create();
  8433. }
  8434. returnSuccessMsg("操作成功");
  8435. return;
  8436. }
  8437. returnErrorMsg("没有找到对应订单");
  8438. return;
  8439. }
  8440. returnErrorMsg("缺少订单编号");
  8441. return;
  8442. }
  8443. public void get_erp_persuadelist()
  8444. {
  8445. DataStruct dStruct = GetPostStruct();
  8446. List<string> lw = new List<string>();
  8447. string ctid = GetPostString("ctid");
  8448. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8449. string shopname = GetPostString("shopname");
  8450. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8451. string buyernick = GetPostString("buyer_nick");
  8452. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8453. string customer = GetPostString("customer");
  8454. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8455. string returndate1 = GetPostString("returndate1");
  8456. string returndate2 = GetPostString("returndate2");
  8457. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8458. if (dw.Length > 0) lw.Add(dw);
  8459. string finishDate1 = GetPostString("finishdate1");
  8460. string finishDate2 = GetPostString("finishdate2");
  8461. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8462. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8463. string persuadetype = GetPostString("persuadetype");
  8464. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8465. string returnvstate = GetPostString("returnvstate");
  8466. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8467. dStruct.Order = "created desc";
  8468. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8469. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8470. writeGridDataTableJson(dStruct.TotalCount, dt);
  8471. }
  8472. public void upd_erp_returnpersuadeback()
  8473. {
  8474. if (UrlPostParmsCheck("ID"))
  8475. {
  8476. int eid = GetPostInt("ID");
  8477. CeErpPersuade entity = null;
  8478. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8479. if (entity != null)
  8480. {
  8481. entity.backreason = GetPostString("reason");
  8482. entity.pstate = 2;
  8483. entity.verifytime = DateTime.Now;
  8484. entity.verifyuserid = CurrentUser.UserID;
  8485. entity.Update();
  8486. returnSuccessMsg("退回成功!");
  8487. return;
  8488. }
  8489. returnErrorMsg("找不到订单记录");
  8490. }
  8491. }
  8492. public void upd_erp_returnpersuadeverify()
  8493. {
  8494. if (UrlPostParmsCheck("ID"))
  8495. {
  8496. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8497. {
  8498. returnErrorMsg("暂无权限审核");
  8499. return;
  8500. }
  8501. int eid = GetPostInt("ID");
  8502. CeErpPersuade entity = null;
  8503. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8504. if (entity != null)
  8505. {
  8506. entity.pstate = 1;
  8507. entity.verifytime = DateTime.Now;
  8508. entity.verifyuserid = CurrentUser.UserID;
  8509. entity.Update();
  8510. returnSuccessMsg("审核成功!");
  8511. return;
  8512. }
  8513. returnErrorMsg("找不到订单记录");
  8514. }
  8515. }
  8516. public void del_erp_persuade()
  8517. {
  8518. if (UrlPostParmsCheck("ID"))
  8519. {
  8520. int eid = GetPostInt("ID");
  8521. CeErpPersuade.Del(eid);
  8522. returnSuccessMsg("操作成功");
  8523. return;
  8524. }
  8525. }
  8526. public void get_erp_oldcustoupload()
  8527. {
  8528. DataStruct dStruct = GetPostStruct();
  8529. List<string> lw = new List<string>();
  8530. string buyernick = GetPostString("buyer_nick");
  8531. if (buyernick.Length > 0)
  8532. {
  8533. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8534. }
  8535. else
  8536. return;
  8537. dStruct.Order = "pay_time desc";
  8538. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8539. DataTable dt = null;
  8540. dt = WebCache.GetData("view_erptradecell", dStruct);
  8541. writeGridDataTableJson(dStruct.TotalCount, dt);
  8542. }
  8543. public void get_erp_checkorderlist()
  8544. {
  8545. DataStruct dStruct = GetPostStruct();
  8546. List<string> lw = new List<string>();
  8547. string tid = GetPostString("ctid");
  8548. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8549. string shopname = GetPostString("shopname");
  8550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8551. string buyernick = GetPostString("buyer_nick");
  8552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8553. string customer = GetPostString("customer");
  8554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8555. string design = GetPostString("design");
  8556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8557. string orderState = GetPostString("orderState");
  8558. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8559. string address = GetPostString("address");
  8560. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8561. string sellermemo = GetPostString("seller_memo");
  8562. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8563. string supplier = GetPostString("supplier");
  8564. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8565. {
  8566. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8567. }
  8568. else
  8569. {
  8570. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8571. }
  8572. string checkst = GetPostString("checkstate");
  8573. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8574. string date1 = GetPostString("date1");
  8575. string date2 = GetPostString("date2");
  8576. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8577. if (dw.Length > 0) lw.Add(dw);
  8578. string placedate1 = GetPostString("placedate1");
  8579. string placedate2 = GetPostString("placedate2");
  8580. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8581. if (fdw.Length > 0) lw.Add(fdw);
  8582. string price1 = GetPostString("price1");
  8583. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8584. string price2 = GetPostString("price2");
  8585. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8586. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8587. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8588. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8589. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8590. writeGridDataTableJson(dStruct.TotalCount, dt);
  8591. }
  8592. public void ins_erp_startCheck()
  8593. {
  8594. if (UrlPostParmsCheck("ctid"))
  8595. {
  8596. string eid = GetPostString("ctid");
  8597. CeErpTradeCell entity = null;
  8598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8599. if (entity != null)
  8600. {
  8601. entity.MemoOpt = 4;
  8602. entity.Update();
  8603. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8604. CeErpSukuraData.createInfo(entity.ctid, 6);
  8605. returnSuccessMsg("操作成功!");
  8606. return;
  8607. }
  8608. returnErrorMsg("找不到记录");
  8609. }
  8610. }
  8611. public void upd_erp_sendXlw()
  8612. {
  8613. if (UrlPostParmsCheck("ctid"))
  8614. {
  8615. string eid = GetPostString("ctid");
  8616. CeErpTradeCell entity = null;
  8617. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8618. if (entity != null)
  8619. {
  8620. if (entity.IsSendGift == 1)
  8621. {
  8622. returnErrorMsg("请勿重复标记");
  8623. return;
  8624. }
  8625. entity.IsSendGift = 1;
  8626. entity.Update();
  8627. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8628. returnSuccessMsg("操作成功!");
  8629. return;
  8630. }
  8631. returnErrorMsg("找不到记录");
  8632. }
  8633. }
  8634. public void cancel_sendXlw()
  8635. {
  8636. if (UrlPostParmsCheck("ctid"))
  8637. {
  8638. string eid = GetPostString("ctid");
  8639. CeErpTradeCell entity = null;
  8640. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8641. if (entity != null)
  8642. {
  8643. if (entity.IsSendGift == 0)
  8644. {
  8645. returnErrorMsg("未标记小礼物");
  8646. return;
  8647. }
  8648. entity.IsSendGift = 0;
  8649. entity.Update();
  8650. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8651. returnSuccessMsg("操作成功!");
  8652. return;
  8653. }
  8654. returnErrorMsg("找不到记录");
  8655. }
  8656. }
  8657. public void get_erp_designbill()
  8658. {
  8659. DataStruct dStruct = GetPostStruct();
  8660. List<string> lw = new List<string>();
  8661. int isMy = GetInt("my");
  8662. if (isMy == 1)
  8663. {
  8664. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8665. }
  8666. string tid = GetPostString("tid");
  8667. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8668. string userName = GetPostString("design");
  8669. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8670. string price1 = GetPostString("price1");
  8671. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8672. string price2 = GetPostString("price2");
  8673. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8674. string rePrice1 = GetPostString("rePrice1");
  8675. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8676. string rePrice2 = GetPostString("rePrice2");
  8677. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8678. string designerType = GetPostString("designerType");
  8679. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8680. string orderState = GetPostString("orderState");
  8681. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8682. string endTime1 = GetPostString("endTime1");
  8683. string endTime2 = GetPostString("endTime2");
  8684. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8685. if (dw.Length > 0) lw.Add(dw);
  8686. string isDk = GetPostString("isDk");
  8687. if (isDk == "1")
  8688. {
  8689. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8690. }
  8691. else if (isDk == "0")
  8692. {
  8693. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8694. }
  8695. dStruct.Order = "oid, create_time desc";
  8696. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8697. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8698. writeGridDataTableJson(dStruct.TotalCount, dt);
  8699. }
  8700. public void upd_erp_designerbill()
  8701. {
  8702. if (UrlPostParmsCheck("ID"))
  8703. {
  8704. string eid = GetPostString("ID");
  8705. CeErpDesignerBill entity = null;
  8706. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8707. if (entity != null)
  8708. {
  8709. if (GetPostDouble("designerpirce") > 0)
  8710. {
  8711. entity.realPrice = GetPostDouble("designerpirce");
  8712. entity.update_time = DateTime.Now;
  8713. entity.update_u_id = CurrentUser.UserID;
  8714. entity.update_u_name = CurrentUser.UserName;
  8715. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8716. entity.Update();
  8717. returnSuccessMsg("操作成功!");
  8718. return;
  8719. }
  8720. else
  8721. {
  8722. entity.price = GetPostDouble("price");
  8723. entity.update_time = DateTime.Now;
  8724. entity.update_u_id = CurrentUser.UserID;
  8725. entity.update_u_name = CurrentUser.UserName;
  8726. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8727. entity.Update();
  8728. returnSuccessMsg("操作成功!");
  8729. return;
  8730. }
  8731. }
  8732. returnErrorMsg("找不到记录");
  8733. }
  8734. }
  8735. public void audit_erp_designerbill()
  8736. {
  8737. if (UrlPostParmsCheck("ID"))
  8738. {
  8739. string eid = GetPostString("ID");
  8740. CeErpDesignerBill entity = null;
  8741. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8742. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8743. if (entity != null)
  8744. {
  8745. entity.realPrice = GetPostDouble("designerpirce");
  8746. entity.update_time = DateTime.Now;
  8747. entity.update_u_id = CurrentUser.UserID;
  8748. entity.update_u_name = CurrentUser.UserName;
  8749. entity.isAudit = 1;
  8750. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8751. entity.Update();
  8752. if (orderEntity != null)
  8753. {
  8754. orderEntity.IsReadTag = 3;
  8755. orderEntity.Update();
  8756. }
  8757. returnSuccessMsg("操作成功!");
  8758. return;
  8759. }
  8760. returnErrorMsg("找不到记录");
  8761. }
  8762. }
  8763. public void all_audit_erp_designerbill()
  8764. {
  8765. if (UrlPostParmsCheck("idList"))
  8766. {
  8767. string[] list = GetPostString("idList").Split(',');
  8768. CeErpDesignerBill entity = null;
  8769. for (int i = 0; i < list.Length; i++)
  8770. {
  8771. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8772. if (entity == null) return;
  8773. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8774. if (orderEntity == null) return;
  8775. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8776. entity.update_time = DateTime.Now;
  8777. entity.update_u_id = CurrentUser.UserID;
  8778. entity.update_u_name = CurrentUser.UserName;
  8779. entity.isAudit = 1;
  8780. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8781. entity.Update();
  8782. orderEntity.IsReadTag = 3;
  8783. orderEntity.Update();
  8784. }
  8785. returnSuccessMsg("操作成功!");
  8786. return;
  8787. }
  8788. }
  8789. public void get_erp_sameorders()
  8790. {
  8791. if (UrlPostParmsCheck("ctid"))
  8792. {
  8793. string eid = GetPostString("ctid");
  8794. CeErpTradeCell entity = null;
  8795. entity = CeErpTradeCell.GetByCtid(eid);
  8796. if (entity != null)
  8797. {
  8798. StringBuilder sql = new StringBuilder();
  8799. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8800. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8801. var res = new
  8802. {
  8803. data = dt.Rows.Count
  8804. };
  8805. string ro_jsond = JsonConvert.SerializeObject(res);
  8806. returnSuccess(ro_jsond);
  8807. return;
  8808. }
  8809. returnErrorMsg("未找到订单");
  8810. return;
  8811. }
  8812. returnErrorMsg("缺少必要的参数");
  8813. }
  8814. public void get_erp_islasthavesameorder()
  8815. {
  8816. if (UrlPostParmsCheck("ctid"))
  8817. {
  8818. string eid = GetPostString("ctid");
  8819. string[] ctidList = eid.Split(',');
  8820. StringBuilder sql = new StringBuilder();
  8821. string tisCtid = "";
  8822. foreach (string ctid in ctidList)
  8823. {
  8824. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8825. if (entity != null)
  8826. {
  8827. sql = new StringBuilder();
  8828. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8829. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8830. if (dth.Rows.Count > 0)
  8831. {
  8832. tisCtid += entity.ctid;
  8833. tisCtid += ",";
  8834. }
  8835. }
  8836. }
  8837. if (tisCtid.Length > 0)
  8838. {
  8839. var res = new
  8840. {
  8841. data = tisCtid
  8842. };
  8843. string ro_jsond = JsonConvert.SerializeObject(res);
  8844. returnSuccess(ro_jsond);
  8845. }
  8846. else
  8847. {
  8848. var res = new
  8849. {
  8850. data = ""
  8851. };
  8852. string ro_jsond = JsonConvert.SerializeObject(res);
  8853. returnSuccess(ro_jsond);
  8854. }
  8855. return;
  8856. }
  8857. returnErrorMsg("缺少必要的参数");
  8858. }
  8859. public void file_client_down_url()
  8860. {
  8861. if (!UrlPostParmsCheck("userId"))
  8862. {
  8863. returnErrorMsg("缺少必要的参数");
  8864. }
  8865. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  8866. }
  8867. public void checkout_form_data()
  8868. {
  8869. if (!UrlPostParmsCheck("tid"))
  8870. {
  8871. returnErrorMsg("缺少必要的参数");
  8872. }
  8873. string tid = GetPostString("tid");
  8874. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  8875. if (ceErpOrderFormData != null)
  8876. {
  8877. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  8878. returnSuccess(ro_jsond);
  8879. return;
  8880. }
  8881. returnErrorMsg("尚未有文件!");
  8882. }
  8883. public void back_supplier_audit()
  8884. {
  8885. int userId = CurrentUser.UserID;
  8886. StringBuilder sql = new StringBuilder();
  8887. 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);
  8888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8889. if (dt.Rows.Count > 0)
  8890. {
  8891. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8892. }
  8893. else
  8894. {
  8895. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8896. }
  8897. }
  8898. public void back_supplier_query()
  8899. {
  8900. string eid = GetPostString("ctid");
  8901. if (eid != "")
  8902. {
  8903. StringBuilder sql = new StringBuilder();
  8904. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  8905. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8906. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8907. }
  8908. else
  8909. {
  8910. returnErrorMsg("找不到订单记录");
  8911. return;
  8912. }
  8913. }
  8914. public void verified_to_order()
  8915. {
  8916. int userId = CurrentUser.UserID;
  8917. StringBuilder sql = new StringBuilder();
  8918. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  8919. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8920. if (dt.Rows.Count > 0)
  8921. {
  8922. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8923. }
  8924. else
  8925. {
  8926. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8927. }
  8928. }
  8929. public void upd_supplier_audit()
  8930. {
  8931. if (UrlPostParmsCheck("ctid"))
  8932. {
  8933. string eid = GetPostString("ctid");
  8934. string reason = GetPostString("returnreason");
  8935. CeErpTradeCell entity = null;
  8936. CeWithdraw withdraw = null;
  8937. withdraw = CeWithdraw.GetByTid(eid);
  8938. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8939. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  8940. {
  8941. if (withdraw != null)
  8942. {
  8943. if (!withdraw.userid.Equals(CurrentUser.UserID))
  8944. {
  8945. returnSuccessMsg("您没有权限操作!");
  8946. return;
  8947. }
  8948. else
  8949. {
  8950. if (reason.Equals("1"))
  8951. {
  8952. if (entity.OrderState == -1)
  8953. {
  8954. if (entity.FinishPlaceTime == null)
  8955. {
  8956. entity.OrderState = 2;
  8957. }
  8958. else
  8959. {
  8960. entity.OrderState = 6;
  8961. }
  8962. }
  8963. entity.Update();
  8964. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  8965. if (withdraw != null)
  8966. {
  8967. withdraw.status = int.Parse(reason);
  8968. withdraw.Update();
  8969. }
  8970. returnSuccessMsg("操作成功!");
  8971. return;
  8972. }
  8973. else
  8974. {
  8975. withdraw.status = int.Parse(reason);
  8976. withdraw.acknowledgingtime = DateTime.Now;
  8977. withdraw.Update();
  8978. returnSuccessMsg("查看详细请点击线下订单查询");
  8979. return;
  8980. }
  8981. }
  8982. }
  8983. // 第一个字符是 'N'
  8984. }
  8985. if (eid[0] != 'N')
  8986. {
  8987. }
  8988. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  8989. {
  8990. entity.IsVerifyToSupplier = false;
  8991. entity.IsReturn = 1;
  8992. entity.ReturnTime = DateTime.Now;
  8993. entity.ReturnReason = reason;
  8994. if (entity.OrderState == 6)
  8995. {
  8996. entity.OrderState = 5;
  8997. }
  8998. entity.Update();
  8999. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9000. if (withdraw != null)
  9001. {
  9002. withdraw.status = int.Parse(reason);
  9003. withdraw.Update();
  9004. }
  9005. returnSuccessMsg("操作成功!");
  9006. return;
  9007. }
  9008. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9009. {
  9010. ;
  9011. if (withdraw != null)
  9012. {
  9013. withdraw.status = int.Parse(reason);
  9014. withdraw.acknowledgingtime = DateTime.Now;
  9015. withdraw.Update();
  9016. returnSuccessMsg("供应商取消撤回!");
  9017. return;
  9018. }
  9019. }
  9020. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9021. {
  9022. if (entity.OrderState == -1)
  9023. {
  9024. if (entity.FinishPlaceTime == null)
  9025. {
  9026. entity.OrderState = 2;
  9027. }
  9028. else
  9029. {
  9030. entity.OrderState = 3;
  9031. }
  9032. commonHelper.getCytPrice(entity);
  9033. }
  9034. entity.Update();
  9035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9036. if (withdraw != null)
  9037. {
  9038. withdraw.status = int.Parse(reason);
  9039. withdraw.Update();
  9040. }
  9041. returnSuccessMsg("操作成功!");
  9042. return;
  9043. }
  9044. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9045. {
  9046. if (withdraw == null)
  9047. {
  9048. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9049. return;
  9050. }
  9051. }
  9052. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9053. {
  9054. if (withdraw != null)
  9055. {
  9056. withdraw.status = int.Parse(reason);
  9057. withdraw.acknowledgingtime = DateTime.Now;
  9058. withdraw.Update();
  9059. returnSuccessMsg("查看详细请点击线下订单查询");
  9060. return;
  9061. }
  9062. }
  9063. return;
  9064. }
  9065. }
  9066. //校验报价
  9067. public void refund_order_tip()
  9068. {
  9069. int userid = CurrentUser.UserID;
  9070. int sectionId = CurrentUser.UserPost.OrgID;
  9071. StringBuilder sql = new StringBuilder();
  9072. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9073. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9074. List<string> ids = new List<string>();
  9075. if (dth.Rows.Count > 0)
  9076. {
  9077. foreach (DataRow dr in dth.Rows)
  9078. {
  9079. ids.Add(dr["ID"].ToString());
  9080. }
  9081. try
  9082. {
  9083. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9084. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9085. }
  9086. catch (Exception ex)
  9087. {
  9088. }
  9089. }
  9090. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9091. }
  9092. public void refund_order_Design()
  9093. {
  9094. int userid = CurrentUser.UserID;
  9095. int sectionId = CurrentUser.UserPost.OrgID;
  9096. StringBuilder sql = new StringBuilder();
  9097. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9098. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9099. List<string> ids = new List<string>();
  9100. if (dth.Rows.Count > 0)
  9101. {
  9102. foreach (DataRow dr in dth.Rows)
  9103. {
  9104. ids.Add(dr["ID"].ToString());
  9105. }
  9106. try
  9107. {
  9108. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9109. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9110. }
  9111. catch (Exception ex)
  9112. {
  9113. }
  9114. }
  9115. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9116. }
  9117. public void change_order_info()
  9118. {
  9119. int userid = CurrentUser.UserID;
  9120. StringBuilder sql = new StringBuilder();
  9121. 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);
  9122. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9123. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9124. }
  9125. public void change_win_mome()
  9126. {
  9127. if (UrlPostParmsCheck("id,ctid"))
  9128. {
  9129. string id = GetPostString("id");
  9130. string ctid = GetPostString("ctid");
  9131. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9132. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9133. if (ce == null || ceErpMessageTip == null)
  9134. {
  9135. returnSuccessMsg("未找到对应的订单!");
  9136. return;
  9137. }
  9138. int type = GetPostInt("type");
  9139. string content = GetPostString("content");
  9140. if (type == 0)
  9141. {
  9142. content = content.Replace("(", "(");
  9143. content = content.Replace(")", ")");
  9144. string check = MidStrEx(content, "(", ")").Trim();
  9145. if (string.IsNullOrEmpty(check))
  9146. {
  9147. returnSuccessMsg("文件名格式不正确");
  9148. return;
  9149. }
  9150. }
  9151. ce.seller_memo = content;
  9152. ce.Update();
  9153. ceErpMessageTip.isVisit = true;
  9154. ceErpMessageTip.Update();
  9155. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9156. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9157. ApiVo apiVo = new ApiVo();
  9158. apiVo.orderNumber = ce.ctid;
  9159. apiVo.actionName = "demandDesign";
  9160. apiVo.orderRemarks = content;
  9161. apiVo.demandExamine = type + 1;
  9162. designHelper.API_WorkCore(apiVo);//demandDesign
  9163. returnSuccessMsg("修改成功!");
  9164. }
  9165. }
  9166. public static string MidStrEx(string sourse, string startstr, string endstr)
  9167. {
  9168. string result = string.Empty;
  9169. int startindex, endindex;
  9170. try
  9171. {
  9172. startindex = sourse.IndexOf(startstr);
  9173. if (startindex == -1)
  9174. return result;
  9175. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9176. endindex = tmpstr.IndexOf(endstr);
  9177. if (endindex == -1)
  9178. return result;
  9179. result = tmpstr.Remove(endindex);
  9180. }
  9181. catch (Exception ex)
  9182. {
  9183. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9184. }
  9185. return result;
  9186. }
  9187. public void refund_order_list()
  9188. {
  9189. int userid = CurrentUser.UserID;
  9190. int sectionId = CurrentUser.UserPost.OrgID;
  9191. StringBuilder sql = new StringBuilder();
  9192. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9193. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9194. DataStruct dStruct = GetPostStruct();
  9195. DataTable dt = null;
  9196. List<string> ids = new List<string>();
  9197. List<string> tids = new List<string>();
  9198. if (dth.Rows.Count > 0)
  9199. {
  9200. foreach (DataRow dr in dth.Rows)
  9201. {
  9202. tids.Add("'" + dr["tid"].ToString() + "'");
  9203. ids.Add(dr["id"].ToString());
  9204. }
  9205. try
  9206. {
  9207. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9208. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9209. List<string> lw = new List<string>();
  9210. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9211. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9212. dt = WebCache.GetData("view_orderlist", dStruct);
  9213. }
  9214. catch (Exception ex)
  9215. {
  9216. }
  9217. }
  9218. writeGridDataTableJson(dStruct.TotalCount, dt);
  9219. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9220. }
  9221. //新增
  9222. public void order_batch_downloads()
  9223. {
  9224. string ceid = GetPostString("tid");
  9225. String[] tid = ceid.Split(',');
  9226. order_batch_caiyingtong(tid);
  9227. /* (string success, string errors) = UploadFiles(tid);
  9228. returnSuccessMsg(success + errors);*/
  9229. return;
  9230. }
  9231. //报价接口
  9232. public void Get_To_Quote()
  9233. {
  9234. string ceid = GetPostString("ctid");
  9235. if (ceid != null)
  9236. {
  9237. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9238. if (entity != null)
  9239. {
  9240. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9241. double price = 0;
  9242. if (cp == null)
  9243. {
  9244. JObject jsonObject12 = new JObject
  9245. {
  9246. { "UserId", "77886" },
  9247. { "Pwd", "lt666888" },
  9248. { "Filename", entity.seller_memo }
  9249. };
  9250. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9251. JObject jsonObjects1 = JObject.Parse(response1);
  9252. string ms1g = (string)jsonObjects1["msg"];
  9253. if (ms1g == "报价成功")
  9254. {
  9255. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9256. string data = (string)jsonObject1["price"];
  9257. 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 + "');";
  9258. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9259. returnSuccessMsg("获取报价成功:" + data);
  9260. price = Convert.ToDouble(data);
  9261. }
  9262. else
  9263. {
  9264. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9265. return;
  9266. }
  9267. }
  9268. String[] beizhu = entity.seller_memo.Split('-');
  9269. String chanp = "";
  9270. if (beizhu.Length > 0)
  9271. {
  9272. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9273. }
  9274. else
  9275. {
  9276. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9277. }
  9278. JObject jsonObject = new JObject
  9279. {
  9280. { "UserId", "77886" },
  9281. { "Pwd", "lt666888" },
  9282. { "Filename", chanp }
  9283. };
  9284. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9285. JObject jsonObjects = JObject.Parse(response);
  9286. string msg = (string)jsonObjects["msg"];
  9287. if (msg == "报价成功")
  9288. {
  9289. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9290. string data = (string)jsonObject1["price"];
  9291. 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 + "');";
  9292. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9293. returnSuccessMsg("获取报价成功:" + data);
  9294. price = Convert.ToDouble(data);
  9295. }
  9296. else
  9297. {
  9298. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9299. return;
  9300. }
  9301. if (price > 0)
  9302. {
  9303. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9304. if (ceErpTradeCellExtend == null)
  9305. {
  9306. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9307. ceErpTradeCellExtend.ctid = entity.ctid;
  9308. ceErpTradeCellExtend.payment_cyt = price;
  9309. ceErpTradeCellExtend.Create();
  9310. }
  9311. else
  9312. {
  9313. ceErpTradeCellExtend.payment_cyt = price;
  9314. ceErpTradeCellExtend.Update();
  9315. }
  9316. }
  9317. return;
  9318. }
  9319. }
  9320. else
  9321. {
  9322. returnErrorMsg("请至少选择一条数据");
  9323. return;
  9324. }
  9325. }
  9326. //新增
  9327. public void order_To_Supplier()
  9328. {
  9329. string ceid = GetPostString("tid");
  9330. String[] tid = ceid.Split(',');
  9331. if (tid.Length > 0)
  9332. {
  9333. try
  9334. {
  9335. for (int i = 0; i < tid.Length; i++)
  9336. {
  9337. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9338. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9339. entity.SupplierId = suid;
  9340. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9341. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9342. entity.Update();
  9343. }
  9344. }
  9345. catch (Exception ex)
  9346. {
  9347. returnErrorMsg("自动匹配供应商失败");
  9348. return;
  9349. }
  9350. }
  9351. else
  9352. {
  9353. returnErrorMsg("请至少选择一条数据");
  9354. return;
  9355. }
  9356. returnSuccessMsg("自动匹配供应商成功");
  9357. return;
  9358. }
  9359. public (string, string) UploadFiles(string[] urls)
  9360. {
  9361. string success = "";
  9362. string errors = "";
  9363. int userid = CurrentUser.UserID;
  9364. foreach (string url in urls)
  9365. {
  9366. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9367. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9368. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9369. {
  9370. JObject jsonObject = new JObject
  9371. {
  9372. { "Userid", "77886" },
  9373. { "pwd", "cyt86435015" },
  9374. { "content", base64FileContent },
  9375. { "ext", Path.GetExtension(fileName) }
  9376. };
  9377. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9378. JObject jsonObjects = JObject.Parse(response);
  9379. string msg = (string)jsonObjects["msg"];
  9380. if (msg.Equals("上传成功"))
  9381. {
  9382. success += url + " 上传成功";
  9383. }
  9384. else
  9385. {
  9386. errors += url + " 上传失败";
  9387. }
  9388. }
  9389. else
  9390. {
  9391. errors += url + " 格式出现问题";
  9392. }
  9393. }
  9394. if (urls.Length == 0)
  9395. {
  9396. return (success, errors);
  9397. }
  9398. return (success, errors);
  9399. }
  9400. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9401. {
  9402. return true; //总是接受
  9403. }
  9404. public static string HttpPost(string url, string param = null)
  9405. {
  9406. HttpWebRequest request;
  9407. //如果是发送HTTPS请求
  9408. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9409. {
  9410. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9411. request = WebRequest.Create(url) as HttpWebRequest;
  9412. request.ProtocolVersion = HttpVersion.Version10;
  9413. }
  9414. else
  9415. {
  9416. request = WebRequest.Create(url) as HttpWebRequest;
  9417. }
  9418. request.Method = "POST";
  9419. request.ContentType = "application/json";
  9420. request.Accept = "*/*";
  9421. request.Timeout = 120000;
  9422. request.AllowAutoRedirect = false;
  9423. StreamWriter requestStream = null;
  9424. WebResponse response = null;
  9425. string responseStr = null;
  9426. try
  9427. {
  9428. requestStream = new StreamWriter(request.GetRequestStream());
  9429. requestStream.Write(param);
  9430. requestStream.Close();
  9431. response = request.GetResponse();
  9432. if (response != null)
  9433. {
  9434. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9435. responseStr = reader.ReadToEnd();
  9436. reader.Close();
  9437. }
  9438. }
  9439. catch (Exception ex)
  9440. {
  9441. return ex.Message;
  9442. }
  9443. finally
  9444. {
  9445. request = null;
  9446. requestStream = null;
  9447. response = null;
  9448. }
  9449. return responseStr;
  9450. }
  9451. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9452. {
  9453. string base64FileContent;
  9454. string fileName;
  9455. using (WebClient webClient = new WebClient())
  9456. {
  9457. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9458. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9459. {
  9460. using (Stream stream = response.GetResponseStream())
  9461. {
  9462. using (MemoryStream memoryStream = new MemoryStream())
  9463. {
  9464. stream.CopyTo(memoryStream);
  9465. byte[] fileBytes = memoryStream.ToArray();
  9466. base64FileContent = Convert.ToBase64String(fileBytes);
  9467. fileName = response.Headers["Content-Disposition"];
  9468. if (!string.IsNullOrEmpty(fileName))
  9469. {
  9470. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9471. if (index >= 0)
  9472. {
  9473. fileName = fileName.Substring(index + 9).Trim('\"');
  9474. }
  9475. }
  9476. else
  9477. {
  9478. fileName = Path.GetFileName(downloadUrl);
  9479. }
  9480. }
  9481. }
  9482. }
  9483. }
  9484. return (fileName, base64FileContent);
  9485. }
  9486. //新增
  9487. public void order_batch_caiyingtong(string[] downloadUrls)
  9488. {
  9489. try
  9490. {
  9491. //遍历文件
  9492. DataStruct dStruct = GetPostStruct();
  9493. DataTable dt = null;
  9494. int userid = CurrentUser.UserID;
  9495. List<string> ids = new List<string>();//失败组
  9496. List<string> tids = new List<string>();
  9497. using (WebClient webClient = new WebClient())
  9498. {
  9499. foreach (var url in downloadUrls)
  9500. {
  9501. try
  9502. {
  9503. tids.Add("'" + url + "'");
  9504. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9505. if (entity != null)
  9506. {
  9507. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9508. if (cp == null)
  9509. {
  9510. JObject jsonObject = new JObject
  9511. {
  9512. { "Userid", "77886" },
  9513. { "pwd", "lt666888" },
  9514. { "Filename",entity.seller_memo }
  9515. };
  9516. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9517. JObject jsonObjects = JObject.Parse(response);
  9518. string msg = (string)jsonObjects["msg"];
  9519. if (msg == "报价成功")
  9520. {
  9521. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9522. DownloadAndConvertToBase64(url1);
  9523. }
  9524. else
  9525. {
  9526. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9527. }
  9528. }
  9529. else
  9530. {
  9531. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9532. JObject jsonObject = new JObject
  9533. {
  9534. { "Userid", "77886" },
  9535. { "pwd", "lt666888" },
  9536. { "Filename",chanp }
  9537. };
  9538. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9539. JObject jsonObjects = JObject.Parse(response);
  9540. string msg = (string)jsonObjects["msg"];
  9541. if (msg == "报价成功")
  9542. {
  9543. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9544. DownloadAndConvertToBase64(url1);
  9545. }
  9546. else
  9547. {
  9548. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9549. }
  9550. }
  9551. }
  9552. // 上传文件到FTP
  9553. }
  9554. catch (Exception ex)
  9555. {
  9556. Console.WriteLine($"An error occurred: {ex.Message}");
  9557. }
  9558. }
  9559. List<string> lw = new List<string>();
  9560. lw.Add(string.Format("( OrderState < 6 )"));
  9561. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9563. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9564. if (dt.Rows.Count > 0)
  9565. {
  9566. foreach (DataRow dr in dt.Rows)
  9567. {
  9568. ids.Add(dr["ctid"].ToString());
  9569. }
  9570. }
  9571. String ErrorMsgs = "";
  9572. foreach (String id in ids)
  9573. {
  9574. ErrorMsgs += id + ",";
  9575. }
  9576. if (ErrorMsgs.Length > 1)
  9577. {
  9578. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9579. }
  9580. if (ErrorMsgs.Length < 1)
  9581. {
  9582. ErrorMsgs = "上传成功";
  9583. returnSuccessMsg(ErrorMsgs);
  9584. }
  9585. else
  9586. {
  9587. returnErrorMsg("以下订单" + ErrorMsgs);
  9588. }
  9589. }
  9590. // 删除文件夹及其内容
  9591. /* Directory.Delete(localDirectory, true);*/
  9592. }
  9593. catch { }
  9594. }
  9595. public void get_center_data()
  9596. {
  9597. int userId = CurrentUser.UserID;
  9598. string postCode = CurrentUser.UserPost.Post.Code;
  9599. List<string> lw = new List<string>();
  9600. List<string> ww = new List<string>();
  9601. DateTime currentTime = DateTime.Now;
  9602. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9603. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9604. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9605. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9606. string sql = " SELECT ";
  9607. string startTime = "2023-10-01 11:22:31";
  9608. //设计
  9609. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9610. {
  9611. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9612. 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));
  9613. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9614. 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));
  9615. }
  9616. //客服
  9617. else if (postCode == "CustomerService" || postCode == "Director")
  9618. {
  9619. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9620. 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));
  9621. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9622. 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));
  9623. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9624. 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));
  9625. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9626. 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));
  9627. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9628. 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));
  9629. }
  9630. //售后
  9631. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9632. {
  9633. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9634. 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));
  9635. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9636. 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));
  9637. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9638. 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));
  9639. }
  9640. //下单部
  9641. else if (postCode == "Place" || postCode == "PlaceMr")
  9642. {
  9643. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9644. 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));
  9645. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9646. 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));
  9647. }
  9648. //车间
  9649. else if (postCode == "Supplier")
  9650. {
  9651. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9652. 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));
  9653. }
  9654. DataTable dt = new DataTable();
  9655. if (lw.Count > 0)
  9656. {
  9657. sql += string.Join(" , ", lw);
  9658. sql += " FROM ";
  9659. sql += string.Join(" , ", ww);
  9660. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9661. }
  9662. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9663. }
  9664. public void get_center_data_list()
  9665. {
  9666. int userId = CurrentUser.UserID;
  9667. string postCode = CurrentUser.UserPost.Post.Code;
  9668. string shopIds = CurrentUser.User.pemShop;
  9669. DataStruct dStruct = GetPostStruct();
  9670. List<string> lw = new List<string>();
  9671. DateTime currentTime = DateTime.Now;
  9672. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9673. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9674. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9675. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9676. string startTime = "2023-10-01 11:22:31";
  9677. int order_type = GetPostInt("order_type");
  9678. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9679. {
  9680. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9681. if (order_type == 0)
  9682. {
  9683. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9684. }
  9685. else if (order_type == 3)
  9686. {
  9687. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9688. }
  9689. else
  9690. {
  9691. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9692. }
  9693. }
  9694. //客服
  9695. if (postCode == "CustomerService" || postCode == "Director")
  9696. {
  9697. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9698. if (order_type == 0)
  9699. {
  9700. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9701. }
  9702. else if (order_type == 1)
  9703. {
  9704. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9705. }
  9706. else if (order_type == 2)
  9707. {
  9708. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9709. }
  9710. else if (order_type == 3)
  9711. {
  9712. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9713. }
  9714. else if (order_type == 4)
  9715. {
  9716. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9717. }
  9718. else
  9719. {
  9720. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9721. }
  9722. }
  9723. //售后
  9724. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9725. {
  9726. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9727. if (shopIds != "")
  9728. {
  9729. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9730. }
  9731. if (order_type == 2)
  9732. {
  9733. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9734. }
  9735. else if (order_type == 4)
  9736. {
  9737. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9738. }
  9739. else if (order_type == 5)
  9740. {
  9741. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9742. }
  9743. else
  9744. {
  9745. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9746. }
  9747. }
  9748. //下单部
  9749. if (postCode == "Place" || postCode == "PlaceMr")
  9750. {
  9751. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9752. if (shopIds != "")
  9753. {
  9754. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9755. }
  9756. else if (order_type == 1)
  9757. {
  9758. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9759. }
  9760. else if (order_type == 2)
  9761. {
  9762. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9763. }
  9764. else
  9765. {
  9766. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9767. }
  9768. }
  9769. //车间
  9770. if (postCode == "Supplier")
  9771. {
  9772. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9773. if (order_type == 5)
  9774. {
  9775. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9776. }
  9777. else
  9778. {
  9779. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9780. }
  9781. }
  9782. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9783. dStruct.Fileds = "tid,ctid";
  9784. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9785. writeGridDataTableJson(dStruct.TotalCount, dt);
  9786. }
  9787. public void aftersale_audit_master()
  9788. {
  9789. if (UrlPostParmsCheck("ctid"))
  9790. {
  9791. string ctid = GetPostString("ctid");
  9792. if (ctid.Length > 0)
  9793. {
  9794. bool result = aftersale_data_change(ctid);
  9795. if (result)
  9796. {
  9797. returnSuccessMsg("修改成功!");
  9798. return;
  9799. }
  9800. }
  9801. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9802. }
  9803. }
  9804. public void aftersale_batch_audit_master()
  9805. {
  9806. if (UrlPostParmsCheck("ctids"))
  9807. {
  9808. string ctids = GetPostString("ctids");
  9809. if (ctids.Length > 0)
  9810. {
  9811. List<string> list = new List<string>();
  9812. string[] ctid_list = ctids.Split(',');
  9813. foreach (var item in ctid_list)
  9814. {
  9815. bool result = aftersale_data_change(item);
  9816. if (!result)
  9817. {
  9818. list.Add(item);
  9819. }
  9820. }
  9821. if (list.Count > 0)
  9822. {
  9823. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9824. return;
  9825. }
  9826. returnSuccessMsg("修改成功!");
  9827. return;
  9828. }
  9829. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9830. }
  9831. }
  9832. public bool aftersale_data_change(string ctid)
  9833. {
  9834. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9835. if (ceErpTradeCell != null)
  9836. {
  9837. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9838. ceErpTradeCell.AfterSaleSupplierState = 0;
  9839. StringBuilder sql = new StringBuilder();
  9840. sql.AppendFormat("select IsFlow,IsSup,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9841. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9842. if ((ceErpTradeCell.AfterSaleResponsible.IndexOf("客户问题") != -1 && ceErpTradeCell.AfterSaleResponsible.IndexOf(",客户问题") == -1) || ceErpTradeCell.supRefundType == "正常损耗" || ceErpTradeCell.supRefundType == "车间不售后" || ceErpTradeCell.supRefundType == "不售后" || ceErpTradeCell.supRefundType == "不理赔")
  9843. {
  9844. CeErpTradeResponsible.DelByTid(ctid, 1);
  9845. ceErpTradeCell.AfterSaleSupplierState = 1;
  9846. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9847. ceErpTradeCell.AfterSaleState = 4;
  9848. }
  9849. else
  9850. {
  9851. ceErpTradeCell.AfterSaleState = 3;
  9852. }
  9853. bool needCyt = false;
  9854. if (dt != null)
  9855. {
  9856. if (dt.Rows.Count == 1)
  9857. {
  9858. bool isEnd = false;
  9859. foreach (DataRow dr in dt.Rows)
  9860. {
  9861. if (!Convert.IsDBNull(dr["IsFlow"]) && Convert.ToInt32(dr["IsFlow"]) == 1 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9862. {
  9863. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9864. isEnd = true;
  9865. }
  9866. if (!Convert.IsDBNull(dr["IsFlow"]) && Convert.ToInt32(dr["IsFlow"]) == 0 && !Convert.IsDBNull(dr["IsSup"]) && Convert.ToInt32(dr["IsSup"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  9867. {
  9868. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9869. isEnd = true;
  9870. }
  9871. if (!Convert.IsDBNull(dr["IsSup"]) && Convert.ToInt32(dr["IsSup"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9872. {
  9873. needCyt = true;
  9874. }
  9875. }
  9876. if (isEnd)
  9877. {
  9878. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9879. ceErpTradeCell.AfterSaleState = 4;
  9880. ceErpTradeCell.AfterSaleSupplierState = 1;
  9881. }
  9882. }
  9883. else
  9884. {
  9885. bool isAll = true;
  9886. foreach (DataRow dr in dt.Rows)
  9887. {
  9888. if (!Convert.IsDBNull(dr["IsFlow"]) && Convert.ToInt32(dr["IsFlow"]) == 1 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9889. {
  9890. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9891. continue;
  9892. }
  9893. if (!Convert.IsDBNull(dr["IsFlow"]) && Convert.ToInt32(dr["IsFlow"]) == 0 && !Convert.IsDBNull(dr["IsSup"]) && Convert.ToInt32(dr["IsSup"]) == 0)
  9894. {
  9895. string path = "";
  9896. int OrgID = 0;
  9897. if (!Convert.IsDBNull(dr["OrgPath"]))
  9898. {
  9899. path = dr["OrgPath"].ToString();
  9900. }
  9901. if (!Convert.IsDBNull(dr["OrgID"]))
  9902. {
  9903. OrgID = Convert.ToInt32(dr["OrgID"]);
  9904. }
  9905. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  9906. {
  9907. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9908. continue;
  9909. }
  9910. }
  9911. if (!Convert.IsDBNull(dr["IsSup"]) && Convert.ToInt32(dr["IsSup"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9912. {
  9913. needCyt = true;
  9914. }
  9915. isAll = false;
  9916. }
  9917. if (isAll)
  9918. {
  9919. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9920. ceErpTradeCell.AfterSaleState = 4;
  9921. ceErpTradeCell.AfterSaleSupplierState = 1;
  9922. }
  9923. }
  9924. }
  9925. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  9926. {
  9927. commonHelper.sendCytAfterSale(ceErpTradeCell);
  9928. }
  9929. if (ceErpTradeCell.AfterSaleState == 4)
  9930. {
  9931. ApiVo apiVo = new ApiVo();
  9932. apiVo.orderNumber = ceErpTradeCell.ctid;
  9933. apiVo.actionName = "afterOver";
  9934. designHelper.API_WorkCore(apiVo); //afterOver
  9935. }
  9936. ceErpTradeCell.Update();
  9937. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  9938. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  9939. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  9940. return true;
  9941. }
  9942. return false;
  9943. }
  9944. public void get_erp_wechatorder()
  9945. {
  9946. DataStruct dStruct = GetPostStruct();
  9947. List<string> lw = new List<string>();
  9948. string tid = GetPostString("tid");
  9949. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9950. string shopname = GetPostString("shopname");
  9951. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9952. string buyernick = GetPostString("buyer_nick");
  9953. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9954. string customer = GetPostString("customer");
  9955. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9956. string returndate1 = GetPostString("returndate1");
  9957. string returndate2 = GetPostString("returndate2");
  9958. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9959. if (dw.Length > 0) lw.Add(dw);
  9960. string finishDate1 = GetPostString("finishdate1");
  9961. string finishDate2 = GetPostString("finishdate2");
  9962. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9963. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9964. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9965. dStruct.Order = "created desc";
  9966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9967. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  9968. writeGridDataTableJson(dStruct.TotalCount, dt);
  9969. }
  9970. public void get_erp_wechatlist_sumprice()
  9971. {
  9972. DataStruct dStruct = GetPostStruct();
  9973. List<string> lw = new List<string>();
  9974. string tid = GetPostString("tid");
  9975. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9976. string shopname = GetPostString("shopname");
  9977. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9978. string buyernick = GetPostString("buyer_nick");
  9979. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9980. string customer = GetPostString("customer");
  9981. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9982. string returndate1 = GetPostString("returndate1");
  9983. string returndate2 = GetPostString("returndate2");
  9984. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9985. if (dw.Length > 0) lw.Add(dw);
  9986. string finishDate1 = GetPostString("finishdate1");
  9987. string finishDate2 = GetPostString("finishdate2");
  9988. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9989. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9990. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9991. string mainWhere = string.Join(" and ", lw.ToArray());
  9992. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  9993. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  9994. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  9995. decimal total = 0;
  9996. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  9997. {
  9998. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  9999. }
  10000. var res = new
  10001. {
  10002. data = total
  10003. };
  10004. string ro_jsond = JsonConvert.SerializeObject(res);
  10005. returnSuccess(ro_jsond);
  10006. return;
  10007. }
  10008. public void get_erp_qr_waitdeliverylist()
  10009. {
  10010. DataStruct dStruct = GetPostStruct();
  10011. List<string> lw = new List<string>();
  10012. string tid = GetPostString("ctid");
  10013. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10016. var res_objz = new
  10017. {
  10018. restype = 1,
  10019. data = dt
  10020. };
  10021. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10022. returnSuccess(ro_jsonz);
  10023. }
  10024. public void get_erp_yield_list()
  10025. {
  10026. DataStruct dStruct = GetPostStruct();
  10027. List<string> lw = new List<string>();
  10028. string tid = GetPostString("ctid");
  10029. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10030. string shopname = GetPostString("shopname");
  10031. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10032. string buyernick = GetPostString("buyer_nick");
  10033. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10034. //if (tid.Length == 0 && buyernick.Length == 0)
  10035. //{
  10036. // lw.Add(string.Format("IsRefund<={0}", 1));
  10037. //}
  10038. string customer = GetPostString("customer");
  10039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10040. string design = GetPostString("design");
  10041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10042. string orderState = GetPostString("orderState");
  10043. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10044. string address = GetPostString("address");
  10045. 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));
  10046. string sellermemo = GetPostString("seller_memo");
  10047. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10048. string supplier = GetPostString("supplier");
  10049. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10050. string OrderArea = GetPostString("order_area");
  10051. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10052. string placedate1 = GetPostString("placedate1");
  10053. string placedate2 = GetPostString("placedate2");
  10054. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10055. if (fdw.Length > 0) lw.Add(fdw);
  10056. string price1 = GetPostString("price1");
  10057. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10058. string price2 = GetPostString("price2");
  10059. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10060. string unusualCon = GetPostString("unusualcon");
  10061. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10062. string posTag = CurrentUser.UserPost.Post.Code;
  10063. if (posTag == "Supplier")
  10064. {
  10065. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10066. }
  10067. lw.Add(string.Format("OrderState = 6 "));
  10068. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10069. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10071. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10072. writeGridDataTableJson(dStruct.TotalCount, dt);
  10073. }
  10074. public void change_erp_sup_state()
  10075. {
  10076. if (UrlPostParmsCheck("ctid"))
  10077. {
  10078. string ctid = GetPostString("ctid");
  10079. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10080. if (ceErpTradeCell != null)
  10081. {
  10082. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10083. if (ceErpTradeCellExtend == null)
  10084. {
  10085. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10086. ceErpTradeCellExtend.ctid = ctid;
  10087. ceErpTradeCellExtend.SupState = 1;
  10088. ceErpTradeCellExtend.Create();
  10089. }
  10090. else
  10091. {
  10092. ceErpTradeCellExtend.SupState = 1;
  10093. ceErpTradeCellExtend.Update();
  10094. }
  10095. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10096. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10097. return;
  10098. }
  10099. returnErrorMsg("找不到订单");
  10100. }
  10101. }
  10102. public void supplier_all_downs()
  10103. {
  10104. if (UrlPostParmsCheck("tids"))
  10105. {
  10106. string tids = GetPostString("tids");
  10107. if (tids != null && tids.Length > 0)
  10108. {
  10109. StringBuilder sql = new StringBuilder();
  10110. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10111. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10112. sql = new StringBuilder();
  10113. 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, "下载设计文件");
  10114. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10115. string[] list = tids.Split(',');
  10116. foreach (string ctid in list)
  10117. {
  10118. CeErpSukuraData.createInfo(ctid, 3);
  10119. }
  10120. designHelper.api_approveDesign(tids); //approveDesign
  10121. returnSuccessMsg("下载成功!");
  10122. return;
  10123. }
  10124. returnErrorMsg("下载订单更新失败");
  10125. }
  10126. }
  10127. public void uploaderFileSuccess()
  10128. {
  10129. if (UrlPostParmsCheck("fileName"))
  10130. {
  10131. string fileName = GetPostString("fileName");
  10132. ApiVo apiVo = new ApiVo();
  10133. apiVo.orderNumber = fileName;
  10134. apiVo.actionName = "finishDesign";
  10135. designHelper.API_WorkCore(apiVo);//finishDesign
  10136. returnSuccessMsg("");
  10137. }
  10138. }
  10139. public void get_sample2_order()
  10140. {
  10141. if (UrlPostParmsCheck("ctid"))
  10142. {
  10143. string ctid = GetPostString("ctid");
  10144. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10145. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10146. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10147. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10148. double total = 0.0;
  10149. double order_price = 0.0;
  10150. if (dt_bu.Rows.Count > 0)
  10151. {
  10152. foreach (DataRow dr in dt_bu.Rows)
  10153. {
  10154. total += Convert.ToDouble(dr["payment"]);
  10155. }
  10156. }
  10157. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10158. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10159. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10160. string tid = ctid.Replace("S_", "");
  10161. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10162. double paymant = 0.0;
  10163. if (entity != null)
  10164. {
  10165. paymant = entity.payment;
  10166. }
  10167. string return_reason = "";
  10168. if (dt_after != null && dt_after.Rows.Count > 0)
  10169. {
  10170. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10171. }
  10172. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10173. }
  10174. }
  10175. public void get_erp_design_status()
  10176. {
  10177. string designName = GetPostString("designName");
  10178. DataStruct dStruct = GetPostStruct();
  10179. if (designName.Length > 0)
  10180. {
  10181. 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";
  10182. sql_user += " and Name like '%" + designName + "%'";
  10183. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10184. List<string> ids_list = new List<string>();
  10185. if (user_table.Rows.Count > 0)
  10186. {
  10187. foreach (DataRow item in user_table.Rows)
  10188. {
  10189. ids_list.Add(item["id"].ToString());
  10190. string ids_s = item["TeamIds"].ToString();
  10191. if (ids_s.Length > 0)
  10192. {
  10193. ids_list.AddRange(ids_s.Split(','));
  10194. }
  10195. }
  10196. }
  10197. HashSet<string> set = new HashSet<string>(ids_list);
  10198. ids_list = set.ToList();
  10199. if (ids_list.Count > 0)
  10200. {
  10201. 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));
  10202. dStruct.MainWhere = sql;
  10203. DataTable dt = null;
  10204. dt = WebCache.GetData("view_ErpUser", dStruct);
  10205. writeGridDataTableJson(dStruct.TotalCount, dt);
  10206. }
  10207. }
  10208. }
  10209. public void change_erp_order_price()
  10210. {
  10211. string ctid = GetPostString("ctid");
  10212. double price = GetPostDouble("price");
  10213. if (ctid.Length > 0)
  10214. {
  10215. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10216. if (ceErpTradeCellExtend == null)
  10217. {
  10218. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10219. ceErpTradeCellExtend.ctid = ctid;
  10220. ceErpTradeCellExtend.payment_cyt = price;
  10221. ceErpTradeCellExtend.Create();
  10222. }
  10223. else
  10224. {
  10225. ceErpTradeCellExtend.payment_cyt = price;
  10226. ceErpTradeCellExtend.Update();
  10227. }
  10228. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10229. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10230. {
  10231. ceErpDataSendOrderInfo.isSync = false;
  10232. ceErpDataSendOrderInfo.Update();
  10233. }
  10234. if (ceErpDataSendOrderInfo == null)
  10235. {
  10236. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10237. ceErpDataSendOrderInfo.isSync = false;
  10238. ceErpDataSendOrderInfo.ctid = ctid;
  10239. ceErpDataSendOrderInfo.Create();
  10240. }
  10241. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10242. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10243. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10244. if (dth != null && dth.Rows.Count > 0)
  10245. {
  10246. dataSendOrderBean dataSendOrderBean = null;
  10247. foreach (DataRow item in dth.Rows)
  10248. {
  10249. try
  10250. {
  10251. dataSendOrderBean = new dataSendOrderBean();
  10252. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10253. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10254. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10255. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10256. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10257. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10258. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10259. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10260. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10261. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10262. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10263. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10264. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10265. if (result != null)
  10266. {
  10267. if ("0".Equals(result.errcode))
  10268. {
  10269. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10270. }
  10271. else
  10272. {
  10273. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10274. }
  10275. }
  10276. }
  10277. catch (Exception ex)
  10278. {
  10279. }
  10280. }
  10281. }
  10282. returnSuccessMsg("修改成功!");
  10283. return;
  10284. }
  10285. returnErrorMsg("找不到订单");
  10286. }
  10287. public void find_he_together()
  10288. {
  10289. string ctid = GetPostString("ctid");
  10290. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10291. List<string> list = new List<string>();
  10292. if (ceErpTradeCell != null)
  10293. {
  10294. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10295. {
  10296. 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);
  10297. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10298. if (table != null && table.Rows.Count > 0)
  10299. {
  10300. foreach (TableRow row in table.Rows)
  10301. {
  10302. }
  10303. }
  10304. }
  10305. }
  10306. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10307. }
  10308. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10309. {
  10310. //chy----19
  10311. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10312. //GD-CYT-----64
  10313. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10314. //ZHX----3
  10315. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10316. //JK----97
  10317. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10318. //ZT----70
  10319. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10320. //LHCY-----98
  10321. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10322. //XD-----90
  10323. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10324. //CYCY-----14
  10325. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10326. };
  10327. //其他改名
  10328. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10329. {
  10330. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10331. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10332. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10333. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10334. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10335. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10336. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10337. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10338. };
  10339. //不统计
  10340. List<int> no_suppliers = new List<int>()
  10341. {
  10342. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10343. };
  10344. //配件单
  10345. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10346. {
  10347. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10348. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10349. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10350. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10351. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10352. {"旗杆",new List<string>(){ "班旗" } },
  10353. {"牙签",new List<string>(){ "不干胶" } }
  10354. };
  10355. public void get_place_order_data()
  10356. {
  10357. string date1 = GetPostString("date1");
  10358. string date2 = GetPostString("date2");
  10359. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10360. DateTime start = DateTime.Parse(starttime);
  10361. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10362. DateTime end = DateTime.Parse(endtime);
  10363. if (date1 != null && date1.Length > 0)
  10364. {
  10365. DateTime dateTime = DateTime.Parse(date1);
  10366. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10367. start = DateTime.Parse(starttime);
  10368. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10369. end = DateTime.Parse(endtime);
  10370. }
  10371. if (date2 != null && date2.Length > 0)
  10372. {
  10373. DateTime dateTime = DateTime.Parse(date2);
  10374. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10375. end = DateTime.Parse(endtime);
  10376. }
  10377. 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);
  10378. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10379. //不干胶-----1,卡片-----29
  10380. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10381. foreach (DataRow row in data.Rows)
  10382. {
  10383. int productId = Convert.ToInt32(row["ProductId"]);
  10384. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10385. if (no_suppliers.Contains(supplierId))
  10386. {
  10387. continue;
  10388. }
  10389. string seller_memo = row["seller_memo"].ToString();
  10390. bool ispj = false;//是否配件单
  10391. bool isfirst = true;//第一个配
  10392. maps.Keys.ForEach(key =>
  10393. {
  10394. //备注包含配件
  10395. if (seller_memo.Contains(key) && isfirst)
  10396. {
  10397. List<string> list = maps[key];
  10398. ispj = true;
  10399. isfirst = false;
  10400. for (int i = 0; i < list.Count; i++)
  10401. {
  10402. if (seller_memo.Contains(list[i]))
  10403. {
  10404. ispj = false;
  10405. break;
  10406. }
  10407. }
  10408. }
  10409. });
  10410. if (ispj)
  10411. {
  10412. continue;
  10413. }
  10414. seller_memo = seller_memo.Replace("UV", "uv");
  10415. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10416. //吊牌归到卡片
  10417. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10418. seller_memo = seller_memo.Replace("卡套", "卡片");
  10419. seller_memo = seller_memo.Replace("封套", "卡片");
  10420. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10421. seller_memo = seller_memo.Replace("腰封", "卡片");
  10422. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10423. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10424. seller_memo = seller_memo.Replace("横幅", "条幅");
  10425. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10426. string map_key = "";
  10427. string type = "";
  10428. if (supplierMap.ContainsKey(supplierId))
  10429. {
  10430. foreach (var kvp in supplierMap[supplierId])
  10431. {
  10432. if (seller_memo.Contains(kvp.Key))
  10433. {
  10434. map_key = kvp.Value;
  10435. type = kvp.Value;
  10436. break;
  10437. }
  10438. }
  10439. }
  10440. if (map_key == "")
  10441. {
  10442. type = "其他";
  10443. map_key = "其他";
  10444. }
  10445. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10446. {
  10447. map_key = suppliers[supplierId];
  10448. }
  10449. if (supplierId == 70)
  10450. {
  10451. supplierId = 70;
  10452. }
  10453. map_key += "_" + row["SupplierName"].ToString();
  10454. Dictionary<string, int> map = null;
  10455. if (other_map.ContainsKey(map_key))
  10456. {
  10457. other_map.TryGetValue(map_key, out map);
  10458. }
  10459. else
  10460. {
  10461. map = new Dictionary<string, int>();
  10462. map.Add("dayDev", 0);//当天出货
  10463. map.Add("dayTotal", 0);//下单总数
  10464. map.Add("payTotal", 0);//500以上
  10465. map.Add("today", 0);//当天出货数量
  10466. map.Add("unusua", 0);//异常数
  10467. other_map.Add(map_key, map);
  10468. other_map.TryGetValue(map_key, out map);
  10469. }
  10470. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10471. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10472. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10473. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10474. {
  10475. map["dayTotal"]++;
  10476. if (supplierId == 97)
  10477. {
  10478. supplierId = 97;
  10479. }
  10480. }
  10481. if (Convert.ToDecimal(row["payment"]) >= 500)
  10482. {
  10483. map["payTotal"]++;
  10484. }
  10485. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10486. {
  10487. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10488. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10489. {
  10490. map["today"]++;
  10491. }
  10492. }
  10493. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10494. {
  10495. map["unusua"]++;
  10496. }
  10497. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10498. //GD-CYT-----64
  10499. DateTime two = palceTimeStart.AddHours(14);
  10500. DateTime three = palceTimeStart.AddHours(15);
  10501. DateTime four = palceTimeStart.AddHours(16);
  10502. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10503. {
  10504. //下午四点前 500-1000
  10505. string count = row["ProductCount"].ToString();
  10506. if (count != null && count.Length > 0)
  10507. {
  10508. int productCount = commonHelper.getPlaceProductCount(count);
  10509. if (productCount >= 500 && productCount <= 1000)
  10510. {
  10511. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10512. {
  10513. map["dayDev"]++;
  10514. }
  10515. }
  10516. }
  10517. }
  10518. //UV
  10519. else if ("uv".Equals(type))
  10520. {
  10521. //ZT----70
  10522. //ZHX----3
  10523. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10524. {
  10525. map["dayDev"]++;
  10526. }
  10527. //JK----97
  10528. //HZX----105
  10529. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10530. {
  10531. map["dayDev"]++;
  10532. if (supplierId == 97)
  10533. {
  10534. supplierId = 97;
  10535. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10536. }
  10537. }
  10538. }
  10539. //帆布---52|条幅---27
  10540. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10541. {
  10542. //LHCY-----98
  10543. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10544. {
  10545. map["dayDev"]++;
  10546. }
  10547. }
  10548. //条幅
  10549. else if ("条幅".Equals(type))
  10550. {
  10551. //XD-----90
  10552. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10553. {
  10554. map["dayDev"]++;
  10555. }
  10556. }
  10557. //桌布
  10558. else if ("桌布".Equals(type))
  10559. {
  10560. //XD-----90
  10561. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10562. {
  10563. map["dayDev"]++;
  10564. }
  10565. }
  10566. //DL---10
  10567. //AYTW---119
  10568. //FS-CYT-DY ----80
  10569. //JK----97
  10570. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10571. {
  10572. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10573. {
  10574. map["dayDev"]++;
  10575. }
  10576. }
  10577. }
  10578. DataTable dt = new DataTable();
  10579. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10580. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10581. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10582. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10583. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10584. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10585. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10586. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10587. other_map.Keys.ForEach(key =>
  10588. {
  10589. DataRow dr = dt.NewRow();
  10590. Dictionary<string, int> map = other_map[key];
  10591. string[] key_list = key.Split('_');
  10592. dr[0] = key_list[0];
  10593. dr[1] = key_list[1];
  10594. if (key_list.Length > 2)
  10595. {
  10596. dr[1] += "(" + key_list[2] + ")";
  10597. }
  10598. dr[2] = map["dayTotal"];
  10599. dr[3] = map["payTotal"];
  10600. dr[4] = map["today"];
  10601. dr[5] = map["unusua"];
  10602. dr[6] = map["dayDev"];
  10603. double rate = 0.00;
  10604. if (map["dayDev"] > 0)
  10605. {
  10606. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10607. }
  10608. dr[7] = rate.ToString();
  10609. dt.Rows.Add(dr);
  10610. });
  10611. DataView dv = new DataView(dt);
  10612. dv.Sort = "SupplierName";
  10613. //dv.Sort = "AllOrder desc";
  10614. DataTable dtNew = dv.ToTable();
  10615. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10616. }
  10617. public void check_order_desing_info()
  10618. {
  10619. string ctid = GetPostString("ctid");
  10620. if (!string.IsNullOrEmpty(ctid))
  10621. {
  10622. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10623. if (ceErpTradeCell != null)
  10624. {
  10625. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10626. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10627. return;
  10628. }
  10629. returnErrorMsg("找不到订单");
  10630. return;
  10631. }
  10632. returnErrorMsg("找不到订单");
  10633. }
  10634. public void get_timeout_detail()
  10635. {
  10636. string poscode = CurrentUser.UserPost.Post.Code;
  10637. DataStruct dStruct = GetPostStruct();
  10638. List<string> lw = new List<string>();
  10639. string id = GetPostString("id");
  10640. string pay_date1 = GetPostString("pay_date1");
  10641. string pay_date2 = GetPostString("pay_date2");
  10642. int type = GetPostInt("type");
  10643. if (type == 0)
  10644. {
  10645. if (pay_date1.Length > 0)
  10646. {
  10647. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10648. }
  10649. if (pay_date2.Length > 0)
  10650. {
  10651. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10652. }
  10653. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10654. }
  10655. if (type == 1)
  10656. {
  10657. if (pay_date1.Length > 0)
  10658. {
  10659. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10660. }
  10661. if (pay_date2.Length > 0)
  10662. {
  10663. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10664. }
  10665. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10666. }
  10667. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10668. DataTable dt = null;
  10669. dt = WebCache.GetData("view_orderlist", dStruct);
  10670. writeGridDataTableJson(dStruct.TotalCount, dt);
  10671. }
  10672. public void saveUrgentChargePrice()
  10673. {
  10674. string ctid = GetPostString("ctid");
  10675. if (!string.IsNullOrEmpty(ctid))
  10676. {
  10677. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10678. if (ceErpTradeCell != null)
  10679. {
  10680. double price = GetPostDouble("price");
  10681. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10682. if (ceErpTradeCellExtend == null)
  10683. {
  10684. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10685. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10686. }
  10687. ceErpTradeCellExtend.urgentCharge = price;
  10688. if (ceErpTradeCellExtend.ID > 0)
  10689. {
  10690. ceErpTradeCellExtend.Update();
  10691. }
  10692. else
  10693. {
  10694. ceErpTradeCellExtend.Save();
  10695. }
  10696. returnSuccessMsg("修改成功!");
  10697. return;
  10698. }
  10699. returnErrorMsg("找不到订单");
  10700. return;
  10701. }
  10702. returnErrorMsg("找不到订单");
  10703. }
  10704. public void finish_erp_order()
  10705. {
  10706. string ctid = GetPostString("ctid");
  10707. if (!string.IsNullOrEmpty(ctid))
  10708. {
  10709. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10710. {
  10711. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10712. if (ceErpTradeCell != null)
  10713. {
  10714. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10715. ceErpTradeCell.Update();
  10716. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10717. returnSuccessMsg("修改成功!");
  10718. return;
  10719. }
  10720. }
  10721. }
  10722. returnErrorMsg("找不到订单");
  10723. }
  10724. public void get_trade_order_list()
  10725. {
  10726. string tid = GetPostString("tid");
  10727. if (!string.IsNullOrEmpty(tid))
  10728. {
  10729. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10730. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10731. writeGridDataTableJson(data.Rows.Count, data);
  10732. return;
  10733. }
  10734. returnErrorMsg("找不到订单");
  10735. }
  10736. public void save_cell_spu()
  10737. {
  10738. string ctid = GetPostString("ctid");
  10739. string spu_id = GetPostString("spu_id");
  10740. if (!string.IsNullOrEmpty(ctid))
  10741. {
  10742. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10743. if (ceErpTradeCellExtend == null)
  10744. {
  10745. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10746. ceErpTradeCellExtend.ctid = ctid;
  10747. }
  10748. ceErpTradeCellExtend.spu_id = spu_id;
  10749. if (ceErpTradeCellExtend.ID == 0)
  10750. {
  10751. ceErpTradeCellExtend.Create();
  10752. }
  10753. else
  10754. {
  10755. ceErpTradeCellExtend.Update();
  10756. }
  10757. returnSuccessMsg("修改成功!");
  10758. return;
  10759. }
  10760. returnErrorMsg("找不到订单");
  10761. }
  10762. public void change_express_info()
  10763. {
  10764. string ctid = GetPostString("ctid");
  10765. string transNo = GetPostString("transNo");
  10766. string transCom = GetPostString("transCom");
  10767. if (!string.IsNullOrEmpty(ctid))
  10768. {
  10769. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10770. if (ceErpTradeCellExtend == null)
  10771. {
  10772. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10773. ceErpTradeCellExtend.ctid = ctid;
  10774. }
  10775. ceErpTradeCellExtend.modExpressNo = transNo;
  10776. ceErpTradeCellExtend.modExpressCom = transCom;
  10777. ceErpTradeCellExtend.readMod = 2;
  10778. if (ceErpTradeCellExtend.ID == 0)
  10779. {
  10780. ceErpTradeCellExtend.Create();
  10781. }
  10782. else
  10783. {
  10784. ceErpTradeCellExtend.Update();
  10785. }
  10786. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10787. returnSuccessMsg("修改成功!");
  10788. return;
  10789. }
  10790. returnErrorMsg("找不到订单");
  10791. }
  10792. public void get_change_express_list()
  10793. {
  10794. DataStruct dStruct = GetPostStruct();
  10795. List<string> lw = new List<string>();
  10796. int st = 2;
  10797. string tid = GetPostString("ctid");
  10798. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10799. string shopname = GetPostString("shopname");
  10800. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10801. string buyernick = GetPostString("buyer_nick");
  10802. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10803. string sellermemo = GetPostString("seller_memo");
  10804. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10805. string supplier = GetPostString("supplier");
  10806. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10807. string customer = GetPostString("customer");
  10808. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10809. string design = GetPostString("design");
  10810. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10811. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10812. string poscode = CurrentUser.UserPost.Post.Code;
  10813. if (poscode != "SysAdmin")
  10814. {
  10815. string shopid = CurrentUser.User.pemShop;
  10816. lw.Add(string.Format("shopId in ({0})", shopid));
  10817. }
  10818. lw.Add("readMod = 2");
  10819. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10820. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10821. writeGridDataTableJson(dStruct.TotalCount, dt);
  10822. }
  10823. public void deal_express_complete()
  10824. {
  10825. string ctid = GetPostString("ctid");
  10826. if (!string.IsNullOrEmpty(ctid))
  10827. {
  10828. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10829. if (ceErpTradeCellExtend == null)
  10830. {
  10831. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10832. ceErpTradeCellExtend.ctid = ctid;
  10833. }
  10834. ceErpTradeCellExtend.readMod = 1;
  10835. if (ceErpTradeCellExtend.ID == 0)
  10836. {
  10837. ceErpTradeCellExtend.Create();
  10838. }
  10839. else
  10840. {
  10841. ceErpTradeCellExtend.Update();
  10842. }
  10843. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10844. returnSuccessMsg("修改成功!");
  10845. return;
  10846. }
  10847. returnErrorMsg("找不到订单");
  10848. }
  10849. public void aftersale_return_visit()
  10850. {
  10851. string ctid = GetPostString("ctid");
  10852. if (!string.IsNullOrEmpty(ctid))
  10853. {
  10854. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10855. if (ceErpTradeCellExtend == null)
  10856. {
  10857. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10858. ceErpTradeCellExtend.ctid = ctid;
  10859. }
  10860. ceErpTradeCellExtend.returnVisit = 1;
  10861. if (ceErpTradeCellExtend.ID == 0)
  10862. {
  10863. ceErpTradeCellExtend.Create();
  10864. }
  10865. else
  10866. {
  10867. ceErpTradeCellExtend.Update();
  10868. }
  10869. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  10870. if (ceErpTradeAfterSaleExtend != null)
  10871. {
  10872. ceErpTradeAfterSaleExtend.TextResult = "";
  10873. ceErpTradeAfterSaleExtend.Update();
  10874. }
  10875. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  10876. returnSuccessMsg("修改成功!");
  10877. return;
  10878. }
  10879. returnErrorMsg("找不到订单");
  10880. }
  10881. public void orderPlaceInfo()
  10882. {
  10883. string ctids = GetPostString("ctids");
  10884. string[] list = ctids.Split(',');
  10885. foreach (string ctid in list)
  10886. {
  10887. CeErpSukuraData.createInfo(ctid, 3);
  10888. }
  10889. designHelper.api_approveDesign(ctids); //approveDesign
  10890. returnSuccessMsg("");
  10891. }
  10892. }
  10893. }