sync.order.cs 654 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. namespace SiteCore.Handler
  51. {
  52. public partial class sync
  53. {
  54. public void get_erp_orderlist()
  55. {
  56. string poscode = CurrentUser.UserPost.Post.Code;
  57. DataStruct dStruct = GetPostStruct();
  58. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  59. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\镭射银吊牌(1).xlsx");
  60. //apiHelper.Api_SyncOrderByTime("598825");
  61. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  62. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  63. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  64. //banniuApiHelper.sendLogisticsInfo(null);
  65. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  66. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  67. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  68. //int sid = commonHelper.autoDistributeToSupplier(entity);
  69. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  70. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1752654175000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1752826970000,\"lines\":[{\"latestDeliveryTime\":1752826970000,\"mark2\":[],\"num\":23,\"outerId\":\"DGCP\",\"payment\":460.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2200806677467/O1CN01Wlpmej251wOGAuYd2_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":20.0,\"refOlId\":\"4634728491992436446\",\"refSkuId\":\"0\",\"refSpuId\":\"617207822351\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":20.0,\"singleFee\":20.0,\"spuOuterId\":\"DGCP\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"蛋糕logo插牌定制烘焙店插卡插排生日小卡片装饰甜品标签插件设计\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1752658857000,\"openBuyerId\":\"AAHqRHraABkUZRPgSx1P9I8b\",\"openBuyerNick\":\"b**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1752654168000,\"payTime\":1752654170000,\"payment\":460.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"佛山市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"禅城区\",\"receiverId\":\"882d7aaecddc7a9698cc36e36a46ba24$\",\"receiverState\":\"广东省\",\"receiverTown\":\"石湾镇街道\",\"refOid\":\"4634728491992436446\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"60x12mm-2款各500张-插卡-350克铜板纸-直角单面烫金模切-bowie_s-英子-240元-(纯烫金)-老客户204.02.20,40x40mm-2000张-插卡-350克铜板纸-方形直角裁切-bowie_s-英子-220元--老客户2024.02.20\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0,\"type\":\"SALE\"}}");
  71. //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}}");
  72. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  73. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  74. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  75. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  76. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  77. string tids = File.ReadAllText(path);
  78. List<string> list = tids.Split(',').ToList();
  79. int index = 0;
  80. foreach (string item in list)
  81. {
  82. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  83. try
  84. {
  85. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  86. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  87. List<string> tidList = new List<string>();
  88. if (dataTable != null && dataTable.Rows.Count > 0)
  89. {
  90. foreach (DataRow row in dataTable.Rows)
  91. {
  92. tidList.Add("'" + row["tid"].ToString() + "'");
  93. }
  94. }
  95. if (tidList.Count > 0)
  96. {
  97. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  98. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  99. if (dataTable != null && dataTable.Rows.Count > 0)
  100. {
  101. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  102. if (count > 0)
  103. {
  104. Debug.WriteLine(index++);
  105. continue;
  106. }
  107. }
  108. }
  109. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  110. }
  111. catch (Exception e)
  112. {
  113. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  114. }
  115. Debug.WriteLine(index++);
  116. }*/
  117. List<string> lw = new List<string>();
  118. string tid = GetPostString("ctid");
  119. string date1 = GetPostString("date1");
  120. //12-1 修改
  121. string urgent = GetPostString("urgent");
  122. string back = GetPostString("back");
  123. string offlineSearch = GetPostString("offlineSearch");
  124. int paramsCount = 0;
  125. if (!string.IsNullOrWhiteSpace(urgent))
  126. {
  127. if (urgent.Equals("true"))
  128. {
  129. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  130. }
  131. }
  132. if (!string.IsNullOrWhiteSpace(back))
  133. {
  134. if (back.Equals("true"))
  135. {
  136. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  137. }
  138. }
  139. if (!string.IsNullOrWhiteSpace(offlineSearch))
  140. {
  141. if (offlineSearch.Equals("true"))
  142. {
  143. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  144. }
  145. }
  146. //end
  147. string date2 = GetPostString("date2");
  148. string buyernick = GetPostString("buyer_nick");
  149. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  150. {
  151. if (tid.Length <= 0 && buyernick.Length <= 0)
  152. {
  153. return;
  154. }
  155. }
  156. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  157. {
  158. if (tid.Length > 0)
  159. {
  160. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  161. if (ceErpTradeCell != null)
  162. {
  163. tid = ceErpTradeCell.tid;
  164. }
  165. List<string> select_tid = getTidByCtidMore(tid);
  166. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  167. }
  168. if (buyernick.Length > 0)
  169. {
  170. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  171. }
  172. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  173. if (dw.Length > 0)
  174. {
  175. lw.Add(dw);
  176. }
  177. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  178. {
  179. string usershop = CurrentUser.User.pemShop;
  180. lw.Add(string.Format("ShopId in ({0})", usershop));
  181. }
  182. }
  183. else
  184. {
  185. if (ex_psize == 0)
  186. {
  187. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  188. }
  189. if (PKey != "admin" && poscode != "SysAdmin")
  190. {
  191. string usershop = CurrentUser.User.pemShop;
  192. lw.Add(string.Format("ShopId in ({0})", usershop));
  193. paramsCount++;
  194. }
  195. }
  196. string uploaddate1 = GetPostString("uploaddate1");
  197. string uploaddate2 = GetPostString("uploaddate2");
  198. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  199. if (update.Length > 0) lw.Add(update);
  200. string deliverydate1 = GetPostString("deliverydate1");
  201. string deliverydate2 = GetPostString("deliverydate2");
  202. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  203. if (deliverydate.Length > 0)
  204. {
  205. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  206. };
  207. string shopname = GetPostString("shopname");
  208. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  209. string addwechat = GetPostString("addwechat");
  210. if (addwechat.Length > 0)
  211. {
  212. int addWt = Convert.ToInt32(addwechat);
  213. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  214. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  215. }
  216. string customer = GetPostString("customer");
  217. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  218. string design = GetPostString("design");
  219. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  220. string orderState = GetPostString("orderState");
  221. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  222. string address = GetPostString("address");
  223. 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));
  224. string sellermemo = GetPostString("seller_memo");
  225. if (sellermemo.Length > 0)
  226. {
  227. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  228. }
  229. string backReason = GetPostString("backReason");
  230. if (backReason.Length > 0)
  231. {
  232. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  233. }
  234. string apdate1 = GetPostString("apdate1");
  235. string apdate2 = GetPostString("apdate2");
  236. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  237. if (dwap.Length > 0) lw.Add(dwap);
  238. string price1 = GetPostString("price1");
  239. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  240. string price2 = GetPostString("price2");
  241. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  242. string isoldcustomer = GetPostString("isoldcus");
  243. string spudata = GetPostString("spudata");
  244. if ("0".Equals(spudata))
  245. {
  246. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  247. }
  248. if ("1".Equals(spudata))
  249. {
  250. lw.Add(string.Format("spu_id <> ''"));
  251. }
  252. string finishdate1 = GetPostString("finishdate1");
  253. string finishdate2 = GetPostString("finishdate2");
  254. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  255. bool isFinish = false;
  256. if (finishdate.Length > 0)
  257. {
  258. lw.Add(finishdate);
  259. isFinish = true;
  260. paramsCount++;
  261. }
  262. if (isoldcustomer.Length > 0)
  263. {
  264. if ("2".Equals(isoldcustomer))
  265. {
  266. lw.Add(string.Format("VipCustomer=1"));
  267. }
  268. else
  269. {
  270. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  271. }
  272. }
  273. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  274. if (ex_psize > 0)
  275. {
  276. int UserID = CurrentUser.UserID;
  277. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  278. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  279. {
  280. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  281. }
  282. dStruct.Order = "pay_time desc";
  283. }
  284. string isNew = GetPostString("isNew");
  285. if (isNew == "true")
  286. {
  287. lw.Add(string.Format("IsNew = {0}", 1));
  288. }
  289. string overtime = GetPostString("overtime");
  290. if (overtime == "1")
  291. {
  292. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  293. }
  294. String usePost = CurrentUser.UserPost.Post.Code;
  295. if (usePost.Equals("Operation") == true)
  296. {
  297. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  298. }
  299. else
  300. {
  301. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  302. }
  303. //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";
  304. if (dStruct.PageSize == 100000)
  305. {
  306. dStruct.Order = "";
  307. }
  308. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  309. DataTable dt = null;
  310. string tablename = "view_orderlist";
  311. if (isFinish)
  312. {
  313. tablename = "view_orderlist_end";
  314. }
  315. dt = WebCache.GetData(tablename, dStruct);
  316. if (dt != null && dt.Rows.Count > 0)
  317. {
  318. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  319. foreach (DataRow dr in dt.Rows)
  320. {
  321. try
  322. {
  323. if (dr["refund_fees"] != null)
  324. {
  325. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  326. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  327. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  328. if (payment == refund_fees)
  329. {
  330. dr["refund_fees"] = Math.Round(refund_fees, 2);
  331. }
  332. else if (refund_fees == total_fee)
  333. {
  334. dr["refund_fees"] = payment;
  335. }
  336. else
  337. {
  338. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  339. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  340. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  341. }
  342. }
  343. // 对象操作
  344. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  345. ceErpTradeCell.ctid = dr["ctid"].ToString();
  346. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  347. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  348. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  349. if (dStruct.PageSize != 100000)
  350. {
  351. if (dr["DispatchSort"].ToString() == "2")
  352. {
  353. dr["gongchuang"] = 200;
  354. }
  355. else if ("外协".Equals(dr["ToType"].ToString()))
  356. {
  357. dr["gongchuang"] = 200;
  358. }
  359. else if ("内部".Equals(dr["ToType"].ToString()))
  360. {
  361. dr["gongchuang"] = -1;
  362. }
  363. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  364. {
  365. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  366. dr["gongchuang"] = response.code;
  367. }
  368. }
  369. }
  370. catch (NullReferenceException ex)
  371. {
  372. // 处理空引用异常
  373. dr["refund_fees"] = "0.00";
  374. }
  375. }
  376. }
  377. writeGridDataTableJson(dStruct.TotalCount, dt);
  378. }
  379. public void get_erp_orderlist_sumprice()
  380. {
  381. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  382. return;
  383. List<string> lw = new List<string>();
  384. string tid = GetPostString("ctid");
  385. string date1 = GetPostString("date1");
  386. string date2 = GetPostString("date2");
  387. if (tid.Length > 0 || date1.Length > 0)
  388. {
  389. lw.Add(string.Format("ctid like '%{0}%'", tid));
  390. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  391. if (dw.Length > 0) lw.Add(dw);
  392. }
  393. else
  394. {
  395. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  396. }
  397. string shopname = GetPostString("shopname");
  398. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  399. string buyernick = GetPostString("buyer_nick");
  400. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  401. string customer = GetPostString("customer");
  402. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  403. string design = GetPostString("design");
  404. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  405. string orderState = GetPostString("orderState");
  406. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  407. string address = GetPostString("address");
  408. 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));
  409. string sellermemo = GetPostString("seller_memo");
  410. if (sellermemo.Length > 0)
  411. {
  412. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  413. }
  414. string apdate1 = GetPostString("apdate1");
  415. string apdate2 = GetPostString("apdate2");
  416. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  417. if (dwap.Length > 0) lw.Add(dwap);
  418. string price1 = GetPostString("price1");
  419. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  420. string price2 = GetPostString("price2");
  421. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  422. string isoldcustomer = GetPostString("isoldcus");
  423. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  424. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  425. if (PKey != "admin")
  426. {
  427. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  428. lw.Add(string.Format("shopId in ({0})", usershop));
  429. }
  430. //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";
  431. string mainWhere = string.Join(" and ", lw.ToArray());
  432. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  433. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  434. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  435. decimal total = 0;
  436. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  437. {
  438. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  439. }
  440. var res = new
  441. {
  442. data = total
  443. };
  444. string ro_jsond = JsonConvert.SerializeObject(res);
  445. returnSuccess(ro_jsond);
  446. return;
  447. }
  448. public void get_erp_CustomerServiceGather()
  449. {
  450. string userWhere = "", orderWhere = "";
  451. List<string> lw = new List<string>();
  452. string customer = GetPostString("customer");
  453. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  454. string shopname = GetPostString("shopname");
  455. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  456. string date1 = GetPostString("date1");
  457. string date2 = GetPostString("date2");
  458. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  459. if (dw.Length > 0) lw.Add(dw);
  460. orderWhere = string.Join(" and ", lw.ToArray());
  461. 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 " +
  462. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  463. "left join " +
  464. "( " +
  465. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  466. ") as b on a.ID = b.CustomerUserId " +
  467. "left join " +
  468. "( " +
  469. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  470. ") as d on a.ID = d.CustomerUserId " +
  471. "left join " +
  472. "( " +
  473. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  474. ") as e on a.ID = e.CustomerUserId " +
  475. "left join " +
  476. "( " +
  477. " select CustomerUserId, RefundCount, RefundSum from " +
  478. " ( " +
  479. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  480. " from CE_ErpTradeRefund a " +
  481. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  482. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  483. " group by CustomerUserId " +
  484. " ) as a " +
  485. ") as f on a.ID = f.CustomerUserId " +
  486. "where a.PostCode = 'CustomerService'",
  487. userWhere, orderWhere);
  488. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  489. writeGridDataTableJson(dt.Rows.Count, dt);
  490. //writeGridDataTableJson(dt.Rows.Count, dt);
  491. }
  492. //设计汇总
  493. public void get_erp_DesignerGather()
  494. {
  495. string userWhere = "", orderWhere = "";
  496. List<string> lw = new List<string>();
  497. string Designer = GetPostString("designer");
  498. int org = GetPostInt("org");
  499. if (Designer.Length > 0)
  500. {
  501. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  502. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  503. }
  504. else if (org > 0)
  505. {
  506. userWhere = string.Format(" where OrgID ={0}", org);
  507. }
  508. string shopname = GetPostString("shopname");
  509. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  510. string state = GetPostString("state");
  511. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  512. string OrderArea = GetPostString("order_area");
  513. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  514. string date1 = GetPostString("date1");
  515. string date2 = GetPostString("date2");
  516. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  517. if (dw.Length > 0) lw.Add(dw);
  518. string UpDate1 = GetPostString("UpDate1");
  519. string UpDate2 = GetPostString("UpDate2");
  520. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  521. if (dw.Length > 0) lw.Add(dw);
  522. orderWhere = string.Join(" and ", lw.ToArray());
  523. 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 (" +
  524. "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 " +
  525. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  526. "left join " +
  527. "( " +
  528. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  529. ") as b on a.ID = b.DesignUserId " +
  530. "left join " +
  531. "( " +
  532. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  533. ") as d on a.ID = d.DesignUserId " +
  534. "left join " +
  535. "( " +
  536. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  537. ") as e on a.ID = e.DesignUserId " +
  538. "left join " +
  539. "( " +
  540. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  541. ") as g on a.ID = g.DesignUserId " +
  542. "left join " +
  543. "( " +
  544. " select CustomerUserId, RefundCount, RefundSum from " +
  545. " ( " +
  546. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  547. " from CE_ErpTradeRefund a " +
  548. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  549. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  550. " group by CustomerUserId " +
  551. " ) as a " +
  552. ") as f on a.ID = f.CustomerUserId " +
  553. "where a.PostCode = 'Designer') as z",
  554. userWhere, orderWhere);
  555. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  556. writeGridDataTableJson(dt.Rows.Count, dt);
  557. }
  558. //删除tradecell的订单
  559. public void del_erp_cellorder()
  560. {
  561. if (UrlPostParmsCheck("ctid"))
  562. {
  563. string eid = GetPostString("ctid");
  564. CeErpTradeCell.DelByCtid(eid);
  565. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  566. returnSuccessMsg("删除成功");
  567. }
  568. }
  569. public void clear_erp_refundstate()
  570. {
  571. if (UrlPostParmsCheck("ids"))
  572. {
  573. string eids = GetPostString("ids");
  574. string[] ctidList = eids.Split(',');
  575. foreach (string ctid in ctidList)
  576. {
  577. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  578. if (entity != null)
  579. {
  580. entity.IsRefund = 0;
  581. entity.Update();
  582. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  583. }
  584. else
  585. continue;
  586. }
  587. returnSuccessMsg("操作成功");
  588. return;
  589. }
  590. returnErrorMsg("缺少必要参数");
  591. }
  592. public void set_erp_urgency()
  593. {
  594. if (UrlPostParmsCheck("ctid"))
  595. {
  596. string eid = GetPostString("ctid");
  597. CeErpTradeCell entity = null;
  598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  599. if (entity != null)
  600. {
  601. double prices = commonHelper.calculationPrice(entity);
  602. if (prices <= 100)
  603. {
  604. returnErrorMsg("此订单金额不足100元,无法加急。");
  605. return;
  606. }
  607. string utime = GetPostString("urgencytime");
  608. if (utime.Length > 0)
  609. {
  610. entity.UrgencyTime = Convert.ToDateTime(utime);
  611. }
  612. else
  613. {
  614. returnErrorMsg("请选择加急时间");
  615. return;
  616. }
  617. if (entity.OrderState <= 4)
  618. {
  619. //entity.seller_memo = entity.seller_memo + "-加急";
  620. string smemo = entity.seller_memo;
  621. int kindex = smemo.IndexOf(")");
  622. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  623. if (lastoneStr != "-")
  624. {
  625. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  626. }
  627. string prememo = smemo.Substring(0, kindex + 2);
  628. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  629. int lastkindex = lastmemo.IndexOf("(");
  630. DateTime urgtime = Convert.ToDateTime(utime);
  631. string newlastmemo = "";
  632. if (lastkindex == 0)
  633. {
  634. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  635. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  636. }
  637. else
  638. {
  639. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  640. }
  641. entity.seller_memo = prememo + newlastmemo;
  642. }
  643. entity.IsUrgency = true;
  644. entity.UpdateTime = DateTime.Now;
  645. entity.Update();
  646. ApiVo apiVo = new ApiVo();
  647. apiVo.orderNumber = entity.ctid;
  648. apiVo.actionName = "changeDesign";
  649. apiVo.orderRemarks = entity.seller_memo;
  650. apiVo.remarkSign = 3;
  651. designHelper.API_WorkCore(apiVo); //changeDesign
  652. CeErpSukuraData.createInfo(entity.ctid, 7);
  653. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  654. returnSuccessMsg("设置成功!");
  655. return;
  656. }
  657. returnErrorMsg("找不到记录");
  658. }
  659. }
  660. public void set_erp_reset()
  661. {
  662. if (UrlPostParmsCheck("ctid"))
  663. {
  664. string eid = GetPostString("ctid");
  665. CeErpTradeCell entity = null;
  666. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  667. if (entity != null)
  668. {
  669. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  670. {
  671. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  672. {
  673. returnErrorMsg("财务要求已下单已发货无法重置");
  674. return;
  675. }
  676. }
  677. entity.IsUrgency = false;
  678. entity.seller_memo = "";
  679. entity.OtherMemo = "";
  680. entity.OrderState = 0;
  681. entity.IsReturn = 0;
  682. //entity.IsRefund = 0;
  683. entity.MemoOpt = 0;
  684. entity.AfterSaleState = 0;
  685. entity.AfterSaleResponsible = "";
  686. entity.AfterSaleUserId = 0;
  687. entity.IsNeedBill = 0;
  688. entity.CustomerUserId = 0;
  689. entity.DesignUserId = 0;
  690. entity.SupplierId = 0;
  691. entity.PlaceUserId = 0;
  692. entity.ptid = "";
  693. entity.IsSample = 0;
  694. entity.IsXianHuo = 0;
  695. entity.isDianziOrder = 0;
  696. entity.DispatchSort = 0;
  697. entity.IsVerifyToSupplier = false;
  698. entity.FinishPlaceTime = null;
  699. entity.Update();
  700. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  701. if (trade != null)
  702. {
  703. trade.seller_memo = "";
  704. trade.Update();
  705. }
  706. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  707. returnSuccessMsg("重置成功!");
  708. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  709. if (desginBill != null)
  710. {
  711. desginBill.isDel = 1;
  712. desginBill.Update();
  713. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  714. }
  715. ApiVo apiVo = new ApiVo();
  716. apiVo.orderNumber = entity.ctid;
  717. apiVo.actionName = "resetDesign";
  718. designHelper.API_WorkCore(apiVo);//resetDesign
  719. return;
  720. }
  721. returnErrorMsg("找不到记录");
  722. }
  723. }
  724. public void save_erp_sellermemo()
  725. {
  726. if (UrlPostParmsCheck("ctid"))
  727. {
  728. string ctid = GetPostString("ctid");
  729. CeErpTradeCell entity = null;
  730. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  731. if (entity != null)
  732. {
  733. string memo = GetPostString("seller_memo");
  734. memo = memo.Replace(" ", "");
  735. if (memo.Contains("补差"))
  736. {
  737. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  738. return;
  739. }
  740. List<string> bitList = new List<string>
  741. {
  742. "\\","/",":","*","?", "\"","<" ,">","|"
  743. };
  744. bool isIn = false;
  745. foreach (string bit in bitList)
  746. {
  747. if (memo.Contains(bit))
  748. {
  749. isIn = true;
  750. }
  751. }
  752. if (isIn)
  753. {
  754. returnErrorMsg("不能使用 一些符合作为文件名");
  755. return;
  756. }
  757. if (entity.seller_memo != memo)
  758. {
  759. if (entity.IsSample == 2)
  760. {
  761. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  762. return;
  763. }
  764. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  765. {
  766. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  767. {
  768. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  769. return;
  770. }
  771. /*if (CurrentUser.UserPost.Post.Code != "Place")
  772. {
  773. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  774. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  775. {
  776. returnErrorMsg("售前系统订单无法再此修改!");
  777. return;
  778. }
  779. }*/
  780. }
  781. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  782. }
  783. commonHelper.getCytPrice(entity);
  784. int memoopt = GetPostInt("MemoOpt");
  785. Boolean ismemoopt = false;
  786. if (memoopt > 0)
  787. {
  788. string stropt = "";
  789. if (memoopt == 1)
  790. {
  791. stropt = "“改稿”";
  792. ismemoopt = true;
  793. }
  794. else if (memoopt == 2)
  795. {
  796. stropt = "“定稿”";
  797. }
  798. else if (memoopt == 3)
  799. {
  800. stropt = "“查货”";
  801. CeErpSukuraData.createInfo(entity.ctid, 6);
  802. }
  803. entity.MemoOpt = Convert.ToInt32(memoopt);
  804. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  805. }
  806. if (entity.OrderState < 5)
  807. {
  808. memo = memo.Replace("(", "(");
  809. memo = memo.Replace(")", ")");
  810. }
  811. if (entity.OrderState < 3)
  812. {
  813. entity.DispatchSort = 0;
  814. }
  815. entity.seller_memo = memo;
  816. entity.UpdateTime = DateTime.Now;
  817. entity.Update();
  818. ApiVo apiVo = new ApiVo();
  819. apiVo.orderNumber = entity.ctid;
  820. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  821. apiVo.orderRemarks = memo;
  822. apiVo.remarkSign = memoopt;
  823. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  824. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  825. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  826. {
  827. dataHelper.api_orderBack(entity.ctid, "0", "");
  828. }
  829. if (entity.seller_memo.Contains("改稿"))
  830. {
  831. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  832. }
  833. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  834. returnSuccessMsg("保存成功!");
  835. return;
  836. }
  837. returnErrorMsg("找不到记录");
  838. }
  839. }
  840. public void ins_erp_checkorder()
  841. {
  842. if (UrlPostParmsCheck("ctid"))
  843. {
  844. string ctid = GetPostString("ctid");
  845. CeErpTradeCell entity = null;
  846. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  847. if (entity != null)
  848. {
  849. if (entity.OrderState < 6)
  850. {
  851. returnErrorMsg("下单完成后才可查货");
  852. return;
  853. }
  854. /*if (entity.OrderState > 6)
  855. {
  856. returnErrorMsg("订单已发货");
  857. return;
  858. }*/
  859. if (entity.FinishPlaceTime != null)
  860. {
  861. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  862. {
  863. returnErrorMsg("下单时间不足,无法查货");
  864. return;
  865. }
  866. }
  867. entity.MemoOpt = 3;
  868. entity.CheckOrderTime = DateTime.Now;
  869. entity.UpdateTime = DateTime.Now;
  870. entity.Update();
  871. CeErpSukuraData.createInfo(entity.ctid, 6);
  872. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  873. returnSuccessMsg("操作成功!");
  874. return;
  875. }
  876. returnErrorMsg("找不到记录");
  877. }
  878. }
  879. public void save_erp_othermemo()
  880. {
  881. if (UrlPostParmsCheck("ctid"))
  882. {
  883. string ctid = GetPostString("ctid");
  884. CeErpTradeCell entity = null;
  885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  886. if (entity != null)
  887. {
  888. entity.OtherMemo = GetPostString("otherMemo");
  889. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  890. {
  891. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  892. StringBuilder sql = new StringBuilder();
  893. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  894. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  895. if (dt != null && dt.Rows.Count > 0)
  896. {
  897. foreach (DataRow dr in dt.Rows)
  898. {
  899. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  900. {
  901. //品类一直
  902. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  903. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  904. if (ceErpSampleCustomer == null)
  905. {
  906. ceErpSampleCustomer = new CeErpSampleCustomer();
  907. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  908. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  909. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  910. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  911. ceErpSampleCustomer.shopId = entity.ShopId;
  912. }
  913. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  914. ceErpSampleCustomer.lastTid = entity.tid;
  915. if (ceErpSampleCustomer.ID > 0)
  916. {
  917. ceErpSampleCustomer.Update();
  918. }
  919. else
  920. {
  921. ceErpSampleCustomer.Create();
  922. }
  923. }
  924. }
  925. }
  926. }
  927. //if (entity.IsOldCustomer == 1)
  928. //{
  929. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  930. //{
  931. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  932. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  933. //}
  934. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  935. //{
  936. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  937. // {
  938. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  939. // {
  940. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  941. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  942. // }
  943. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  944. // {
  945. // entity.OrderState = 2;
  946. // entity.DesignUserId = 0;
  947. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  948. // }
  949. // else
  950. // {
  951. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  952. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  953. // }
  954. // }
  955. //}
  956. //}
  957. entity.UpdateTime = DateTime.Now;
  958. entity.Update();
  959. returnSuccessMsg("保存成功!");
  960. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  961. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  962. if (entity.OtherMemo.Contains("改稿"))
  963. {
  964. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  965. }
  966. return;
  967. }
  968. returnErrorMsg("找不到记录");
  969. }
  970. }
  971. public void save_erp_customermemo()
  972. {
  973. if (UrlPostParmsCheck("ctid"))
  974. {
  975. string ctid = GetPostString("ctid");
  976. CeErpTradeCell entity = null;
  977. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  978. if (entity != null)
  979. {
  980. entity.UpdateTime = DateTime.Now;
  981. entity.CustomerMemo = GetPostString("CustomerMemo");
  982. entity.Update();
  983. ApiVo apiVo = new ApiVo();
  984. apiVo.orderNumber = entity.ctid;
  985. apiVo.actionName = "followRemarks";
  986. apiVo.orderRemarks = entity.CustomerMemo;
  987. designHelper.API_WorkCore(apiVo);//followRemarks
  988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  989. returnSuccessMsg("保存成功!");
  990. return;
  991. }
  992. returnErrorMsg("找不到记录");
  993. }
  994. }
  995. public void upd_erp_addmemotag()
  996. {
  997. if (UrlPostParmsCheck("ctid"))
  998. {
  999. ;
  1000. string eid = GetPostString("ctid");
  1001. string sfTagstr = GetPostString("memotag");
  1002. CeErpTradeCell entity = null;
  1003. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1004. if (entity != null)
  1005. {
  1006. ApiVo apiVo = new ApiVo();
  1007. if (entity.OrderState == 0)
  1008. {
  1009. returnErrorMsg("请先领单");
  1010. return;
  1011. }
  1012. //撤销顺丰
  1013. if (sfTagstr == "撤销顺丰")
  1014. {
  1015. entity.IsSF = 0;
  1016. string reMsg = "";
  1017. string oldmemo = entity.seller_memo;
  1018. if (entity.OrderState < 5)
  1019. {
  1020. oldmemo = oldmemo.Replace("顺丰到付", "");
  1021. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1022. entity.seller_memo = oldmemo;
  1023. }
  1024. else
  1025. {
  1026. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1027. {
  1028. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1029. }
  1030. }
  1031. entity.Update();
  1032. apiVo.orderNumber = entity.ctid;
  1033. apiVo.actionName = "orderRemarks";
  1034. apiVo.orderRemarks = entity.seller_memo;
  1035. apiVo.isSf = entity.IsSF.ToString();
  1036. designHelper.API_WorkCore(apiVo);//orderRemarks
  1037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1038. returnSuccessMsg("撤销成功!" + reMsg);
  1039. return;
  1040. }
  1041. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1042. {
  1043. //string oldmemo = entity.seller_memo;
  1044. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1045. string sfStr = GetPostString("memotag");
  1046. string smemo = entity.seller_memo;
  1047. int kindex = smemo.IndexOf(")");
  1048. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1049. if (lastoneStr != "-")
  1050. {
  1051. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1052. }
  1053. string prememo = smemo.Substring(0, kindex + 2);
  1054. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1055. int lastkindex = lastmemo.IndexOf("(");
  1056. string newlastmemo = "";
  1057. if (lastkindex == 0)
  1058. {
  1059. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1060. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1061. }
  1062. else
  1063. {
  1064. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1065. }
  1066. entity.seller_memo = prememo + newlastmemo;
  1067. }
  1068. string sfTagMSg = "";
  1069. if (sfTagstr == "顺丰寄付")
  1070. {
  1071. entity.IsSF = 1;
  1072. sfTagMSg = "顺丰寄付";
  1073. }
  1074. else if (sfTagstr == "顺丰到付")
  1075. {
  1076. entity.IsSF = 2;
  1077. sfTagMSg = "顺丰到付";
  1078. }
  1079. entity.Update();
  1080. apiVo = new ApiVo();
  1081. apiVo.orderNumber = entity.ctid;
  1082. apiVo.actionName = "orderRemarks";
  1083. apiVo.orderRemarks = entity.seller_memo;
  1084. apiVo.isSf = entity.IsSF.ToString();
  1085. designHelper.API_WorkCore(apiVo);//orderRemarks
  1086. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1087. returnSuccessMsg("标记成功!");
  1088. return;
  1089. }
  1090. returnErrorMsg("找不到记录");
  1091. }
  1092. }
  1093. public void upd_erp_ordertag()
  1094. {
  1095. if (UrlPostParmsCheck("ctid"))
  1096. {
  1097. string eid = GetPostString("ctid");
  1098. CeErpTradeCell entity = null;
  1099. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1100. if (entity != null)
  1101. {
  1102. int tag = GetPostInt("wechattag");
  1103. //if(tag==4 && entity.IsSample == 2)
  1104. //{
  1105. // returnErrorMsg("补差价单不能标记微信单");
  1106. // return;
  1107. //}
  1108. entity.wechatTag = tag;
  1109. entity.Update();
  1110. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1111. if (tag == 1)
  1112. {
  1113. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1114. if (cash == null)
  1115. {
  1116. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1117. cash = new CeErpReturnCash();
  1118. cash.tid = entity.tid;
  1119. cash.seller_nick = main.seller_nick;
  1120. cash.payment = trade.payment;
  1121. cash.buyer_nick = main.buyer_nick;
  1122. cash.cashstate = 0;
  1123. cash.rtype = "微信返现";
  1124. cash.returnprice = 0;
  1125. cash.created = DateTime.Now;
  1126. cash.con = "订单标记微信单";
  1127. cash.img = "";
  1128. cash.applyuserid = CurrentUser.UserID;
  1129. cash.Create();
  1130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1131. }
  1132. else
  1133. {
  1134. cash.cashstate = 0;
  1135. cash.Update();
  1136. }
  1137. CeErpSukuraData.createInfo(entity.ctid, 9);
  1138. }
  1139. else if (tag == 2)
  1140. {
  1141. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1142. if (cash == null)
  1143. {
  1144. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1145. cash = new CeErpReturnCash();
  1146. cash.tid = entity.tid;
  1147. cash.seller_nick = main.seller_nick;
  1148. cash.payment = trade.payment;
  1149. cash.buyer_nick = main.buyer_nick;
  1150. cash.cashstate = 0;
  1151. cash.rtype = "推购返现";
  1152. cash.returnprice = 5;
  1153. cash.created = DateTime.Now;
  1154. cash.con = "订单标记推购单";
  1155. cash.img = "";
  1156. cash.applyuserid = CurrentUser.UserID;
  1157. cash.Create();
  1158. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1159. }
  1160. else
  1161. {
  1162. cash.cashstate = 0;
  1163. cash.Update();
  1164. }
  1165. CeErpSukuraData.createInfo(entity.ctid, 9);
  1166. }
  1167. else if (tag == 3)
  1168. {
  1169. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1170. if (pers == null)
  1171. {
  1172. pers = new CeErpPersuade();
  1173. pers.ctid = entity.ctid;
  1174. pers.pstate = 0;
  1175. pers.created = DateTime.Now;
  1176. pers.applyuserid = CurrentUser.UserID;
  1177. pers.Create();
  1178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1179. }
  1180. else
  1181. {
  1182. pers.pstate = 0;
  1183. pers.Update();
  1184. }
  1185. }
  1186. else if (tag == 4 || tag == 5)
  1187. {
  1188. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1189. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1190. if (pers == null)
  1191. {
  1192. pers = CeErpStayGoods.GetByTid(entity.tid);
  1193. }
  1194. if (pers == null)
  1195. {
  1196. pers = new CeErpStayGoods();
  1197. pers.t_id = entity.tid;
  1198. pers.ctid = entity.ctid;
  1199. pers.status = "待审核";
  1200. pers.audit_type = 0;
  1201. if (tag == 4)
  1202. {
  1203. pers.stay_type = "微信推购";
  1204. }
  1205. else
  1206. {
  1207. pers.stay_type = "旺旺推购";
  1208. }
  1209. if (entity.IsXianHuo == 0)
  1210. {
  1211. pers.product_id = entity.ProductId;
  1212. }
  1213. pers.wangwang = main.buyer_nick;
  1214. pers.shop_name = main.seller_nick;
  1215. pers.creata_time = DateTime.Now;
  1216. pers.create_u_id = CurrentUser.UserID;
  1217. pers.create_u_name = CurrentUser.UserName;
  1218. pers.Create();
  1219. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1220. }
  1221. else
  1222. {
  1223. pers.ctid = entity.ctid;
  1224. pers.audit_type = 0;
  1225. pers.Update();
  1226. }
  1227. CeErpSukuraData.createInfo(entity.ctid, 10);
  1228. }
  1229. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1230. returnSuccessMsg("标记成功!");
  1231. return;
  1232. }
  1233. returnErrorMsg("找不到记录");
  1234. }
  1235. }
  1236. public void upd_erp_ordertag_cancel()
  1237. {
  1238. if (UrlPostParmsCheck("ctid"))
  1239. {
  1240. string eid = GetPostString("ctid");
  1241. CeErpTradeCell entity = null;
  1242. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1243. if (entity != null)
  1244. {
  1245. entity.wechatTag = 0;
  1246. entity.Update();
  1247. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1248. if (pers != null)
  1249. {
  1250. pers.status = "取消推购";
  1251. pers.audit_type = 3;
  1252. pers.Update();
  1253. }
  1254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1255. returnSuccessMsg("标记成功!");
  1256. return;
  1257. }
  1258. returnErrorMsg("找不到记录");
  1259. }
  1260. }
  1261. public void upd_erp_addweichattag()
  1262. {
  1263. if (UrlPostParmsCheck("ctid"))
  1264. {
  1265. ;
  1266. string eid = GetPostString("ctid");
  1267. CeErpTradeCell entity = null;
  1268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1269. if (entity != null)
  1270. {
  1271. if (entity.IsAddWechat > 0)
  1272. {
  1273. returnErrorMsg("此单已经标记过了");
  1274. return;
  1275. }
  1276. 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);
  1277. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1278. if (dt.Rows.Count > 0)
  1279. {
  1280. entity.IsAddWechat = 2;
  1281. }
  1282. else
  1283. {
  1284. entity.IsAddWechat = 1;
  1285. }
  1286. entity.Update();
  1287. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1288. returnSuccessMsg("标记成功!");
  1289. return;
  1290. }
  1291. returnErrorMsg("找不到记录");
  1292. }
  1293. }
  1294. public void upd_erp_getmyorder()
  1295. {
  1296. if (UrlPostParmsCheck("ctid"))
  1297. {
  1298. string eid = GetPostString("ctid");
  1299. CeErpTradeCell entity = null;
  1300. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1301. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1302. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1303. {
  1304. returnErrorMsg("台湾客户需填写身份证号!");
  1305. return;
  1306. }
  1307. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1308. {
  1309. returnErrorMsg("偏远地区需要填写物流费!");
  1310. return;
  1311. }
  1312. if (entity != null)
  1313. {
  1314. if (entity.ctid.IndexOf("C") != -1)
  1315. {
  1316. StringBuilder sql = new StringBuilder();
  1317. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1318. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1319. if (dt.Rows.Count > 0)
  1320. {
  1321. decimal total = 0;
  1322. foreach (DataRow dr in dt.Rows)
  1323. {
  1324. total += Convert.ToDecimal(dr["payment"]);
  1325. }
  1326. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1327. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1328. {
  1329. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1330. return;
  1331. }
  1332. }
  1333. }
  1334. if (entity.OrderState == -1)
  1335. {
  1336. returnErrorMsg("待审核订单无法领取!");
  1337. return;
  1338. }
  1339. entity.CustomerUserId = CurrentUser.UserID;
  1340. if (entity.OrderState < 2)
  1341. {
  1342. entity.OrderState = 2;
  1343. if (entity.ShopId != 0)
  1344. {
  1345. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1346. }
  1347. }
  1348. entity.UpdateTime = DateTime.Now;
  1349. entity.Update();
  1350. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1351. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1352. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1353. {
  1354. dataHelper.api_orderBack(entity.ctid, "0", "");
  1355. }
  1356. returnSuccessMsg("领单成功!");
  1357. return;
  1358. }
  1359. returnErrorMsg("找不到记录");
  1360. }
  1361. }
  1362. public void getmyorder_from_init()
  1363. {
  1364. if (UrlPostParmsCheck("ctid"))
  1365. {
  1366. string eid = GetPostString("ctid");
  1367. CeErpTradeCell entity = null;
  1368. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1369. if (entity != null)
  1370. {
  1371. string sellerMemo = GetPostString("sellerMemo");
  1372. if (sellerMemo.Length > 0)
  1373. {
  1374. entity.seller_memo = sellerMemo;
  1375. }
  1376. string oterhMemo = GetPostString("otherMemo");
  1377. if (oterhMemo.Length > 0)
  1378. {
  1379. entity.OtherMemo = oterhMemo;
  1380. }
  1381. int urg = GetPostInt("urgency");
  1382. entity.IsUrgency = (urg == 1 ? true : false);
  1383. int wechat = GetPostInt("wechat");
  1384. int command = GetPostInt("command");
  1385. if (wechat == 1)
  1386. {
  1387. entity.wechatTag = 1;
  1388. }
  1389. if (command == 1)
  1390. {
  1391. entity.wechatTag = 2;
  1392. }
  1393. string pPro = GetPostString("pprofession");
  1394. if (pPro.Length > 0)
  1395. {
  1396. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1397. string spro = GetPostString("profession");
  1398. if (spro.Length > 0)
  1399. {
  1400. entity.ProfessionId = Convert.ToInt32(spro);
  1401. }
  1402. }
  1403. string proId = GetPostString("productId");
  1404. if (proId.Length > 0)
  1405. {
  1406. entity.ProductId = Convert.ToInt32(proId);
  1407. }
  1408. entity.Material = GetPostString("material");
  1409. entity.Craft = GetPostString("craft");
  1410. entity.CustomerUserId = CurrentUser.UserID;
  1411. if (entity.OrderState < 2)
  1412. {
  1413. entity.OrderState = 2;
  1414. if (entity.ShopId != 0)
  1415. {
  1416. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1417. }
  1418. }
  1419. entity.Update();
  1420. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1421. returnSuccessMsg("领单成功!");
  1422. return;
  1423. }
  1424. returnErrorMsg("找不到记录");
  1425. }
  1426. }
  1427. public void upd_erp_setrelationorder()
  1428. {
  1429. if (UrlPostParmsCheck("ctid"))
  1430. {
  1431. ;
  1432. string eid = GetPostString("ctid");
  1433. string ftid = GetPostString("ftid");
  1434. CeErpTradeCell entity = null;
  1435. CeErpTradeCell fentity = null;
  1436. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1437. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1438. if (fentity == null)
  1439. {
  1440. returnErrorMsg("找不到关联的主订单");
  1441. return;
  1442. }
  1443. if (entity != null)
  1444. {
  1445. if (entity.OrderState >= 5)
  1446. {
  1447. returnErrorMsg("本单已经设计完成无法关联");
  1448. return;
  1449. }
  1450. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1451. {
  1452. returnErrorMsg("线下单续审核后才能关联!");
  1453. return;
  1454. }
  1455. entity.ptid = ftid;
  1456. entity.OrderState = fentity.OrderState;
  1457. //entity.status = fentity.status;
  1458. entity.CustomerUserId = fentity.CustomerUserId;
  1459. entity.DesignUserId = fentity.DesignUserId;
  1460. entity.seller_memo = "补差价单:" + ftid;
  1461. entity.IsSample = 2;
  1462. entity.Update();
  1463. ApiVo apiVo = new ApiVo();
  1464. apiVo.orderNumber = ftid;
  1465. apiVo.payment = entity.payment;
  1466. apiVo.actionName = "repairDesign";
  1467. designHelper.API_WorkCore(apiVo);//repairDesign
  1468. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1469. returnSuccessMsg("关联成功!");
  1470. return;
  1471. }
  1472. else
  1473. returnErrorMsg("找不到记录");
  1474. }
  1475. }
  1476. public void download_erp_neworder()
  1477. {
  1478. string seller = GetPostString("seller_nick");
  1479. string tid = GetPostString("tid");
  1480. if (seller.Length <= 0 || tid.Length <= 0)
  1481. {
  1482. returnErrorMsg("数据错误");
  1483. }
  1484. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1485. //{
  1486. // returnErrorMsg("找不到店铺Sessionkey");
  1487. //}
  1488. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1489. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1490. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1491. if (res.IndexOf("refOid") == -1)
  1492. {
  1493. returnErrorMsg("下载订单数据失败");
  1494. return;
  1495. }
  1496. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1497. returnSuccessMsg("下载完成");
  1498. //tmcHelper.createNewOrder(res);
  1499. //CeErpTrade entr = null;
  1500. //entr = CeErpTrade.Get(tid);
  1501. //if (entr != null)
  1502. //{
  1503. // returnSuccess("下载成功");
  1504. // //下载成功之后,Cell表生成对应的订单;
  1505. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1506. //}
  1507. //else
  1508. //{
  1509. // returnErrorMsg("下载失败或者创建订单失败");
  1510. //}
  1511. }
  1512. public void set_erp_atersale()
  1513. {
  1514. if (UrlPostParmsCheck("ctid"))
  1515. {
  1516. string eid = GetPostString("ctid");
  1517. string reason = GetPostString("AfterSaleReason");
  1518. CeErpTradeCell entity = null;
  1519. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1520. if (entity != null)
  1521. {
  1522. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1523. {
  1524. returnErrorMsg("此订单已经在售后");
  1525. return;
  1526. }*/
  1527. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1528. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1529. entity.AfterSaleTime = DateTime.Now;
  1530. entity.HandleTime = null;
  1531. entity.Update();
  1532. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1533. returnSuccessMsg("转售后成功!");
  1534. return;
  1535. }
  1536. returnErrorMsg("找不到记录");
  1537. }
  1538. }
  1539. public void set_erp_withdraw()
  1540. {
  1541. if (UrlPostParmsCheck("ctid"))
  1542. {
  1543. try
  1544. {
  1545. string eid = GetPostString("ctid");//商品id
  1546. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1547. CeWithdraw ceWithdrawSelect = null;
  1548. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1549. if (ceWithdrawSelect != null)
  1550. {
  1551. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1552. {
  1553. ceWithdrawSelect.status = -1;
  1554. ceWithdrawSelect.Update();
  1555. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1556. returnSuccessMsg("重新发起审核成功");
  1557. return;
  1558. }
  1559. else
  1560. {
  1561. returnSuccessMsg("请勿重复申请!");
  1562. return;
  1563. }
  1564. }
  1565. else
  1566. {
  1567. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1568. if (string.IsNullOrEmpty(CustomerUserId))
  1569. {
  1570. CustomerUserId = "-1";
  1571. }
  1572. int Userid = CurrentUser.UserID;//用户id
  1573. CeWithdraw ceWithdraw = new CeWithdraw();
  1574. ceWithdraw.tid = eid;
  1575. ceWithdraw.userid = Userid;
  1576. ceWithdraw.providerid = CustomerUserId;
  1577. ceWithdraw.status = 3;
  1578. ceWithdraw.creationtime = DateTime.Now;
  1579. ceWithdraw.Create();
  1580. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1581. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1582. return;
  1583. }
  1584. }
  1585. catch
  1586. {
  1587. returnErrorMsg("申请撤回订单失败");
  1588. return;
  1589. }
  1590. }
  1591. }
  1592. public void ins_erp_billinfo()
  1593. {
  1594. if (UrlPostParmsCheck("ctid"))
  1595. {
  1596. string eid = GetPostString("ctid");
  1597. CeErpTradeCell entity = null;
  1598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1599. if (entity != null)
  1600. {
  1601. CeErpBill bill = CeErpBill.GetByTid(eid);
  1602. bool isHave = false;
  1603. if (bill != null)
  1604. {
  1605. isHave = true;
  1606. if (bill.state != 4)
  1607. {
  1608. returnErrorMsg("此单已经申请过发票了");
  1609. return;
  1610. }
  1611. }
  1612. if (entity.IsNeedBill == 0)
  1613. {
  1614. entity.IsNeedBill = 1;
  1615. }
  1616. entity.Update();
  1617. string errjson = "";
  1618. try
  1619. {
  1620. CeErpBill bill_entity = new CeErpBill();
  1621. bill_entity.tid = entity.tid;
  1622. bill_entity.title = GetPostString("title");
  1623. string taxstr = GetPostString("tax");
  1624. taxstr = taxstr.Replace(" ", "");
  1625. bill_entity.tax = taxstr;
  1626. bill_entity.bank = GetPostString("bank");
  1627. string bankacstr = GetPostString("bankac");
  1628. bankacstr = bankacstr.Replace(" ", "");
  1629. bill_entity.bankac = bankacstr;
  1630. bill_entity.address = GetPostString("address");
  1631. bill_entity.phone = GetPostString("phone");
  1632. bill_entity.price = GetPostString("price");
  1633. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1634. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1635. {
  1636. billCount += 1;
  1637. }
  1638. string prebill = "ltb";
  1639. for (int idx = 1; idx <= billCount; idx++)
  1640. {
  1641. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1642. string billoid = prebill + idx + dtstr;
  1643. bill_entity.billOrderId += billoid;
  1644. if (idx < billCount)
  1645. {
  1646. bill_entity.billOrderId += ",";
  1647. }
  1648. }
  1649. bill_entity.productId = GetPostInt("ProductName");
  1650. bill_entity.num = GetPostInt("num");
  1651. bill_entity.unit = GetPostString("unit");
  1652. bill_entity.type = GetPostString("type");
  1653. bill_entity.sendType = GetPostString("SendType");
  1654. bill_entity.email = GetPostString("email");
  1655. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1656. bill_entity.shopName = GetPostString("ShopName");
  1657. bill_entity.applymemo = GetPostString("applyMemo");
  1658. bill_entity.createTime = DateTime.Now;
  1659. bill_entity.state = 0;
  1660. bill_entity.userId = CurrentUser.UserID;
  1661. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1662. bill_entity.Create();
  1663. }
  1664. catch (Exception ex)
  1665. {
  1666. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1667. returnErrorMsg("创建发票出错!");
  1668. return;
  1669. }
  1670. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1671. returnSuccessMsg("发票申请成功!");
  1672. return;
  1673. }
  1674. returnErrorMsg("找不到记录");
  1675. }
  1676. }
  1677. public void ins_erp_neworder()
  1678. {
  1679. if (UrlPostParmsCheck("receiver_name"))
  1680. {
  1681. CeErpTrade entity = new CeErpTrade();
  1682. string plat_form = GetPostString("platform");
  1683. string preStr = "N_";
  1684. if (plat_form == "拼多多")
  1685. {
  1686. preStr = "P_";
  1687. }
  1688. else if (plat_form == "阿里巴巴")
  1689. {
  1690. preStr = "A_";
  1691. }
  1692. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1693. entity.seller_nick = GetPostString("seller_nick");
  1694. entity.buyer_nick = GetPostString("buyer_nick");
  1695. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1696. entity.total_fee = entity.payment;
  1697. entity.pay_time = DateTime.Now;
  1698. entity.status = "NOT_SHIPPED";
  1699. entity.receiver_name = GetPostString("receiver_name");
  1700. entity.receiver_mobile = GetPostString("receiver_mobile");
  1701. entity.receiver_state = GetPostString("receiver_state");
  1702. entity.receiver_city = GetPostString("receiver_city");
  1703. entity.receiver_district = GetPostString("receiver_district");
  1704. entity.receiver_address = GetPostString("receiver_address");
  1705. if (entity.receiver_state == "" || entity.receiver_city == "")
  1706. {
  1707. returnErrorMsg("收件地址不能为空");
  1708. return;
  1709. }
  1710. int shopId = 0;
  1711. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1712. if (nShop != null)
  1713. {
  1714. shopId = nShop.ID;
  1715. }
  1716. if (shopId != 34 && entity.payment == 0)
  1717. {
  1718. returnErrorMsg("公司自用的单金额才能为0");
  1719. return;
  1720. }
  1721. entity.Create();
  1722. CeErpTradeCell entitycell = new CeErpTradeCell();
  1723. entitycell.ctid = entity.tid;
  1724. entitycell.tid = entity.tid;
  1725. entitycell.ShopId = shopId;
  1726. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1727. entitycell.OrderState = 0;
  1728. entitycell.pay_time = entity.pay_time;
  1729. entitycell.IsOffLineOrder = 1;
  1730. entitycell.Create();
  1731. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1732. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1733. return;
  1734. }
  1735. }
  1736. public void ins_erp_neworder2()
  1737. {
  1738. if (UrlPostParmsCheck("receiver_name"))
  1739. {
  1740. //string plat_form = GetPostString("platform");
  1741. string preStr = "X_";
  1742. string memo = GetPostString("memo");
  1743. string productId = GetPostString("productId");
  1744. string primg = GetPostString("proofimg");
  1745. string sellerNick = GetPostString("seller_nick");
  1746. string addFrom = GetPostString("addfrom");
  1747. if (addFrom == "1")
  1748. {
  1749. preStr = "N_";
  1750. }
  1751. int shopId = 0;
  1752. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1753. if (nShop != null)
  1754. {
  1755. shopId = nShop.ID;
  1756. }
  1757. else
  1758. {
  1759. returnErrorMsg("找不到对应店铺");
  1760. return;
  1761. }
  1762. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1763. {
  1764. returnErrorMsg("必须上传付款凭证");
  1765. return;
  1766. }
  1767. CeErpTrade entity = new CeErpTrade();
  1768. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1769. entity.seller_nick = sellerNick;
  1770. entity.buyer_nick = GetPostString("buyer_nick");
  1771. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1772. entity.total_fee = entity.payment;
  1773. entity.pay_time = DateTime.Now;
  1774. entity.status = "NOT_SHIPPED";
  1775. entity.receiver_name = GetPostString("receiver_name");
  1776. entity.receiver_mobile = GetPostString("receiver_mobile");
  1777. entity.receiver_state = GetPostString("receiver_state");
  1778. entity.receiver_city = GetPostString("receiver_city");
  1779. entity.receiver_district = GetPostString("receiver_district");
  1780. entity.receiver_address = GetPostString("receiver_address");
  1781. entity.seller_memo = memo;
  1782. entity.orderFrom = 20;
  1783. entity.orderType = 15;
  1784. if (entity.receiver_state == "" || entity.receiver_city == "")
  1785. {
  1786. returnErrorMsg("收件地址不能为空");
  1787. return;
  1788. }
  1789. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1790. {
  1791. returnErrorMsg("公司自用的单金额才能为0");
  1792. return;
  1793. }
  1794. entity.Create();
  1795. string toWhere = GetPostString("towhere");
  1796. CeErpTradeCell entitycell = new CeErpTradeCell();
  1797. entitycell.ctid = entity.tid;
  1798. //唯一标识
  1799. entitycell.OrderSn = entity.tid;
  1800. string orderSn = dataHelper.getSaleOrderSn();
  1801. if (orderSn != "")
  1802. {
  1803. entitycell.OrderSn = orderSn;
  1804. }
  1805. entitycell.tid = entity.tid;
  1806. //if (preStr == "X_")
  1807. //{
  1808. entitycell.IsOffLineOrder = 1;
  1809. //}
  1810. entitycell.CustomerUserId = CurrentUser.UserID;
  1811. entitycell.PayProofImg = primg;
  1812. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1813. entitycell.ProductId = Convert.ToInt32(productId);
  1814. entitycell.ShopId = shopId;
  1815. entitycell.UpdateTime = DateTime.Now;
  1816. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1817. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1818. {
  1819. entitycell.IsXianHuo = 1;
  1820. }
  1821. entitycell.pay_time = entity.pay_time;
  1822. if (toWhere == "1")
  1823. {
  1824. entitycell.OrderState = 2;
  1825. }
  1826. else
  1827. {
  1828. entitycell.OrderState = 6;
  1829. entitycell.FinishPlaceTime = entitycell.pay_time;
  1830. }
  1831. if (shopId == 94)
  1832. {
  1833. entitycell.OrderState = 4;
  1834. entitycell.WaitDesignTime = entitycell.pay_time;
  1835. entitycell.StartDesignTime = entitycell.pay_time;
  1836. entitycell.DesignUserId = 218;
  1837. }
  1838. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1839. {
  1840. entitycell.OrderState = -1;//修改12-5
  1841. CeWithdraw ceWithdraw = new CeWithdraw();
  1842. ceWithdraw.tid = entity.tid;
  1843. ceWithdraw.providerid = "-1";
  1844. ceWithdraw.status = -1;
  1845. ceWithdraw.creationtime = DateTime.Now;
  1846. ceWithdraw.userid = 742;
  1847. ceWithdraw.Create();
  1848. }
  1849. entitycell.Create();
  1850. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1851. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1852. {
  1853. addPlaceRegist(entitycell, CurrentUser.UserID);
  1854. }
  1855. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1856. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1857. return;
  1858. }
  1859. }
  1860. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1861. {
  1862. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1863. entity.PlactTime = tradecell.pay_time;
  1864. entity.AddUserId = userid;
  1865. entity.FileName = tradecell.seller_memo;
  1866. entity.Supplier = 24;
  1867. entity.CreateTime = DateTime.Now;
  1868. entity.Did = tradecell.ctid;
  1869. entity.tid = tradecell.tid;
  1870. entity.splitTag = tradecell.SplitTag;
  1871. entity.CurState = "未完成";
  1872. entity.Create();
  1873. }
  1874. public void get_erp_offlinelist()
  1875. {
  1876. DataStruct dStruct = GetPostStruct();
  1877. List<string> lw = new List<string>();
  1878. string tid = GetPostString("ctid");
  1879. string date1 = GetPostString("date1");
  1880. string date2 = GetPostString("date2");
  1881. if (tid.Length > 0 || date1.Length > 0)
  1882. {
  1883. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1884. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1885. if (dw.Length > 0) lw.Add(dw);
  1886. }
  1887. else
  1888. {
  1889. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1890. }
  1891. string shopname = GetPostString("shopname");
  1892. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1893. string buyernick = GetPostString("buyer_nick");
  1894. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1895. string customer = GetPostString("customer");
  1896. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1897. string design = GetPostString("design");
  1898. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1899. string orderState = GetPostString("orderState");
  1900. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1901. string address = GetPostString("address");
  1902. 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));
  1903. string sellermemo = GetPostString("seller_memo");
  1904. if (sellermemo.Length > 0)
  1905. {
  1906. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1907. }
  1908. string price1 = GetPostString("price1");
  1909. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1910. string price2 = GetPostString("price2");
  1911. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1912. //if (PKey != "admin")
  1913. //{
  1914. // string usershop = CurrentUser.User.pemShop;
  1915. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1916. //}
  1917. //if (ex_psize > 0)
  1918. //{
  1919. dStruct.Order = "pay_time desc";
  1920. //}
  1921. //else
  1922. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1923. lw.Add(string.Format("IsOffLineOrder=1"));
  1924. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1925. DataTable dt = null;
  1926. dt = WebCache.GetData("view_erptradecell", dStruct);
  1927. writeGridDataTableJson(dStruct.TotalCount, dt);
  1928. }
  1929. public void get_erp_returncashrecord()
  1930. {
  1931. DataStruct dStruct = GetPostStruct();
  1932. List<string> lw = new List<string>();
  1933. string tid = GetPostString("ctid");
  1934. if (tid.Length > 0)
  1935. {
  1936. lw.Add(string.Format("tid like '%{0}%'", tid));
  1937. dStruct.Order = "id desc";
  1938. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1939. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1940. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1941. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1942. return;
  1943. }
  1944. returnErrorMsg("id数据错误!");
  1945. }
  1946. public void ins_erp_returncashrecord()
  1947. {
  1948. if (UrlPostParmsCheck("tid"))
  1949. {
  1950. string tid = GetPostString("tid");
  1951. string retype = GetPostString("type");
  1952. StringBuilder sql = new StringBuilder();
  1953. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1954. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1955. if (dt.Rows.Count > 0)
  1956. {
  1957. returnErrorMsg("相同返现类型记录已存在");
  1958. return;
  1959. }
  1960. CeErpReturnCash entity = new CeErpReturnCash();
  1961. entity.tid = tid;
  1962. entity.seller_nick = GetPostString("seller_nick");
  1963. string pment = GetPostString("payment");
  1964. if (pment.Length > 0)
  1965. {
  1966. entity.payment = Convert.ToDouble(pment);
  1967. }
  1968. entity.buyer_nick = GetPostString("buyer_nick");
  1969. entity.cashstate = 0;
  1970. entity.rtype = retype;
  1971. string rPrice = GetPostString("returnprice");
  1972. if (rPrice.Length > 0)
  1973. {
  1974. entity.returnprice = Convert.ToDouble(rPrice);
  1975. }
  1976. entity.created = DateTime.Now;
  1977. entity.con = GetPostString("con");
  1978. entity.img = GetPostString("img");
  1979. entity.applyuserid = CurrentUser.UserID;
  1980. entity.Create();
  1981. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1982. returnSuccessMsg("操作成功!");
  1983. return;
  1984. }
  1985. }
  1986. public void set_erp_predelivery()
  1987. {
  1988. if (UrlPostParmsCheck("ctid"))
  1989. {
  1990. string eid = GetPostString("ctid");
  1991. CeErpTradeCell entity = null;
  1992. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1993. if (entity != null)
  1994. {
  1995. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1996. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1997. //{
  1998. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1999. // return;
  2000. //}
  2001. entity.IsPreDelivery = 1;
  2002. entity.Update();
  2003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2004. returnSuccessMsg("预发货成功!");
  2005. return;
  2006. //string shop = GetPostString("seller_nick");
  2007. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2008. //string comName = GetPostString("comName");
  2009. //string comCode = GetPostString("comCode");
  2010. //string outSid = GetPostString("outSid");//运单号
  2011. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2012. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2013. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2014. //string apires = "";
  2015. //if (deliveryType == "虚拟发货")
  2016. //{
  2017. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2018. //}
  2019. //else
  2020. //{
  2021. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2022. //}
  2023. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2024. ////{
  2025. //if (apires.IndexOf("发货成功") != -1)
  2026. //{
  2027. // if (deliveryType != "虚拟发货")
  2028. // {
  2029. // //还要插入快递信息到 快递信息表
  2030. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2031. // exinfo.tid = eid;
  2032. // exinfo.out_sid = outSid;
  2033. // exinfo.company_code = comCode;
  2034. // exinfo.company_name = comName;
  2035. // exinfo.delivery_memo = deliveryMemo;
  2036. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2037. // exinfo.deliveryType = deliveryType;
  2038. // exinfo.Create();
  2039. // }
  2040. // returnSuccessMsg("发货成功!");
  2041. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2042. //}
  2043. //else
  2044. //{
  2045. // returnErrorMsg("淘宝发货失败!!");
  2046. //}
  2047. //return;
  2048. }
  2049. returnErrorMsg("找不到订单记录");
  2050. }
  2051. }
  2052. public void get_erp_unusuallist()
  2053. {
  2054. DataStruct dStruct = GetPostStruct();
  2055. List<string> lw = new List<string>();
  2056. string tid = GetPostString("ctid");
  2057. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2058. string shopname = GetPostString("shopname");
  2059. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2060. string buyernick = GetPostString("buyer_nick");
  2061. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2062. string ResponsibleMan = GetPostString("responsible");
  2063. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2064. string date1 = GetPostString("date1");
  2065. string date2 = GetPostString("date2");
  2066. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2067. if (dw.Length > 0) lw.Add(dw);
  2068. string price1 = GetPostString("price1");
  2069. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2070. string price2 = GetPostString("price2");
  2071. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2072. string orderState = GetPostString("orderState");
  2073. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2074. string sellermemo = GetPostString("seller_memo");
  2075. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2076. lw.Add(string.Format("UnusualTag > 0"));
  2077. lw.Add(string.Format("IsRefund<={0}", 1));
  2078. dStruct.Order = "pay_time desc";
  2079. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2080. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2081. writeGridDataTableJson(dStruct.TotalCount, dt);
  2082. }
  2083. public void set_erp_unusualtonomal()
  2084. {
  2085. if (UrlPostParmsCheck("ctid"))
  2086. {
  2087. string eid = GetPostString("ctid");
  2088. CeErpTradeCell entity = null;
  2089. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2090. if (entity != null)
  2091. {
  2092. entity.UnusualTag = -1;
  2093. entity.Update();
  2094. returnSuccessMsg("忽略成功!");
  2095. return;
  2096. }
  2097. returnErrorMsg("找不到记录");
  2098. }
  2099. }
  2100. public void ins_erp_unusualreason()
  2101. {
  2102. if (UrlPostParmsCheck("ctid"))
  2103. {
  2104. string eid = GetPostString("ctid");
  2105. CeErpTradeCell entity = null;
  2106. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2107. if (entity != null)
  2108. {
  2109. entity.MemoOpt = 4;
  2110. entity.UnusualCon = GetPostString("con");
  2111. entity.Update();
  2112. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2113. if (trade != null)
  2114. {
  2115. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2116. }
  2117. //查货是否超时
  2118. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2119. if (ceErpTradeCellExtend == null)
  2120. {
  2121. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2122. ceErpTradeCellExtend.ctid = entity.ctid;
  2123. }
  2124. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2125. {
  2126. ceErpTradeCellExtend.CheckOut += 1;
  2127. }
  2128. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2129. if (ceErpTradeCellExtend.ID > 0)
  2130. {
  2131. ceErpTradeCellExtend.Update();
  2132. }
  2133. else
  2134. {
  2135. ceErpTradeCellExtend.Create();
  2136. }
  2137. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2138. returnSuccessMsg("操作成功!");
  2139. return;
  2140. }
  2141. returnErrorMsg("找不到记录");
  2142. }
  2143. }
  2144. public void upd_erp_sampleorder()
  2145. {
  2146. if (UrlPostParmsCheck("ctid"))
  2147. {
  2148. string eid = GetPostString("ctid");
  2149. string[] eArr = eid.Split(',');
  2150. if (eArr.Length > 1)
  2151. {
  2152. List<string> eLst = new List<string>();
  2153. for (int i = 0; i < eArr.Length; i++)
  2154. {
  2155. eLst.Add("'" + eArr[i] + "'");
  2156. }
  2157. eid = string.Join(",", eLst.ToArray());
  2158. }
  2159. else
  2160. {
  2161. eid = "'" + eid + "'";
  2162. }
  2163. StringBuilder sql = new StringBuilder();
  2164. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2165. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2166. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2167. if (dt.Rows.Count > 0)
  2168. {
  2169. string errmsg = "";
  2170. foreach (DataRow dr in dt.Rows)
  2171. {
  2172. StringBuilder sqlsb = new StringBuilder();
  2173. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2174. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2175. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2176. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2177. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2178. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2179. {
  2180. continue;
  2181. }
  2182. else
  2183. {
  2184. string emsg = commonHelper.KeepChinese(apires);
  2185. errmsg += emsg;
  2186. }
  2187. }
  2188. if (errmsg.Length > 0)
  2189. {
  2190. returnErrorMsg(errmsg);
  2191. return;
  2192. }
  2193. returnSuccessMsg("操作成功");
  2194. return;
  2195. }
  2196. returnErrorMsg("找不到记录");
  2197. }
  2198. }
  2199. public void upd_erp_transcustomer()
  2200. {
  2201. if (UrlPostParmsCheck("ctid"))
  2202. {
  2203. string eid = GetPostString("ctid");
  2204. int userid = GetPostInt("CustomerUserId");
  2205. CeErpTradeCell entity = null;
  2206. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2207. if (entity != null)
  2208. {
  2209. //string[] mlist = entity.seller_memo.Split('-');
  2210. //string sql = "select * from view_erpuser where id=" + userid;
  2211. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2212. //if (dt != null && dt.Rows.Count > 0)
  2213. //{
  2214. // string nmemo = "";
  2215. // for(int i = 0; i < mlist.Length - 1; i++)
  2216. // {
  2217. // nmemo += mlist[i];
  2218. // nmemo += "-";
  2219. // }
  2220. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2221. // entity.seller_memo = nmemo;
  2222. //}
  2223. entity.CustomerUserId = userid;
  2224. entity.Update();
  2225. returnSuccessMsg("操作成功!");
  2226. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2227. return;
  2228. }
  2229. returnErrorMsg("找不到记录");
  2230. }
  2231. }
  2232. public void upd_erp_transdesigner()
  2233. {
  2234. if (UrlPostParmsCheck("ctid"))
  2235. {
  2236. string eids = GetPostString("ctid");
  2237. string[] ctidList = eids.Split(',');
  2238. int userid = GetPostInt("DesignUserId");
  2239. foreach (string ctid in ctidList)
  2240. {
  2241. CeErpTradeCell entity = null;
  2242. CeErpDesignerBill entitys = null;
  2243. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2244. entitys = CeErpDesignerBill.GetByTid(ctid);
  2245. if (entity != null)
  2246. {
  2247. if (entity.OrderState > 4)
  2248. {
  2249. continue;
  2250. }
  2251. //存在退款不能流转
  2252. if (entity.IsRefund > 0)
  2253. {
  2254. continue;
  2255. }
  2256. entity.DesignUserId = userid;
  2257. entity.WaitDesignTime = DateTime.Now;
  2258. entity.Update();
  2259. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2260. }
  2261. }
  2262. returnSuccessMsg("操作成功!");
  2263. }
  2264. }
  2265. public void upd_erp_distributedesigner()
  2266. {
  2267. if (UrlPostParmsCheck("ctid"))
  2268. {
  2269. string eid = GetPostString("ctid");
  2270. int userid = GetPostInt("DesignUserId");
  2271. string[] idlist = eid.Split(',');
  2272. if (idlist.Length <= 0)
  2273. {
  2274. returnErrorMsg("订单不能为空");
  2275. return;
  2276. }
  2277. foreach (string ctid in idlist)
  2278. {
  2279. CeErpTradeCell entity = null;
  2280. CeErpDesignerBill entitys = null;
  2281. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2282. else continue;
  2283. if (entity != null)
  2284. {
  2285. if (userid == 2125 || userid == 3542)
  2286. { }
  2287. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2288. {
  2289. returnErrorMsg("金额错误的订单无法指派");
  2290. return;
  2291. }
  2292. if (entity.OrderState >= 5)
  2293. {
  2294. returnErrorMsg("已经设计完成无法指派");
  2295. return;
  2296. }
  2297. if (entity.OrderState == -1)
  2298. {
  2299. returnErrorMsg("审核中的订单无法指派");
  2300. return;
  2301. }
  2302. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2303. {
  2304. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2305. return;
  2306. }
  2307. //157赖橙帆 159林晨 73 静之颖
  2308. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2309. {
  2310. returnErrorMsg("指派设计共创无法再次指派!");
  2311. return;
  2312. }
  2313. entity.OrderState = 3;
  2314. if (entity.SupplierId == 0)
  2315. {
  2316. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2317. entity.SupplierId = suid;
  2318. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2319. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2320. }
  2321. if (userid == 2125 && entity.seller_memo != "")
  2322. {
  2323. apiDesign.API_GetPrintData_CreateOrder(entity);
  2324. }
  2325. if (userid == 3542 && entity.seller_memo != "")
  2326. {
  2327. string userPost = CurrentUser.UserPost.Post.Code;
  2328. if (CurrentUser.UserID == 73)
  2329. {
  2330. userPost = "SysAdmin";
  2331. }
  2332. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2333. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2334. if (response.msg != "设计共创:成功")
  2335. {
  2336. returnErrorMsg(response.msg);
  2337. return;
  2338. }
  2339. entity.DispatchSort = 2;
  2340. }
  2341. else
  2342. {
  2343. if (entity.DispatchSort == 2)
  2344. {
  2345. ApiVo apiVo = new ApiVo();
  2346. apiVo.actionName = "closeDesign";
  2347. apiVo.orderNumber = entity.ctid;
  2348. designHelper.API_WorkCore(apiVo);//closeDesign
  2349. }
  2350. entity.DispatchSort = 0;
  2351. }
  2352. entity.DesignUserId = userid;
  2353. entity.WaitDesignTime = DateTime.Now;
  2354. entity.UpdateTime = DateTime.Now;
  2355. entity.Update();
  2356. string name = commonHelper.getUserNameById(userid);
  2357. commonHelper.UpdateRelationOrder(entity.ctid);
  2358. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2359. }
  2360. }
  2361. returnSuccessMsg("操作成功!");
  2362. return;
  2363. }
  2364. }
  2365. public string getTidByCtid(string ctid)
  2366. {
  2367. string tid = "";
  2368. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2369. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2370. if (dataTable != null && dataTable.Rows.Count > 0)
  2371. {
  2372. tid = dataTable.Rows[0]["tid"].ToString();
  2373. }
  2374. return tid;
  2375. }
  2376. public List<string> getTidByCtidMore(string ctid)
  2377. {
  2378. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2379. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2380. List<string> list = new List<string>();
  2381. if (dataTable != null && dataTable.Rows.Count > 0)
  2382. {
  2383. foreach (DataRow item in dataTable.Rows)
  2384. {
  2385. list.Add("'" + item["tid"].ToString() + "'");
  2386. }
  2387. }
  2388. return list;
  2389. }
  2390. public List<string> getTidByCtidLike(string ctid)
  2391. {
  2392. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2393. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2394. List<string> list = new List<string>();
  2395. if (dataTable != null && dataTable.Rows.Count > 0)
  2396. {
  2397. foreach (DataRow item in dataTable.Rows)
  2398. {
  2399. list.Add("'" + item["tid"].ToString() + "'");
  2400. }
  2401. }
  2402. return list;
  2403. }
  2404. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2405. {
  2406. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2407. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2408. List<string> list = new List<string>();
  2409. if (dataTable != null && dataTable.Rows.Count > 0)
  2410. {
  2411. foreach (DataRow item in dataTable.Rows)
  2412. {
  2413. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2414. {
  2415. continue;
  2416. }
  2417. list.Add("'" + item["receiverId"].ToString() + "'");
  2418. }
  2419. }
  2420. return list;
  2421. }
  2422. public void get_erp_myorderlist()
  2423. {
  2424. DataStruct dStruct = GetPostStruct();
  2425. List<string> lw = new List<string>();
  2426. string tid = GetPostString("ctid");
  2427. if (tid.Length > 0)
  2428. {
  2429. string select_tid = getTidByCtid(tid);
  2430. lw.Add(string.Format("tid='{0}'", select_tid));
  2431. }
  2432. else
  2433. {
  2434. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2435. }
  2436. //12-1 修改
  2437. string urgent = GetPostString("urgent");
  2438. string back = GetPostString("back");
  2439. string offlineSearch = GetPostString("offlineSearch");
  2440. if (!string.IsNullOrWhiteSpace(urgent))
  2441. {
  2442. if (urgent.Equals("true"))
  2443. {
  2444. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2445. }
  2446. }
  2447. if (!string.IsNullOrWhiteSpace(back))
  2448. {
  2449. if (back.Equals("true"))
  2450. {
  2451. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2452. }
  2453. }
  2454. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2455. {
  2456. if (offlineSearch.Equals("true"))
  2457. {
  2458. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2459. }
  2460. }
  2461. //end
  2462. string shopname = GetPostString("shopname");
  2463. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2464. string buyernick = GetPostString("buyer_nick");
  2465. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2466. string design = GetPostString("design");
  2467. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2468. string orderState = GetPostString("orderState");
  2469. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2470. string sellermemo = GetPostString("seller_memo");
  2471. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2472. string date1 = GetPostString("date1");
  2473. string date2 = GetPostString("date2");
  2474. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2475. if (dw.Length > 0) lw.Add(dw);
  2476. string price1 = GetPostString("price1");
  2477. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2478. string price2 = GetPostString("price2");
  2479. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2480. string urgency = GetPostString("urgency");
  2481. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2482. string after = GetPostString("after");
  2483. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2484. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2485. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2486. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2487. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2488. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2489. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2490. if (dt != null && dt.Rows.Count > 0)
  2491. {
  2492. foreach (DataRow dr in dt.Rows)
  2493. {
  2494. try
  2495. {
  2496. // 对象操作
  2497. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2498. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2499. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2500. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2501. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2502. if (dStruct.PageSize != 100000)
  2503. {
  2504. if (dr["DispatchSort"].ToString() == "2")
  2505. {
  2506. dr["gongchuang"] = 200;
  2507. }
  2508. else if ("外协".Equals(dr["ToType"].ToString()))
  2509. {
  2510. dr["gongchuang"] = 200;
  2511. }
  2512. else if ("内部".Equals(dr["ToType"].ToString()))
  2513. {
  2514. dr["gongchuang"] = -1;
  2515. }
  2516. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2517. {
  2518. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2519. dr["gongchuang"] = response.code;
  2520. }
  2521. }
  2522. }
  2523. catch (NullReferenceException ex)
  2524. {
  2525. }
  2526. }
  2527. }
  2528. writeGridDataTableJson(dStruct.TotalCount, dt);
  2529. }
  2530. public void get_erp_myreturnorderlist()
  2531. {
  2532. DataStruct dStruct = GetPostStruct();
  2533. List<string> lw = new List<string>();
  2534. string tid = GetPostString("ctid");
  2535. if (tid.Length > 0)
  2536. {
  2537. string select_tid = getTidByCtid(tid);
  2538. lw.Add(string.Format("tid='{0}'", select_tid));
  2539. }
  2540. else
  2541. {
  2542. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2543. }
  2544. string shopname = GetPostString("shopname");
  2545. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2546. string buyernick = GetPostString("buyer_nick");
  2547. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2548. string design = GetPostString("design");
  2549. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2550. string orderState = GetPostString("orderState");
  2551. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2552. string sellermemo = GetPostString("seller_memo");
  2553. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2554. string date1 = GetPostString("date1");
  2555. string date2 = GetPostString("date2");
  2556. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2557. if (dw.Length > 0) lw.Add(dw);
  2558. string price1 = GetPostString("price1");
  2559. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2560. string price2 = GetPostString("price2");
  2561. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2562. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2563. {
  2564. lw.Add(string.Format("CusOrgID = 94"));
  2565. }
  2566. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2567. {
  2568. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2569. }
  2570. else
  2571. {
  2572. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2573. }
  2574. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2575. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2576. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2577. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2578. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2579. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2580. if (dt != null && dt.Rows.Count > 0)
  2581. {
  2582. foreach (DataRow dr in dt.Rows)
  2583. {
  2584. try
  2585. {
  2586. // 对象操作
  2587. if (dStruct.PageSize != 100000)
  2588. {
  2589. if (dr["DispatchSort"].ToString() == "2")
  2590. {
  2591. dr["gongchuang"] = 200;
  2592. }
  2593. else if ("外协".Equals(dr["ToType"].ToString()))
  2594. {
  2595. dr["gongchuang"] = 200;
  2596. }
  2597. else if ("内部".Equals(dr["ToType"].ToString()))
  2598. {
  2599. dr["gongchuang"] = -1;
  2600. }
  2601. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2602. {
  2603. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2604. dr["gongchuang"] = response.code;
  2605. }
  2606. }
  2607. }
  2608. catch (NullReferenceException ex)
  2609. {
  2610. // 处理空引用异常
  2611. }
  2612. }
  2613. }
  2614. writeGridDataTableJson(dStruct.TotalCount, dt);
  2615. }
  2616. public void get_erp_myorderlist_pregather()
  2617. {
  2618. string date1 = GetPostString("date1");
  2619. string date2 = GetPostString("date2");
  2620. int userId = CurrentUser.UserID; //客服id
  2621. string orderWhere = "";
  2622. List<string> lw = new List<string>();
  2623. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2624. if (dw.Length > 0) lw.Add(dw);
  2625. lw.Add(string.Format("CustomerUserId={0}", userId));
  2626. lw.Add(string.Format("OrderState<9"));
  2627. orderWhere = string.Join(" and ", lw.ToArray());
  2628. string orderWhere2 = "";
  2629. List<string> lw2 = new List<string>();
  2630. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2631. if (dw2.Length > 0) lw2.Add(dw2);
  2632. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2633. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2634. string sql = string.Format("select *" +
  2635. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2636. "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 " +
  2637. "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 " +
  2638. "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");
  2639. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2640. //writeGridDataTableJson(dt.Rows.Count, dt);
  2641. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2642. }
  2643. public void upd_erp_publishorder()
  2644. {
  2645. if (UrlPostParmsCheck("ctid"))
  2646. {
  2647. string eid = GetPostString("ctid");
  2648. CeErpTradeCell entity = null;
  2649. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2650. if (entity != null)
  2651. {
  2652. entity.OrderState = 0; //发布后,变为待抢单
  2653. entity.Update();
  2654. commonHelper.UpdateRelationOrder(entity.ctid);
  2655. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2656. returnSuccessMsg("发布成功!");
  2657. return;
  2658. }
  2659. returnErrorMsg("找不到记录");
  2660. }
  2661. }
  2662. public void get_erp_my_tiporder()
  2663. {
  2664. StringBuilder sql = new StringBuilder();
  2665. int userId = 0;
  2666. if (CurrentUser != null) userId = CurrentUser.UserID;
  2667. string posCode = CurrentUser.UserPost.Post.Code;
  2668. string isTipedAfterSaleVerify = GetPostString("af");
  2669. DataTable dt = new DataTable();
  2670. if (posCode != "Supplier")
  2671. {
  2672. if (posCode == "CustomerService" || posCode == "Director")
  2673. {
  2674. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2675. }
  2676. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2677. {
  2678. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2679. }
  2680. else
  2681. {
  2682. string teamIds = CurrentUser.User.TeamIds;
  2683. if (teamIds == "")
  2684. {
  2685. teamIds = "0";
  2686. }
  2687. 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);
  2688. }
  2689. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2690. }
  2691. if (dt.Rows.Count <= 0)
  2692. {
  2693. string key = "aftersale_order_" + userId;
  2694. if (RedisHelper.HasKey(key))
  2695. {
  2696. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2697. dt.Columns.Add("ctid", typeof(string));
  2698. dt.Columns.Add("IsReadTag", typeof(int));
  2699. foreach (var i in list)
  2700. {
  2701. DataRow data = dt.NewRow();
  2702. data["ctid"] = i;
  2703. data["IsReadTag"] = 4;
  2704. dt.Rows.Add(data);
  2705. }
  2706. RedisHelper.StringDelete(key);
  2707. }
  2708. }
  2709. if (dt.Rows.Count <= 0)
  2710. {
  2711. sql = new StringBuilder();
  2712. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2713. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2714. }
  2715. if (posCode == "Supplier")
  2716. {
  2717. string ids = CurrentUser.User.pemVend;
  2718. if (ids != null && ids.Length > 0)
  2719. {
  2720. string[] ids_list = ids.Split(',');
  2721. foreach (var item in ids_list)
  2722. {
  2723. string key = "return_order_" + item;
  2724. if (RedisHelper.HasKey(key))
  2725. {
  2726. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2727. dt.Columns.Add("ctid", typeof(string));
  2728. dt.Columns.Add("IsReadTag", typeof(int));
  2729. foreach (var i in list)
  2730. {
  2731. DataRow data = dt.NewRow();
  2732. data["ctid"] = i;
  2733. data["IsReadTag"] = 1;
  2734. dt.Rows.Add(data);
  2735. }
  2736. RedisHelper.StringDelete(key);
  2737. }
  2738. }
  2739. }
  2740. if (dt.Rows.Count <= 0)
  2741. {
  2742. sql = new StringBuilder();
  2743. 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);
  2744. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2745. }
  2746. }
  2747. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2748. }
  2749. public void reset_erp_tiporder()
  2750. {
  2751. string ids = GetPostString("ids");
  2752. string[] ctidList = ids.Split(',');
  2753. foreach (string ctid in ctidList)
  2754. {
  2755. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2756. if (enty != null)
  2757. {
  2758. enty.IsReadTag = 0;
  2759. enty.Update();
  2760. }
  2761. }
  2762. returnSuccessMsg("成功!");
  2763. return;
  2764. }
  2765. public void get_erp_designlist()
  2766. {
  2767. DataStruct dStruct = GetPostStruct();
  2768. List<string> lw = new List<string>();
  2769. string tid = GetPostString("ctid");
  2770. if (tid.Length > 0)
  2771. {
  2772. string select_tid = getTidByCtid(tid);
  2773. lw.Add(string.Format("tid='{0}'", select_tid));
  2774. }
  2775. string shopname = GetPostString("shopname");
  2776. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2777. string buyernick = GetPostString("buyer_nick");
  2778. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2779. string customer = GetPostString("customer");
  2780. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2781. string design = GetPostString("design");
  2782. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2783. string orderState = GetPostString("orderState");
  2784. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2785. lw.Add(string.Format("OrderState<6"));
  2786. string address = GetPostString("address");
  2787. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2788. string sellermemo = GetPostString("seller_memo");
  2789. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2790. string date1 = GetPostString("date1");
  2791. string date2 = GetPostString("date2");
  2792. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2793. if (dw.Length > 0) lw.Add(dw);
  2794. string apdate1 = GetPostString("apdate1");
  2795. string apdate2 = GetPostString("apdate2");
  2796. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2797. if (dwap.Length > 0) lw.Add(dwap);
  2798. string price1 = GetPostString("price1");
  2799. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2800. string price2 = GetPostString("price2");
  2801. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2802. string designTime = GetPostString("designtime");
  2803. if (designTime.Length > 0)
  2804. {
  2805. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2806. }
  2807. string usershop = CurrentUser.User.pemShop;
  2808. if (usershop.Length > 0)
  2809. {
  2810. lw.Add(string.Format("shopId in ({0})", usershop));
  2811. }
  2812. int myOrgid = CurrentUser.UserPost.OrgID;
  2813. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2814. if (myOrgCode.IndexOf("Designer") != -1)
  2815. {
  2816. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2817. {
  2818. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2819. }
  2820. else
  2821. {
  2822. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2823. }
  2824. }
  2825. else
  2826. {
  2827. string orgId = GetPostString("designerhd");
  2828. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2829. }
  2830. if (tid.Length > 0 || buyernick.Length > 0)
  2831. {
  2832. lw.Add(string.Format("OrderState >= 3"));
  2833. }
  2834. else
  2835. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2836. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2837. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2838. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2839. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2840. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2841. if (dt != null && dt.Rows.Count > 0)
  2842. {
  2843. foreach (DataRow dr in dt.Rows)
  2844. {
  2845. try
  2846. {
  2847. // 对象操作
  2848. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2849. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2850. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2851. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2852. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2853. if (dStruct.PageSize != 100000)
  2854. {
  2855. if (dr["DispatchSort"].ToString() == "2")
  2856. {
  2857. dr["gongchuang"] = 200;
  2858. }
  2859. else if ("外协".Equals(dr["ToType"].ToString()))
  2860. {
  2861. dr["gongchuang"] = 200;
  2862. }
  2863. else if ("内部".Equals(dr["ToType"].ToString()))
  2864. {
  2865. dr["gongchuang"] = -1;
  2866. }
  2867. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2868. {
  2869. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2870. dr["gongchuang"] = response.code;
  2871. }
  2872. }
  2873. }
  2874. catch (NullReferenceException ex)
  2875. {
  2876. }
  2877. }
  2878. }
  2879. writeGridDataTableJson(dStruct.TotalCount, dt);
  2880. }
  2881. public void get_erp_mydesignlist()
  2882. {
  2883. DataStruct dStruct = GetPostStruct();
  2884. List<string> lw = new List<string>();
  2885. string tid = GetPostString("ctid");
  2886. if (tid.Length > 0)
  2887. {
  2888. string select_tid = getTidByCtid(tid);
  2889. lw.Add(string.Format("tid='{0}'", select_tid));
  2890. }
  2891. string shopname = GetPostString("shopname");
  2892. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2893. string buyernick = GetPostString("buyer_nick");
  2894. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2895. string customer = GetPostString("customer");
  2896. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2897. string orderState = GetPostString("orderState");
  2898. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2899. //lw.Add(string.Format("OrderState<6"));
  2900. string date1 = GetPostString("date1");
  2901. string date2 = GetPostString("date2");
  2902. string dw = GetDateWhere("pay_time", date1, date2);
  2903. if (dw.Length > 0) lw.Add(dw);
  2904. string apdate1 = GetPostString("apdate1");
  2905. string apdate2 = GetPostString("apdate2");
  2906. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2907. if (dwap.Length > 0) lw.Add(dwap);
  2908. string price1 = GetPostString("price1");
  2909. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2910. string price2 = GetPostString("price2");
  2911. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2912. string olddownload = GetPostString("olddown");
  2913. if (olddownload == "1")
  2914. {
  2915. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2916. }
  2917. else if (olddownload == "2")
  2918. {
  2919. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2920. }
  2921. string sellermemo = GetPostString("seller_memo");
  2922. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2923. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2924. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2925. {
  2926. if (CurrentUser.User.TeamIds.Length > 0)
  2927. {
  2928. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2929. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2930. else
  2931. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2932. }
  2933. else
  2934. {
  2935. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2936. }
  2937. }
  2938. if (tid.Length <= 0)
  2939. {
  2940. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2941. }
  2942. lw.Add(string.Format("IsReturn!=3"));
  2943. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2944. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2945. string teamids = CurrentUser.User.TeamIds.ToString();
  2946. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2947. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2948. if (dt != null && dt.Rows.Count > 0)
  2949. {
  2950. foreach (DataRow dr in dt.Rows)
  2951. {
  2952. try
  2953. {
  2954. // 对象操作
  2955. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2956. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2957. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2958. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2959. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2960. if (dStruct.PageSize != 100000)
  2961. {
  2962. if (dr["DispatchSort"].ToString() == "2")
  2963. {
  2964. dr["gongchuang"] = 200;
  2965. }
  2966. else if ("外协".Equals(dr["ToType"].ToString()))
  2967. {
  2968. dr["gongchuang"] = 200;
  2969. }
  2970. else if ("内部".Equals(dr["ToType"].ToString()))
  2971. {
  2972. dr["gongchuang"] = -1;
  2973. }
  2974. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2975. {
  2976. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2977. dr["gongchuang"] = response.code;
  2978. }
  2979. }
  2980. }
  2981. catch (NullReferenceException ex)
  2982. {
  2983. }
  2984. }
  2985. }
  2986. writeGridDataTableJson(dStruct.TotalCount, dt);
  2987. }
  2988. public void set_erp_startdesign()
  2989. {
  2990. if (UrlPostParmsCheck("ctid"))
  2991. {
  2992. string eid = GetPostString("ctid");
  2993. CeErpTradeCell entity = null;
  2994. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2995. if (entity != null)
  2996. {
  2997. if (entity.OrderState != 3)
  2998. {
  2999. returnErrorMsg("请刷新,订单已经设计了");
  3000. return;
  3001. }
  3002. entity.StartDesignTime = DateTime.Now;
  3003. entity.OrderState = 4;
  3004. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3005. {
  3006. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3007. entity.SupplierId = suid;
  3008. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3009. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3010. }
  3011. entity.UpdateTime = DateTime.Now;
  3012. //entity.MakeSupplier = suname;
  3013. entity.Update();
  3014. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3015. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3016. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3017. commonHelper.getCytPrice(entity);
  3018. returnSuccessMsg("操作成功!");
  3019. return;
  3020. }
  3021. returnErrorMsg("找不到记录");
  3022. }
  3023. }
  3024. public void ins_erp_designselfmemo()
  3025. {
  3026. if (UrlPostParmsCheck("ctid"))
  3027. {
  3028. string eid = GetPostString("ctid");
  3029. string con = GetPostString("con");
  3030. CeErpTradeCell entity = null;
  3031. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3032. if (entity != null)
  3033. {
  3034. entity.DesignSelfMemo = con;
  3035. entity.Update();
  3036. returnSuccessMsg("操作成功!");
  3037. return;
  3038. }
  3039. returnErrorMsg("找不到记录");
  3040. }
  3041. }
  3042. public void ins_erp_designprice()
  3043. {
  3044. if (UrlPostParmsCheck("ctid"))
  3045. {
  3046. string eid = GetPostString("ctid");
  3047. int uid = CurrentUser.UserID;
  3048. string userName = CurrentUser.UserName;
  3049. CeErpTradeCell entity = null;
  3050. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3052. if (entitys == null)
  3053. {
  3054. entitys = new CeErpDesignerBill();
  3055. }
  3056. if (entity != null)
  3057. {
  3058. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3059. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3060. entity.StartDesignTime = DateTime.Now;
  3061. entity.OrderState = 4;
  3062. string suname = "";
  3063. if (entity.SupplierId == 0)
  3064. {
  3065. int sid = commonHelper.autoDistributeToSupplier(entity);
  3066. entity.SupplierId = sid;
  3067. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3068. }
  3069. entity.Update();
  3070. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3071. if (ceErpUserPost != null)
  3072. {
  3073. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3074. if (ceErpPost != null)
  3075. {
  3076. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3077. {
  3078. entitys.tid = entity.ctid;
  3079. entitys.oid = entity.tid;
  3080. entitys.uid = uid;
  3081. entitys.userName = userName;
  3082. entitys.designerType = 1;
  3083. entitys.designerTypeText = "内部设计师";
  3084. entitys.price = Convert.ToDouble(GetPostString("price"));
  3085. entitys.designNum = GetPostInt("designNum");
  3086. entitys.modifyNum = GetPostInt("modifyNum");
  3087. entitys.designSize = GetPostString("designSize");
  3088. entitys.modifySize = GetPostString("modifySize");
  3089. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3090. {
  3091. entitys.create_time = DateTime.Now;
  3092. entitys.create_u_id = uid;
  3093. entitys.create_u_name = userName;
  3094. entitys.Save();
  3095. }
  3096. else
  3097. {
  3098. entitys.update_time = DateTime.Now;
  3099. entitys.update_u_id = uid;
  3100. entitys.update_u_name = userName;
  3101. entitys.Update();
  3102. }
  3103. }
  3104. }
  3105. }
  3106. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3107. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3108. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3109. if (suname != "")
  3110. {
  3111. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3112. }
  3113. commonHelper.getCytPrice(entity);
  3114. returnSuccessMsg("操作成功!");
  3115. return;
  3116. }
  3117. returnErrorMsg("找不到记录");
  3118. }
  3119. }
  3120. public void upload_erp_filecomplete()
  3121. {
  3122. if (UrlPostParmsCheck("ctid"))
  3123. {
  3124. string eid = GetPostString("ctid");
  3125. CeErpTradeCell entity = null;
  3126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3127. if (entity != null)
  3128. {
  3129. entity.OrderState = 5; //设计完成
  3130. entity.Update();
  3131. returnSuccessMsg(eid + "上传成功,设计完成!");
  3132. return;
  3133. }
  3134. returnErrorMsg("找不到订单记录");
  3135. }
  3136. }
  3137. public void get_erp_designovertimelist()
  3138. {
  3139. DataStruct dStruct = GetPostStruct();
  3140. List<string> lw = new List<string>();
  3141. string tid = GetPostString("ctid");
  3142. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3143. string shopname = GetPostString("shopname");
  3144. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3145. string buyernick = GetPostString("buyer_nick");
  3146. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3147. string ResponsibleMan = GetPostString("responsible");
  3148. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3149. string date1 = GetPostString("date1");
  3150. string date2 = GetPostString("date2");
  3151. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3152. if (dw.Length > 0) lw.Add(dw);
  3153. string price1 = GetPostString("price1");
  3154. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3155. string price2 = GetPostString("price2");
  3156. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3157. string orderState = GetPostString("orderState");
  3158. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3159. string sellermemo = GetPostString("seller_memo");
  3160. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3161. lw.Add(string.Format("UnusualTag=3"));
  3162. lw.Add(string.Format("IsRefund<={0}", 1));
  3163. dStruct.Order = "WaitDesignTime desc";
  3164. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3165. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3166. writeGridDataTableJson(dStruct.TotalCount, dt);
  3167. }
  3168. //设计管理 获取抢单大厅列表
  3169. public void get_erp_grabinglist()
  3170. {
  3171. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3172. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3173. bool oldOrder = false;
  3174. if (org != null)
  3175. {
  3176. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3177. }
  3178. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3179. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3180. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3181. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3182. //先处理订单数据
  3183. if (dt.Rows.Count > 0)
  3184. {
  3185. Dictionary<string, int> design = null;
  3186. int count = 0;
  3187. foreach (DataRow row in dt.Rows)
  3188. {
  3189. if (map.ContainsKey(row["ShopId"].ToString()))
  3190. {
  3191. map.TryGetValue(row["ShopId"].ToString(), out design);
  3192. }
  3193. else
  3194. {
  3195. design = new Dictionary<string, int>();
  3196. }
  3197. if (design.ContainsKey(row["ProductId"].ToString()))
  3198. {
  3199. design.TryGetValue(row["ProductId"].ToString(), out count);
  3200. }
  3201. count++;
  3202. design[row["ProductId"].ToString()] = count;
  3203. map[row["ShopId"].ToString()] = design;
  3204. }
  3205. }
  3206. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3207. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3208. //把店铺排序和技能排序分类
  3209. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3210. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3211. if (design_dt.Rows.Count > 0)
  3212. {
  3213. Dictionary<string, string> design = null;
  3214. List<string> shopIds = null;
  3215. foreach (DataRow row in design_dt.Rows)
  3216. {
  3217. if ("0".Equals(row["designId"].ToString()))
  3218. {
  3219. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3220. {
  3221. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3222. }
  3223. else
  3224. {
  3225. shopIds = new List<string>();
  3226. }
  3227. shopIds.Add(row["shopId"].ToString());
  3228. shop_orders[row["orders"].ToString()] = shopIds;
  3229. }
  3230. else
  3231. {
  3232. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3233. {
  3234. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3235. }
  3236. else
  3237. {
  3238. design = new Dictionary<string, string>();
  3239. }
  3240. design[row["orders"].ToString()] = row["designId"].ToString();
  3241. design_orders[row["shopId"].ToString()] = design;
  3242. }
  3243. }
  3244. //处理成key value后根据key排序
  3245. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3246. foreach (List<string> val in shop_orders.Values)
  3247. {
  3248. if (val != null)
  3249. {
  3250. foreach (string key in val)
  3251. {
  3252. if (design_orders.ContainsKey(key.ToString()))
  3253. {
  3254. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3255. }
  3256. }
  3257. }
  3258. }
  3259. }
  3260. //校验哪个优先级有订单
  3261. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3262. foreach (string key in shop_orders.Keys)
  3263. {
  3264. List<string> ids = null;
  3265. shop_orders.TryGetValue(key, out ids);
  3266. //id为shopid
  3267. foreach (string id in ids)
  3268. {
  3269. Dictionary<string, int> list = null;
  3270. Dictionary<string, string> desing = null;
  3271. map.TryGetValue(id, out list);
  3272. design_orders.TryGetValue(id, out desing);
  3273. if (list != null && desing != null)
  3274. {
  3275. foreach (var item in desing)
  3276. {
  3277. int count = 0;
  3278. if (list.ContainsKey(item.Value))
  3279. {
  3280. list.TryGetValue(item.Value, out count);
  3281. if (count > 0)
  3282. {
  3283. designIds[id] = item.Value;
  3284. break;
  3285. }
  3286. }
  3287. }
  3288. }
  3289. }
  3290. if (designIds.Count > 0)
  3291. {
  3292. break;
  3293. }
  3294. }
  3295. DataTable table = new DataTable();
  3296. table.Columns.Add("tid", typeof(string));
  3297. table.Columns.Add("ctid", typeof(string));
  3298. table.Columns.Add("seller_nick", typeof(string));
  3299. table.Columns.Add("productName", typeof(string));
  3300. table.Columns.Add("pay_time", typeof(string));
  3301. table.Columns.Add("seller_memo", typeof(string));
  3302. if (designIds.Count > 0)
  3303. {
  3304. string shopId = "";
  3305. string productId = "";
  3306. foreach (var designInfo in designIds)
  3307. {
  3308. shopId = designInfo.Key;
  3309. productId = designInfo.Value;
  3310. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3311. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3312. if (dt.Rows.Count > 0)
  3313. {
  3314. foreach (DataRow row in dt.Rows)
  3315. {
  3316. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3317. {
  3318. DataRow data = table.NewRow();
  3319. data["ctid"] = row["ctid"].ToString();
  3320. data["tid"] = row["tid"].ToString();
  3321. data["seller_nick"] = ceErpShop.ShopName;
  3322. data["pay_time"] = row["pay_time"].ToString();
  3323. data["seller_memo"] = row["seller_memo"].ToString();
  3324. data["productName"] = ceErpProduct.PType;
  3325. table.Rows.Add(data);
  3326. }
  3327. }
  3328. }
  3329. }
  3330. }
  3331. writeGridDataTableJson(table.Rows.Count, table);
  3332. }
  3333. private object rushLockObject = new object();
  3334. public void set_erp_grabingorder()
  3335. {
  3336. if (UrlPostParmsCheck("ctid"))
  3337. {
  3338. int total = CurrentUser.User.Person.Total;
  3339. int userId = CurrentUser.User.ID;
  3340. int noFinish = CurrentUser.User.Person.NoFinish;
  3341. int finalization = CurrentUser.User.Person.Finalization;
  3342. string eids = GetPostString("ctid");
  3343. string key = "RushKey_" + userId;
  3344. int count = 0;
  3345. if (erpRedis.RedisHelper.KeyExists(key))
  3346. {
  3347. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3348. if (redisCount != null)
  3349. {
  3350. count = Convert.ToInt32(redisCount);
  3351. }
  3352. }
  3353. if (count >= total)
  3354. {
  3355. returnErrorMsg("半小时内已经抢" + total + "单");
  3356. return;
  3357. }
  3358. string[] ctidlist = eids.Split(',');
  3359. if (count + ctidlist.Length > total)
  3360. {
  3361. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3362. return;
  3363. }
  3364. int itag = 0;
  3365. lock (rushLockObject)
  3366. {
  3367. if (ctidlist.Length > 0)
  3368. {
  3369. string[] dtList = new string[ctidlist.Length];
  3370. for (int i = 0; i < ctidlist.Length; i++)
  3371. {
  3372. dtList[i] = "'" + ctidlist[i] + "'";
  3373. }
  3374. 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"));
  3375. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3376. if (dt_user.Rows.Count > 0)
  3377. {
  3378. int doing = 0;//未定稿
  3379. int finish = 0;//已完成
  3380. foreach (DataRow dr in dt_user.Rows)
  3381. {
  3382. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3383. {
  3384. doing++;
  3385. }
  3386. else
  3387. {
  3388. finish++;
  3389. }
  3390. }
  3391. if (doing >= noFinish)
  3392. {
  3393. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3394. return;
  3395. }
  3396. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3397. {
  3398. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3399. return;
  3400. }
  3401. }
  3402. //校验选择单子状态
  3403. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3404. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3405. if (dt.Rows.Count > 0)
  3406. {
  3407. List<string> list = new List<string>();
  3408. foreach (DataRow dr in dt.Rows)
  3409. {
  3410. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3411. {
  3412. list.Add(dr["ctid"].ToString());
  3413. }
  3414. }
  3415. if (list.Count > 0)
  3416. {
  3417. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3418. return;
  3419. }
  3420. }
  3421. foreach (string ctid in ctidlist)
  3422. {
  3423. CeErpTradeCell entity = null;
  3424. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3425. if (entity != null)
  3426. {
  3427. entity.OrderState = 3;
  3428. entity.DesignUserId = CurrentUser.UserID;
  3429. entity.WaitDesignTime = DateTime.Now;
  3430. entity.StartDesignTime = DateTime.Now;
  3431. entity.Update();
  3432. commonHelper.UpdateRelationOrder(entity.ctid);
  3433. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3434. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3435. itag++;
  3436. }
  3437. }
  3438. }
  3439. }
  3440. count += ctidlist.Length;
  3441. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3442. if (itag == 0)
  3443. returnErrorMsg("没有找到相关订单");
  3444. else
  3445. returnSuccessMsg("抢单成功!");
  3446. return;
  3447. }
  3448. }
  3449. public void get_erp_waitorderlist()
  3450. {
  3451. DataStruct dStruct = GetPostStruct();
  3452. List<string> lw = new List<string>();
  3453. string tid = GetPostString("ctid");
  3454. if (tid.Length > 0)
  3455. {
  3456. string select_tid = getTidByCtid(tid);
  3457. lw.Add(string.Format("tid='{0}'", select_tid));
  3458. }
  3459. string shopname = GetPostString("shopname");
  3460. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3461. string buyernick = GetPostString("buyer_nick");
  3462. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3463. string customer = GetPostString("customer");
  3464. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3465. string design = GetPostString("design");
  3466. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3467. string orderState = GetPostString("orderState");
  3468. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3469. string supplier = GetPostString("supplier");
  3470. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3471. string sellermemo = GetPostString("seller_memo");
  3472. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3473. string otherMemo = GetPostString("otherMemo");
  3474. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3475. string address = GetPostString("address");
  3476. 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));
  3477. string date1 = GetPostString("date1");
  3478. string date2 = GetPostString("date2");
  3479. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3480. if (dw.Length > 0) lw.Add(dw);
  3481. string price1 = GetPostString("price1");
  3482. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3483. string price2 = GetPostString("price2");
  3484. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3485. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3486. lw.Add(string.Format("IsSample != 2 "));
  3487. lw.Add(string.Format("OrderState = 5 "));
  3488. lw.Add(string.Format("IsRefund<={0}", 1));
  3489. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3490. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3491. string pagesize = GetPostString("pagesize");
  3492. if (pagesize != null)
  3493. {
  3494. dStruct.PageSize = 200;
  3495. }
  3496. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3497. List<string> tids = new List<string>();
  3498. if (dt != null)
  3499. {
  3500. dt.Columns.Add("compenPrice", typeof(double));
  3501. foreach (DataRow dr in dt.Rows)
  3502. {
  3503. if (Convert.IsDBNull(dr["compenPrice"]))
  3504. {
  3505. dr["compenPrice"] = 0;
  3506. }
  3507. tids.Add("'" + dr["tid"].ToString() + "'");
  3508. 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();
  3509. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3510. {
  3511. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3512. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3513. entity.SupplierId = suid;
  3514. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3515. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3516. entity.Update();
  3517. }
  3518. }
  3519. }
  3520. if (tids.Count > 0)
  3521. {
  3522. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3523. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3524. if (dt_price != null && dt_price.Rows.Count > 0)
  3525. {
  3526. foreach (DataRow dr in dt_price.Rows)
  3527. {
  3528. foreach (DataRow row in dt.Rows)
  3529. {
  3530. if (row["tid"].Equals(dr["ptid"]))
  3531. {
  3532. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3533. break;
  3534. }
  3535. }
  3536. }
  3537. }
  3538. }
  3539. writeGridDataTableJson(dStruct.TotalCount, dt);
  3540. }
  3541. public void get_erp_supplierwaitorderlist()
  3542. {
  3543. DataStruct dStruct = GetPostStruct();
  3544. List<string> lw = new List<string>();
  3545. string tid = GetPostString("ctid");
  3546. if (tid.Length > 0)
  3547. {
  3548. string select_tid = getTidByCtid(tid);
  3549. lw.Add(string.Format("tid='{0}'", select_tid));
  3550. }
  3551. string shopname = GetPostString("shopname");
  3552. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3553. string sellermemo = GetPostString("seller_memo");
  3554. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3555. string date1 = GetPostString("date1");
  3556. string date2 = GetPostString("date2");
  3557. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3558. if (dw.Length > 0) lw.Add(dw);
  3559. lw.Add(string.Format("OrderState = 5 "));
  3560. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3561. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3562. {
  3563. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3564. }
  3565. string supplier = GetPostString("supplier");
  3566. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3567. {
  3568. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3569. }
  3570. lw.Add(string.Format("IsRefund<={0}", 1));
  3571. dStruct.Order = "FinishDesignTime desc";
  3572. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3573. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3574. if (dt != null)
  3575. {
  3576. foreach (DataRow dr in dt.Rows)
  3577. {
  3578. 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();
  3579. }
  3580. }
  3581. writeGridDataTableJson(dStruct.TotalCount, dt);
  3582. }
  3583. public void upd_erp_verifytosupplier()
  3584. {
  3585. if (UrlPostParmsCheck("ctid"))
  3586. {
  3587. string eids = GetPostString("ctid");
  3588. CeErpTradeCell entity = null;
  3589. string[] eidsList = eids.Split(',');
  3590. if (eidsList.Length <= 0)
  3591. {
  3592. returnErrorMsg("订单号不能空");
  3593. return;
  3594. }
  3595. List<string> tLst = new List<string>();
  3596. foreach (string ctidstr in eidsList)
  3597. {
  3598. tLst.Add("'" + ctidstr + "'");
  3599. CeErpDataSendOrderInfo.createObject(ctidstr);
  3600. }
  3601. string needtids = string.Join(",", tLst.ToArray());
  3602. StringBuilder sql = new StringBuilder();
  3603. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3604. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
  3605. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3606. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3607. returnSuccessMsg("操作成功!");
  3608. return;
  3609. /**foreach (string ctidstr in eidsList)
  3610. {
  3611. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3612. if (entity != null)
  3613. {
  3614. if (entity.SupplierId == 0)
  3615. {
  3616. continue;
  3617. }
  3618. entity.IsVerifyToSupplier = true;
  3619. if (entity.IsReturn == 1) //1是供应商打回
  3620. {
  3621. entity.IsReturn = 0;
  3622. }
  3623. entity.FinishPlaceTime = DateTime.Now;
  3624. entity.PlaceUserId = CurrentUser.UserID;
  3625. entity.Update();
  3626. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3627. }
  3628. }
  3629. returnSuccessMsg("操作成功!");
  3630. return;**/
  3631. }
  3632. }
  3633. public void upd_erp_supplierback()
  3634. {
  3635. if (UrlPostParmsCheck("ctid"))
  3636. {
  3637. string eid = GetPostString("ctid");
  3638. string reason = GetPostString("returnreason");
  3639. CeErpTradeCell entity = null;
  3640. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3641. if (entity != null)
  3642. {
  3643. string message = "操作成功!";
  3644. string isDown = "";
  3645. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3646. {
  3647. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3648. isDown = "被点击下载";
  3649. }
  3650. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3651. {
  3652. string key = "return_order_" + entity.SupplierId;
  3653. List<string> list = new List<string>();
  3654. if (RedisHelper.HasKey(key))
  3655. {
  3656. object data = RedisHelper.StringGet(key);
  3657. list = Convert.ToString(data).Split(',').ToList();
  3658. }
  3659. list.Add(eid);
  3660. RedisHelper.StringSet(key, string.Join(",", list));
  3661. }
  3662. entity.IsVerifyToSupplier = false;
  3663. entity.IsReturn = 1;
  3664. entity.IsHaveNewOrder = 0;
  3665. entity.ReturnTime = DateTime.Now;
  3666. entity.ReturnReason = reason;
  3667. if (entity.OrderState == 6)
  3668. {
  3669. entity.OrderState = 5;
  3670. }
  3671. entity.Update();
  3672. CeErpSukuraData.createInfo(entity.ctid, 5);
  3673. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3674. returnSuccessMsg(message);
  3675. return;
  3676. }
  3677. returnErrorMsg("找不到订单记录");
  3678. }
  3679. }
  3680. public void upd_erp_toaftersaleorder()
  3681. {
  3682. if (UrlPostParmsCheck("ctid"))
  3683. {
  3684. string eid = GetPostString("ctid");
  3685. string reason = GetPostString("returnreason");
  3686. CeErpTradeCell entity = null;
  3687. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3688. if (entity != null)
  3689. {
  3690. if (entity.isAfterSaleOrder != 1)
  3691. {
  3692. returnErrorMsg("带S的售后单才能打回给售后");
  3693. return;
  3694. }
  3695. if (entity.OrderState >= 5)
  3696. {
  3697. returnErrorMsg("已经设计完成了不能打回给售后");
  3698. return;
  3699. }
  3700. entity.OrderState = 0;
  3701. entity.IsReturn = 3;
  3702. entity.ReturnTime = DateTime.Now;
  3703. entity.UpdateTime = DateTime.Now;
  3704. entity.ReturnReason = reason;
  3705. entity.Update();
  3706. CeErpSukuraData.createInfo(entity.ctid, 5);
  3707. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3708. returnSuccessMsg("操作成功!");
  3709. return;
  3710. }
  3711. returnErrorMsg("找不到订单记录");
  3712. }
  3713. }
  3714. public void upd_erp_aftersaletodesign()
  3715. {
  3716. if (UrlPostParmsCheck("ctid"))
  3717. {
  3718. string eid = GetPostString("ctid");
  3719. CeErpTradeCell entity = null;
  3720. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3721. if (entity != null)
  3722. {
  3723. entity.OrderState = 3;
  3724. entity.IsReturn = 0;
  3725. entity.UpdateTime = DateTime.Now;
  3726. entity.Update();
  3727. CeErpSukuraData.createInfo(entity.ctid, 5);
  3728. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3729. returnSuccessMsg("操作成功!");
  3730. return;
  3731. }
  3732. returnErrorMsg("找不到订单记录");
  3733. }
  3734. }
  3735. public void assign_erp_supplier()
  3736. {
  3737. if (UrlPostParmsCheck("ctid"))
  3738. {
  3739. string eids = GetPostString("ctid");
  3740. int sid = GetPostInt("SupplierName");
  3741. string fromTag = GetPostString("tag");
  3742. string[] eidList = eids.Split(',');
  3743. if (eidList.Length <= 0)
  3744. {
  3745. returnErrorMsg("指派不能为空");
  3746. return;
  3747. }
  3748. string errMsg = "";
  3749. string suname = commonHelper.getSupplierNameById(sid);
  3750. foreach (string ctid in eidList)
  3751. {
  3752. CeErpTradeCell entity = null;
  3753. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3754. if (entity != null)
  3755. {
  3756. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3757. {
  3758. errMsg += (ctid + "指派失败!!!");
  3759. continue;
  3760. }
  3761. entity.SupplierId = sid;
  3762. entity.Update();
  3763. commonHelper.UpdateRelationOrder(entity.ctid);
  3764. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3765. if (entity.OrderState >= 6)
  3766. {
  3767. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3768. //{
  3769. // string msl = entity.MakeSupplier;
  3770. // string[] mslist = msl.Split(',');
  3771. // 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);
  3772. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3773. //}
  3774. //else
  3775. //{
  3776. StringBuilder sql = new StringBuilder();
  3777. 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);
  3778. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3779. //}
  3780. }
  3781. }
  3782. else
  3783. {
  3784. continue;
  3785. }
  3786. }
  3787. if (errMsg.Length > 0)
  3788. {
  3789. returnErrorMsg(errMsg);
  3790. return;
  3791. }
  3792. returnSuccessMsg("操作成功!");
  3793. return;
  3794. }
  3795. }
  3796. public void assign_erp_makesupplier()
  3797. {
  3798. if (UrlPostParmsCheck("ctid"))
  3799. {
  3800. string eids = GetPostString("ctid");
  3801. string sname = GetPostString("SupplierName");
  3802. string[] eidList = eids.Split(',');
  3803. if (eidList.Length <= 0)
  3804. {
  3805. returnErrorMsg("指派不能为空");
  3806. return;
  3807. }
  3808. List<string> tLst = new List<string>();
  3809. foreach (string ctid in eidList)
  3810. {
  3811. CeErpTradeCell entity = null;
  3812. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3813. if (entity != null)
  3814. {
  3815. entity.MakeSupplier = sname;
  3816. entity.Update();
  3817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3818. tLst.Add("'" + ctid + "'");
  3819. }
  3820. else
  3821. {
  3822. continue;
  3823. }
  3824. }
  3825. string ctids = string.Join(",", tLst.ToArray());
  3826. StringBuilder sql2 = new StringBuilder();
  3827. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3828. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3829. returnSuccessMsg("操作成功!");
  3830. return;
  3831. }
  3832. }
  3833. public void ins_erp_returnreason()
  3834. {
  3835. if (UrlPostParmsCheck("ctid"))
  3836. {
  3837. string eid = GetPostString("ctid");
  3838. CeErpTradeCell entity = null;
  3839. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3840. string userpost = CurrentUser.UserPost.Post.Code;
  3841. if (entity != null)
  3842. {
  3843. bool isPlace = false;
  3844. if (entity.OrderState > 6)
  3845. {
  3846. returnErrorMsg("已发货无法打回!");
  3847. return;
  3848. }
  3849. if (entity.OrderState == 6)
  3850. {
  3851. isPlace = true;
  3852. }
  3853. bool isNeedUpdateCell2 = false;
  3854. if (entity.OrderState >= 6)
  3855. {
  3856. isNeedUpdateCell2 = true;
  3857. }
  3858. int returnTag = 2;
  3859. if (userpost == "Supplier")
  3860. {
  3861. returnTag = 1;
  3862. }
  3863. int toType = GetPostInt("totype");
  3864. string fromType = "3";
  3865. if (entity.OrderState < 5)
  3866. {
  3867. fromType = "3";
  3868. }
  3869. else
  3870. {
  3871. fromType = "4";
  3872. }
  3873. if (entity.IsXianHuo == 0)
  3874. {
  3875. if (returnTag == 2)
  3876. {
  3877. if (toType == 1)
  3878. {
  3879. entity.OrderState = 0;
  3880. entity.ReturnUserType = 1;
  3881. string clearman = GetPostString("clearman");
  3882. if (!string.IsNullOrEmpty(clearman))
  3883. {
  3884. entity.DesignUserId = 0;
  3885. }
  3886. }
  3887. else
  3888. {
  3889. entity.OrderState = 3;
  3890. entity.ReturnUserType = 2;
  3891. }
  3892. entity.IsReadTag = 1;
  3893. }
  3894. else if (returnTag == 1)
  3895. {
  3896. entity.OrderState = 5;
  3897. }
  3898. entity.IsVerifyToSupplier = false;
  3899. }
  3900. if (entity.IsXianHuo == 1)
  3901. {
  3902. entity.OrderState = 5;
  3903. }
  3904. entity.UnusualTag = 0;
  3905. entity.UnusualTime = null;
  3906. entity.UnusualCon = "";
  3907. entity.IsReturn = returnTag;
  3908. entity.ReturnTime = DateTime.Now;
  3909. entity.UpdateTime = DateTime.Now;
  3910. entity.ReturnReason = GetPostString("returnreason");
  3911. entity.Update();
  3912. if (entity.OrderState == 3)
  3913. {
  3914. ApiVo apiVo = new ApiVo();
  3915. apiVo.orderNumber = entity.ctid;
  3916. apiVo.actionName = "rebutDesign";
  3917. apiVo.orderRemarks = entity.ReturnReason;
  3918. designHelper.API_WorkCore(apiVo);//rebutDesign
  3919. }
  3920. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3921. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3922. {
  3923. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3924. }
  3925. CeErpSukuraData.createInfo(entity.ctid, 5);
  3926. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3927. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3928. if (isPlace)
  3929. {
  3930. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3931. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3932. if (dth != null && dth.Rows.Count > 0)
  3933. {
  3934. dataSendOrderBean dataSendOrderBean = null;
  3935. foreach (DataRow item in dth.Rows)
  3936. {
  3937. try
  3938. {
  3939. dataSendOrderBean = new dataSendOrderBean();
  3940. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3941. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3942. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3943. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3944. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3945. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3946. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3947. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3948. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3949. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3950. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3951. dataSendOrderBean.Radio1723534706288 = "打回";
  3952. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3953. if (result != null)
  3954. {
  3955. if ("0".Equals(result.errcode))
  3956. {
  3957. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3958. }
  3959. else
  3960. {
  3961. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3962. }
  3963. }
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. }
  3968. }
  3969. }
  3970. }
  3971. if (isNeedUpdateCell2)
  3972. {
  3973. if (entity.MakeSupplier.IndexOf(",") != -1)
  3974. {
  3975. StringBuilder sql2 = new StringBuilder();
  3976. 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);
  3977. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3978. }
  3979. else
  3980. {
  3981. StringBuilder sql2 = new StringBuilder();
  3982. 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);
  3983. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3984. }
  3985. }
  3986. returnSuccessMsg("操作成功!");
  3987. return;
  3988. }
  3989. returnErrorMsg("找不到订单记录");
  3990. }
  3991. }
  3992. public void cyt_erp_returnreason()
  3993. {
  3994. if (UrlPostParmsCheck("ctid"))
  3995. {
  3996. string eid = GetPostString("ctid");
  3997. CeErpTradeCell entity = null;
  3998. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3999. string userpost = CurrentUser.UserPost.Post.Code;
  4000. if (entity != null)
  4001. {
  4002. if (entity.OrderState > 6)
  4003. {
  4004. returnErrorMsg("已发货无法打回!");
  4005. return;
  4006. }
  4007. JObject jsonObject = new JObject
  4008. {
  4009. { "Userid", "77886" },
  4010. { "Pwd", "lt666888" },
  4011. { "LTOrderId",eid }
  4012. };
  4013. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4014. JObject jsonObjects = JObject.Parse(response);
  4015. string msg = (string)jsonObjects["msg"];
  4016. if (msg != "取消成功")
  4017. {
  4018. returnErrorMsg(msg);
  4019. return;
  4020. }
  4021. bool isNeedUpdateCell2 = false;
  4022. if (entity.OrderState >= 6)
  4023. {
  4024. isNeedUpdateCell2 = true;
  4025. }
  4026. int returnTag = 2;
  4027. if (userpost == "Supplier")
  4028. {
  4029. returnTag = 1;
  4030. }
  4031. if (entity.IsXianHuo == 0)
  4032. {
  4033. if (returnTag == 2)
  4034. {
  4035. int toType = GetPostInt("totype");
  4036. if (toType == 1)
  4037. {
  4038. entity.OrderState = 0;
  4039. entity.ReturnUserType = 1;
  4040. }
  4041. else
  4042. {
  4043. entity.OrderState = 4;
  4044. entity.ReturnUserType = 2;
  4045. }
  4046. entity.IsReadTag = 1;
  4047. }
  4048. else if (returnTag == 1)
  4049. {
  4050. entity.OrderState = 5;
  4051. }
  4052. entity.IsVerifyToSupplier = false;
  4053. }
  4054. entity.UnusualTag = 0;
  4055. entity.UnusualTime = null;
  4056. entity.UnusualCon = "";
  4057. entity.IsReturn = returnTag;
  4058. entity.ReturnTime = DateTime.Now;
  4059. entity.ReturnReason = GetPostString("returnreason");
  4060. entity.Update();
  4061. if (entity.OrderState == 4)
  4062. {
  4063. ApiVo apiVo = new ApiVo();
  4064. apiVo.orderNumber = entity.ctid;
  4065. apiVo.actionName = "rebutDesign";
  4066. apiVo.orderRemarks = entity.ReturnReason;
  4067. designHelper.API_WorkCore(apiVo);//rebutDesign
  4068. }
  4069. CeErpSukuraData.createInfo(entity.ctid, 5);
  4070. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4071. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4072. if (isNeedUpdateCell2)
  4073. {
  4074. if (entity.MakeSupplier.IndexOf(",") != -1)
  4075. {
  4076. StringBuilder sql2 = new StringBuilder();
  4077. 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);
  4078. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4079. }
  4080. else
  4081. {
  4082. StringBuilder sql2 = new StringBuilder();
  4083. 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);
  4084. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4085. }
  4086. }
  4087. returnSuccessMsg("操作成功!");
  4088. return;
  4089. }
  4090. returnErrorMsg("找不到订单记录");
  4091. }
  4092. }
  4093. public void upd_erp_xianhuoreturntag()
  4094. {
  4095. if (UrlPostParmsCheck("ctid"))
  4096. {
  4097. string eids = GetPostString("ctid");
  4098. string[] ctids = eids.Split(',');
  4099. foreach (string ctid in ctids)
  4100. {
  4101. CeErpTradeCell entity = null;
  4102. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4103. if (entity != null)
  4104. {
  4105. entity.IsReturn = 0;
  4106. entity.Update();
  4107. CeErpSukuraData.createInfo(entity.ctid, 5);
  4108. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4109. }
  4110. }
  4111. returnSuccessMsg("操作成功!");
  4112. return;
  4113. }
  4114. }
  4115. public void get_erp_waitdeliverylist()
  4116. {
  4117. DataStruct dStruct = GetPostStruct();
  4118. List<string> lw = new List<string>();
  4119. string tid = GetPostString("ctid");
  4120. if (tid.Length > 0)
  4121. {
  4122. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4123. if (tid.Length > 5)
  4124. {
  4125. List<string> tids = getTidByCtidLike(tid);
  4126. if (tids.Count > 0 && tids.Count < 10)
  4127. {
  4128. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4129. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4130. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4131. {
  4132. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4133. }*/
  4134. }
  4135. }
  4136. lw.Add(tid_sql);
  4137. }
  4138. string shopname = GetPostString("shopname");
  4139. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4140. string buyernick = GetPostString("buyer_nick");
  4141. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4142. //if (tid.Length == 0 && buyernick.Length == 0)
  4143. //{
  4144. // lw.Add(string.Format("IsRefund<={0}", 1));
  4145. //}
  4146. string customer = GetPostString("customer");
  4147. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4148. string design = GetPostString("design");
  4149. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4150. string orderState = GetPostString("orderState");
  4151. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4152. string address = GetPostString("address");
  4153. 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));
  4154. string sellermemo = GetPostString("seller_memo");
  4155. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4156. string supplier = GetPostString("supplier");
  4157. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4158. string OrderArea = GetPostString("order_area");
  4159. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4160. string placedate1 = GetPostString("placedate1");
  4161. string placedate2 = GetPostString("placedate2");
  4162. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4163. if (fdw.Length > 0) lw.Add(fdw);
  4164. string price1 = GetPostString("price1");
  4165. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4166. string price2 = GetPostString("price2");
  4167. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4168. string unusualCon = GetPostString("unusualcon");
  4169. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4170. string otherMemo = GetPostString("otherMemo");
  4171. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4172. string posTag = CurrentUser.UserPost.Post.Code;
  4173. if (posTag == "Supplier")
  4174. {
  4175. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4176. }
  4177. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4178. lw.Add(string.Format("type != 'PDD' "));
  4179. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4180. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4182. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4183. writeGridDataTableJson(dStruct.TotalCount, dt);
  4184. }
  4185. public void get_erp_changedeliverylist()
  4186. {
  4187. DataStruct dStruct = GetPostStruct();
  4188. List<string> lw = new List<string>();
  4189. string tid = GetPostString("ctid");
  4190. if (tid.Length > 0)
  4191. {
  4192. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4193. if (tid.Length > 5)
  4194. {
  4195. List<string> tids = getTidByCtidLike(tid);
  4196. if (tids.Count > 0 && tids.Count < 10)
  4197. {
  4198. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4199. }
  4200. }
  4201. lw.Add(tid_sql);
  4202. }
  4203. string shopname = GetPostString("shopname");
  4204. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4205. string buyernick = GetPostString("buyer_nick");
  4206. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4207. //if (tid.Length == 0 && buyernick.Length == 0)
  4208. //{
  4209. // lw.Add(string.Format("IsRefund<={0}", 1));
  4210. //}
  4211. string customer = GetPostString("customer");
  4212. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4213. string design = GetPostString("design");
  4214. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4215. string orderState = GetPostString("orderState");
  4216. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4217. string address = GetPostString("address");
  4218. 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));
  4219. string sellermemo = GetPostString("seller_memo");
  4220. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4221. string supplier = GetPostString("supplier");
  4222. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4223. string OrderArea = GetPostString("order_area");
  4224. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4225. string placedate1 = GetPostString("placedate1");
  4226. string placedate2 = GetPostString("placedate2");
  4227. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4228. if (fdw.Length > 0) lw.Add(fdw);
  4229. string price1 = GetPostString("price1");
  4230. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4231. string price2 = GetPostString("price2");
  4232. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4233. string unusualCon = GetPostString("unusualcon");
  4234. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4235. string otherMemo = GetPostString("otherMemo");
  4236. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4237. string posTag = CurrentUser.UserPost.Post.Code;
  4238. if (posTag == "Supplier")
  4239. {
  4240. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4241. }
  4242. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4243. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4244. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4246. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4247. /*if (tid.Length > 0)
  4248. {
  4249. List<string> tids = new List<string>();
  4250. if (dt != null && dt.Rows.Count > 0)
  4251. {
  4252. foreach (DataRow item in dt.Rows)
  4253. {
  4254. tids.Add("'" + item["tid"] + "'");
  4255. }
  4256. }
  4257. if (tids.Count > 0)
  4258. {
  4259. lw.RemoveAt(0);
  4260. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4261. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4262. dt = WebCache.GetData("view_erptradecell", dStruct);
  4263. }
  4264. }*/
  4265. writeGridDataTableJson(dStruct.TotalCount, dt);
  4266. }
  4267. public void get_erp_pddderiving()
  4268. {
  4269. DataStruct dStruct = GetPostStruct();
  4270. List<string> lw = new List<string>();
  4271. string tid = GetPostString("ctid");
  4272. if (tid.Length > 0)
  4273. {
  4274. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4275. if (tid.Length > 5)
  4276. {
  4277. List<string> tids = getTidByCtidLike(tid);
  4278. if (tids.Count > 0 && tids.Count < 10)
  4279. {
  4280. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4281. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4282. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4283. {
  4284. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4285. }*/
  4286. }
  4287. }
  4288. lw.Add(tid_sql);
  4289. }
  4290. string shopname = GetPostString("shopname");
  4291. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4292. string buyernick = GetPostString("buyer_nick");
  4293. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4294. //if (tid.Length == 0 && buyernick.Length == 0)
  4295. //{
  4296. // lw.Add(string.Format("IsRefund<={0}", 1));
  4297. //}
  4298. string customer = GetPostString("customer");
  4299. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4300. string design = GetPostString("design");
  4301. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4302. string orderState = GetPostString("orderState");
  4303. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4304. string address = GetPostString("address");
  4305. 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));
  4306. string sellermemo = GetPostString("seller_memo");
  4307. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4308. string supplier = GetPostString("supplier");
  4309. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4310. string OrderArea = GetPostString("order_area");
  4311. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4312. string placedate1 = GetPostString("placedate1");
  4313. string placedate2 = GetPostString("placedate2");
  4314. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4315. if (fdw.Length > 0) lw.Add(fdw);
  4316. string price1 = GetPostString("price1");
  4317. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4318. string price2 = GetPostString("price2");
  4319. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4320. string unusualCon = GetPostString("unusualcon");
  4321. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4322. string posTag = CurrentUser.UserPost.Post.Code;
  4323. if (posTag == "Supplier")
  4324. {
  4325. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4326. }
  4327. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4328. lw.Add(string.Format("type = 'PDD' "));
  4329. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4330. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4331. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4332. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4333. /*if (tid.Length > 0)
  4334. {
  4335. List<string> tids = new List<string>();
  4336. if (dt != null && dt.Rows.Count > 0)
  4337. {
  4338. foreach (DataRow item in dt.Rows)
  4339. {
  4340. tids.Add("'" + item["tid"] + "'");
  4341. }
  4342. }
  4343. if (tids.Count > 0)
  4344. {
  4345. lw.RemoveAt(0);
  4346. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4347. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4348. dt = WebCache.GetData("view_erptradecell", dStruct);
  4349. }
  4350. }*/
  4351. writeGridDataTableJson(dStruct.TotalCount, dt);
  4352. }
  4353. public void get_erp_jdderiving()
  4354. {
  4355. DataStruct dStruct = GetPostStruct();
  4356. List<string> lw = new List<string>();
  4357. string tid = GetPostString("ctid");
  4358. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4359. string shopname = GetPostString("shopname");
  4360. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4361. string buyernick = GetPostString("buyer_nick");
  4362. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4363. //if (tid.Length == 0 && buyernick.Length == 0)
  4364. //{
  4365. // lw.Add(string.Format("IsRefund<={0}", 1));
  4366. //}
  4367. string customer = GetPostString("customer");
  4368. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4369. string design = GetPostString("design");
  4370. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4371. string orderState = GetPostString("orderState");
  4372. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4373. string address = GetPostString("address");
  4374. 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));
  4375. string sellermemo = GetPostString("seller_memo");
  4376. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4377. string supplier = GetPostString("supplier");
  4378. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4379. string OrderArea = GetPostString("order_area");
  4380. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4381. string placedate1 = GetPostString("placedate1");
  4382. string placedate2 = GetPostString("placedate2");
  4383. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4384. if (fdw.Length > 0) lw.Add(fdw);
  4385. string price1 = GetPostString("price1");
  4386. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4387. string price2 = GetPostString("price2");
  4388. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4389. string unusualCon = GetPostString("unusualcon");
  4390. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4391. string posTag = CurrentUser.UserPost.Post.Code;
  4392. if (posTag == "Supplier")
  4393. {
  4394. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4395. }
  4396. lw.Add(string.Format("OrderState = 6 "));
  4397. lw.Add(string.Format("type = 'JD' "));
  4398. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4399. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4400. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4401. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4402. writeGridDataTableJson(dStruct.TotalCount, dt);
  4403. }
  4404. public void get_erp_demoorderlist()
  4405. {
  4406. DataStruct dStruct = GetPostStruct();
  4407. List<string> lw = new List<string>();
  4408. string tid = GetPostString("ctid");
  4409. if (tid.Length > 0)
  4410. {
  4411. string select_tid = getTidByCtid(tid);
  4412. lw.Add(string.Format("tid='{0}'", select_tid));
  4413. }
  4414. string shopname = GetPostString("shopname");
  4415. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4416. string buyernick = GetPostString("buyer_nick");
  4417. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4418. string customer = GetPostString("customer");
  4419. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4420. string design = GetPostString("design");
  4421. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4422. string orderState = GetPostString("orderState");
  4423. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4424. string address = GetPostString("address");
  4425. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4426. string sellermemo = GetPostString("seller_memo");
  4427. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4428. string supplier = GetPostString("supplier");
  4429. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4430. string OrderArea = GetPostString("order_area");
  4431. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4432. string date1 = GetPostString("date1");
  4433. string date2 = GetPostString("date2");
  4434. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4435. if (dw.Length > 0) lw.Add(dw);
  4436. string price1 = GetPostString("price1");
  4437. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4438. string price2 = GetPostString("price2");
  4439. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4440. string posTag = CurrentUser.UserPost.Post.Code;
  4441. if (posTag == "Supplier")
  4442. {
  4443. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4444. }
  4445. //lw.Add(string.Format("OrderState = 6 "));
  4446. lw.Add(string.Format("IsSample={0}", 3));
  4447. lw.Add(string.Format("IsRefund<={0}", 1));
  4448. dStruct.Order = "pay_time desc";
  4449. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4450. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4451. writeGridDataTableJson(dStruct.TotalCount, dt);
  4452. }
  4453. public void save_erp_checkmemo()
  4454. {
  4455. if (UrlPostParmsCheck("ctid"))
  4456. {
  4457. string ctid = GetPostString("ctid");
  4458. CeErpTradeCell entity = null;
  4459. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4460. if (entity != null)
  4461. {
  4462. entity.CheckMemo = GetPostString("CheckMemo");
  4463. entity.Update();
  4464. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4465. if (trade != null)
  4466. {
  4467. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4468. }
  4469. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4470. returnSuccessMsg("保存成功!");
  4471. return;
  4472. }
  4473. returnErrorMsg("找不到记录");
  4474. }
  4475. }
  4476. public void get_erp_returnlist()
  4477. {
  4478. DataStruct dStruct = GetPostStruct();
  4479. List<string> lw = new List<string>();
  4480. string tid = GetPostString("ctid");
  4481. if (tid.Length > 0)
  4482. {
  4483. string select_tid = getTidByCtid(tid);
  4484. lw.Add(string.Format("tid='{0}'", select_tid));
  4485. }
  4486. string shopname = GetPostString("shopname");
  4487. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4488. string buyernick = GetPostString("buyer_nick");
  4489. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4490. string customer = GetPostString("customer");
  4491. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4492. string design = GetPostString("design");
  4493. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4494. string orderState = GetPostString("orderState");
  4495. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4496. string address = GetPostString("address");
  4497. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4498. string sellermemo = GetPostString("seller_memo");
  4499. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4500. string supplier = GetPostString("supplier");
  4501. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4502. string date1 = GetPostString("date1");
  4503. string date2 = GetPostString("date2");
  4504. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4505. if (dw.Length > 0) lw.Add(dw);
  4506. string bdate1 = GetPostString("backdate1");
  4507. string bdate2 = GetPostString("backdate2");
  4508. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4509. if (dw_back.Length > 0) lw.Add(dw_back);
  4510. string price1 = GetPostString("price1");
  4511. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4512. string price2 = GetPostString("price2");
  4513. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4514. lw.Add(string.Format("IsReturn>0"));
  4515. lw.Add(string.Format("IsXianHuo=0"));
  4516. lw.Add(string.Format("IsReturn!=3"));
  4517. string backtype = GetPostString("backtype");
  4518. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4519. dStruct.Order = "FinishDesignTime desc";
  4520. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4521. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4522. writeGridDataTableJson(dStruct.TotalCount, dt);
  4523. }
  4524. public void get_erp_today_sumreturn()
  4525. {
  4526. DataStruct dStruct = GetPostStruct();
  4527. List<string> lw = new List<string>();
  4528. string bdate1 = GetPostString("returnTimeS");
  4529. string bdate2 = GetPostString("returnTimeE");
  4530. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4531. if (dw_back.Length > 0) lw.Add(dw_back);
  4532. lw.Add(string.Format("IsReturn=0"));
  4533. lw.Add(string.Format("IsXianHuo=0"));
  4534. string mainWhere = string.Join(" and ", lw.ToArray());
  4535. string sql = "";
  4536. if (dw_back.Length > 0)
  4537. {
  4538. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4539. }
  4540. else
  4541. {
  4542. 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 + "'";
  4543. }
  4544. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4545. decimal total = 0, today_finish = 0;
  4546. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4547. {
  4548. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4549. }
  4550. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4551. {
  4552. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4553. }
  4554. var res = new
  4555. {
  4556. data = total,
  4557. data1 = today_finish,
  4558. };
  4559. string ro_jsond = JsonConvert.SerializeObject(res);
  4560. returnSuccess(ro_jsond);
  4561. return;
  4562. }
  4563. public void get_erp_allreturnlist()
  4564. {
  4565. DataStruct dStruct = GetPostStruct();
  4566. List<string> lw = new List<string>();
  4567. string tid = GetPostString("ctid");
  4568. if (tid.Length > 0)
  4569. {
  4570. string select_tid = getTidByCtid(tid);
  4571. lw.Add(string.Format("tid='{0}'", select_tid));
  4572. }
  4573. string shopname = GetPostString("shopname");
  4574. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4575. string buyernick = GetPostString("buyer_nick");
  4576. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4577. string customer = GetPostString("customer");
  4578. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4579. string design = GetPostString("design");
  4580. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4581. string orderState = GetPostString("orderState");
  4582. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4583. string address = GetPostString("address");
  4584. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4585. string sellermemo = GetPostString("seller_memo");
  4586. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4587. string supplier = GetPostString("supplier");
  4588. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4589. string date1 = GetPostString("date1");
  4590. string date2 = GetPostString("date2");
  4591. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4592. if (dw.Length > 0) lw.Add(dw);
  4593. string bdate1 = GetPostString("backdate1");
  4594. string bdate2 = GetPostString("backdate2");
  4595. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4596. if (dw_back.Length > 0) lw.Add(dw_back);
  4597. string price1 = GetPostString("price1");
  4598. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4599. string price2 = GetPostString("price2");
  4600. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4601. string backreason = GetPostString("backreason");
  4602. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4603. lw.Add(string.Format("IsXianHuo=0"));
  4604. lw.Add(string.Format("ReturnTime != ''"));
  4605. string backtype = GetPostString("backtype");
  4606. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4607. dStruct.Order = "FinishDesignTime desc";
  4608. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4609. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4610. writeGridDataTableJson(dStruct.TotalCount, dt);
  4611. }
  4612. public void get_erp_aftersalereturnlist()
  4613. {
  4614. DataStruct dStruct = GetPostStruct();
  4615. List<string> lw = new List<string>();
  4616. string tid = GetPostString("ctid");
  4617. if (tid.Length > 0)
  4618. {
  4619. string select_tid = getTidByCtid(tid);
  4620. lw.Add(string.Format("tid='{0}'", select_tid));
  4621. }
  4622. string shopname = GetPostString("shopname");
  4623. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4624. string buyernick = GetPostString("buyer_nick");
  4625. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4626. string customer = GetPostString("customer");
  4627. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4628. string design = GetPostString("design");
  4629. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4630. string orderState = GetPostString("orderState");
  4631. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4632. string address = GetPostString("address");
  4633. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4634. string sellermemo = GetPostString("seller_memo");
  4635. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4636. string supplier = GetPostString("supplier");
  4637. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4638. string date1 = GetPostString("date1");
  4639. string date2 = GetPostString("date2");
  4640. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4641. if (dw.Length > 0) lw.Add(dw);
  4642. string bdate1 = GetPostString("backdate1");
  4643. string bdate2 = GetPostString("backdate2");
  4644. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4645. if (dw_back.Length > 0) lw.Add(dw_back);
  4646. string price1 = GetPostString("price1");
  4647. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4648. string price2 = GetPostString("price2");
  4649. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4650. lw.Add(string.Format("IsReturn=3"));
  4651. string backtype = GetPostString("backtype");
  4652. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4653. string backreason = GetPostString("backreason");
  4654. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4655. dStruct.Order = "ReturnTime desc";
  4656. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4657. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4658. writeGridDataTableJson(dStruct.TotalCount, dt);
  4659. }
  4660. public void get_erp_xianhuoreturnlist()
  4661. {
  4662. DataStruct dStruct = GetPostStruct();
  4663. List<string> lw = new List<string>();
  4664. string tid = GetPostString("ctid");
  4665. if (tid.Length > 0)
  4666. {
  4667. string select_tid = getTidByCtid(tid);
  4668. lw.Add(string.Format("tid='{0}'", select_tid));
  4669. }
  4670. string shopname = GetPostString("shopname");
  4671. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4672. string buyernick = GetPostString("buyer_nick");
  4673. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4674. string customer = GetPostString("customer");
  4675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4676. string design = GetPostString("design");
  4677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4678. string orderState = GetPostString("orderState");
  4679. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4680. string address = GetPostString("address");
  4681. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4682. string sellermemo = GetPostString("seller_memo");
  4683. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4684. string supplier = GetPostString("supplier");
  4685. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4686. string OrderArea = GetPostString("order_area");
  4687. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4688. string date1 = GetPostString("date1");
  4689. string date2 = GetPostString("date2");
  4690. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4691. if (dw.Length > 0) lw.Add(dw);
  4692. string price1 = GetPostString("price1");
  4693. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4694. string price2 = GetPostString("price2");
  4695. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4696. string posTag = CurrentUser.UserPost.Post.Code;
  4697. if (posTag == "Supplier")
  4698. {
  4699. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4700. }
  4701. lw.Add(string.Format("OrderState=6 "));
  4702. lw.Add(string.Format("IsXianHuo=1 "));
  4703. lw.Add(string.Format("IsReturn>0 "));
  4704. lw.Add(string.Format("IsReturn!=3"));
  4705. lw.Add(string.Format("IsRefund<={0}", 1));
  4706. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4707. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4708. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4709. writeGridDataTableJson(dStruct.TotalCount, dt);
  4710. }
  4711. public void set_erp_orderdelivery()
  4712. {
  4713. if (UrlPostParmsCheck("ctid"))
  4714. {
  4715. string eid = GetPostString("ctid");
  4716. CeErpTradeCell entity = null;
  4717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4718. if (entity != null)
  4719. {
  4720. if (entity.OrderState >= 7)
  4721. {
  4722. returnErrorMsg("此单已发货,无需重复发货");
  4723. return;
  4724. }
  4725. if (entity.OrderState != 6)
  4726. {
  4727. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4728. return;
  4729. }
  4730. string shop = GetPostString("seller_nick");
  4731. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4732. string comName = GetPostString("comName");
  4733. string comCode = GetPostString("comCode");
  4734. string outSid = GetPostString("outSid");
  4735. string deliveryType = GetPostString("deliveryType");
  4736. string deliveryMemo = GetPostString("deliveryMemo");
  4737. outSid = outSid.Trim();
  4738. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4739. if (mainEn == null)
  4740. {
  4741. returnErrorMsg("找不到原始订单记录");
  4742. return;
  4743. }
  4744. bool isInitOrderDeliv = false;
  4745. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4746. {
  4747. isInitOrderDeliv = true;
  4748. }
  4749. string apires = "";
  4750. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4751. 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)
  4752. {
  4753. apires = "发货成功true";
  4754. }
  4755. else
  4756. {
  4757. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4758. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4759. }
  4760. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4761. {
  4762. entity.OrderState = 7;//发货后订单已发货
  4763. entity.OutSid = outSid;
  4764. entity.MemoOpt = 0;
  4765. entity.UpdateTime = DateTime.Now;
  4766. entity.FinishDeliveryTime = DateTime.Now;
  4767. entity.Update();
  4768. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4769. commonHelper.UpdateRelationOrder(entity.ctid);
  4770. //还要插入快递信息到 快递信息表
  4771. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4772. exinfo.tid = eid;
  4773. exinfo.out_sid = outSid;
  4774. exinfo.company_code = comCode;
  4775. exinfo.company_name = comName;
  4776. exinfo.delivery_memo = deliveryMemo;
  4777. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4778. exinfo.deliveryType = deliveryType;
  4779. exinfo.Create();
  4780. returnSuccessMsg("发货操作成功!");
  4781. commonHelper.UpdateRelationOrder(entity.ctid);
  4782. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4783. CeErpSukuraData.createInfo(entity.ctid, 4);
  4784. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4785. {
  4786. commonHelper.sendCytExpress(exinfo);
  4787. }
  4788. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4789. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4790. }
  4791. else
  4792. {
  4793. string errmsg = commonHelper.KeepChinese(apires);
  4794. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4795. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4796. }
  4797. return;
  4798. }
  4799. returnErrorMsg("找不到订单记录");
  4800. }
  4801. }
  4802. public void set_erp_multidelivery()
  4803. {
  4804. string eids = GetPostString("tids");
  4805. string[] eidList = eids.Split(',');
  4806. if (eidList.Length <= 0)
  4807. {
  4808. returnErrorMsg("发货不能为空");
  4809. return;
  4810. }
  4811. foreach (string ctid in eidList)
  4812. {
  4813. if (ctid.Length <= 0) continue;
  4814. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4815. if (expInfo != null)
  4816. {
  4817. StringBuilder sql = new StringBuilder();
  4818. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4819. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4820. if (dt.Rows.Count > 0)
  4821. {
  4822. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4823. {
  4824. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4825. expInfo.state = "异常";
  4826. expInfo.isMultiDelivery = 1;
  4827. expInfo.Update();
  4828. continue;
  4829. }
  4830. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4831. {
  4832. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4833. expInfo.state = "异常";
  4834. expInfo.Update();
  4835. continue;
  4836. }
  4837. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4838. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4839. bool isInitOrderDeliv = false;
  4840. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4841. {
  4842. isInitOrderDeliv = true;
  4843. expInfo.isMultiDelivery = 1;
  4844. }
  4845. if (ctid.IndexOf("N") != -1)
  4846. {
  4847. StringBuilder sqlbucha = new StringBuilder();
  4848. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4849. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4850. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4851. commonHelper.UpdateRelationOrder(ctid);
  4852. expInfo.delivery_memo = "发货成功";
  4853. expInfo.state = "发货成功";
  4854. expInfo.isMultiDelivery = 1;
  4855. expInfo.Update();
  4856. }
  4857. else
  4858. {
  4859. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4860. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4861. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4862. {
  4863. expInfo.delivery_memo = "发货成功";
  4864. expInfo.state = "发货成功";
  4865. expInfo.isMultiDelivery = 1;
  4866. expInfo.Update();
  4867. commonHelper.UpdateRelationOrder(ctid);
  4868. CeErpSukuraData.createInfo(ctid, 4);
  4869. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4870. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4871. }
  4872. else
  4873. {
  4874. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4875. expInfo.state = "异常";
  4876. expInfo.Update();
  4877. }
  4878. }
  4879. }
  4880. }
  4881. }
  4882. returnSuccessMsg("操作完成");
  4883. }
  4884. public void reset_erp_memoopt()
  4885. {
  4886. if (UrlPostParmsCheck("ctid"))
  4887. {
  4888. string eid = GetPostString("ctid");
  4889. CeErpTradeCell entity = null;
  4890. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4891. if (entity != null)
  4892. {
  4893. string stropt = "";
  4894. if (entity.MemoOpt == 1)
  4895. {
  4896. stropt = "“改稿”";
  4897. }
  4898. else if (entity.MemoOpt == 2)
  4899. {
  4900. stropt = "“定稿”";
  4901. }
  4902. else if (entity.MemoOpt == 3)
  4903. {
  4904. stropt = "“完成查货”";
  4905. CeErpSukuraData.createInfo(entity.ctid, 6);
  4906. }
  4907. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4908. entity.UpdateTime = DateTime.Now;
  4909. entity.MemoOpt = 0;
  4910. entity.Update();
  4911. returnSuccessMsg("操作成功!");
  4912. return;
  4913. }
  4914. returnErrorMsg("找不到记录");
  4915. }
  4916. }
  4917. public void get_erp_deliveryunusual()
  4918. {
  4919. DataStruct dStruct = GetPostStruct();
  4920. List<string> lw = new List<string>();
  4921. string tid = GetPostString("ctid");
  4922. if (tid.Length > 0)
  4923. {
  4924. string select_tid = getTidByCtid(tid);
  4925. lw.Add(string.Format("tid='{0}'", select_tid));
  4926. }
  4927. string shopname = GetPostString("shopname");
  4928. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4929. string buyernick = GetPostString("buyer_nick");
  4930. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4931. string customer = GetPostString("customer");
  4932. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4933. string design = GetPostString("design");
  4934. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4935. string sellermemo = GetPostString("seller_memo");
  4936. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4937. string supplier = GetPostString("supplier");
  4938. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4939. string date1 = GetPostString("date1");
  4940. string date2 = GetPostString("date2");
  4941. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4942. if (dw.Length > 0) lw.Add(dw);
  4943. string placedate1 = GetPostString("placedate1");
  4944. string placedate2 = GetPostString("placedate2");
  4945. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4946. if (dw_place.Length > 0) lw.Add(dw_place);
  4947. string price1 = GetPostString("price1");
  4948. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4949. string price2 = GetPostString("price2");
  4950. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4951. string unusualCon = GetPostString("unusualcon");
  4952. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4953. string posTag = CurrentUser.UserPost.Post.Code;
  4954. if (posTag == "Supplier")
  4955. {
  4956. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4957. }
  4958. lw.Add(string.Format("OrderState = 6"));
  4959. lw.Add(string.Format("UnusualTag = 5"));
  4960. lw.Add(string.Format("IsRefund<={0}", 1));
  4961. dStruct.Order = "FinishPlaceTime desc";
  4962. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4963. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4964. writeGridDataTableJson(dStruct.TotalCount, dt);
  4965. }
  4966. public void get_erp_deliveryedlist()
  4967. {
  4968. DataStruct dStruct = GetPostStruct();
  4969. List<string> lw = new List<string>();
  4970. string tid = GetPostString("ctid");
  4971. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4972. string shopname = GetPostString("shopname");
  4973. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4974. string buyernick = GetPostString("buyer_nick");
  4975. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4976. string customer = GetPostString("customer");
  4977. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4978. string design = GetPostString("design");
  4979. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4980. string sellermemo = GetPostString("seller_memo");
  4981. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4982. string logistics = GetPostString("logistics");
  4983. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4984. string date1 = GetPostString("date1");
  4985. string date2 = GetPostString("date2");
  4986. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4987. //if (dw.Length > 0) lw.Add(dw);
  4988. string placedate1 = GetPostString("placedate1");
  4989. string placedate2 = GetPostString("placedate2");
  4990. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4991. if (fdw.Length > 0) lw.Add(fdw);
  4992. string devdate1 = GetPostString("deliverydate1");
  4993. string devdate2 = GetPostString("deliverydate2");
  4994. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4995. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4996. string price1 = GetPostString("price1");
  4997. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4998. string price2 = GetPostString("price2");
  4999. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5000. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5001. {
  5002. if (tid.Length > 0)
  5003. {
  5004. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5005. if (tid.Length > 5)
  5006. {
  5007. List<string> tids = getTidByCtidLike(tid);
  5008. if (tids.Count > 0 && tids.Count < 10)
  5009. {
  5010. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5011. }
  5012. }
  5013. lw.Add(tid_sql);
  5014. }
  5015. if (buyernick.Length > 0)
  5016. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5017. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5018. if (dw.Length > 0) lw.Add(dw);
  5019. }
  5020. else
  5021. {
  5022. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5023. }
  5024. string posTag = CurrentUser.UserPost.Post.Code;
  5025. if (posTag == "Supplier")
  5026. {
  5027. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5028. }
  5029. else
  5030. {
  5031. string supplier = GetPostString("supplier");
  5032. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5033. }
  5034. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5035. lw.Add(string.Format("type != 'PDD' "));
  5036. lw.Add(string.Format("IsRefund!={0}", 2));
  5037. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5038. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5039. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5040. /*if (tid.Length > 0)
  5041. {
  5042. List<string> tids = new List<string>();
  5043. if (dt != null && dt.Rows.Count > 0)
  5044. {
  5045. foreach (DataRow item in dt.Rows)
  5046. {
  5047. tids.Add("'" + item["tid"] + "'");
  5048. }
  5049. }
  5050. if (tids.Count > 0)
  5051. {
  5052. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5053. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5054. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5055. dt = WebCache.GetData("view_erptradecell", dStruct);
  5056. }
  5057. }*/
  5058. if (dt != null)
  5059. {
  5060. foreach (DataRow dr in dt.Rows)
  5061. {
  5062. 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();
  5063. }
  5064. }
  5065. writeGridDataTableJson(dStruct.TotalCount, dt);
  5066. }
  5067. public void get_erp_pdddeliveryed()
  5068. {
  5069. DataStruct dStruct = GetPostStruct();
  5070. List<string> lw = new List<string>();
  5071. string tid = GetPostString("ctid");
  5072. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5073. string shopname = GetPostString("shopname");
  5074. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5075. string buyernick = GetPostString("buyer_nick");
  5076. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5077. string customer = GetPostString("customer");
  5078. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5079. string design = GetPostString("design");
  5080. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5081. string sellermemo = GetPostString("seller_memo");
  5082. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5083. string logistics = GetPostString("logistics");
  5084. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5085. string date1 = GetPostString("date1");
  5086. string date2 = GetPostString("date2");
  5087. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5088. //if (dw.Length > 0) lw.Add(dw);
  5089. string placedate1 = GetPostString("placedate1");
  5090. string placedate2 = GetPostString("placedate2");
  5091. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5092. if (fdw.Length > 0) lw.Add(fdw);
  5093. string devdate1 = GetPostString("deliverydate1");
  5094. string devdate2 = GetPostString("deliverydate2");
  5095. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5096. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5097. string price1 = GetPostString("price1");
  5098. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5099. string price2 = GetPostString("price2");
  5100. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5101. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5102. {
  5103. if (tid.Length > 0)
  5104. {
  5105. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5106. if (tid.Length > 5)
  5107. {
  5108. List<string> tids = getTidByCtidLike(tid);
  5109. if (tids.Count > 0 && tids.Count < 10)
  5110. {
  5111. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5112. }
  5113. }
  5114. lw.Add(tid_sql);
  5115. }
  5116. if (buyernick.Length > 0)
  5117. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5118. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5119. if (dw.Length > 0) lw.Add(dw);
  5120. }
  5121. else
  5122. {
  5123. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5124. }
  5125. string posTag = CurrentUser.UserPost.Post.Code;
  5126. if (posTag == "Supplier")
  5127. {
  5128. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5129. }
  5130. else
  5131. {
  5132. string supplier = GetPostString("supplier");
  5133. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5134. }
  5135. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5136. lw.Add(string.Format("type = 'PDD' "));
  5137. lw.Add(string.Format("IsRefund!={0}", 2));
  5138. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5139. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5140. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5141. /* if (tid.Length > 0)
  5142. {
  5143. List<string> tids = new List<string>();
  5144. if (dt != null && dt.Rows.Count > 0)
  5145. {
  5146. foreach (DataRow item in dt.Rows)
  5147. {
  5148. tids.Add("'" + item["tid"] + "'");
  5149. }
  5150. }
  5151. if (tids.Count > 0)
  5152. {
  5153. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5154. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5155. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5156. dt = WebCache.GetData("view_erptradecell", dStruct);
  5157. }
  5158. }*/
  5159. foreach (DataRow dr in dt.Rows)
  5160. {
  5161. 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();
  5162. }
  5163. writeGridDataTableJson(dStruct.TotalCount, dt);
  5164. }
  5165. public void get_erp_jddeliveryed()
  5166. {
  5167. DataStruct dStruct = GetPostStruct();
  5168. List<string> lw = new List<string>();
  5169. string tid = GetPostString("ctid");
  5170. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5171. string shopname = GetPostString("shopname");
  5172. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5173. string buyernick = GetPostString("buyer_nick");
  5174. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5175. string customer = GetPostString("customer");
  5176. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5177. string design = GetPostString("design");
  5178. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5179. string sellermemo = GetPostString("seller_memo");
  5180. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5181. string date1 = GetPostString("date1");
  5182. string date2 = GetPostString("date2");
  5183. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5184. //if (dw.Length > 0) lw.Add(dw);
  5185. string placedate1 = GetPostString("placedate1");
  5186. string placedate2 = GetPostString("placedate2");
  5187. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5188. if (fdw.Length > 0) lw.Add(fdw);
  5189. string devdate1 = GetPostString("deliverydate1");
  5190. string devdate2 = GetPostString("deliverydate2");
  5191. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5192. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5193. string price1 = GetPostString("price1");
  5194. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5195. string price2 = GetPostString("price2");
  5196. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5197. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5198. {
  5199. if (tid.Length > 0)
  5200. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5201. if (buyernick.Length > 0)
  5202. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5203. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5204. if (dw.Length > 0) lw.Add(dw);
  5205. }
  5206. else
  5207. {
  5208. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5209. }
  5210. string posTag = CurrentUser.UserPost.Post.Code;
  5211. if (posTag == "Supplier")
  5212. {
  5213. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5214. }
  5215. else
  5216. {
  5217. string supplier = GetPostString("supplier");
  5218. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5219. }
  5220. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5221. lw.Add(string.Format("type = 'JD' "));
  5222. lw.Add(string.Format("IsRefund!={0}", 2));
  5223. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5224. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5225. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5226. foreach (DataRow dr in dt.Rows)
  5227. {
  5228. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5229. }
  5230. writeGridDataTableJson(dStruct.TotalCount, dt);
  5231. }
  5232. public void get_erp_allplacelist()
  5233. {
  5234. DataStruct dStruct = GetPostStruct();
  5235. List<string> lw = new List<string>();
  5236. string tid = GetPostString("ctid");
  5237. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5238. string shopname = GetPostString("shopname");
  5239. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5240. string buyernick = GetPostString("buyer_nick");
  5241. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5242. string customer = GetPostString("customer");
  5243. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5244. string design = GetPostString("design");
  5245. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5246. string sellermemo = GetPostString("seller_memo");
  5247. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5248. string supplier = GetPostString("supplier");
  5249. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5250. string date1 = GetPostString("date1");
  5251. string date2 = GetPostString("date2");
  5252. string pldate1 = GetPostString("placedate1");
  5253. string pldate2 = GetPostString("placedate2");
  5254. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5255. //if (dw.Length > 0) lw.Add(dw);
  5256. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5257. {
  5258. if (tid.Length > 0)
  5259. {
  5260. string select_tid = getTidByCtid(tid);
  5261. lw.Add(string.Format("tid='{0}'", select_tid));
  5262. }
  5263. if (buyernick.Length > 0)
  5264. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5265. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5266. if (dw.Length > 0) lw.Add(dw);
  5267. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5268. if (dw_place.Length > 0) lw.Add(dw_place);
  5269. }
  5270. else
  5271. {
  5272. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5273. {
  5274. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5275. }
  5276. }
  5277. string price1 = GetPostString("price1");
  5278. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5279. string price2 = GetPostString("price2");
  5280. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5281. string posTag = CurrentUser.UserPost.Post.Code;
  5282. if (posTag == "Supplier")
  5283. {
  5284. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5285. }
  5286. lw.Add(string.Format("OrderState >= 6"));
  5287. lw.Add(string.Format("IsSample != 2 "));
  5288. //lw.Add(string.Format("isDianziOrder = 0 "));
  5289. lw.Add(string.Format("SupplierId > 0 "));
  5290. //lw.Add(string.Format("IsRefund<={0}", 1));
  5291. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5292. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5293. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5294. foreach (DataRow dr in dt.Rows)
  5295. {
  5296. 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();
  5297. }
  5298. writeGridDataTableJson(dStruct.TotalCount, dt);
  5299. }
  5300. public void get_erp_financeallplacelist()
  5301. {
  5302. DataStruct dStruct = GetPostStruct();
  5303. List<string> lw = new List<string>();
  5304. string tid = GetPostString("ctid");
  5305. string shopname = GetPostString("shopname");
  5306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5307. string buyernick = GetPostString("buyer_nick");
  5308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5309. string customer = GetPostString("customer");
  5310. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5311. string design = GetPostString("design");
  5312. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5313. string sellermemo = GetPostString("seller_memo");
  5314. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5315. string supplier = GetPostString("supplier");
  5316. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5317. string date1 = GetPostString("date1");
  5318. string date2 = GetPostString("date2");
  5319. string pldate1 = GetPostString("placedate1");
  5320. string pldate2 = GetPostString("placedate2");
  5321. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5322. {
  5323. if (tid.Length > 0)
  5324. {
  5325. string select_tid = getTidByCtid(tid);
  5326. lw.Add(string.Format("tid='{0}'", select_tid));
  5327. }
  5328. if (buyernick.Length > 0)
  5329. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5330. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5331. if (dw.Length > 0) lw.Add(dw);
  5332. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5333. if (dw_place.Length > 0) lw.Add(dw_place);
  5334. }
  5335. else
  5336. {
  5337. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5338. {
  5339. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5340. }
  5341. }
  5342. string price1 = GetPostString("price1");
  5343. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5344. string price2 = GetPostString("price2");
  5345. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5346. string posTag = CurrentUser.UserPost.Post.Code;
  5347. if (posTag == "Supplier")
  5348. {
  5349. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5350. }
  5351. //lw.Add(string.Format("OrderState >= 6"));
  5352. lw.Add(string.Format("IsSample != 2 "));
  5353. lw.Add(string.Format("isDianziOrder = 0 "));
  5354. //lw.Add(string.Format("IsRefund<={0}", 1));
  5355. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5356. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5357. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5358. foreach (DataRow dr in dt.Rows)
  5359. {
  5360. 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();
  5361. }
  5362. writeGridDataTableJson(dStruct.TotalCount, dt);
  5363. }
  5364. public void get_erp_expresslist()
  5365. {
  5366. int listtype = GetInt("ltype");
  5367. DataStruct dStruct = GetPostStruct();
  5368. List<string> lw = new List<string>();
  5369. string tid = GetPostString("tid");
  5370. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5371. string outsid = GetPostString("out_sid");
  5372. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5373. string importer = GetPostString("ImportUserName");
  5374. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5375. string file = GetPostString("import_file");
  5376. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5377. string printman = GetPostString("printman");
  5378. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5379. string date1 = GetPostString("date1");
  5380. string date2 = GetPostString("date2");
  5381. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5382. if (dw.Length > 0) lw.Add(dw);
  5383. string fdate1 = GetPostString("finishdate1");
  5384. string fdate2 = GetPostString("finishdate2");
  5385. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5386. if (fdw.Length > 0) lw.Add(fdw);
  5387. string supplierId = GetPostString("supplierId");
  5388. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5389. if (listtype == 1)
  5390. {
  5391. lw.Add(string.Format("importUserId !=0"));
  5392. }
  5393. string posTag = CurrentUser.UserPost.Post.Code;
  5394. if (posTag == "Supplier")
  5395. {
  5396. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5397. }
  5398. if (dStruct.PageSize != 100000)
  5399. {
  5400. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5401. }
  5402. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5403. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5404. writeGridDataTableJson(dStruct.TotalCount, dt);
  5405. }
  5406. public void set_erp_buchaorderdelivery()
  5407. {
  5408. if (UrlPostParmsCheck("ctid"))
  5409. {
  5410. string eid = GetPostString("ctid");
  5411. CeErpTradeCell entity = null;
  5412. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5413. if (entity != null)
  5414. {
  5415. if (entity.IsSample != 2)
  5416. {
  5417. returnErrorMsg("补差价单才能标记为已发货");
  5418. return;
  5419. }
  5420. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5421. entity.OrderState = 7;
  5422. entity.Update();
  5423. returnSuccessMsg("操作成功!");
  5424. return;
  5425. }
  5426. returnErrorMsg("找不到记录");
  5427. }
  5428. }
  5429. public void get_stdtemplates()
  5430. {
  5431. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5432. //string res = taobaoHelper.test();
  5433. string res = apiHelper.API_PrintTemplate();
  5434. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5435. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5436. {
  5437. int sidx = res.IndexOf("error_code");
  5438. int eidx = res.IndexOf("success");
  5439. string msg = res.Substring(sidx, eidx - sidx);
  5440. returnErrorMsg(msg);
  5441. return;
  5442. }
  5443. if (res.Length <= 0)
  5444. {
  5445. returnErrorMsg("模板数据为空!");
  5446. return;
  5447. }
  5448. ReturnSuccess(res);
  5449. }
  5450. public void cancel_print_order()
  5451. {
  5452. if (UrlPostParmsCheck("ctid"))
  5453. {
  5454. string ctid = GetPostString("ctid");
  5455. CeErpTradeCell entity = null;
  5456. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5457. if (entity != null)
  5458. {
  5459. string res = "";
  5460. string code = entity.LastBillWaybillCode;
  5461. if (code == "")
  5462. {
  5463. code = entity.OutSid;
  5464. }
  5465. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5466. XLog.SaveLog(0, "取消面单" + res);
  5467. }
  5468. }
  5469. }
  5470. public void set_erp_printwaybill()
  5471. {
  5472. if (UrlPostParmsCheck("ctid"))
  5473. {
  5474. string ctid = GetPostString("ctid");
  5475. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5476. string cpName = GetPostString("cpname");
  5477. string isTogether = GetPostString("together");
  5478. string printType = GetPostString("printType");
  5479. //var res_obj = new
  5480. //{
  5481. // restype = 1,
  5482. // 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\"}"
  5483. //};
  5484. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5485. //ReturnSuccess(ro_json);
  5486. //return;
  5487. bool isUseLastWayBillCode = false;
  5488. CeErpTradeCell entity = null;
  5489. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5490. if (entity != null)
  5491. {
  5492. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5493. {
  5494. isUseLastWayBillCode = true;
  5495. }
  5496. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5497. {
  5498. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5499. return;
  5500. }
  5501. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5502. {
  5503. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5504. return;
  5505. }
  5506. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5507. {
  5508. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5509. return;
  5510. }
  5511. }
  5512. string res = "";
  5513. Api_waybill_code_response_Obj fullObj = null;
  5514. string pData_str = "";
  5515. string curUseWayBillCode = "";
  5516. if (isUseLastWayBillCode == false)
  5517. {
  5518. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5519. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5520. if (res.IndexOf("failure") != -1)
  5521. {
  5522. //int idx = res.IndexOf("sub_message");
  5523. //int idx2 = res.IndexOf("flag");
  5524. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5525. string errMsgNeed = commonHelper.KeepChinese(res);
  5526. var res_objd = new
  5527. {
  5528. restype = 0,
  5529. data = "获取面单失败" + errMsgNeed
  5530. };
  5531. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5532. returnSuccess(ro_jsond);
  5533. if (res.IndexOf("停发") != -1)
  5534. {
  5535. entity.UnusualCon = "物流停发";
  5536. entity.Update();
  5537. }
  5538. //returnErrorMsg("获取面单失败,"+emsg);
  5539. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5540. return;
  5541. }
  5542. else if (res.IndexOf("errorMsg") != -1)
  5543. {
  5544. //int idx = res.IndexOf("errorMsg");
  5545. //int idx2 = res.IndexOf("}]}");
  5546. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5547. string errMsgNeed = commonHelper.KeepChinese(res);
  5548. var res_objf = new
  5549. {
  5550. restype = 0,
  5551. data = "获取面单失败2" + errMsgNeed
  5552. };
  5553. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5554. if (res.IndexOf("停发") != -1)
  5555. {
  5556. entity.UnusualCon = "物流停发";
  5557. entity.Update();
  5558. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5559. if (trade != null)
  5560. {
  5561. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5562. }
  5563. }
  5564. returnSuccess(ro_jsonf);
  5565. //returnErrorMsg("获取面单失败," + emsg);
  5566. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5567. return;
  5568. }
  5569. try
  5570. {
  5571. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5572. //res = res.Replace(" ", "");
  5573. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5574. }
  5575. catch (Exception ex)
  5576. {
  5577. XLog.SaveLog(0, "生成fullObj" + res);
  5578. var res_objf = new
  5579. {
  5580. restype = 0,
  5581. data = "生成fullObj发生错误" + ex.Message
  5582. };
  5583. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5584. returnSuccess(ro_jsonf);
  5585. return;
  5586. }
  5587. if (fullObj.response.data.content.Count > 0)
  5588. {
  5589. ContentItem codeObj = fullObj.response.data.content[0];
  5590. if (cpCode.IndexOf("SFFQ-") != -1)
  5591. {
  5592. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5593. }
  5594. else
  5595. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5596. curUseWayBillCode = codeObj.waybillCode;
  5597. }
  5598. else
  5599. {
  5600. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5601. var res_objf = new
  5602. {
  5603. restype = 0,
  5604. data = "生成fullObj找不到快递单号waybillCode"
  5605. };
  5606. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5607. returnSuccess(ro_jsonf);
  5608. return;
  5609. }
  5610. }
  5611. else
  5612. {
  5613. //使用上次打印的快递单号
  5614. if (cpCode == "SFFQ-LY")
  5615. {
  5616. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5617. }
  5618. else
  5619. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5620. curUseWayBillCode = entity.LastBillWaybillCode;
  5621. }
  5622. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5623. {
  5624. var res_obje = new
  5625. {
  5626. restype = 0,
  5627. data = "获取加密打印数据失败"
  5628. };
  5629. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5630. returnSuccess(ro_jsone);
  5631. entity.LastBillCpCode = cpCode;
  5632. entity.LastBillWaybillCode = curUseWayBillCode;
  5633. entity.Update();
  5634. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5635. //returnErrorMsg("获取加密打印数据失败");
  5636. return;
  5637. }
  5638. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5639. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5640. string btnType = "";
  5641. string errorMsg = "";
  5642. if (entity != null)
  5643. {
  5644. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5645. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5646. //cpcode是 YTO-CAINIAO
  5647. //string comCode = cpCode.Split('-')[0].ToString();
  5648. string apires = "";
  5649. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5650. //isTogether=2是新的合包弹窗
  5651. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5652. {
  5653. if (ctid.IndexOf("N") != -1)
  5654. {
  5655. apires = "发货成功";
  5656. }
  5657. else
  5658. {
  5659. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5660. }
  5661. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5662. //打单后发货
  5663. StringBuilder sql = new StringBuilder();
  5664. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5665. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5666. {
  5667. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5668. }
  5669. else
  5670. {
  5671. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5672. }
  5673. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5674. foreach (DataRow row in dt.Rows)
  5675. {
  5676. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5677. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5678. {
  5679. try
  5680. {
  5681. btnType = "待发货";
  5682. entity.OutSid = curUseWayBillCode;
  5683. entity.OrderState = 7;
  5684. entity.IsUrgency = false;
  5685. entity.LastBillCpCode = "";
  5686. entity.LastBillWaybillCode = "";
  5687. entity.FinishDeliveryTime = DateTime.Now;
  5688. entity.IsReturn = 0;
  5689. entity.MemoOpt = 0;
  5690. entity.UpdateTime = DateTime.Now;
  5691. entity.Update();
  5692. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5693. //还要插入快递信息到 快递信息表
  5694. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5695. exinfo.tid = entity.ctid;
  5696. exinfo.out_sid = curUseWayBillCode;
  5697. exinfo.company_code = cpCode;
  5698. exinfo.company_name = cpName;
  5699. exinfo.supplierUserName = supplierName;
  5700. exinfo.deliveryType = "发货成功";
  5701. exinfo.print_time = DateTime.Now;
  5702. exinfo.printUser = CurrentUser.UserName;
  5703. exinfo.postData = pData_str;
  5704. exinfo.Create();
  5705. commonHelper.UpdateRelationOrder(entity.ctid);
  5706. CeErpSukuraData.createInfo(ctid, 4);
  5707. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5708. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5709. {
  5710. commonHelper.sendCytExpress(exinfo);
  5711. }
  5712. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5713. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5714. }
  5715. catch (Exception ex)
  5716. {
  5717. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5718. }
  5719. }
  5720. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5721. {
  5722. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5723. if (entity.OrderState == 6)
  5724. {
  5725. entity.OrderState = 7;
  5726. }
  5727. entity.UpdateTime = DateTime.Now;
  5728. entity.FinishDeliveryTime = DateTime.Now;
  5729. btnType = "已发货";
  5730. entity.Update();
  5731. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5732. exinfo.tid = entity.ctid;
  5733. exinfo.out_sid = curUseWayBillCode;
  5734. exinfo.company_code = cpCode;
  5735. exinfo.company_name = cpName;
  5736. exinfo.supplierUserName = supplierName;
  5737. exinfo.deliveryType = "发货成功";
  5738. exinfo.print_time = DateTime.Now;
  5739. exinfo.printUser = CurrentUser.UserName;
  5740. exinfo.postData = pData_str;
  5741. exinfo.Create();
  5742. commonHelper.UpdateRelationOrder(entity.ctid);
  5743. CeErpSukuraData.createInfo(entity.ctid, 4);
  5744. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5745. {
  5746. commonHelper.sendCytExpress(exinfo);
  5747. }
  5748. //不处理
  5749. }
  5750. else
  5751. {
  5752. entity.UpdateTime = DateTime.Now;
  5753. entity.LastBillCpCode = cpCode;
  5754. entity.LastBillWaybillCode = curUseWayBillCode;
  5755. entity.Update();
  5756. string errmsg = commonHelper.KeepChinese(apires);
  5757. var res_objz = new
  5758. {
  5759. restype = 0,
  5760. data = "打单后发货失败"
  5761. };
  5762. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5763. returnSuccess(ro_jsonz);
  5764. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5765. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5766. return;
  5767. }
  5768. }
  5769. }
  5770. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5771. {
  5772. string ctids = GetPostString("ctids");
  5773. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5774. List<string> list = new List<string>();
  5775. List<string> send_list = new List<string>();
  5776. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5777. CeErpTrade ceErpTrade = new CeErpTrade();
  5778. //可合包的合并一起发货
  5779. if (dt == null && string.IsNullOrEmpty(ctids))
  5780. {
  5781. var res_objz = new
  5782. {
  5783. restype = 0,
  5784. data = "打单后发货失败"
  5785. };
  5786. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5787. returnSuccess(ro_jsonz);
  5788. return;
  5789. }
  5790. if (!string.IsNullOrEmpty(ctids))
  5791. {
  5792. StringBuilder sql = new StringBuilder();
  5793. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5794. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5795. }
  5796. foreach (DataRow row in dt.Rows)
  5797. {
  5798. list.Add("'" + row["ctid"] + "'");
  5799. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5800. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5801. if (ctid.IndexOf("N") != -1)
  5802. {
  5803. apires = "发货成功";
  5804. }
  5805. else
  5806. {
  5807. if (!send_list.Contains(ceErpTrade.tid))
  5808. {
  5809. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5810. }
  5811. else
  5812. {
  5813. apires = "发货成功";
  5814. }
  5815. }
  5816. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5817. {
  5818. send_list.Add(ceErpTrade.tid);
  5819. try
  5820. {
  5821. btnType = "待发货";
  5822. ceErpTradeCell.OutSid = curUseWayBillCode;
  5823. ceErpTradeCell.OrderState = 7;
  5824. ceErpTradeCell.IsUrgency = false;
  5825. ceErpTradeCell.LastBillCpCode = "";
  5826. ceErpTradeCell.LastBillWaybillCode = "";
  5827. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5828. ceErpTradeCell.IsReturn = 0;
  5829. ceErpTradeCell.MemoOpt = 0;
  5830. ceErpTradeCell.UpdateTime = DateTime.Now;
  5831. ceErpTradeCell.Update();
  5832. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5833. //还要插入快递信息到 快递信息表
  5834. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5835. exinfo.tid = ceErpTradeCell.ctid;
  5836. exinfo.out_sid = curUseWayBillCode;
  5837. exinfo.company_code = cpCode;
  5838. exinfo.company_name = cpName;
  5839. exinfo.supplierUserName = supplierName;
  5840. exinfo.deliveryType = "发货成功";
  5841. exinfo.print_time = DateTime.Now;
  5842. exinfo.printUser = CurrentUser.UserName;
  5843. exinfo.postData = pData_str;
  5844. exinfo.Create();
  5845. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5846. CeErpSukuraData.createInfo(ctid, 4);
  5847. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5848. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5849. {
  5850. commonHelper.sendCytExpress(exinfo);
  5851. }
  5852. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5853. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5854. }
  5855. catch (Exception ex)
  5856. {
  5857. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5858. }
  5859. }
  5860. else
  5861. {
  5862. ceErpTradeCell.UpdateTime = DateTime.Now;
  5863. ceErpTradeCell.LastBillCpCode = cpCode;
  5864. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5865. ceErpTradeCell.Update();
  5866. string errmsg = commonHelper.KeepChinese(apires);
  5867. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5868. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5869. }
  5870. }
  5871. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5872. }
  5873. }
  5874. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5875. var res_obj = new
  5876. {
  5877. restype = 1,
  5878. data = pData_str,
  5879. errorMsg
  5880. };
  5881. string ro_json = JsonConvert.SerializeObject(res_obj);
  5882. ReturnSuccess(ro_json);
  5883. return;
  5884. }
  5885. }
  5886. private string GetUTF8String(byte[] vs)
  5887. {
  5888. throw new NotImplementedException();
  5889. }
  5890. public void set_erp_printwaybill_cn()
  5891. {
  5892. if (UrlPostParmsCheck("ctid"))
  5893. {
  5894. string ctid = GetPostString("ctid");
  5895. string cpCode = GetPostString("cpcode");
  5896. string cpName = GetPostString("cpname");
  5897. string tempUrl = GetPostString("tempurl");
  5898. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5899. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5900. //string res = taobaoHelper.test();
  5901. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5902. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5903. {
  5904. int sidx = res.IndexOf("errorMsg");
  5905. int eidx = res.IndexOf("}");
  5906. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5907. var res_objzxx = new
  5908. {
  5909. restype = 0,
  5910. data = msg
  5911. };
  5912. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5913. returnSuccess(ro_jsonzxx);
  5914. //returnErrorMsg(msg);
  5915. return;
  5916. }
  5917. int idx = res.IndexOf("waybillCode");
  5918. int idx2 = res.IndexOf("printData");
  5919. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5920. string eid = GetPostString("ctid");
  5921. CeErpTradeCell entity = null;
  5922. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5923. if (entity != null)
  5924. {
  5925. string osid = entity.OutSid;
  5926. entity.OutSid = osid + "," + outsid;
  5927. entity.FinishDeliveryTime = DateTime.Now;
  5928. entity.OrderState = 7;
  5929. entity.UpdateTime = DateTime.Now;
  5930. entity.IsReturn = 0;
  5931. entity.Update();
  5932. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5933. exinfo.tid = entity.ctid;
  5934. exinfo.out_sid = outsid;
  5935. exinfo.company_code = cpCode;
  5936. exinfo.company_name = cpName;
  5937. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5938. exinfo.deliveryType = "发货成功";
  5939. exinfo.print_time = DateTime.Now;
  5940. exinfo.printUser = CurrentUser.UserName;
  5941. exinfo.Create();
  5942. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5943. {
  5944. commonHelper.sendCytExpress(exinfo);
  5945. }
  5946. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5947. }
  5948. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5949. var res_objz = new
  5950. {
  5951. restype = 1,
  5952. data = res
  5953. };
  5954. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5955. returnSuccess(ro_jsonz);
  5956. //ReturnSuccess(res);
  5957. }
  5958. }
  5959. ////打单,打印面单 获取面单号
  5960. //public void set_erp_printwaybill()
  5961. //{
  5962. // if (UrlPostParmsCheck("ctid"))
  5963. // {
  5964. // string ctid = GetPostString("ctid");
  5965. // string cpCode = GetPostString("cpcode");
  5966. // string tempUrl = GetPostString("tempurl");
  5967. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5968. // //string res = taobaoHelper.test();
  5969. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5970. // if (res.IndexOf("error_response") != -1)
  5971. // {
  5972. // int sidx = res.IndexOf("sub_msg");
  5973. // int eidx = res.IndexOf("request_id");
  5974. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5975. // returnErrorMsg(msg);
  5976. // return;
  5977. // }
  5978. // int idx = res.IndexOf("waybill_code");
  5979. // int idx2 = res.IndexOf("}]}");
  5980. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5981. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5982. // ReturnSuccess(res);
  5983. // }
  5984. //}
  5985. public void cancel_erp_aftersale()
  5986. {
  5987. if (UrlPostParmsCheck("ctid"))
  5988. {
  5989. string eid = GetPostString("ctid");
  5990. CeErpTradeCell entity = null;
  5991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5992. if (entity != null)
  5993. {
  5994. //有过处理的售后,取消也不能删除 售 字,保留
  5995. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5996. {
  5997. entity.AfterSaleState = 4;
  5998. }
  5999. else
  6000. entity.AfterSaleState = 0;
  6001. entity.UpdateTime = DateTime.Now;
  6002. entity.Update();
  6003. returnSuccessMsg("操作成功!");
  6004. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6005. return;
  6006. }
  6007. returnErrorMsg("找不到订单记录");
  6008. }
  6009. }
  6010. public void get_erp_aftersalelist()
  6011. {
  6012. DataStruct dStruct = GetPostStruct();
  6013. List<string> lw = new List<string>();
  6014. int st = GetInt("st");
  6015. string tid = GetPostString("ctid");
  6016. if (st == 3)
  6017. {
  6018. if (tid.Length > 0)
  6019. {
  6020. string select_tid = getTidByCtid(tid);
  6021. lw.Add(string.Format("tid='{0}'", select_tid));
  6022. }
  6023. }
  6024. else
  6025. {
  6026. if (tid.Length > 0)
  6027. {
  6028. string select_tid = getTidByCtid(tid);
  6029. lw.Add(string.Format("tid='{0}'", select_tid));
  6030. }
  6031. }
  6032. string shopname = GetPostString("shopname");
  6033. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6034. string buyernick = GetPostString("buyer_nick");
  6035. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6036. string sellermemo = GetPostString("seller_memo");
  6037. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6038. string orderState = GetPostString("orderState");
  6039. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6040. string afterState = GetPostString("afterstate");
  6041. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6042. string date1 = GetPostString("date1");
  6043. string date2 = GetPostString("date2");
  6044. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6045. if (dw.Length > 0) lw.Add(dw);
  6046. string price1 = GetPostString("price1");
  6047. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6048. string price2 = GetPostString("price2");
  6049. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6050. //lw.Add(string.Format("IsRefund!={0}", 1));
  6051. string reason = GetPostString("reason");
  6052. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6053. string method = GetPostString("method");
  6054. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6055. string handler = GetPostString("handler");
  6056. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6057. string handledate1 = GetPostString("handledate1");
  6058. string handledate2 = GetPostString("handledate2");
  6059. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6060. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6061. string finish1 = GetPostString("finishdate1");
  6062. string finish2 = GetPostString("finishdate2");
  6063. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6064. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6065. string afterdate1 = GetPostString("afterdate1");
  6066. string afterdate2 = GetPostString("afterdate2");
  6067. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6068. if (afterDate.Length > 0) lw.Add(afterDate);
  6069. string supplier = GetPostString("supplier");
  6070. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6071. string responsible = GetPostString("responsibleman");
  6072. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6073. string customer = GetPostString("customer");
  6074. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6075. string design = GetPostString("design");
  6076. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6077. string afterMemoType = GetPostString("aftermemotype");
  6078. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6079. string posCode = CurrentUser.UserPost.Post.Code;
  6080. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6081. //{
  6082. // string vstate = GetPostString("vstate");
  6083. // if (vstate.Length > 0)
  6084. // {
  6085. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6086. // }
  6087. // if (posCode == "Supplier")
  6088. // {
  6089. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6090. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6091. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6092. // }
  6093. // else
  6094. // {
  6095. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6096. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6097. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6098. // {
  6099. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6100. // }
  6101. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6102. // {
  6103. // int orgid = CurrentUser.UserPost.OrgID;
  6104. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6105. // }
  6106. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6107. // {
  6108. // string shopid = CurrentUser.User.pemShop;
  6109. // lw.Add(string.Format("shopId in ({0})", shopid));
  6110. // }
  6111. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6112. // //{
  6113. // // int org_id = CurrentUser.UserPost.OrgID;
  6114. // // lw.Add(string.Format("OrgID={0}", org_id));
  6115. // //}
  6116. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6117. // }
  6118. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6119. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6120. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6121. //}
  6122. if (st == 5)
  6123. {
  6124. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6125. {
  6126. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6127. {
  6128. string shopid = CurrentUser.User.pemShop;
  6129. lw.Add(string.Format("shopId in ({0})", shopid));
  6130. }
  6131. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6132. {
  6133. int mrOrgid = CurrentUser.UserPost.OrgID;
  6134. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6135. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6136. }
  6137. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6138. //{
  6139. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6140. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6141. //}
  6142. else
  6143. {
  6144. string userIdStr = "";
  6145. if (posCode == "CustomerService")
  6146. {
  6147. userIdStr = CurrentUser.UserID + "_k";
  6148. }
  6149. else if (posCode == "Designer" || posCode == "wxDesigner")
  6150. {
  6151. userIdStr = CurrentUser.UserID + "_s";
  6152. }
  6153. else if (posCode == "Place")
  6154. {
  6155. userIdStr = CurrentUser.UserID + "_x";
  6156. }
  6157. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6158. }
  6159. }
  6160. string placedate1 = GetPostString("placedate1");
  6161. string placedate2 = GetPostString("placedate2");
  6162. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6163. if (dwplace.Length > 0) lw.Add(dwplace);
  6164. string supState = GetPostString("supState");
  6165. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6166. string searchType = GetPostString("searchType");
  6167. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6168. {
  6169. lw.Add(string.Format("BackNum>1"));
  6170. }
  6171. lw.Add(string.Format("AfterSaleState>0"));
  6172. if (ex_psize > 0)
  6173. {
  6174. if (CurrentUser.UserPost.Post.Code == "Finance")
  6175. dStruct.Order = "pay_time desc";
  6176. else
  6177. dStruct.Order = "HandleTime desc";
  6178. }
  6179. else
  6180. dStruct.Order = "HandleTime desc";
  6181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6182. DataTable dt = WebCache.GetData("view_test", dStruct);
  6183. writeGridDataTableJson(dStruct.TotalCount, dt);
  6184. }
  6185. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6186. //{
  6187. // lw.Add(string.Format("AfterSaleState=4"));
  6188. // string code = CurrentUser.UserPost.Post.Code;
  6189. // if (code == "CustomerService")
  6190. // {
  6191. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6192. // }
  6193. // else if (code == "Designer" || code == "DesignerMr")
  6194. // {
  6195. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6196. // }
  6197. // else if (code == "Place" || code == "PlaceMr")
  6198. // {
  6199. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6200. // }
  6201. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6202. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6203. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6204. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6205. //}
  6206. //else //处理中的售后,待处理和处理中合并
  6207. //{
  6208. // if (afterState.Length <= 0)
  6209. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6210. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6211. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6212. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6213. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6214. //}
  6215. }
  6216. public void get_erp_disagreeftersalelist()
  6217. {
  6218. DataStruct dStruct = GetPostStruct();
  6219. List<string> lw = new List<string>();
  6220. int st = 2;
  6221. string tid = GetPostString("ctid");
  6222. if (tid.Length > 0)
  6223. {
  6224. string select_tid = getTidByCtid(tid);
  6225. lw.Add(string.Format("tid='{0}'", select_tid));
  6226. }
  6227. string shopname = GetPostString("shopname");
  6228. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6229. string buyernick = GetPostString("buyer_nick");
  6230. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6231. string sellermemo = GetPostString("seller_memo");
  6232. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6233. string orderState = GetPostString("orderState");
  6234. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6235. string afterState = GetPostString("afterstate");
  6236. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6237. string date1 = GetPostString("date1");
  6238. string date2 = GetPostString("date2");
  6239. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6240. if (dw.Length > 0) lw.Add(dw);
  6241. string price1 = GetPostString("price1");
  6242. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6243. string price2 = GetPostString("price2");
  6244. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6245. //lw.Add(string.Format("IsRefund!={0}", 1));
  6246. string reason = GetPostString("reason");
  6247. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6248. string method = GetPostString("method");
  6249. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6250. string handler = GetPostString("handler");
  6251. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6252. string handledate1 = GetPostString("handledate1");
  6253. string handledate2 = GetPostString("handledate2");
  6254. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6255. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6256. string afterdate1 = GetPostString("afterdate1");
  6257. string afterdate2 = GetPostString("afterdate2");
  6258. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6259. if (afterDate.Length > 0) lw.Add(afterDate);
  6260. string backdate1 = GetPostString("backdate1");
  6261. string backdate2 = GetPostString("backdate2");
  6262. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6263. if (backDate.Length > 0) lw.Add(backDate);
  6264. string supplier = GetPostString("supplier");
  6265. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6266. string responsible = GetPostString("responsibleman");
  6267. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6268. string customer = GetPostString("customer");
  6269. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6270. string design = GetPostString("design");
  6271. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6272. string afterSaleMemo = GetPostString("afterSaleMemo");
  6273. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6274. string afterMemoType = GetPostString("aftermemotype");
  6275. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6276. string aftersakereason = GetPostString("aftersakereason");
  6277. if (aftersakereason.Length > 0)
  6278. {
  6279. if (aftersakereason == "1")
  6280. {
  6281. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6282. }
  6283. if (aftersakereason == "2")
  6284. {
  6285. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6286. }
  6287. }
  6288. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6289. string poscode = CurrentUser.UserPost.Post.Code;
  6290. if (poscode != "SysAdmin")
  6291. {
  6292. string shopid = CurrentUser.User.pemShop;
  6293. lw.Add(string.Format("shopId in ({0})", shopid));
  6294. }
  6295. string searchType = GetPostString("searchType");
  6296. if (searchType == "wait")
  6297. {
  6298. lw.Add(string.Format("HandleTime is null"));
  6299. }
  6300. if (searchType == "handling")
  6301. {
  6302. lw.Add(string.Format("HandleTime is not null "));
  6303. }
  6304. if (searchType == "back" || searchType == "puBack")
  6305. {
  6306. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6307. }
  6308. if (searchType == "reBack")
  6309. {
  6310. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6311. }
  6312. if (searchType == "moreBack")
  6313. {
  6314. lw.Add(string.Format("backNum > 1"));
  6315. }
  6316. lw.Add(string.Format("(AfterSaleState=5)"));
  6317. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6318. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6319. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6320. writeGridDataTableJson(dStruct.TotalCount, dt);
  6321. }
  6322. public void get_erp_handlingaftersalelist()
  6323. {
  6324. DataStruct dStruct = GetPostStruct();
  6325. List<string> lw = new List<string>();
  6326. int st = 2;
  6327. string tid = GetPostString("ctid");
  6328. if (tid.Length > 0)
  6329. {
  6330. string select_tid = getTidByCtid(tid);
  6331. lw.Add(string.Format("tid='{0}'", select_tid));
  6332. }
  6333. string shopname = GetPostString("shopname");
  6334. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6335. string buyernick = GetPostString("buyer_nick");
  6336. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6337. string sellermemo = GetPostString("seller_memo");
  6338. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6339. string orderState = GetPostString("orderState");
  6340. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6341. string afterState = GetPostString("afterstate");
  6342. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6343. string date1 = GetPostString("date1");
  6344. string date2 = GetPostString("date2");
  6345. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6346. if (dw.Length > 0) lw.Add(dw);
  6347. string price1 = GetPostString("price1");
  6348. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6349. string price2 = GetPostString("price2");
  6350. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6351. //lw.Add(string.Format("IsRefund!={0}", 1));
  6352. string reason = GetPostString("reason");
  6353. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6354. string method = GetPostString("method");
  6355. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6356. string handler = GetPostString("handler");
  6357. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6358. string handledate1 = GetPostString("handledate1");
  6359. string handledate2 = GetPostString("handledate2");
  6360. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6361. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6362. string afterdate1 = GetPostString("afterdate1");
  6363. string afterdate2 = GetPostString("afterdate2");
  6364. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6365. if (afterDate.Length > 0) lw.Add(afterDate);
  6366. string supplier = GetPostString("supplier");
  6367. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6368. string responsible = GetPostString("responsibleman");
  6369. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6370. string customer = GetPostString("customer");
  6371. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6372. string design = GetPostString("design");
  6373. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6374. string afterSaleMemo = GetPostString("afterSaleMemo");
  6375. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6376. string afterMemoType = GetPostString("aftermemotype");
  6377. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6378. string afterresult = GetPostString("afterresult");
  6379. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6380. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6381. string poscode = CurrentUser.UserPost.Post.Code;
  6382. if (poscode != "SysAdmin")
  6383. {
  6384. string shopid = CurrentUser.User.pemShop;
  6385. lw.Add(string.Format("shopId in ({0})", shopid));
  6386. }
  6387. string searchType = GetPostString("searchType");
  6388. if (searchType == "wait")
  6389. {
  6390. lw.Add(string.Format("HandleTime is null"));
  6391. }
  6392. if (searchType == "documentary")
  6393. {
  6394. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6395. }
  6396. if (searchType == "handling")
  6397. {
  6398. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6399. }
  6400. if (searchType == "back" || searchType == "puBack")
  6401. {
  6402. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6403. }
  6404. if (searchType == "reBack")
  6405. {
  6406. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6407. }
  6408. if (afterState.Length <= 0)
  6409. {
  6410. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6411. }
  6412. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6414. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6415. writeGridDataTableJson(dStruct.TotalCount, dt);
  6416. }
  6417. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6418. //public void get_erp_back_handlingaftersalelist()
  6419. //{
  6420. // DataStruct dStruct = GetPostStruct();
  6421. // List<string> lw = new List<string>();
  6422. // string tid = GetPostString("ctid");
  6423. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6424. // string shopname = GetPostString("shopname");
  6425. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6426. // string buyernick = GetPostString("buyer_nick");
  6427. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6428. // string sellermemo = GetPostString("seller_memo");
  6429. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6430. // string orderState = GetPostString("orderState");
  6431. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6432. // string afterState = GetPostString("afterstate");
  6433. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6434. // string date1 = GetPostString("date1");
  6435. // string date2 = GetPostString("date2");
  6436. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6437. // if (dw.Length > 0) lw.Add(dw);
  6438. // string price1 = GetPostString("price1");
  6439. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6440. // string price2 = GetPostString("price2");
  6441. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6442. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6443. // string reason = GetPostString("reason");
  6444. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6445. // string method = GetPostString("method");
  6446. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6447. // string handler = GetPostString("handler");
  6448. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6449. // string handledate1 = GetPostString("handledate1");
  6450. // string handledate2 = GetPostString("handledate2");
  6451. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6452. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6453. // string afterdate1 = GetPostString("afterdate1");
  6454. // string afterdate2 = GetPostString("afterdate2");
  6455. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6456. // if (afterDate.Length > 0) lw.Add(afterDate);
  6457. // string supplier = GetPostString("supplier");
  6458. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6459. // string responsible = GetPostString("responsibleman");
  6460. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6461. // string customer = GetPostString("customer");
  6462. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6463. // string design = GetPostString("design");
  6464. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6465. // string afterMemoType = GetPostString("aftermemotype");
  6466. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6467. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6468. // if (afterState.Length <= 0)
  6469. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6470. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6471. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6472. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6473. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6474. //}
  6475. public void get_erp_aftersaleverifylist()
  6476. {
  6477. DataStruct dStruct = GetPostStruct();
  6478. List<string> lw = new List<string>();
  6479. string tid = GetPostString("ctid");
  6480. if (tid.Length > 0)
  6481. {
  6482. string select_tid = getTidByCtid(tid);
  6483. lw.Add(string.Format("otid='{0}'", select_tid));
  6484. }
  6485. string shopname = GetPostString("shopname");
  6486. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6487. string buyernick = GetPostString("buyer_nick");
  6488. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6489. string sellermemo = GetPostString("seller_memo");
  6490. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6491. string orderState = GetPostString("orderState");
  6492. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6493. //lw.Add(string.Format("IsRefund!={0}", 1));
  6494. string reason = GetPostString("reason");
  6495. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6496. string method = GetPostString("method");
  6497. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6498. string handler = GetPostString("handler");
  6499. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6500. string handledate1 = GetPostString("handledate1");
  6501. string handledate2 = GetPostString("handledate2");
  6502. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6503. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6504. string finish1 = GetPostString("finishdate1");
  6505. string finish2 = GetPostString("finishdate2");
  6506. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6507. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6508. string supplier = GetPostString("supplier");
  6509. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6510. string responsible = GetPostString("responsibleman");
  6511. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6512. string posCode = CurrentUser.UserPost.Post.Code;
  6513. string vstate = GetPostString("vstate");
  6514. if (vstate.Length > 0)
  6515. {
  6516. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6517. }
  6518. if (posCode == "Supplier")
  6519. {
  6520. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6521. lw.Add(string.Format("VerifyState = 0"));
  6522. lw.Add("type = 1");
  6523. lw.Add(string.Format("AfterSaleState={0}", 3));
  6524. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6525. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6526. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6527. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6528. writeGridDataTableJson(dStruct.TotalCount, dt);
  6529. }
  6530. else if (posCode == "logistics")
  6531. {
  6532. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6533. lw.Add(string.Format("VerifyState = 0"));
  6534. lw.Add("type = 2");
  6535. lw.Add(string.Format("AfterSaleState={0}", 3));
  6536. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6537. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6538. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6539. writeGridDataTableJson(dStruct.TotalCount, dt);
  6540. }
  6541. else
  6542. {
  6543. lw.Add(string.Format("(AfterSaleState = 3)"));
  6544. lw.Add("type = 0");
  6545. string reasonState = GetPostString("reasonState");
  6546. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6547. {
  6548. if (reasonState == "2")
  6549. {
  6550. lw.Add("VerifyState = 3");
  6551. }
  6552. else if (reasonState == "1")
  6553. {
  6554. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6555. }
  6556. else
  6557. {
  6558. lw.Add("VerifyState in (0,3)");
  6559. }
  6560. //不加条件,可以看全部
  6561. }
  6562. 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")
  6563. {
  6564. int orgid = CurrentUser.UserPost.OrgID;
  6565. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6566. if (string.IsNullOrEmpty(manageOrgId))
  6567. {
  6568. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6569. }
  6570. else
  6571. {
  6572. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6573. }
  6574. if (reasonState == "1")
  6575. {
  6576. lw.Add("VerifyState = 3");
  6577. }
  6578. else if (reasonState == "2")
  6579. {
  6580. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6581. }
  6582. else
  6583. {
  6584. }
  6585. }
  6586. else
  6587. {
  6588. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6589. }
  6590. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6591. //{
  6592. // int org_id = CurrentUser.UserPost.OrgID;
  6593. // lw.Add(string.Format("OrgID={0}", org_id));
  6594. //}
  6595. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6596. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6597. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6598. writeGridDataTableJson(dStruct.TotalCount, dt);
  6599. }
  6600. }
  6601. public void get_erp_finishaftersalelist()
  6602. {
  6603. DataStruct dStruct = GetPostStruct();
  6604. List<string> lw = new List<string>();
  6605. int st = 4;
  6606. string tid = GetPostString("ctid");
  6607. if (tid.Length > 0)
  6608. {
  6609. string select_tid = getTidByCtid(tid);
  6610. lw.Add(string.Format("otid='{0}'", select_tid));
  6611. }
  6612. string shopname = GetPostString("shopname");
  6613. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6614. //lw.Add(string.Format("IsRefund!={0}", 1));
  6615. string reason = GetPostString("reason");
  6616. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6617. string method = GetPostString("method");
  6618. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6619. string buyernick = GetPostString("buyer_nick");
  6620. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6621. string handler = GetPostString("handler");
  6622. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6623. string handledate1 = GetPostString("handledate1");
  6624. string handledate2 = GetPostString("handledate2");
  6625. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6626. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6627. string finish1 = GetPostString("finishdate1");
  6628. string finish2 = GetPostString("finishdate2");
  6629. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6630. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6631. string supplier = GetPostString("supplier");
  6632. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6633. string responsible = GetPostString("responsibleman");
  6634. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6635. string vstate = GetPostString("vstate");
  6636. if (vstate.Length > 0)
  6637. {
  6638. if ("3".Equals(vstate))
  6639. {
  6640. lw.Add(string.Format("IsTem=1"));
  6641. }
  6642. else
  6643. {
  6644. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6645. }
  6646. }
  6647. lw.Add(string.Format("AfterSaleState=4"));
  6648. string code = CurrentUser.UserPost.Post.Code;
  6649. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6650. {
  6651. //不加条件,可以看全部
  6652. }
  6653. else if (code == "Supplier")
  6654. {
  6655. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6656. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6657. lw.Add("type = 1");
  6658. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6659. }
  6660. else if (code == "logistics")
  6661. {
  6662. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6663. lw.Add("type = 2");
  6664. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6665. }
  6666. 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")
  6667. {
  6668. lw.Add("type = 0");
  6669. int orgid = CurrentUser.UserPost.OrgID;
  6670. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6671. if (string.IsNullOrEmpty(manageOrgIds))
  6672. {
  6673. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6674. }
  6675. else
  6676. {
  6677. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6678. }
  6679. }
  6680. else
  6681. {
  6682. lw.Add("type = 0");
  6683. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6684. }
  6685. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6686. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6687. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6688. writeGridDataTableJson(dStruct.TotalCount, dt);
  6689. }
  6690. public void handle_erp_aftersale()
  6691. {
  6692. if (UrlPostParmsCheck("ctid"))
  6693. {
  6694. string eid = GetPostString("ctid");
  6695. string responStr = GetPostString("AfterSaleResponsible");
  6696. if (responStr.Length <= 0)
  6697. {
  6698. returnErrorMsg("售后责任人不能为空");
  6699. return;
  6700. }
  6701. bool isDesign = false;
  6702. double designFree = 0.00;
  6703. int responsibleId = 0;
  6704. CeErpTradeCell entity = null;
  6705. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6706. if (entity != null)
  6707. {
  6708. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6709. string afterMethod = GetPostString("AfterSaleMethod");
  6710. if (isNeedNewOrder == 1)
  6711. {
  6712. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6713. bool ishav = true;
  6714. if (newentity == null)
  6715. {
  6716. newentity = entity.Clone() as CeErpTradeCell;
  6717. ishav = false;
  6718. newentity.ctid = "S_" + entity.ctid;
  6719. newentity.OrderState = 0;
  6720. //唯一标识
  6721. newentity.OrderSn = newentity.ctid;
  6722. string orderSn = dataHelper.getSaleOrderSn();
  6723. if (orderSn != "")
  6724. {
  6725. newentity.OrderSn = orderSn;
  6726. }
  6727. }
  6728. newentity.UpdateTime = DateTime.Now;
  6729. newentity.AfterSaleState = 0;
  6730. newentity.AfterSaleMethod = afterMethod;
  6731. if (!ishav)
  6732. {
  6733. string memo_str = newentity.seller_memo;
  6734. memo_str = memo_str.Replace("(", "(");
  6735. memo_str = memo_str.Replace(")", ")");
  6736. int sIndex = memo_str.IndexOf("(");
  6737. int eIndex = memo_str.IndexOf(")");
  6738. if (sIndex == -1 || eIndex == -1)
  6739. {
  6740. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6741. return;
  6742. }
  6743. string first = memo_str.Substring(0, sIndex + 1);
  6744. string memoCtid = newentity.OrderSn;
  6745. //if (memoCtid.IndexOf("C") != -1)
  6746. //{
  6747. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6748. //if (CIdx.IndexOf("+") != -1)
  6749. //{
  6750. //CIdx = "C" + CIdx.Split('+')[1];
  6751. //}
  6752. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6753. //}
  6754. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6755. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6756. string newMemo = first + memoCtid + last;
  6757. newentity.seller_memo = newMemo;
  6758. newentity.FinishPlaceTime = null;
  6759. newentity.UnusualTag = 0;
  6760. newentity.UnusualCon = "";
  6761. newentity.UnusualTime = null;
  6762. newentity.AfterSaleMemo = "";
  6763. newentity.AfterSaleMethod = afterMethod;
  6764. newentity.AfterSalePreTime = null;
  6765. newentity.AfterSaleReason = "";
  6766. newentity.AfterSaleResponsible = "";
  6767. newentity.AfterSaleState = 0;
  6768. newentity.AfterSaleTime = null;
  6769. newentity.AfterSaleUserId = 0;
  6770. newentity.AfterSaleSupplierState = 0;
  6771. newentity.LastBillWaybillCode = "";
  6772. newentity.LastBillCpCode = "";
  6773. newentity.FinishAfterSaleTime = null;
  6774. newentity.HandleTime = null;
  6775. newentity.IsSF = 0;
  6776. newentity.IsOldCustomer = 0;
  6777. newentity.UrgencyTime = null;
  6778. newentity.ResponsibleUserId = "";
  6779. newentity.IsVerifyToSupplier = false;
  6780. newentity.payment = 0;
  6781. newentity.CheckMemo = "";
  6782. newentity.OutSid = "";
  6783. newentity.CheckOrderTime = null;
  6784. newentity.MemoOpt = 0;
  6785. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6786. }
  6787. newentity.isAfterSaleOrder = 1;
  6788. newentity.IsRefund = 0;
  6789. string receiveMobile = GetPostString("receiver_mobile");
  6790. if (receiveMobile.Length > 0)
  6791. {
  6792. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6793. if (trade != null)
  6794. {
  6795. trade.receiver_name = GetPostString("receiver_name");
  6796. trade.receiver_mobile = receiveMobile;
  6797. trade.receiver_state = GetPostString("receiver_state");
  6798. trade.receiver_city = GetPostString("receiver_city");
  6799. trade.receiver_district = GetPostString("receiver_district");
  6800. trade.receiver_address = GetPostString("receiver_address");
  6801. newentity.IsOffLineOrder = 1;
  6802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6803. }
  6804. }
  6805. string st = GetPostString("ToState");
  6806. if (st.Length > 0)
  6807. {
  6808. if (newentity.OrderState <= 3)
  6809. {
  6810. newentity.WaitDesignTime = DateTime.Now;
  6811. newentity.StartDesignTime = null;
  6812. newentity.FinishDesignTime = null;
  6813. newentity.OrderState = 3;
  6814. if (st == "下单员")
  6815. {
  6816. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6817. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6818. {
  6819. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6820. }
  6821. }
  6822. else
  6823. {
  6824. newentity.WaitDesignTime = DateTime.Now;
  6825. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6826. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6827. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6828. {
  6829. DataRow user = dt1.Rows[0];
  6830. //找主管
  6831. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6832. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6833. if (dt != null && dt.Rows.Count > 0)
  6834. {
  6835. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6836. newentity.DesignUserId = designMr;
  6837. string key = "aftersale_order_" + designMr;
  6838. if (RedisHelper.HasKey(key))
  6839. {
  6840. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6841. list.Add(newentity.ctid);
  6842. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6843. }
  6844. }
  6845. //账号正常
  6846. if (user["State"].ToString() == "0")
  6847. {
  6848. newentity.DesignUserId = entity.DesignUserId;
  6849. string key = "aftersale_order_" + entity.DesignUserId;
  6850. if (RedisHelper.HasKey(key))
  6851. {
  6852. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6853. list.Add(newentity.ctid);
  6854. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6855. }
  6856. }
  6857. }
  6858. }
  6859. }
  6860. if (entity.IsXianHuo == 1)
  6861. {
  6862. newentity.OrderState = 6;
  6863. entity.FinishPlaceTime = DateTime.Now;
  6864. }
  6865. }
  6866. if (ishav)
  6867. {
  6868. newentity.Update();
  6869. }
  6870. else
  6871. {
  6872. newentity.Create();
  6873. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6874. newCellExtend.ctid = newentity.ctid;
  6875. newCellExtend.orderFrom = 20;
  6876. newCellExtend.orderType = 30;
  6877. if (st == "下单员")
  6878. {
  6879. }
  6880. else
  6881. {
  6882. newCellExtend.ReprintTime = DateTime.Now;
  6883. }
  6884. newCellExtend.Create();
  6885. }
  6886. if (st != "下单员")
  6887. {
  6888. if (entity.DispatchSort == 2)
  6889. {
  6890. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6891. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6892. }
  6893. }
  6894. }
  6895. //处理售后扩展
  6896. string resIdStr = GetPostString("ResponsibleUserId");
  6897. string refundFees = GetPostString("refundFrees");
  6898. int IsComplain = GetPostInt("isComplain");
  6899. int IsBad = GetPostInt("isBad");
  6900. string IsOriginal = GetPostString("isOriginal");
  6901. double diffResultPrice = GetPostDouble("diffResultPrice");
  6902. string textResult = GetPostString("textResult");
  6903. string supplierResponsible = GetPostString("supplierResponsible");
  6904. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6905. if (ceErpTradeAfterSaleExtend == null)
  6906. {
  6907. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6908. ceErpTradeAfterSaleExtend.tid = eid;
  6909. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6910. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6911. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6912. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6913. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6914. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6915. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6916. ceErpTradeAfterSaleExtend.Create();
  6917. }
  6918. else
  6919. {
  6920. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6921. {
  6922. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6923. }
  6924. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6925. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6926. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6927. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6928. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6929. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6930. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6931. ceErpTradeAfterSaleExtend.Update();
  6932. }
  6933. int gysid = GetPostInt("ResponsibleSupId");
  6934. if (entity.AfterSaleUserId == 0)
  6935. {
  6936. entity.AfterSaleUserId = CurrentUser.UserID;
  6937. }
  6938. entity.ResponsibleUserId = resIdStr;
  6939. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6940. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6941. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6942. {
  6943. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6944. int backNum = 0;
  6945. if (number != null)
  6946. {
  6947. backNum = number.BackNum;
  6948. }
  6949. char[] separator = { ',' };
  6950. string[] sArray = resIdStr.Split(separator);
  6951. string[] refundFreeList = { };
  6952. if (refundFees.Length > 0)
  6953. {
  6954. refundFreeList = refundFees.Split(separator);
  6955. }
  6956. int index = -1;
  6957. List<int> responsibleIds = new List<int>();
  6958. foreach (string i in sArray)
  6959. {
  6960. index++;
  6961. if (i.Length <= 0) continue;
  6962. char[] separator2 = { '_' };
  6963. string idstr = i.Split(separator2)[0];
  6964. string idtype = i.Split(separator2)[1];
  6965. double refudFree = 0;
  6966. if (refundFreeList.Length > 0)
  6967. {
  6968. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6969. }
  6970. if (idtype == "s")
  6971. {
  6972. isDesign = true;
  6973. designFree = refudFree;
  6974. }
  6975. int userId = Convert.ToInt32(idstr);
  6976. int type = 0;
  6977. if (idtype == "g")
  6978. {
  6979. type = 1;
  6980. }
  6981. if (idtype == "w")
  6982. {
  6983. type = 2;
  6984. }
  6985. if (idtype == "t")
  6986. {
  6987. type = 3;
  6988. }
  6989. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6990. if (ceErpTradeResponsible == null)
  6991. {
  6992. ceErpTradeResponsible = new CeErpTradeResponsible();
  6993. ceErpTradeResponsible.tid = eid;
  6994. ceErpTradeResponsible.UserId = userId;
  6995. ceErpTradeResponsible.createdTime = DateTime.Now;
  6996. ceErpTradeResponsible.type = type;
  6997. if (type == 1)
  6998. {
  6999. ceErpTradeResponsible.IsSup = 1;
  7000. }
  7001. if (type == 2)
  7002. {
  7003. ceErpTradeResponsible.IsFlow = 1;
  7004. }
  7005. }
  7006. int state = 0;
  7007. //已认可的不需要再次认可
  7008. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7009. {
  7010. state = 1;
  7011. }
  7012. ceErpTradeResponsible.RefundFee = refudFree;
  7013. ceErpTradeResponsible.VerifyState = state;
  7014. if (userId == 2125 || idtype == "w")
  7015. {
  7016. ceErpTradeResponsible.VerifyState = 1;
  7017. }
  7018. if (idtype == "w" && userId == 101)
  7019. {
  7020. ceErpTradeResponsible.VerifyState = state;
  7021. }
  7022. if (ceErpTradeResponsible.ID > 0)
  7023. {
  7024. ceErpTradeResponsible.Update();
  7025. }
  7026. else
  7027. {
  7028. ceErpTradeResponsible.Create();
  7029. }
  7030. if (isDesign)
  7031. {
  7032. responsibleId = ceErpTradeResponsible.ID;
  7033. }
  7034. responsibleIds.Add(ceErpTradeResponsible.ID);
  7035. }
  7036. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7037. CeErpTradeResponsible.NumByTid(backNum, eid);
  7038. }
  7039. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7040. if (ceErpTradeCellExtend != null)
  7041. {
  7042. ceErpTradeCellExtend.returnVisit = 0;
  7043. ceErpTradeCellExtend.Update();
  7044. }
  7045. if (entity.HandleTime != null)
  7046. {
  7047. if (entity.AfterSaleState == 1)
  7048. {
  7049. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7050. }
  7051. else
  7052. {
  7053. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7054. }
  7055. }
  7056. else
  7057. {
  7058. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7059. entity.HandleTime = DateTime.Now;
  7060. }
  7061. bool isCompale = false;
  7062. if (entity.AfterSaleState == 5)
  7063. {
  7064. isCompale = true;
  7065. entity.AfterSaleState = 3;
  7066. }
  7067. entity.AfterSaleSupplierState = 0;
  7068. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7069. {
  7070. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7071. }
  7072. string sImgs = GetPostString("img");
  7073. entity.AfterSaleSupplierImg = sImgs;
  7074. entity.supRefundType = GetPostString("supRefundType");
  7075. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7076. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7077. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7078. entity.AfterSaleMemoType = GetPostString("MemoType");
  7079. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7080. {
  7081. //entity.AfterSaleSupplierState = 2;
  7082. }
  7083. string df = GetPostString("DeductFee");
  7084. if (df == "")
  7085. {
  7086. df = "0";
  7087. }
  7088. string rf = GetPostString("RefundFee");
  7089. if (rf == "")
  7090. {
  7091. rf = "0";
  7092. }
  7093. string pm = GetPostString("AfterSalePayment");
  7094. if (pm == "")
  7095. {
  7096. pm = "0";
  7097. }
  7098. entity.AfterSalePayment = Convert.ToDouble(pm);
  7099. entity.DeductFee = Convert.ToDouble(df);
  7100. entity.RefundFee = Convert.ToDouble(rf);
  7101. entity.UpdateTime = DateTime.Now;
  7102. entity.Update();
  7103. string toState = GetPostString("ToState");
  7104. string original = GetPostString("isOriginal");
  7105. ApiVo apiVo = new ApiVo();
  7106. apiVo.orderNumber = entity.ctid;
  7107. apiVo.actionName = "afterDesign";
  7108. apiVo.orderRemarks = entity.AfterSaleMethod;
  7109. apiVo.reasonRemarks = entity.AfterSaleReason;
  7110. apiVo.isDesign = isDesign;
  7111. apiVo.designFree = designFree;
  7112. apiVo.responsibleId = responsibleId;
  7113. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7114. if (toState == "设计师")
  7115. {
  7116. apiVo.isOriginal = Convert.ToBoolean(original);
  7117. }
  7118. designHelper.API_WorkCore(apiVo);//afterDesign
  7119. CeErpMethod methodSql = new CeErpMethod();
  7120. methodSql.con = entity.AfterSaleMethod;
  7121. methodSql.addTime = DateTime.Now;
  7122. methodSql.Create();
  7123. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7124. CeErpMethod.ExecuteNonQuery(delsql);
  7125. if (isCompale)
  7126. {
  7127. aftersale_data_change(entity.ctid);
  7128. }
  7129. returnSuccessMsg("操作成功!");
  7130. return;
  7131. }
  7132. returnErrorMsg("找不到订单记录");
  7133. }
  7134. }
  7135. public void ins_erp_toresponsible()
  7136. {
  7137. if (UrlPostParmsCheck("ctid"))
  7138. {
  7139. string eid = GetPostString("ctid");
  7140. CeErpTradeCell entity = null;
  7141. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7142. if (entity != null)
  7143. {
  7144. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7145. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7146. {
  7147. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7148. return;
  7149. }
  7150. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7151. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7152. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7153. if (entity.AfterSalePreTime == null)
  7154. {
  7155. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7156. {
  7157. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7158. }
  7159. }
  7160. entity.AfterSalePreTime = DateTime.Now;
  7161. //预完成给售后主管审核客户问题直接完成
  7162. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7163. {
  7164. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7165. {
  7166. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7167. }
  7168. }
  7169. ceErpTradeAfterSaleExtend.Update();
  7170. entity.AfterSaleState = 2;
  7171. entity.UpdateTime = DateTime.Now;
  7172. entity.Update();
  7173. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7174. aftersale_data_change(entity.ctid);
  7175. returnSuccessMsg("操作成功!");
  7176. return;
  7177. }
  7178. returnErrorMsg("找不到订单记录");
  7179. }
  7180. }
  7181. public void cancel_erp_aftersaleanddelnew()
  7182. {
  7183. if (UrlPostParmsCheck("ctid"))
  7184. {
  7185. string eid = GetPostString("ctid");
  7186. CeErpTradeCell entity = null;
  7187. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7188. if (entity != null)
  7189. {
  7190. entity.AfterSaleState = 0;
  7191. entity.AfterSaleReason = "";
  7192. entity.AfterSaleMethod = "";
  7193. entity.AfterSaleMemo = "";
  7194. entity.AfterSaleResponsible = "";
  7195. entity.ResponsibleUserId = "";
  7196. entity.DeductFee = 0;
  7197. entity.RefundFee = 0;
  7198. entity.IsArbitrate = 0;
  7199. CeErpTradeResponsible.DelByTid(eid, -1);
  7200. entity.Update();
  7201. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7202. if (after != null)
  7203. {
  7204. if (after.OrderState < 5)
  7205. CeErpTradeCell.DelByCtid("S_" + eid);
  7206. }
  7207. returnSuccessMsg("操作成功!");
  7208. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7209. return;
  7210. }
  7211. returnErrorMsg("找不到订单记录");
  7212. }
  7213. }
  7214. public void get_erp_aftersale_pregather()
  7215. {
  7216. List<string> lw = new List<string>();
  7217. int st = GetInt("st");
  7218. string tid = GetPostString("ctid");
  7219. if (tid.Length > 0)
  7220. {
  7221. string select_tid = getTidByCtid(tid);
  7222. lw.Add(string.Format("tid='{0}'", select_tid));
  7223. }
  7224. string shopname = GetPostString("shopname");
  7225. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7226. string buyernick = GetPostString("buyer_nick");
  7227. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7228. string sellermemo = GetPostString("seller_memo");
  7229. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7230. string orderState = GetPostString("orderState");
  7231. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7232. string reason = GetPostString("reason");
  7233. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7234. string method = GetPostString("method");
  7235. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7236. string handler = GetPostString("handler");
  7237. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7238. string handledate1 = GetPostString("handledate1");
  7239. string handledate2 = GetPostString("handledate2");
  7240. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7241. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7242. string supplier = GetPostString("supplier");
  7243. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7244. string responsible = GetPostString("responsibleman");
  7245. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7246. string customer = GetPostString("customer");
  7247. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7248. string design = GetPostString("design");
  7249. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7250. string afterMemoType = GetPostString("aftermemotype");
  7251. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7252. string afterSaleMemo = GetPostString("afterSaleMemo");
  7253. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7254. string afterresult = GetPostString("afterresult");
  7255. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7256. string poscode = CurrentUser.UserPost.Post.Code;
  7257. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7258. {
  7259. string shopid = CurrentUser.User.pemShop;
  7260. lw.Add(string.Format("shopId in ({0})", shopid));
  7261. }
  7262. var mainwhere = string.Join(" and ", lw.ToArray());
  7263. string ro_json = "";
  7264. string type = GetPostString("gather_type");
  7265. int number = 0;
  7266. if (poscode == "AfterSale")
  7267. {
  7268. //处理中
  7269. if (type == "Handling")
  7270. {
  7271. 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) : ""));
  7272. DataTable dt = null;
  7273. try
  7274. {
  7275. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7276. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7277. }
  7278. catch (Exception e)
  7279. {
  7280. dt = new DataTable();
  7281. }
  7282. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7283. return;
  7284. }
  7285. if (type == "Wait")
  7286. {
  7287. //待处理
  7288. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7289. DataTable dt1 = null;
  7290. try
  7291. {
  7292. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7293. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7294. }
  7295. catch (Exception e)
  7296. {
  7297. dt1 = new DataTable();
  7298. }
  7299. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7300. return;
  7301. }
  7302. if (type == "back")
  7303. {
  7304. //打回
  7305. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7306. DataTable dt2 = null;
  7307. try
  7308. {
  7309. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7310. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7311. }
  7312. catch (Exception e)
  7313. {
  7314. dt2 = new DataTable();
  7315. }
  7316. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7317. return;
  7318. }
  7319. if (type == "preCompletion")
  7320. {
  7321. //预完成
  7322. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7323. DataTable dt3 = null;
  7324. try
  7325. {
  7326. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7327. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7328. }
  7329. catch (Exception e)
  7330. {
  7331. dt3 = new DataTable();
  7332. }
  7333. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7334. return;
  7335. }
  7336. if (type == "documentary")
  7337. {
  7338. //跟单中
  7339. 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) : ""));
  7340. DataTable dt4 = null;
  7341. try
  7342. {
  7343. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7344. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7345. }
  7346. catch (Exception e)
  7347. {
  7348. dt4 = new DataTable();
  7349. }
  7350. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7351. return;
  7352. }
  7353. if (type == "reBack")
  7354. {
  7355. //被打回
  7356. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7357. DataTable dt1 = null;
  7358. try
  7359. {
  7360. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7361. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7362. }
  7363. catch (Exception e)
  7364. {
  7365. dt1 = new DataTable();
  7366. }
  7367. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7368. return;
  7369. }
  7370. }
  7371. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7372. {
  7373. if (type == "puBack")
  7374. {
  7375. //退回
  7376. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7377. DataTable dt = null;
  7378. try
  7379. {
  7380. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7381. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7382. }
  7383. catch (Exception e)
  7384. {
  7385. dt = new DataTable();
  7386. }
  7387. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7388. return;
  7389. }
  7390. if (type == "reBack")
  7391. {
  7392. //打回
  7393. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7394. DataTable dt1 = null;
  7395. try
  7396. {
  7397. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7398. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7399. }
  7400. catch (Exception e)
  7401. {
  7402. dt1 = new DataTable();
  7403. }
  7404. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7405. return;
  7406. }
  7407. if (type == "examEd")
  7408. {
  7409. //已审核
  7410. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7411. DataTable dt2 = null;
  7412. try
  7413. {
  7414. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7415. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7416. }
  7417. catch (Exception e)
  7418. {
  7419. dt2 = new DataTable();
  7420. }
  7421. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7422. return;
  7423. }
  7424. if (type == "waitExam")
  7425. {
  7426. //待审核
  7427. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7428. DataTable dt3 = null;
  7429. try
  7430. {
  7431. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7432. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7433. }
  7434. catch (Exception e)
  7435. {
  7436. dt3 = new DataTable();
  7437. }
  7438. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7439. return;
  7440. }
  7441. if (type == "Handling")
  7442. {
  7443. //处理中
  7444. 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) : ""));
  7445. DataTable dt4 = null;
  7446. try
  7447. {
  7448. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7449. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7450. }
  7451. catch (Exception e)
  7452. {
  7453. dt4 = new DataTable();
  7454. }
  7455. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7456. return;
  7457. }
  7458. if (type == "Wait")
  7459. {
  7460. //待处理
  7461. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7462. DataTable dt5 = null;
  7463. try
  7464. {
  7465. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7466. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7467. }
  7468. catch (Exception e)
  7469. {
  7470. dt5 = new DataTable();
  7471. }
  7472. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7473. return;
  7474. }
  7475. if (type == "documentary")
  7476. {
  7477. //跟单中
  7478. 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) : ""));
  7479. DataTable dt6 = null;
  7480. try
  7481. {
  7482. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7483. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7484. }
  7485. catch (Exception e)
  7486. {
  7487. dt6 = new DataTable();
  7488. }
  7489. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7490. return;
  7491. }
  7492. }
  7493. returnSuccess(ro_json);
  7494. }
  7495. public void end_erp_aftersale()
  7496. {
  7497. if (UrlPostParmsCheck("ctid"))
  7498. {
  7499. string eid = GetPostString("ctid");
  7500. CeErpTradeCell entity = null;
  7501. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7502. if (entity != null)
  7503. {
  7504. string stype = GetPostString("stype");
  7505. string typeStr = stype;
  7506. entity.AfterSaleState = 4;
  7507. entity.FinishAfterSaleTime = DateTime.Now;
  7508. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7509. entity.Update();
  7510. ApiVo apiVo = new ApiVo();
  7511. apiVo.orderNumber = entity.ctid;
  7512. apiVo.actionName = "afterOver";
  7513. designHelper.API_WorkCore(apiVo); //afterOver
  7514. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7515. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7516. CeErpSukuraData.createInfo(entity.ctid, 8);
  7517. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7518. returnSuccessMsg("操作成功!");
  7519. return;
  7520. }
  7521. returnErrorMsg("找不到订单记录");
  7522. }
  7523. }
  7524. public void ins_erp_finishaftersale()
  7525. {
  7526. if (UrlPostParmsCheck("id"))
  7527. {
  7528. string eid = GetPostString("id");
  7529. CeErpTradeResponsible entity = null;
  7530. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7531. if (entity != null)
  7532. {
  7533. entity.VerifyState = 1;
  7534. entity.VerifyTime = DateTime.Now;
  7535. entity.Update();
  7536. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7537. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7538. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7539. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7540. if (dt.Rows.Count <= 0)
  7541. {
  7542. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7543. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7544. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7545. CeErpSukuraData.createInfo(entity.tid, 8);
  7546. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7547. {
  7548. CeErpDesignerBill.Del(entity.tid);
  7549. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7550. }
  7551. }
  7552. returnSuccessMsg("操作成功!");
  7553. return;
  7554. }
  7555. returnErrorMsg("找不到订单记录");
  7556. }
  7557. }
  7558. public void upd_erp_arbitrateaftersale()
  7559. {
  7560. if (UrlPostParmsCheck("id"))
  7561. {
  7562. string eid = GetPostString("id");
  7563. CeErpTradeResponsible entity = null;
  7564. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7565. if (entity != null)
  7566. {
  7567. entity.IsArbitrate = 1;
  7568. entity.ArbitradeMemo = GetPostString("reason");
  7569. entity.VerifyState = 2;
  7570. entity.Update();
  7571. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7572. if (tradecell != null)
  7573. {
  7574. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7575. tradecell.IsArbitrate = 1;
  7576. tradecell.Update();
  7577. }
  7578. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7579. returnSuccessMsg("操作成功!");
  7580. return;
  7581. }
  7582. returnErrorMsg("找不到订单记录");
  7583. }
  7584. }
  7585. public void upd_erp_backaftersale()
  7586. {
  7587. if (UrlPostParmsCheck("tid"))
  7588. {
  7589. string eid = GetPostString("tid");
  7590. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7591. int backNum = 0;
  7592. if (number != null)
  7593. {
  7594. backNum = number.BackNum;
  7595. }
  7596. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7597. CeErpTradeCell entity = null;
  7598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7599. if (entity != null)
  7600. {
  7601. entity.AfterSaleBackReason = GetPostString("backreason");
  7602. entity.AfterSaleState = 1;
  7603. entity.AfterSaleSupplierState = 0;
  7604. entity.UpdateTime = DateTime.Now;
  7605. entity.Update();
  7606. returnSuccessMsg("操作成功!");
  7607. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7608. return;
  7609. }
  7610. returnErrorMsg("找不到订单记录");
  7611. }
  7612. }
  7613. public void get_erp_supplieraftersalelist()
  7614. {
  7615. DataStruct dStruct = GetPostStruct();
  7616. List<string> lw = new List<string>();
  7617. string tid = GetPostString("ctid");
  7618. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7619. string shopname = GetPostString("shopname");
  7620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7621. string buyernick = GetPostString("buyer_nick");
  7622. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7623. string sellermemo = GetPostString("seller_memo");
  7624. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7625. string orderState = GetPostString("orderState");
  7626. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7627. string afterState = GetPostString("afterstate");
  7628. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7629. string date1 = GetPostString("date1");
  7630. string date2 = GetPostString("date2");
  7631. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7632. if (dw.Length > 0) lw.Add(dw);
  7633. string price1 = GetPostString("price1");
  7634. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7635. string price2 = GetPostString("price2");
  7636. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7637. string reason = GetPostString("reason");
  7638. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7639. string method = GetPostString("method");
  7640. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7641. string handledate1 = GetPostString("handledate1");
  7642. string handledate2 = GetPostString("handledate2");
  7643. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7644. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7645. string handler = GetPostString("handler");
  7646. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7647. string afterdate1 = GetPostString("afterdate1");
  7648. string afterdate2 = GetPostString("afterdate2");
  7649. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7650. if (afterDate.Length > 0) lw.Add(afterDate);
  7651. string customer = GetPostString("customer");
  7652. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7653. string design = GetPostString("design");
  7654. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7655. string afterMemoType = GetPostString("aftermemotype");
  7656. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7657. string vstate = GetPostString("vstate");
  7658. if (vstate.Length > 0)
  7659. {
  7660. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7661. }
  7662. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7663. string supplier = GetPostString("supplier");
  7664. int supid = commonHelper.getSupplierIDByName(supplier);
  7665. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7666. string posCode = CurrentUser.UserPost.Post.Code;
  7667. if (posCode == "Supplier")
  7668. {
  7669. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7670. }
  7671. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7672. {
  7673. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7674. }
  7675. else
  7676. {
  7677. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7678. }
  7679. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7680. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7681. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7682. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7683. writeGridDataTableJson(dStruct.TotalCount, dt);
  7684. }
  7685. public void upd_erp_supverifyaftersale()
  7686. {
  7687. if (UrlPostParmsCheck("id"))
  7688. {
  7689. string id = GetPostString("id");
  7690. int st = GetPostInt("afterstate");
  7691. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7692. CeErpTradeCell entity = null;
  7693. if (ceErpTradeResponsible != null)
  7694. {
  7695. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7696. }
  7697. string afmemo = GetPostString("supmemo");
  7698. string image = GetPostString("image");
  7699. if (entity != null)
  7700. {
  7701. entity.AfterSaleSupplierState = st;
  7702. entity.AfterSaleSupplierMemo = afmemo;
  7703. if (st == 1)
  7704. {
  7705. ceErpTradeResponsible.VerifyState = 1;
  7706. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7707. ceErpTradeResponsible.Update();
  7708. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7709. if (isAll)
  7710. {
  7711. entity.AfterSaleState = 4;
  7712. entity.FinishAfterSaleTime = DateTime.Now;
  7713. }
  7714. }
  7715. else
  7716. {
  7717. CeErpTradeResponsible.dateByTid(entity.ctid);
  7718. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7719. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7720. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7721. if (num <= 1)
  7722. {
  7723. entity.AfterSaleState = 1;
  7724. }
  7725. else
  7726. {
  7727. entity.AfterSaleState = 5;
  7728. }
  7729. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7730. if (ceErpTradeAfterSaleExtend != null)
  7731. {
  7732. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7733. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7734. ceErpTradeAfterSaleExtend.Update();
  7735. }
  7736. else
  7737. {
  7738. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7739. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7740. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7741. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7742. ceErpTradeAfterSaleExtend.Create();
  7743. }
  7744. }
  7745. if (entity.AfterSaleState == 4)
  7746. {
  7747. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7748. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7749. {
  7750. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7751. }
  7752. ApiVo apiVo = new ApiVo();
  7753. apiVo.orderNumber = entity.ctid;
  7754. apiVo.actionName = "afterOver";
  7755. designHelper.API_WorkCore(apiVo); //afterOver
  7756. }
  7757. entity.UpdateTime = DateTime.Now;
  7758. entity.Update();
  7759. returnSuccessMsg("操作成功!");
  7760. CeErpSukuraData.createInfo(entity.ctid, 8);
  7761. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7762. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7763. return;
  7764. }
  7765. returnErrorMsg("找不到订单记录");
  7766. }
  7767. }
  7768. public void upd_erp_masteraftersale()
  7769. {
  7770. if (UrlPostParmsCheck("id"))
  7771. {
  7772. string id = GetPostString("id");
  7773. int st = GetPostInt("afterstate");
  7774. string afmemo = GetPostString("supmemo");
  7775. string image = GetPostString("image");
  7776. string textResult = GetPostString("textResult");
  7777. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7778. if (ceErpTradeResponsible != null)
  7779. {
  7780. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7781. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7782. ceErpTradeResponsible.Update();
  7783. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7784. if (entity != null)
  7785. {
  7786. entity.AfterSaleSupplierState = st;
  7787. entity.AfterSaleSupplierMemo = afmemo;
  7788. if (st == 1)
  7789. {
  7790. }
  7791. else
  7792. {
  7793. CeErpTradeResponsible.dateByTid(entity.ctid);
  7794. //退回到售后
  7795. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7796. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7797. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7798. if (num <= 1)
  7799. {
  7800. entity.AfterSaleState = 1;
  7801. }
  7802. else
  7803. {
  7804. entity.AfterSaleState = 5;
  7805. }
  7806. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7807. if (ceErpTradeAfterSaleExtend != null)
  7808. {
  7809. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7810. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7811. ceErpTradeAfterSaleExtend.Update();
  7812. }
  7813. else
  7814. {
  7815. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7816. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7817. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7818. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7819. ceErpTradeAfterSaleExtend.Create();
  7820. }
  7821. }
  7822. entity.UpdateTime = DateTime.Now;
  7823. entity.Update();
  7824. returnSuccessMsg("操作成功!");
  7825. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7826. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7827. return;
  7828. }
  7829. }
  7830. returnErrorMsg("找不到订单记录");
  7831. }
  7832. }
  7833. public void upd_erp_personaftersale()
  7834. {
  7835. if (UrlPostParmsCheck("id"))
  7836. {
  7837. //林小连
  7838. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7839. {
  7840. upd_erp_masteraftersale();
  7841. return;
  7842. }
  7843. string id = GetPostString("id");
  7844. int st = GetPostInt("afterstate");
  7845. string afmemo = GetPostString("supmemo");
  7846. string image = GetPostString("image");
  7847. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7848. if (ceErpTradeResponsible != null)
  7849. {
  7850. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7851. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7852. ceErpTradeResponsible.Update();
  7853. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7854. if (entity != null)
  7855. {
  7856. entity.AfterSaleSupplierMemo = afmemo;
  7857. entity.AfterSaleSupplierState = st;
  7858. if (st == 1)
  7859. {
  7860. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7861. if (isAll)
  7862. {
  7863. entity.AfterSaleState = 4;
  7864. entity.FinishAfterSaleTime = DateTime.Now;
  7865. }
  7866. }
  7867. else
  7868. {
  7869. CeErpTradeResponsible.dateByTid(entity.ctid);
  7870. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7871. if (ceErpTradeAfterSaleExtend != null)
  7872. {
  7873. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7874. ceErpTradeAfterSaleExtend.Update();
  7875. }
  7876. else
  7877. {
  7878. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7879. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7880. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7881. ceErpTradeAfterSaleExtend.Create();
  7882. }
  7883. //退回到主管
  7884. //entity.AfterSaleState = 2;
  7885. }
  7886. if (entity.AfterSaleState == 4)
  7887. {
  7888. ApiVo apiVo = new ApiVo();
  7889. apiVo.orderNumber = entity.ctid;
  7890. apiVo.actionName = "afterOver";
  7891. designHelper.API_WorkCore(apiVo); //afterOver
  7892. }
  7893. entity.UpdateTime = DateTime.Now;
  7894. entity.Update();
  7895. returnSuccessMsg("操作成功!");
  7896. CeErpSukuraData.createInfo(entity.ctid, 8);
  7897. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7898. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7899. return;
  7900. }
  7901. }
  7902. returnErrorMsg("找不到订单记录");
  7903. }
  7904. }
  7905. public void set_erp_supplierrefundtag()
  7906. {
  7907. if (UrlPostParmsCheck("ctid"))
  7908. {
  7909. string eid = GetPostString("ctid");
  7910. CeErpTradeCell entity = null;
  7911. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7912. if (entity != null)
  7913. {
  7914. entity.IsSupplierRefund = GetPostInt("tag");
  7915. entity.Update();
  7916. returnSuccessMsg("操作成功!");
  7917. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7918. return;
  7919. }
  7920. returnErrorMsg("找不到订单记录");
  7921. }
  7922. }
  7923. public void get_erp_refundlist()
  7924. {
  7925. DataStruct dStruct = GetPostStruct();
  7926. List<string> lw = new List<string>();
  7927. string tid = GetPostString("tid");
  7928. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7929. //string rid = GetPostString("refund_id");
  7930. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7931. string shopname = GetPostString("shopname");
  7932. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7933. string buyernick = GetPostString("buyer_nick");
  7934. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7935. string customer = GetPostString("customer");
  7936. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7937. string design = GetPostString("design");
  7938. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7939. string sellermemo = GetPostString("seller_memo");
  7940. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7941. //string date1 = GetPostString("date1");
  7942. //string date2 = GetPostString("date2");
  7943. //string dateType = GetPostString("dateType");
  7944. //if (dateType.Length > 0)
  7945. //{
  7946. // if (dateType == "1001") dateType = "0";
  7947. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7948. // if (searchDT.Count == 2)
  7949. // {
  7950. // date1 = searchDT[0].ToString();
  7951. // date2 = searchDT[1].ToString();
  7952. // }
  7953. //}
  7954. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7955. //if (dw.Length > 0) lw.Add(dw);
  7956. string redate1 = GetPostString("refunddate1");
  7957. string redate2 = GetPostString("refunddate2");
  7958. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7959. if (dwdate.Length > 0) lw.Add(dwdate);
  7960. string price1 = GetPostString("price1");
  7961. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7962. string price2 = GetPostString("price2");
  7963. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7964. string ispartrefund = GetPostString("ispartrefund");
  7965. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7966. string refundState = GetPostString("refundvstate");
  7967. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7968. int st = GetInt("st");
  7969. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7970. {
  7971. string responsible = GetPostString("responsibleman");
  7972. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7973. lw.Add(string.Format("RefundState>={0}", st));
  7974. string code = CurrentUser.UserPost.Post.Code;
  7975. if (code == "CustomerService")
  7976. {
  7977. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7978. }
  7979. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7980. {
  7981. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7982. }
  7983. else if (code == "Place" || code == "PlaceMr")
  7984. {
  7985. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7986. }
  7987. dStruct.Order = "RefundState asc,created desc";
  7988. }
  7989. else if (st == 10)
  7990. {
  7991. string responsible = GetPostString("responsibleman");
  7992. if (responsible == "空白")
  7993. {
  7994. lw.Add(string.Format("ResponsibleUserName = ''"));
  7995. }
  7996. else if (responsible.Length > 0)
  7997. {
  7998. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7999. }
  8000. lw.Add(string.Format("RefundState>=0"));
  8001. dStruct.Order = "created desc";
  8002. }
  8003. else
  8004. {
  8005. string responsible = GetPostString("responsibleman");
  8006. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8007. lw.Add(string.Format("RefundState={0}", st));
  8008. dStruct.Order = "created desc";
  8009. }
  8010. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8011. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8012. dt.Columns.Add("refund_fees");
  8013. foreach (DataRow dr in dt.Rows)
  8014. {
  8015. String status = dr["status"].ToString();
  8016. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8017. {
  8018. dr["refund_fees"] = dr["refund_fee"];
  8019. }
  8020. else
  8021. {
  8022. dr["refund_fees"] = "0.0";
  8023. }
  8024. }
  8025. writeGridDataTableJson(dStruct.TotalCount, dt);
  8026. }
  8027. public void get_erp_refunddesignlist()
  8028. {
  8029. DataStruct dStruct = GetPostStruct();
  8030. List<string> lw = new List<string>();
  8031. string tid = GetPostString("tid");
  8032. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8033. string shopname = GetPostString("shopname");
  8034. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8035. string buyernick = GetPostString("buyer_nick");
  8036. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8037. string customer = GetPostString("customer");
  8038. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8039. string design = GetPostString("design");
  8040. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8041. string sellermemo = GetPostString("seller_memo");
  8042. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8043. string redate1 = GetPostString("refunddate1");
  8044. string redate2 = GetPostString("refunddate2");
  8045. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8046. if (dwdate.Length > 0) lw.Add(dwdate);
  8047. string price1 = GetPostString("price1");
  8048. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8049. string price2 = GetPostString("price2");
  8050. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8051. string ispartrefund = GetPostString("ispartrefund");
  8052. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8053. string designerorg = GetPostString("designerorg");
  8054. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8055. string refundState = GetPostString("refundState");
  8056. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8057. int myOrgid = CurrentUser.UserPost.OrgID;
  8058. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8059. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8060. {
  8061. if (CurrentUser.User.TeamIds.Length > 0)
  8062. {
  8063. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8064. }
  8065. else
  8066. {
  8067. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8068. }
  8069. }
  8070. else if ("SysAdmin".Equals(myOrgCode))
  8071. {
  8072. }
  8073. else
  8074. {
  8075. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8076. {
  8077. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8078. }
  8079. else
  8080. {
  8081. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8082. }
  8083. }
  8084. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8085. dStruct.Order = "created desc";
  8086. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8087. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8088. dt.Columns.Add("refund_fees");
  8089. foreach (DataRow dr in dt.Rows)
  8090. {
  8091. String status = dr["status"].ToString();
  8092. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8093. {
  8094. dr["refund_fees"] = dr["refund_fee"];
  8095. }
  8096. else
  8097. {
  8098. dr["refund_fees"] = "0.0";
  8099. }
  8100. }
  8101. writeGridDataTableJson(dStruct.TotalCount, dt);
  8102. }
  8103. public void handle_erp_refundtag()
  8104. {
  8105. if (UrlPostParmsCheck("refund_id"))
  8106. {
  8107. string eid = GetPostString("refund_id");
  8108. string respMan = GetPostString("ResponsibleName");
  8109. if (respMan.Length <= 0)
  8110. {
  8111. returnErrorMsg("责任人不能为空");
  8112. return;
  8113. }
  8114. CeErpTradeRefund entity = null;
  8115. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8116. if (entity != null)
  8117. {
  8118. entity.ResponsibleUserName = respMan;
  8119. string userid = GetPostString("ResponsibleUserId");
  8120. if (userid.Length > 0)
  8121. {
  8122. entity.ResponsibleUserId = userid;
  8123. }
  8124. entity.Memo = GetPostString("Memo");
  8125. if (respMan.IndexOf("客服") != -1 ||
  8126. respMan.IndexOf("设计师") != -1 ||
  8127. respMan.IndexOf("下单员") != -1)
  8128. {
  8129. entity.RefundState = 2;
  8130. }
  8131. else
  8132. {
  8133. entity.RefundState = 3;
  8134. }
  8135. entity.modified = DateTime.Now;
  8136. entity.Update();
  8137. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8138. returnSuccessMsg("操作成功!");
  8139. return;
  8140. }
  8141. returnErrorMsg("找不到订单记录");
  8142. }
  8143. }
  8144. public void handle_erp_designrefundtag()
  8145. {
  8146. if (UrlPostParmsCheck("refund_id"))
  8147. {
  8148. string eid = GetPostString("refund_id");
  8149. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8150. if (ceErpTradeCellExtend == null)
  8151. {
  8152. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8153. ceErpTradeCellExtend.ctid = eid;
  8154. }
  8155. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8156. if (ceErpTradeCellExtend.ID > 0)
  8157. {
  8158. ceErpTradeCellExtend.Update();
  8159. }
  8160. else
  8161. {
  8162. ceErpTradeCellExtend.Create();
  8163. }
  8164. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8165. returnSuccessMsg("操作成功!");
  8166. return;
  8167. }
  8168. returnErrorMsg("找不到订单记录");
  8169. }
  8170. public void upd_erp_refundverify()
  8171. {
  8172. if (UrlPostParmsCheck("refund_id"))
  8173. {
  8174. string eid = GetPostString("refund_id");
  8175. CeErpTradeRefund entity = null;
  8176. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8177. if (entity != null)
  8178. {
  8179. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8180. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8181. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8182. {
  8183. entity.RefundState = 2;
  8184. }
  8185. else
  8186. {
  8187. entity.RefundState = 3;
  8188. }
  8189. entity.Update();
  8190. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8191. returnSuccessMsg("操作成功!");
  8192. return;
  8193. }
  8194. returnErrorMsg("找不到订单记录");
  8195. }
  8196. }
  8197. public void upd_erp_refundapprove()
  8198. {
  8199. if (UrlPostParmsCheck("refund_id"))
  8200. {
  8201. string eid = GetPostString("refund_id");
  8202. CeErpTradeRefund entity = null;
  8203. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8204. if (entity != null)
  8205. {
  8206. int apr = GetPostInt("approve");
  8207. if (apr == 0)
  8208. {
  8209. entity.RefundState = 1;
  8210. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8211. }
  8212. else if (apr == 1)
  8213. {
  8214. entity.RefundState = 3;
  8215. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8216. }
  8217. entity.modified = DateTime.Now;
  8218. entity.Update();
  8219. returnSuccessMsg("操作成功!");
  8220. return;
  8221. }
  8222. returnErrorMsg("找不到订单记录");
  8223. }
  8224. }
  8225. public void get_erp_billlist()
  8226. {
  8227. DataStruct dStruct = GetPostStruct();
  8228. List<string> lw = new List<string>();
  8229. string title = GetPostString("title");
  8230. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8231. string tid = GetPostString("tid");
  8232. string tids = GetPostString("tids");
  8233. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8234. if (tids.Length > 0)
  8235. {
  8236. tids = "'" + tids + "'";
  8237. tids = tids.Replace(",", "','");
  8238. lw.Add(string.Format("tid in ({0})", tids));
  8239. }
  8240. string shopname = GetPostString("shopname");
  8241. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8242. string buyernick = GetPostString("buyer_nick");
  8243. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8244. string customer = GetPostString("customer");
  8245. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8246. string date1 = GetPostString("date1");
  8247. string date2 = GetPostString("date2");
  8248. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8249. if (dw.Length > 0) lw.Add(dw);
  8250. string price1 = GetPostString("price1");
  8251. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8252. string price2 = GetPostString("price2");
  8253. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8254. string returndate1 = GetPostString("returndate1");
  8255. string returndate2 = GetPostString("returndate2");
  8256. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8257. if (dw1.Length > 0) lw.Add(dw1);
  8258. string billtype = GetPostString("billtype");
  8259. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8260. string billstate = GetPostString("billstate");
  8261. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8262. string usershop = CurrentUser.User.pemShop;
  8263. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8264. dStruct.Order = "createTime desc";
  8265. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8266. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8267. //foreach (DataRow dr in dt.Rows)
  8268. //{
  8269. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8270. //}
  8271. writeGridDataTableJson(dStruct.TotalCount, dt);
  8272. }
  8273. public void modify_erp_billinfo()
  8274. {
  8275. if (UrlPostParmsCheck("ID"))
  8276. {
  8277. string eid = GetPostString("ID");
  8278. CeErpBill bill_entity = null;
  8279. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8280. if (bill_entity != null)
  8281. {
  8282. bill_entity.tid = GetPostString("tid");
  8283. bill_entity.title = GetPostString("title");
  8284. bill_entity.tax = GetPostString("tax");
  8285. bill_entity.bank = GetPostString("bank");
  8286. bill_entity.bankac = GetPostString("bankac");
  8287. bill_entity.address = GetPostString("address");
  8288. bill_entity.phone = GetPostString("phone");
  8289. bill_entity.price = GetPostString("price");
  8290. bill_entity.productId = GetPostInt("ProductName");
  8291. bill_entity.num = GetPostInt("num");
  8292. bill_entity.unit = GetPostString("unit");
  8293. bill_entity.type = GetPostString("type");
  8294. bill_entity.sendType = GetPostString("SendType");
  8295. bill_entity.email = GetPostString("email");
  8296. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8297. bill_entity.shopName = GetPostString("ShopName");
  8298. bill_entity.applymemo = GetPostString("applymemo");
  8299. bill_entity.modifyTime = DateTime.Now;
  8300. bill_entity.createTime = DateTime.Now;
  8301. bill_entity.state = 0;
  8302. bill_entity.Update();
  8303. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8304. returnSuccessMsg("发票修改成功!");
  8305. return;
  8306. }
  8307. returnErrorMsg("找不到对应记录");
  8308. }
  8309. }
  8310. public void set_erp_invoicing()
  8311. {
  8312. if (UrlPostParmsCheck("id"))
  8313. {
  8314. try
  8315. {
  8316. string eid = GetPostString("id");
  8317. CeErpBill bill_entity = null;
  8318. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8319. if (bill_entity != null)
  8320. {
  8321. int ComId = GetPostInt("ComId");
  8322. //string memo = GetPostString("Memo");
  8323. int allInfo = GetPostInt("allinfo");
  8324. string clert = CurrentUser.User.Name;
  8325. //string detailValue = GetPostString("detailvalue");
  8326. string billId = bill_entity.billOrderId;
  8327. string[] billIdList = billId.Split(',');
  8328. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8329. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8330. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8331. {
  8332. billCount += 1;
  8333. }
  8334. if (billId.Length <= 0 || billIdList.Length != billCount)
  8335. {
  8336. bill_entity.billOrderId = "";
  8337. string prebill = "ltb";
  8338. for (int idx = 1; idx <= billCount; idx++)
  8339. {
  8340. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8341. string billoid = prebill + idx + dtstr;
  8342. bill_entity.billOrderId += billoid;
  8343. if (idx < billCount)
  8344. {
  8345. bill_entity.billOrderId += ",";
  8346. }
  8347. }
  8348. }
  8349. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8350. if (bill_entity.state == 5)
  8351. {
  8352. string errMsg = bill_entity.failerror;
  8353. string[] errlist = errMsg.Split('|');
  8354. string[] errTags = new string[errlist.Length];
  8355. for (int itag = 0; itag < errlist.Length; itag++)
  8356. {
  8357. if (errlist[itag].Length <= 0) continue;
  8358. errTags[itag] = errlist[itag].Split('&')[0];
  8359. }
  8360. for (int iii = 0; iii < errTags.Length; iii++)
  8361. {
  8362. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8363. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8364. if (billOrderList.Length >= erroBillOrderTag)
  8365. {
  8366. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8367. if (needModifyBillId.Length <= 19)
  8368. {
  8369. needModifyBillId = needModifyBillId + "1";
  8370. }
  8371. else
  8372. {
  8373. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8374. last = last + 1;
  8375. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8376. }
  8377. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8378. }
  8379. }
  8380. }
  8381. bool isHaveBillSucces = false;
  8382. string totalRes = "";
  8383. bill_entity.failerror = "";
  8384. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8385. {
  8386. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8387. totalRes += res;
  8388. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8389. {
  8390. isHaveBillSucces = true;
  8391. bill_entity.comId = ComId;
  8392. bill_entity.state = 1;
  8393. bill_entity.executeTime = DateTime.Now;
  8394. bill_entity.executeUser = clert;
  8395. }
  8396. else
  8397. {
  8398. bill_entity.state = 5;
  8399. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8400. }
  8401. }
  8402. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8403. bill_entity.Update();
  8404. if (isHaveBillSucces)
  8405. {
  8406. StringBuilder sql = new StringBuilder();
  8407. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8408. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8409. }
  8410. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8411. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8412. {
  8413. returnErrorMsg("开票失败");
  8414. }
  8415. else
  8416. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8417. return;
  8418. }
  8419. returnErrorMsg("找不到对应记录");
  8420. }
  8421. catch (Exception ex)
  8422. {
  8423. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8424. returnErrorMsg("操作失败");
  8425. }
  8426. }
  8427. }
  8428. public void get_erp_invoicing_back()
  8429. {
  8430. if (UrlPostParmsCheck("id"))
  8431. {
  8432. try
  8433. {
  8434. string id = GetPostString("id");
  8435. CeErpBill entiy = CeErpBill.Get(id);
  8436. if (entiy != null)
  8437. {
  8438. if (entiy.state == 0)
  8439. {
  8440. returnErrorMsg("发票还未开具");
  8441. return;
  8442. }
  8443. string[] billOrderList = entiy.billOrderId.Split(',');
  8444. int iTag = 0;
  8445. entiy.fplsh = "";
  8446. entiy.fpdm = "";
  8447. entiy.fphm = "";
  8448. foreach (string billOrderId in billOrderList)
  8449. {
  8450. iTag++;
  8451. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8452. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8453. {
  8454. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8455. try
  8456. {
  8457. Invoicing_get_response_Obj iObj = null;
  8458. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8459. if (iObj != null)
  8460. {
  8461. entiy.state = 2;
  8462. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8463. entiy.fpdm += iObj.list[0].c_fpdm;
  8464. entiy.fphm += iObj.list[0].c_fphm;
  8465. if (iTag < billOrderList.Length)
  8466. {
  8467. entiy.fplsh += ",";
  8468. entiy.fpdm += ",";
  8469. entiy.fphm += ",";
  8470. }
  8471. entiy.Update();
  8472. }
  8473. StringBuilder sql = new StringBuilder();
  8474. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8475. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8476. returnSuccessMsg("开票成功");
  8477. }
  8478. catch (Exception ex)
  8479. {
  8480. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8481. }
  8482. return;
  8483. }
  8484. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8485. {
  8486. var res_obj = new
  8487. {
  8488. data = "开票中"
  8489. };
  8490. string ro_json = JsonConvert.SerializeObject(res_obj);
  8491. returnSuccess(ro_json);
  8492. return;
  8493. }
  8494. else
  8495. {
  8496. int eidx = res.IndexOf("c_resultmsg");
  8497. int lidx = res.IndexOf("c_status");
  8498. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8499. entiy.state = 5;
  8500. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8501. entiy.Update();
  8502. returnErrorMsg("开票失败");
  8503. return;
  8504. }
  8505. }
  8506. }
  8507. }
  8508. catch (Exception ex)
  8509. {
  8510. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8511. }
  8512. return;
  8513. }
  8514. }
  8515. public void get_erp_invoicing()
  8516. {
  8517. if (UrlPostParmsCheck("id"))
  8518. {
  8519. try
  8520. {
  8521. string id = GetPostString("id");
  8522. CeErpBill entiy = CeErpBill.Get(id);
  8523. if (entiy != null)
  8524. {
  8525. if (entiy.state == 0)
  8526. {
  8527. returnErrorMsg("发票还未开具");
  8528. return;
  8529. }
  8530. if (entiy.sendType == "纸质发票")
  8531. {
  8532. if (entiy.img.Length <= 0)
  8533. {
  8534. returnErrorMsg("查无纸质发票");
  8535. return;
  8536. }
  8537. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8538. returnSuccess(returnres);
  8539. return;
  8540. }
  8541. string[] billOrderList = entiy.billOrderId.Split(',');
  8542. int iTag = 0;
  8543. string fpUrl = "";
  8544. entiy.fplsh = "";
  8545. entiy.fpdm = "";
  8546. entiy.fphm = "";
  8547. foreach (string billOrderId in billOrderList)
  8548. {
  8549. iTag++;
  8550. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8551. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8552. {
  8553. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8554. Invoicing_get_response_Obj iObj = null;
  8555. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8556. if (iObj != null)
  8557. {
  8558. //entiy.state = 2;
  8559. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8560. entiy.fpdm += iObj.list[0].c_fpdm;
  8561. entiy.fphm += iObj.list[0].c_fphm;
  8562. if (iTag < billOrderList.Length)
  8563. {
  8564. entiy.fplsh += ",";
  8565. entiy.fpdm += ",";
  8566. entiy.fphm += ",";
  8567. }
  8568. entiy.Update();
  8569. fpUrl += iObj.list[0].c_url + ",";
  8570. }
  8571. //returnSuccess(res);
  8572. StringBuilder sql = new StringBuilder();
  8573. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8574. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8575. }
  8576. else
  8577. {
  8578. int eidx = res.IndexOf("c_resultmsg");
  8579. //int lidx = res.IndexOf("c_status");
  8580. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8581. //开票失败
  8582. entiy.state = 5;
  8583. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8584. entiy.Update();
  8585. returnErrorMsg("开票失败");
  8586. return;
  8587. }
  8588. }
  8589. var returnObj = new
  8590. {
  8591. data = fpUrl
  8592. };
  8593. string ro_json = JsonConvert.SerializeObject(returnObj);
  8594. returnSuccess(ro_json);
  8595. }
  8596. }
  8597. catch (Exception ex)
  8598. {
  8599. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8600. }
  8601. return;
  8602. }
  8603. }
  8604. public void save_erp_billimg()
  8605. {
  8606. if (UrlPostParmsCheck("id"))
  8607. {
  8608. string eid = GetPostString("id");
  8609. CeErpBill bill_entity = null;
  8610. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8611. if (bill_entity != null)
  8612. {
  8613. bill_entity.img = GetPostString("img");
  8614. bill_entity.executeTime = DateTime.Now;
  8615. bill_entity.state = 2;
  8616. bill_entity.Update();
  8617. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8618. returnSuccessMsg("保存成功");
  8619. }
  8620. return;
  8621. }
  8622. }
  8623. public void upd_erp_billreturnback()
  8624. {
  8625. if (UrlPostParmsCheck("id"))
  8626. {
  8627. int eid = GetPostInt("id");
  8628. CeErpBill bill_entity = null;
  8629. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8630. if (bill_entity != null)
  8631. {
  8632. bill_entity.state = 3;
  8633. bill_entity.returnReason = GetPostString("reason");
  8634. bill_entity.Update();
  8635. returnSuccessMsg("驳回成功!");
  8636. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8637. }
  8638. return;
  8639. }
  8640. }
  8641. public void cancel_erp_bill()
  8642. {
  8643. if (UrlPostParmsCheck("id"))
  8644. {
  8645. int eid = GetPostInt("id");
  8646. int detailValue = GetPostInt("detailvalue");
  8647. CeErpBill bill_entity = null;
  8648. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8649. string cres = "";
  8650. string gres = "";
  8651. if (bill_entity != null)
  8652. {
  8653. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8654. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8655. {
  8656. int iTag = 0;
  8657. bill_entity.fplsh = "";
  8658. bill_entity.fpdm = "";
  8659. bill_entity.fphm = "";
  8660. foreach (string billOrderId in billOrderList)
  8661. {
  8662. iTag++;
  8663. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8664. if (gres.IndexOf("success") != -1)
  8665. {
  8666. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8667. Invoicing_get_response_Obj iObj = null;
  8668. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8669. if (iObj != null)
  8670. {
  8671. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8672. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8673. bill_entity.fphm += iObj.list[0].c_fphm;
  8674. if (iTag < billOrderList.Length)
  8675. {
  8676. bill_entity.fplsh += ",";
  8677. bill_entity.fpdm += ",";
  8678. bill_entity.fphm += ",";
  8679. }
  8680. bill_entity.Update();
  8681. }
  8682. }
  8683. else
  8684. {
  8685. returnErrorMsg(gres);
  8686. return;
  8687. }
  8688. }
  8689. }
  8690. if (bill_entity.sendType == "纸质发票")
  8691. {
  8692. //作废
  8693. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8694. //if (DateTime.Now.Month == extime.Month)
  8695. //{
  8696. //cres = taobaoHelper.cancel_invoicing(eid);
  8697. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8698. //{
  8699. bill_entity.state = 4;//已作废
  8700. bill_entity.Update();
  8701. returnSuccessMsg("发票已作废");
  8702. return;
  8703. //}
  8704. //else
  8705. //{
  8706. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8707. // bill_entity.Update();
  8708. // returnErrorMsg(cres);
  8709. // return;
  8710. //}
  8711. //}
  8712. //else
  8713. //{
  8714. // returnErrorMsg("纸质发票只能作废本月的发票");
  8715. // return;
  8716. //}
  8717. }
  8718. //红冲
  8719. int redTag = 0;
  8720. string[] fpdmList = bill_entity.fpdm.Split(',');
  8721. string[] fphmList = bill_entity.fphm.Split(',');
  8722. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8723. {
  8724. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8725. return;
  8726. }
  8727. foreach (string billOrderId in billOrderList)
  8728. {
  8729. redTag++;
  8730. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8731. cres += onecres;
  8732. cres += ",";
  8733. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8734. {
  8735. bill_entity.state = 4;//已作废
  8736. //bill_entity.Update();
  8737. //returnSuccessMsg("发票已红冲");
  8738. }
  8739. else if (onecres.IndexOf("重复冲红") != -1)
  8740. {
  8741. bill_entity.state = 4;//已作废
  8742. //bill_entity.Update();
  8743. //returnSuccessMsg("发票已红冲");
  8744. }
  8745. else
  8746. {
  8747. string errmsg = commonHelper.KeepChinese(onecres);
  8748. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8749. }
  8750. }
  8751. bill_entity.Update();
  8752. if (cres.IndexOf("失败") != -1)
  8753. returnErrorMsg("红冲失败");
  8754. else
  8755. returnSuccessMsg("发票已红冲");
  8756. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8757. return;
  8758. }
  8759. return;
  8760. }
  8761. }
  8762. public void del_erp_billorder()
  8763. {
  8764. if (UrlPostParmsCheck("id"))
  8765. {
  8766. string eid = GetPostString("id");
  8767. CeErpBill.Del(eid);
  8768. CeErpBill bill = CeErpBill.Get(eid);
  8769. if (bill != null)
  8770. {
  8771. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8772. }
  8773. returnSuccessMsg("删除成功");
  8774. }
  8775. }
  8776. public void finish_erp_bill()
  8777. {
  8778. if (UrlPostParmsCheck("ids"))
  8779. {
  8780. string eids = GetPostString("ids");
  8781. string[] list = eids.Split(',');
  8782. foreach (string eid in list)
  8783. {
  8784. CeErpBill bill = CeErpBill.Get(eid);
  8785. if (bill != null)
  8786. {
  8787. bill.state = 2;
  8788. bill.Update();
  8789. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8790. }
  8791. }
  8792. returnSuccessMsg("操作成功");
  8793. }
  8794. }
  8795. public void get_erp_returncash()
  8796. {
  8797. DataStruct dStruct = GetPostStruct();
  8798. List<string> lw = new List<string>();
  8799. string tid = GetPostString("tid");
  8800. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8801. string shopname = GetPostString("shopname");
  8802. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8803. string buyernick = GetPostString("buyer_nick");
  8804. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8805. string customer = GetPostString("customer");
  8806. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8807. string returndate1 = GetPostString("returndate1");
  8808. string returndate2 = GetPostString("returndate2");
  8809. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8810. if (dw.Length > 0) lw.Add(dw);
  8811. string finishDate1 = GetPostString("finishdate1");
  8812. string finishDate2 = GetPostString("finishdate2");
  8813. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8814. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8815. string returntype = GetPostString("returntype");
  8816. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8817. string returnvstate = GetPostString("returnvstate");
  8818. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8819. dStruct.Order = "created desc";
  8820. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8821. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8822. writeGridDataTableJson(dStruct.TotalCount, dt);
  8823. }
  8824. public void get_erp_staygoods()
  8825. {
  8826. DataStruct dStruct = GetPostStruct();
  8827. List<string> lw = new List<string>();
  8828. string tid = GetPostString("tid");
  8829. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8830. string shopname = GetPostString("shopname");
  8831. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8832. string wangwang = GetPostString("wangwang");
  8833. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8834. string customer = GetPostString("customer");
  8835. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8836. string returndate1 = GetPostString("returndate1");
  8837. string returndate2 = GetPostString("returndate2");
  8838. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8839. if (dw.Length > 0) lw.Add(dw);
  8840. string finishDate1 = GetPostString("finishdate1");
  8841. string finishDate2 = GetPostString("finishdate2");
  8842. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8843. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8844. string returnvstate = GetPostString("returnvstate");
  8845. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8846. string persuadetype = GetPostString("persuadetype");
  8847. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8848. string customerOrg = GetPostString("customerOrg");
  8849. if (customerOrg.Length > 0)
  8850. {
  8851. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8852. }
  8853. dStruct.Order = "creata_time desc";
  8854. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8855. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8856. writeGridDataTableJson(dStruct.TotalCount, dt);
  8857. }
  8858. public void upd_erp_staygoods()
  8859. {
  8860. if (UrlPostParmsCheck("id"))
  8861. {
  8862. int eid = GetPostInt("id");
  8863. CeErpStayGoods entity = null;
  8864. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8865. if (entity != null)
  8866. {
  8867. entity.audit_type = 1;
  8868. entity.audit_time = DateTime.Now;
  8869. entity.audit_u_id = CurrentUser.UserID;
  8870. entity.audit_u_name = CurrentUser.UserName;
  8871. entity.Update();
  8872. returnSuccessMsg("审核成功!");
  8873. return;
  8874. }
  8875. returnErrorMsg("找不到订单记录");
  8876. }
  8877. }
  8878. public void upd_erp_stayGoodsback()
  8879. {
  8880. if (UrlPostParmsCheck("id"))
  8881. {
  8882. int eid = GetPostInt("id");
  8883. CeErpStayGoods entity = null;
  8884. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8885. if (entity != null)
  8886. {
  8887. entity.audit_text = GetPostString("reason");
  8888. entity.audit_type = 2;
  8889. entity.audit_time = DateTime.Now;
  8890. entity.audit_u_id = CurrentUser.UserID;
  8891. entity.audit_u_name = CurrentUser.UserName;
  8892. entity.Update();
  8893. returnSuccessMsg("退回成功!");
  8894. return;
  8895. }
  8896. returnErrorMsg("找不到订单记录");
  8897. }
  8898. }
  8899. public void upd_erp_returncashverify()
  8900. {
  8901. if (UrlPostParmsCheck("ID"))
  8902. {
  8903. int eid = GetPostInt("ID");
  8904. CeErpReturnCash entity = null;
  8905. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8906. if (entity != null)
  8907. {
  8908. entity.cashstate = 1;
  8909. entity.verifytime = DateTime.Now;
  8910. entity.verifyuserid = CurrentUser.UserID;
  8911. entity.Update();
  8912. returnSuccessMsg("审核成功!");
  8913. return;
  8914. }
  8915. returnErrorMsg("找不到订单记录");
  8916. }
  8917. }
  8918. public void upd_all_erp_returncashverify()
  8919. {
  8920. if (UrlPostParmsCheck("ID"))
  8921. {
  8922. String[] list = GetPostString("ID").Split(',');
  8923. CeErpReturnCash entity = null;
  8924. for (int i = 0; i < list.Length; i++)
  8925. {
  8926. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8927. if (entity != null)
  8928. {
  8929. if (entity.cashstate == 1)
  8930. {
  8931. returnErrorMsg("已审核过的订单不需要在审核!");
  8932. return;
  8933. }
  8934. entity.cashstate = 1;
  8935. entity.verifytime = DateTime.Now;
  8936. entity.verifyuserid = CurrentUser.UserID;
  8937. entity.Update();
  8938. }
  8939. }
  8940. returnSuccessMsg("审核成功!");
  8941. return;
  8942. }
  8943. }
  8944. public void upd_erp_returncashback()
  8945. {
  8946. if (UrlPostParmsCheck("ID"))
  8947. {
  8948. int eid = GetPostInt("ID");
  8949. CeErpReturnCash entity = null;
  8950. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8951. if (entity != null)
  8952. {
  8953. entity.backreason = GetPostString("reason");
  8954. entity.cashstate = 2;
  8955. entity.verifytime = DateTime.Now;
  8956. entity.verifyuserid = CurrentUser.UserID;
  8957. entity.Update();
  8958. returnSuccessMsg("退回成功!");
  8959. return;
  8960. }
  8961. returnErrorMsg("找不到订单记录");
  8962. }
  8963. }
  8964. public void upd_erp_returnprice()
  8965. {
  8966. if (UrlPostParmsCheck("ID"))
  8967. {
  8968. int eid = GetPostInt("ID");
  8969. CeErpReturnCash entity = null;
  8970. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8971. if (entity != null)
  8972. {
  8973. if (entity.cashstate == 1)
  8974. {
  8975. returnErrorMsg("审核通过了不能改");
  8976. return;
  8977. }
  8978. entity.returnprice = GetPostDouble("returnprice");
  8979. entity.Update();
  8980. returnSuccessMsg("修改成功!");
  8981. return;
  8982. }
  8983. returnErrorMsg("找不到订单记录");
  8984. }
  8985. }
  8986. public void del_erp_returncash()
  8987. {
  8988. if (UrlPostParmsCheck("ID"))
  8989. {
  8990. int eid = GetPostInt("ID");
  8991. CeErpReturnCash.Del(eid);
  8992. returnSuccessMsg("操作成功");
  8993. return;
  8994. }
  8995. }
  8996. public void test_for_do_sql()
  8997. {
  8998. string sql = GetPostString("sqlstr");
  8999. if (sql.Length > 0)
  9000. {
  9001. try
  9002. {
  9003. DbHelper.DbConn.ExecuteNonQuery(sql);
  9004. var res_obj = new
  9005. {
  9006. data = "成功",
  9007. };
  9008. string ro_json = JsonConvert.SerializeObject(res_obj);
  9009. returnSuccess(ro_json);
  9010. }
  9011. catch (Exception ex)
  9012. {
  9013. var res_obj = new
  9014. {
  9015. data = ex.Message,
  9016. };
  9017. string ro_json = JsonConvert.SerializeObject(res_obj);
  9018. returnSuccess(ro_json);
  9019. }
  9020. }
  9021. }
  9022. public void get_user_info()
  9023. {
  9024. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9025. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9026. }
  9027. public void get_total_data()
  9028. {
  9029. int userId = CurrentUser.UserID;
  9030. string sql = "";
  9031. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9032. {
  9033. 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);
  9034. }
  9035. else
  9036. {
  9037. 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 " +
  9038. "(select ID from CE_ErpUser where ID = {0}) d " +
  9039. "left join " +
  9040. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9041. ") a on d.ID = a.id left join " +
  9042. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9043. ") b on a.id = b.id1 left join" +
  9044. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9045. ") c on a.id = c.id2;", userId);
  9046. }
  9047. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9048. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9049. }
  9050. public void get_date_area_total_data2()
  9051. {
  9052. int userId = CurrentUser.UserID;
  9053. string date_type = GetPostString("timetype");
  9054. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9055. string sql = "";
  9056. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9057. {
  9058. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9059. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9060. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9061. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9062. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9063. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9064. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9065. ") a on e.ID = a.id left join " +
  9066. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9067. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9068. ") b on a.id = b.id1 " +
  9069. "left join " +
  9070. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9071. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9072. ") c on a.id = c.id2 " +
  9073. "left join " +
  9074. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9075. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9076. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9077. }
  9078. else
  9079. {
  9080. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9081. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9082. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9083. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9084. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9085. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9086. ") a on e.ID = a.id left join " +
  9087. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9088. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9089. ") c on a.id = c.id2 " +
  9090. "left join " +
  9091. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9092. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9093. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9094. }
  9095. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9096. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9097. }
  9098. public void get_date_area_total_data()
  9099. {
  9100. int userId = CurrentUser.UserID;
  9101. string date_type = GetPostString("timetype");
  9102. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9103. string date1 = searchDT[0].ToString();
  9104. string date2 = searchDT[1].ToString();
  9105. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9106. {
  9107. SqlParameter[] sqlParameter ={
  9108. new SqlParameter("@userId", SqlDbType.Int,4),
  9109. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9110. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9111. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9112. };
  9113. sqlParameter[0].Value = userId;
  9114. sqlParameter[1].Value = date1;
  9115. sqlParameter[2].Value = date2;
  9116. sqlParameter[3].Direction = ParameterDirection.Output;
  9117. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9118. string res = sqlParameter[3].Value.ToString();
  9119. var res_obj = new
  9120. {
  9121. data = res
  9122. };
  9123. string ro_json = JsonConvert.SerializeObject(res_obj);
  9124. returnSuccess(ro_json);
  9125. }
  9126. else
  9127. {
  9128. SqlParameter[] sqlParameter ={
  9129. new SqlParameter("@userId", SqlDbType.Int,4),
  9130. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9131. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9132. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9133. };
  9134. sqlParameter[0].Value = userId;
  9135. sqlParameter[1].Value = date1;
  9136. sqlParameter[2].Value = date2;
  9137. sqlParameter[3].Direction = ParameterDirection.Output;
  9138. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9139. string res = sqlParameter[3].Value.ToString();
  9140. var res_obj = new
  9141. {
  9142. data = res
  9143. };
  9144. string ro_json = JsonConvert.SerializeObject(res_obj);
  9145. returnSuccess(ro_json);
  9146. }
  9147. //writeGridDataViewJson(dt.Rows.Count, dv);
  9148. }
  9149. public void get_order_list()
  9150. {
  9151. string strFields = GetPostString("paraFields");
  9152. string strOrder = GetPostString("paraOrder");
  9153. string strWhere = GetPostString("paraWhere");
  9154. string strPageSize = GetPostString("paraPageSize");
  9155. DataStruct dStruct = GetPostStruct();
  9156. dStruct.PageSize = int.Parse(strPageSize);
  9157. dStruct.Fileds = strFields;
  9158. dStruct.Order = strOrder;
  9159. dStruct.MainWhere = strWhere;
  9160. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9161. writeGridDataTableJson(dStruct.TotalCount, dt);
  9162. }
  9163. ////获取待开始订单列表
  9164. //public void get_wait_design_order_list()
  9165. //{
  9166. // string date_type = GetPostString("date_type");
  9167. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9168. // DataStruct dStruct = GetPostStruct();
  9169. // dStruct.PageSize = 1000;
  9170. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9171. // List<string> lw = new List<string>();
  9172. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9173. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9174. // dStruct.Order = "WaitDesignTime asc";
  9175. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9176. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9177. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9178. //}
  9179. //获取完成单量排名
  9180. public void get_finish_order_count_ranking()
  9181. {
  9182. /* string date_type = GetPostString("date_type");
  9183. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9184. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9185. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9186. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9187. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9188. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9189. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9190. writeGridDataTableJson(0, new DataTable());
  9191. }
  9192. public void get_finish_order_amount_ranking()
  9193. {
  9194. /*string date_type = GetPostString("date_type");
  9195. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9196. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9197. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9198. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9199. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9200. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9201. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9202. writeGridDataTableJson(0, new DataTable());
  9203. }
  9204. public void get_finish_refund_count_ranking()
  9205. {
  9206. string date_type = GetPostString("date_type");
  9207. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9208. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9209. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9210. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9211. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9212. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9213. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9214. writeGridDataTableJson(dt.Rows.Count, dt);
  9215. }
  9216. public void get_finish_refund_amount_ranking()
  9217. {
  9218. string date_type = GetPostString("date_type");
  9219. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9220. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9221. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9222. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9223. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9224. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9225. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9226. writeGridDataTableJson(dt.Rows.Count, dt);
  9227. }
  9228. public void set_erp_finishorder_director()
  9229. {
  9230. if (UrlPostParmsCheck("ctid"))
  9231. {
  9232. string eid = GetPostString("ctid");
  9233. CeErpTradeCell entity = null;
  9234. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9235. if (entity != null)
  9236. {
  9237. entity.OrderState = 8;
  9238. entity.Update();
  9239. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9240. returnSuccessMsg("操作成功!");
  9241. return;
  9242. }
  9243. returnErrorMsg("找不到记录");
  9244. }
  9245. }
  9246. public void get_erp_placeregistlist()
  9247. {
  9248. DataStruct dStruct = GetPostStruct();
  9249. List<string> lw = new List<string>();
  9250. string outsid = GetPostString("outsid");
  9251. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9252. string memo = GetPostString("memo");
  9253. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9254. string filename = GetPostString("filename");
  9255. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9256. string islate = GetPostString("islate");
  9257. if (islate.Length > 0)
  9258. {
  9259. if (islate == "1")
  9260. lw.Add(string.Format("OutLate>0"));
  9261. else
  9262. lw.Add(string.Format("OutLate=0"));
  9263. }
  9264. string placedate1 = GetPostString("placedate1");
  9265. string placedate2 = GetPostString("placedate2");
  9266. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9267. if (dw.Length > 0) lw.Add(dw);
  9268. string deliveryDate1 = GetPostString("deliverydate1");
  9269. string deliveryDate2 = GetPostString("deliverydate2");
  9270. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9271. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9272. dStruct.Order = "ID desc";
  9273. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9274. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9275. writeGridDataTableJson(dStruct.TotalCount, dt);
  9276. }
  9277. public void ins_erp_placeregist()
  9278. {
  9279. if (UrlPostParmsCheck("id"))
  9280. {
  9281. string eid = GetPostString("id");
  9282. CeErpPlaceRegister entity = null;
  9283. if (eid == "0")//新增
  9284. {
  9285. entity = new CeErpPlaceRegister();
  9286. string xdTime = GetPostString("placeTime");
  9287. if (xdTime.Length > 0)
  9288. {
  9289. entity.PlactTime = Convert.ToDateTime(xdTime);
  9290. }
  9291. string fhTime = GetPostString("deliveryTime");
  9292. if (fhTime.Length > 0)
  9293. {
  9294. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9295. }
  9296. string preTime = GetPostString("preOutTime");
  9297. if (preTime.Length > 0)
  9298. {
  9299. entity.PreOutTime = Convert.ToDateTime(preTime);
  9300. }
  9301. entity.DeliveryCount = GetPostInt("deliveryCount");
  9302. entity.ReceiveCount = GetPostInt("receiveCount");
  9303. entity.OutSid = GetPostString("outSid");
  9304. entity.FileName = GetPostString("fileName");
  9305. entity.Memo = GetPostString("memo");
  9306. entity.AddUserId = CurrentUser.UserID;
  9307. entity.CreateTime = DateTime.Now;
  9308. entity.Img = GetPostString("img");
  9309. entity.Supplier = GetPostInt("supplier");
  9310. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9311. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9312. {
  9313. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9314. DateTime dt2 = (DateTime)entity.PreOutTime;
  9315. TimeSpan span = dt1.Subtract(dt2);
  9316. if (span.Days > 0)
  9317. {
  9318. entity.OutLate = span.Days;
  9319. }
  9320. }
  9321. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9322. entity.Create();
  9323. returnSuccessMsg("添加成功!");
  9324. return;
  9325. }
  9326. else //修改
  9327. {
  9328. entity = CeErpPlaceRegister.Get(eid);
  9329. if (entity != null)
  9330. {
  9331. string xdTime = GetPostString("placeTime");
  9332. if (xdTime.Length > 0)
  9333. {
  9334. entity.PlactTime = Convert.ToDateTime(xdTime);
  9335. }
  9336. string fhTime = GetPostString("deliveryTime");
  9337. if (fhTime.Length > 0)
  9338. {
  9339. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9340. }
  9341. string preTime = GetPostString("preOutTime");
  9342. if (preTime.Length > 0)
  9343. {
  9344. entity.PreOutTime = Convert.ToDateTime(preTime);
  9345. }
  9346. entity.DeliveryCount = GetPostInt("deliveryCount");
  9347. entity.ReceiveCount = GetPostInt("receiveCount");
  9348. if (entity.DeliveryCount == entity.ReceiveCount)
  9349. {
  9350. entity.CurState = "已完成";
  9351. }
  9352. else
  9353. {
  9354. entity.CurState = "未完成";
  9355. }
  9356. entity.OutSid = GetPostString("outSid");
  9357. entity.FileName = GetPostString("fileName");
  9358. entity.Memo = GetPostString("memo");
  9359. entity.Img = GetPostString("img");
  9360. entity.Supplier = GetPostInt("supplier");
  9361. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9362. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9363. {
  9364. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9365. DateTime dt2 = (DateTime)entity.PreOutTime;
  9366. TimeSpan span = dt1.Subtract(dt2);
  9367. if (span.Days > 0)
  9368. {
  9369. entity.OutLate = span.Days;
  9370. }
  9371. }
  9372. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9373. entity.Update();
  9374. returnSuccessMsg("修改成功");
  9375. return;
  9376. }
  9377. returnErrorMsg("找不到对应的记录");
  9378. return;
  9379. }
  9380. }
  9381. returnErrorMsg("缺少必要参数");
  9382. }
  9383. public void del_erp_placeregist()
  9384. {
  9385. string eid = GetPostString("id");
  9386. CeErpPlaceRegister.Del(eid);
  9387. returnSuccessMsg("删除成功!");
  9388. return;
  9389. }
  9390. public void ins_erp_placeregistbyorder()
  9391. {
  9392. string ctid = GetPostString("ctid");
  9393. if (ctid.Length > 0)
  9394. {
  9395. StringBuilder sql = new StringBuilder();
  9396. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9397. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9398. if (dt.Rows.Count > 0)
  9399. {
  9400. foreach (DataRow dr in dt.Rows)
  9401. {
  9402. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9403. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9404. entity.AddUserId = CurrentUser.UserID;
  9405. entity.tid = dr["tid"].ToString();
  9406. entity.Did = Convert.ToString(dr["ctid"]);
  9407. entity.splitTag = dr["SplitTag"].ToString();
  9408. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9409. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9410. if (pre_ctid.Length > 0)
  9411. {
  9412. sellmemo = sellmemo.Replace(pre_ctid, "");
  9413. }
  9414. sellmemo = sellmemo.Replace("[", "");
  9415. sellmemo = sellmemo.Replace("]", "");
  9416. entity.FileName = sellmemo;
  9417. string count = dr["ProductCount"].ToString();
  9418. int usecount = commonHelper.getIntCountFromString(count);
  9419. entity.DeliveryCount = usecount;
  9420. entity.CurState = "未完成";
  9421. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9422. {
  9423. entity.Supplier = 24;//dl手提袋定制
  9424. }
  9425. else
  9426. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9427. entity.CreateTime = DateTime.Now;
  9428. entity.Create();
  9429. }
  9430. returnSuccessMsg("操作成功");
  9431. return;
  9432. }
  9433. returnErrorMsg("没有找到对应订单");
  9434. return;
  9435. }
  9436. returnErrorMsg("缺少订单编号");
  9437. return;
  9438. }
  9439. public void get_erp_persuadelist()
  9440. {
  9441. DataStruct dStruct = GetPostStruct();
  9442. List<string> lw = new List<string>();
  9443. string ctid = GetPostString("ctid");
  9444. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9445. string shopname = GetPostString("shopname");
  9446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9447. string buyernick = GetPostString("buyer_nick");
  9448. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9449. string customer = GetPostString("customer");
  9450. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9451. string returndate1 = GetPostString("returndate1");
  9452. string returndate2 = GetPostString("returndate2");
  9453. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9454. if (dw.Length > 0) lw.Add(dw);
  9455. string finishDate1 = GetPostString("finishdate1");
  9456. string finishDate2 = GetPostString("finishdate2");
  9457. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9458. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9459. string persuadetype = GetPostString("persuadetype");
  9460. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9461. string returnvstate = GetPostString("returnvstate");
  9462. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9463. dStruct.Order = "created desc";
  9464. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9465. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9466. writeGridDataTableJson(dStruct.TotalCount, dt);
  9467. }
  9468. public void upd_erp_returnpersuadeback()
  9469. {
  9470. if (UrlPostParmsCheck("ID"))
  9471. {
  9472. int eid = GetPostInt("ID");
  9473. CeErpPersuade entity = null;
  9474. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9475. if (entity != null)
  9476. {
  9477. entity.backreason = GetPostString("reason");
  9478. entity.pstate = 2;
  9479. entity.verifytime = DateTime.Now;
  9480. entity.verifyuserid = CurrentUser.UserID;
  9481. entity.Update();
  9482. returnSuccessMsg("退回成功!");
  9483. return;
  9484. }
  9485. returnErrorMsg("找不到订单记录");
  9486. }
  9487. }
  9488. public void upd_erp_returnpersuadeverify()
  9489. {
  9490. if (UrlPostParmsCheck("ID"))
  9491. {
  9492. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9493. {
  9494. returnErrorMsg("暂无权限审核");
  9495. return;
  9496. }
  9497. int eid = GetPostInt("ID");
  9498. CeErpPersuade entity = null;
  9499. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9500. if (entity != null)
  9501. {
  9502. entity.pstate = 1;
  9503. entity.verifytime = DateTime.Now;
  9504. entity.verifyuserid = CurrentUser.UserID;
  9505. entity.Update();
  9506. returnSuccessMsg("审核成功!");
  9507. return;
  9508. }
  9509. returnErrorMsg("找不到订单记录");
  9510. }
  9511. }
  9512. public void del_erp_persuade()
  9513. {
  9514. if (UrlPostParmsCheck("ID"))
  9515. {
  9516. int eid = GetPostInt("ID");
  9517. CeErpPersuade.Del(eid);
  9518. returnSuccessMsg("操作成功");
  9519. return;
  9520. }
  9521. }
  9522. public void get_erp_oldcustoupload()
  9523. {
  9524. DataStruct dStruct = GetPostStruct();
  9525. List<string> lw = new List<string>();
  9526. string buyernick = GetPostString("buyer_nick");
  9527. if (buyernick.Length > 0)
  9528. {
  9529. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9530. }
  9531. else
  9532. return;
  9533. dStruct.Order = "pay_time desc";
  9534. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9535. DataTable dt = null;
  9536. dt = WebCache.GetData("view_erptradecell", dStruct);
  9537. writeGridDataTableJson(dStruct.TotalCount, dt);
  9538. }
  9539. public void get_erp_checkorderlist()
  9540. {
  9541. DataStruct dStruct = GetPostStruct();
  9542. List<string> lw = new List<string>();
  9543. string tid = GetPostString("ctid");
  9544. if (tid.Length > 0)
  9545. {
  9546. string select_tid = getTidByCtid(tid);
  9547. lw.Add(string.Format("tid='{0}'", select_tid));
  9548. }
  9549. string shopname = GetPostString("shopname");
  9550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9551. string buyernick = GetPostString("buyer_nick");
  9552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9553. string customer = GetPostString("customer");
  9554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9555. string design = GetPostString("design");
  9556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9557. string orderState = GetPostString("orderState");
  9558. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9559. string address = GetPostString("address");
  9560. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9561. string sellermemo = GetPostString("seller_memo");
  9562. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9563. string supplier = GetPostString("supplier");
  9564. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9565. {
  9566. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9567. }
  9568. else
  9569. {
  9570. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9571. }
  9572. string date1 = GetPostString("date1");
  9573. string date2 = GetPostString("date2");
  9574. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9575. if (dw.Length > 0) lw.Add(dw);
  9576. string placedate1 = GetPostString("placedate1");
  9577. string placedate2 = GetPostString("placedate2");
  9578. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9579. if (fdw.Length > 0) lw.Add(fdw);
  9580. string price1 = GetPostString("price1");
  9581. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9582. string price2 = GetPostString("price2");
  9583. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9584. string checkst = GetPostString("checkstate");
  9585. if (checkst.Length > 0 && "10".Equals(checkst))
  9586. {
  9587. lw.Add(string.Format("CheckOut>0"));
  9588. }
  9589. else
  9590. {
  9591. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9592. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9593. }
  9594. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9595. {
  9596. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9597. }
  9598. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9599. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9600. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9601. writeGridDataTableJson(dStruct.TotalCount, dt);
  9602. }
  9603. public void ins_erp_startCheck()
  9604. {
  9605. if (UrlPostParmsCheck("ctid"))
  9606. {
  9607. string eid = GetPostString("ctid");
  9608. CeErpTradeCell entity = null;
  9609. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9610. if (entity != null)
  9611. {
  9612. entity.MemoOpt = 4;
  9613. entity.UpdateTime = DateTime.Now;
  9614. entity.Update();
  9615. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9616. CeErpSukuraData.createInfo(entity.ctid, 6);
  9617. returnSuccessMsg("操作成功!");
  9618. return;
  9619. }
  9620. returnErrorMsg("找不到记录");
  9621. }
  9622. }
  9623. public void upd_erp_sendXlw()
  9624. {
  9625. if (UrlPostParmsCheck("ctid"))
  9626. {
  9627. string eid = GetPostString("ctid");
  9628. CeErpTradeCell entity = null;
  9629. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9630. if (entity != null)
  9631. {
  9632. if (entity.IsSendGift == 1)
  9633. {
  9634. returnErrorMsg("请勿重复标记");
  9635. return;
  9636. }
  9637. entity.IsSendGift = 1;
  9638. entity.Update();
  9639. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9640. returnSuccessMsg("操作成功!");
  9641. return;
  9642. }
  9643. returnErrorMsg("找不到记录");
  9644. }
  9645. }
  9646. public void cancel_sendXlw()
  9647. {
  9648. if (UrlPostParmsCheck("ctid"))
  9649. {
  9650. string eid = GetPostString("ctid");
  9651. CeErpTradeCell entity = null;
  9652. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9653. if (entity != null)
  9654. {
  9655. if (entity.IsSendGift == 0)
  9656. {
  9657. returnErrorMsg("未标记小礼物");
  9658. return;
  9659. }
  9660. entity.IsSendGift = 0;
  9661. entity.Update();
  9662. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9663. returnSuccessMsg("操作成功!");
  9664. return;
  9665. }
  9666. returnErrorMsg("找不到记录");
  9667. }
  9668. }
  9669. public void get_erp_designbill()
  9670. {
  9671. DataStruct dStruct = GetPostStruct();
  9672. List<string> lw = new List<string>();
  9673. int isMy = GetInt("my");
  9674. if (isMy == 1)
  9675. {
  9676. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9677. }
  9678. string tid = GetPostString("tid");
  9679. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9680. string userName = GetPostString("design");
  9681. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9682. string price1 = GetPostString("price1");
  9683. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9684. string price2 = GetPostString("price2");
  9685. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9686. string rePrice1 = GetPostString("rePrice1");
  9687. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9688. string rePrice2 = GetPostString("rePrice2");
  9689. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9690. string designerType = GetPostString("designerType");
  9691. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9692. string orderState = GetPostString("orderState");
  9693. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9694. string endTime1 = GetPostString("endTime1");
  9695. string endTime2 = GetPostString("endTime2");
  9696. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9697. if (dw.Length > 0) lw.Add(dw);
  9698. string isDk = GetPostString("isDk");
  9699. if (isDk == "1")
  9700. {
  9701. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9702. }
  9703. else if (isDk == "0")
  9704. {
  9705. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9706. }
  9707. dStruct.Order = "oid, create_time desc";
  9708. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9709. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9710. writeGridDataTableJson(dStruct.TotalCount, dt);
  9711. }
  9712. public void upd_erp_designerbill()
  9713. {
  9714. if (UrlPostParmsCheck("ID"))
  9715. {
  9716. string eid = GetPostString("ID");
  9717. CeErpDesignerBill entity = null;
  9718. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9719. if (entity != null)
  9720. {
  9721. if (GetPostDouble("designerpirce") > 0)
  9722. {
  9723. entity.realPrice = GetPostDouble("designerpirce");
  9724. entity.update_time = DateTime.Now;
  9725. entity.update_u_id = CurrentUser.UserID;
  9726. entity.update_u_name = CurrentUser.UserName;
  9727. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9728. entity.Update();
  9729. returnSuccessMsg("操作成功!");
  9730. return;
  9731. }
  9732. else
  9733. {
  9734. entity.price = GetPostDouble("price");
  9735. entity.update_time = DateTime.Now;
  9736. entity.update_u_id = CurrentUser.UserID;
  9737. entity.update_u_name = CurrentUser.UserName;
  9738. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9739. entity.Update();
  9740. returnSuccessMsg("操作成功!");
  9741. return;
  9742. }
  9743. }
  9744. returnErrorMsg("找不到记录");
  9745. }
  9746. }
  9747. public void audit_erp_designerbill()
  9748. {
  9749. if (UrlPostParmsCheck("ID"))
  9750. {
  9751. string eid = GetPostString("ID");
  9752. CeErpDesignerBill entity = null;
  9753. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9754. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9755. if (entity != null)
  9756. {
  9757. entity.realPrice = GetPostDouble("designerpirce");
  9758. entity.update_time = DateTime.Now;
  9759. entity.update_u_id = CurrentUser.UserID;
  9760. entity.update_u_name = CurrentUser.UserName;
  9761. entity.isAudit = 1;
  9762. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9763. entity.Update();
  9764. if (orderEntity != null)
  9765. {
  9766. orderEntity.IsReadTag = 3;
  9767. orderEntity.Update();
  9768. }
  9769. returnSuccessMsg("操作成功!");
  9770. return;
  9771. }
  9772. returnErrorMsg("找不到记录");
  9773. }
  9774. }
  9775. public void all_audit_erp_designerbill()
  9776. {
  9777. if (UrlPostParmsCheck("idList"))
  9778. {
  9779. string[] list = GetPostString("idList").Split(',');
  9780. CeErpDesignerBill entity = null;
  9781. for (int i = 0; i < list.Length; i++)
  9782. {
  9783. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9784. if (entity == null) return;
  9785. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9786. if (orderEntity == null) return;
  9787. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9788. entity.update_time = DateTime.Now;
  9789. entity.update_u_id = CurrentUser.UserID;
  9790. entity.update_u_name = CurrentUser.UserName;
  9791. entity.isAudit = 1;
  9792. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9793. entity.Update();
  9794. orderEntity.IsReadTag = 3;
  9795. orderEntity.Update();
  9796. }
  9797. returnSuccessMsg("操作成功!");
  9798. return;
  9799. }
  9800. }
  9801. public void get_erp_sameorders()
  9802. {
  9803. if (UrlPostParmsCheck("ctid"))
  9804. {
  9805. string eid = GetPostString("ctid");
  9806. CeErpTradeCell entity = null;
  9807. entity = CeErpTradeCell.GetByCtid(eid);
  9808. if (entity != null)
  9809. {
  9810. StringBuilder sql = new StringBuilder();
  9811. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9812. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9813. var res = new
  9814. {
  9815. data = dt.Rows.Count
  9816. };
  9817. string ro_jsond = JsonConvert.SerializeObject(res);
  9818. returnSuccess(ro_jsond);
  9819. return;
  9820. }
  9821. returnErrorMsg("未找到订单");
  9822. return;
  9823. }
  9824. returnErrorMsg("缺少必要的参数");
  9825. }
  9826. public void get_erp_islasthavesameorder()
  9827. {
  9828. if (UrlPostParmsCheck("ctid"))
  9829. {
  9830. string eid = GetPostString("ctid");
  9831. string[] ctidList = eid.Split(',');
  9832. StringBuilder sql = new StringBuilder();
  9833. string tisCtid = "";
  9834. foreach (string ctid in ctidList)
  9835. {
  9836. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9837. if (entity != null)
  9838. {
  9839. sql = new StringBuilder();
  9840. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9841. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9842. if (dth.Rows.Count > 0)
  9843. {
  9844. tisCtid += entity.ctid;
  9845. tisCtid += ",";
  9846. }
  9847. }
  9848. }
  9849. if (tisCtid.Length > 0)
  9850. {
  9851. var res = new
  9852. {
  9853. data = tisCtid
  9854. };
  9855. string ro_jsond = JsonConvert.SerializeObject(res);
  9856. returnSuccess(ro_jsond);
  9857. }
  9858. else
  9859. {
  9860. var res = new
  9861. {
  9862. data = ""
  9863. };
  9864. string ro_jsond = JsonConvert.SerializeObject(res);
  9865. returnSuccess(ro_jsond);
  9866. }
  9867. return;
  9868. }
  9869. returnErrorMsg("缺少必要的参数");
  9870. }
  9871. public void file_client_down_url()
  9872. {
  9873. if (!UrlPostParmsCheck("userId"))
  9874. {
  9875. returnErrorMsg("缺少必要的参数");
  9876. }
  9877. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9878. }
  9879. public void checkout_form_data()
  9880. {
  9881. if (!UrlPostParmsCheck("tid"))
  9882. {
  9883. returnErrorMsg("缺少必要的参数");
  9884. }
  9885. string tid = GetPostString("tid");
  9886. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9887. if (ceErpOrderFormData != null)
  9888. {
  9889. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9890. returnSuccess(ro_jsond);
  9891. return;
  9892. }
  9893. returnErrorMsg("尚未有文件!");
  9894. }
  9895. public void back_supplier_audit()
  9896. {
  9897. int userId = CurrentUser.UserID;
  9898. StringBuilder sql = new StringBuilder();
  9899. 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);
  9900. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9901. if (dt.Rows.Count > 0)
  9902. {
  9903. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9904. }
  9905. else
  9906. {
  9907. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9908. }
  9909. }
  9910. public void back_supplier_query()
  9911. {
  9912. string eid = GetPostString("ctid");
  9913. if (eid != "")
  9914. {
  9915. StringBuilder sql = new StringBuilder();
  9916. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9917. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9918. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9919. }
  9920. else
  9921. {
  9922. returnErrorMsg("找不到订单记录");
  9923. return;
  9924. }
  9925. }
  9926. public void verified_to_order()
  9927. {
  9928. int userId = CurrentUser.UserID;
  9929. StringBuilder sql = new StringBuilder();
  9930. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9931. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9932. if (dt.Rows.Count > 0)
  9933. {
  9934. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9935. }
  9936. else
  9937. {
  9938. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9939. }
  9940. }
  9941. public void upd_supplier_audit()
  9942. {
  9943. if (UrlPostParmsCheck("ctid"))
  9944. {
  9945. string eid = GetPostString("ctid");
  9946. string reason = GetPostString("returnreason");
  9947. CeErpTradeCell entity = null;
  9948. CeWithdraw withdraw = null;
  9949. withdraw = CeWithdraw.GetByTid(eid);
  9950. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9951. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9952. {
  9953. if (withdraw != null)
  9954. {
  9955. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9956. {
  9957. returnSuccessMsg("您没有权限操作!");
  9958. return;
  9959. }
  9960. else
  9961. {
  9962. if (reason.Equals("1"))
  9963. {
  9964. if (entity.OrderState == -1)
  9965. {
  9966. if (entity.FinishPlaceTime == null)
  9967. {
  9968. entity.OrderState = 2;
  9969. }
  9970. else
  9971. {
  9972. entity.OrderState = 6;
  9973. }
  9974. }
  9975. entity.Update();
  9976. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9977. if (withdraw != null)
  9978. {
  9979. withdraw.status = int.Parse(reason);
  9980. withdraw.Update();
  9981. }
  9982. returnSuccessMsg("操作成功!");
  9983. return;
  9984. }
  9985. else
  9986. {
  9987. withdraw.status = int.Parse(reason);
  9988. withdraw.acknowledgingtime = DateTime.Now;
  9989. withdraw.Update();
  9990. returnSuccessMsg("查看详细请点击线下订单查询");
  9991. return;
  9992. }
  9993. }
  9994. }
  9995. // 第一个字符是 'N'
  9996. }
  9997. if (eid[0] != 'N')
  9998. {
  9999. }
  10000. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10001. {
  10002. entity.IsVerifyToSupplier = false;
  10003. entity.IsReturn = 1;
  10004. entity.ReturnTime = DateTime.Now;
  10005. entity.ReturnReason = reason;
  10006. if (entity.OrderState == 6)
  10007. {
  10008. entity.OrderState = 5;
  10009. }
  10010. entity.Update();
  10011. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10012. if (withdraw != null)
  10013. {
  10014. withdraw.status = int.Parse(reason);
  10015. withdraw.Update();
  10016. }
  10017. returnSuccessMsg("操作成功!");
  10018. return;
  10019. }
  10020. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10021. {
  10022. ;
  10023. if (withdraw != null)
  10024. {
  10025. withdraw.status = int.Parse(reason);
  10026. withdraw.acknowledgingtime = DateTime.Now;
  10027. withdraw.Update();
  10028. returnSuccessMsg("供应商取消撤回!");
  10029. return;
  10030. }
  10031. }
  10032. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10033. {
  10034. if (entity.OrderState == -1)
  10035. {
  10036. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10037. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10038. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10039. {
  10040. returnErrorMsg("台湾客户需填写身份证!");
  10041. return;
  10042. }
  10043. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10044. {
  10045. returnErrorMsg("偏远地区需要填写物流费!");
  10046. return;
  10047. }
  10048. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10049. {
  10050. returnErrorMsg("订单spu没有确认无法通过审核!");
  10051. return;
  10052. }
  10053. if (entity.FinishPlaceTime == null)
  10054. {
  10055. entity.OrderState = 2;
  10056. }
  10057. else
  10058. {
  10059. entity.OrderState = 3;
  10060. }
  10061. commonHelper.getCytPrice(entity);
  10062. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10063. {
  10064. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10065. }
  10066. }
  10067. entity.Update();
  10068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10069. if (withdraw != null)
  10070. {
  10071. withdraw.status = int.Parse(reason);
  10072. withdraw.Update();
  10073. }
  10074. returnSuccessMsg("操作成功!");
  10075. return;
  10076. }
  10077. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10078. {
  10079. if (withdraw == null)
  10080. {
  10081. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10082. return;
  10083. }
  10084. }
  10085. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10086. {
  10087. if (withdraw != null)
  10088. {
  10089. withdraw.status = int.Parse(reason);
  10090. withdraw.acknowledgingtime = DateTime.Now;
  10091. withdraw.Update();
  10092. returnSuccessMsg("查看详细请点击线下订单查询");
  10093. return;
  10094. }
  10095. }
  10096. return;
  10097. }
  10098. }
  10099. //校验报价
  10100. public void refund_order_tip()
  10101. {
  10102. int userid = CurrentUser.UserID;
  10103. int sectionId = CurrentUser.UserPost.OrgID;
  10104. StringBuilder sql = new StringBuilder();
  10105. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10106. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10107. List<string> ids = new List<string>();
  10108. if (dth.Rows.Count > 0)
  10109. {
  10110. foreach (DataRow dr in dth.Rows)
  10111. {
  10112. ids.Add(dr["ID"].ToString());
  10113. }
  10114. try
  10115. {
  10116. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10117. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10118. }
  10119. catch (Exception ex)
  10120. {
  10121. }
  10122. }
  10123. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10124. }
  10125. public void refund_order_Design()
  10126. {
  10127. int userid = CurrentUser.UserID;
  10128. int sectionId = CurrentUser.UserPost.OrgID;
  10129. StringBuilder sql = new StringBuilder();
  10130. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10131. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10132. List<string> ids = new List<string>();
  10133. if (dth.Rows.Count > 0)
  10134. {
  10135. foreach (DataRow dr in dth.Rows)
  10136. {
  10137. ids.Add(dr["ID"].ToString());
  10138. }
  10139. try
  10140. {
  10141. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10142. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10143. }
  10144. catch (Exception ex)
  10145. {
  10146. }
  10147. }
  10148. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10149. }
  10150. public void change_order_info()
  10151. {
  10152. int userid = CurrentUser.UserID;
  10153. StringBuilder sql = new StringBuilder();
  10154. 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);
  10155. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10156. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10157. }
  10158. public void change_win_mome()
  10159. {
  10160. if (UrlPostParmsCheck("id,ctid"))
  10161. {
  10162. string id = GetPostString("id");
  10163. string ctid = GetPostString("ctid");
  10164. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10165. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10166. if (ce == null || ceErpMessageTip == null)
  10167. {
  10168. returnSuccessMsg("未找到对应的订单!");
  10169. return;
  10170. }
  10171. if (ce.OrderState >= 5)
  10172. {
  10173. ceErpMessageTip.isVisit = true;
  10174. ceErpMessageTip.Update();
  10175. returnSuccessMsg("已上传文件无法修改!");
  10176. return;
  10177. }
  10178. int type = GetPostInt("type");
  10179. string content = GetPostString("content");
  10180. if (type == 0)
  10181. {
  10182. content = content.Replace("(", "(");
  10183. content = content.Replace(")", ")");
  10184. string check = MidStrEx(content, "(", ")").Trim();
  10185. if (string.IsNullOrEmpty(check))
  10186. {
  10187. returnSuccessMsg("文件名格式不正确");
  10188. return;
  10189. }
  10190. }
  10191. ce.seller_memo = content;
  10192. ce.Update();
  10193. ceErpMessageTip.isVisit = true;
  10194. ceErpMessageTip.Update();
  10195. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10196. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10197. ApiVo apiVo = new ApiVo();
  10198. apiVo.orderNumber = ce.ctid;
  10199. apiVo.actionName = "demandDesign";
  10200. apiVo.orderRemarks = content;
  10201. apiVo.demandExamine = type + 1;
  10202. designHelper.API_WorkCore(apiVo);//demandDesign
  10203. returnSuccessMsg("修改成功!");
  10204. }
  10205. }
  10206. public static string MidStrEx(string sourse, string startstr, string endstr)
  10207. {
  10208. string result = string.Empty;
  10209. int startindex, endindex;
  10210. try
  10211. {
  10212. startindex = sourse.IndexOf(startstr);
  10213. if (startindex == -1)
  10214. return result;
  10215. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10216. endindex = tmpstr.IndexOf(endstr);
  10217. if (endindex == -1)
  10218. return result;
  10219. result = tmpstr.Remove(endindex);
  10220. }
  10221. catch (Exception ex)
  10222. {
  10223. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10224. }
  10225. return result;
  10226. }
  10227. public void refund_order_list()
  10228. {
  10229. int userid = CurrentUser.UserID;
  10230. int sectionId = CurrentUser.UserPost.OrgID;
  10231. StringBuilder sql = new StringBuilder();
  10232. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10233. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10234. DataStruct dStruct = GetPostStruct();
  10235. DataTable dt = null;
  10236. List<string> ids = new List<string>();
  10237. List<string> tids = new List<string>();
  10238. if (dth.Rows.Count > 0)
  10239. {
  10240. foreach (DataRow dr in dth.Rows)
  10241. {
  10242. tids.Add("'" + dr["tid"].ToString() + "'");
  10243. ids.Add(dr["id"].ToString());
  10244. }
  10245. try
  10246. {
  10247. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10248. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10249. List<string> lw = new List<string>();
  10250. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10251. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10252. dt = WebCache.GetData("view_orderlist", dStruct);
  10253. }
  10254. catch (Exception ex)
  10255. {
  10256. }
  10257. }
  10258. writeGridDataTableJson(dStruct.TotalCount, dt);
  10259. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10260. }
  10261. //新增
  10262. public void order_batch_downloads()
  10263. {
  10264. string ceid = GetPostString("tid");
  10265. String[] tid = ceid.Split(',');
  10266. order_batch_caiyingtong(tid);
  10267. /* (string success, string errors) = UploadFiles(tid);
  10268. returnSuccessMsg(success + errors);*/
  10269. return;
  10270. }
  10271. //报价接口
  10272. public void Get_To_Quote()
  10273. {
  10274. string ceid = GetPostString("ctid");
  10275. if (ceid != null)
  10276. {
  10277. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10278. if (entity != null)
  10279. {
  10280. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10281. {
  10282. return;
  10283. }
  10284. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10285. double price = 0;
  10286. if (cp == null)
  10287. {
  10288. JObject jsonObject12 = new JObject
  10289. {
  10290. { "UserId", "77886" },
  10291. { "Pwd", "lt666888" },
  10292. { "Filename", entity.seller_memo }
  10293. };
  10294. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10295. JObject jsonObjects1 = JObject.Parse(response1);
  10296. string ms1g = (string)jsonObjects1["msg"];
  10297. if (ms1g == "报价成功")
  10298. {
  10299. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10300. string data = (string)jsonObject1["price"];
  10301. 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 + "');";
  10302. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10303. returnSuccessMsg("获取报价成功:" + data);
  10304. price = Convert.ToDouble(data);
  10305. }
  10306. else
  10307. {
  10308. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10309. return;
  10310. }
  10311. }
  10312. String[] beizhu = entity.seller_memo.Split('-');
  10313. String chanp = "";
  10314. if (beizhu.Length > 0)
  10315. {
  10316. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10317. }
  10318. else
  10319. {
  10320. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10321. }
  10322. JObject jsonObject = new JObject
  10323. {
  10324. { "UserId", "77886" },
  10325. { "Pwd", "lt666888" },
  10326. { "Filename", chanp }
  10327. };
  10328. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10329. JObject jsonObjects = JObject.Parse(response);
  10330. string msg = (string)jsonObjects["msg"];
  10331. if (msg == "报价成功")
  10332. {
  10333. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10334. string data = (string)jsonObject1["price"];
  10335. 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 + "');";
  10336. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10337. returnSuccessMsg("获取报价成功:" + data);
  10338. price = Convert.ToDouble(data);
  10339. }
  10340. else
  10341. {
  10342. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10343. return;
  10344. }
  10345. if (price > 0)
  10346. {
  10347. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10348. if (ceErpTradeCellExtend == null)
  10349. {
  10350. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10351. ceErpTradeCellExtend.ctid = entity.ctid;
  10352. ceErpTradeCellExtend.payment_cyt = price;
  10353. ceErpTradeCellExtend.Create();
  10354. }
  10355. else
  10356. {
  10357. ceErpTradeCellExtend.payment_cyt = price;
  10358. ceErpTradeCellExtend.Update();
  10359. }
  10360. }
  10361. return;
  10362. }
  10363. }
  10364. else
  10365. {
  10366. returnErrorMsg("请至少选择一条数据");
  10367. return;
  10368. }
  10369. }
  10370. //新增
  10371. public void order_To_Supplier()
  10372. {
  10373. string ceid = GetPostString("tid");
  10374. String[] tid = ceid.Split(',');
  10375. if (tid.Length > 0)
  10376. {
  10377. try
  10378. {
  10379. for (int i = 0; i < tid.Length; i++)
  10380. {
  10381. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10382. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10383. entity.SupplierId = suid;
  10384. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10385. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10386. entity.Update();
  10387. }
  10388. }
  10389. catch (Exception ex)
  10390. {
  10391. returnErrorMsg("自动匹配供应商失败");
  10392. return;
  10393. }
  10394. }
  10395. else
  10396. {
  10397. returnErrorMsg("请至少选择一条数据");
  10398. return;
  10399. }
  10400. returnSuccessMsg("自动匹配供应商成功");
  10401. return;
  10402. }
  10403. public (string, string) UploadFiles(string[] urls)
  10404. {
  10405. string success = "";
  10406. string errors = "";
  10407. int userid = CurrentUser.UserID;
  10408. foreach (string url in urls)
  10409. {
  10410. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10411. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10412. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10413. {
  10414. JObject jsonObject = new JObject
  10415. {
  10416. { "Userid", "77886" },
  10417. { "pwd", "cyt86435015" },
  10418. { "content", base64FileContent },
  10419. { "ext", Path.GetExtension(fileName) }
  10420. };
  10421. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10422. JObject jsonObjects = JObject.Parse(response);
  10423. string msg = (string)jsonObjects["msg"];
  10424. if (msg.Equals("上传成功"))
  10425. {
  10426. success += url + " 上传成功";
  10427. }
  10428. else
  10429. {
  10430. errors += url + " 上传失败";
  10431. }
  10432. }
  10433. else
  10434. {
  10435. errors += url + " 格式出现问题";
  10436. }
  10437. }
  10438. if (urls.Length == 0)
  10439. {
  10440. return (success, errors);
  10441. }
  10442. return (success, errors);
  10443. }
  10444. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10445. {
  10446. return true; //总是接受
  10447. }
  10448. public static string HttpPost(string url, string param = null)
  10449. {
  10450. HttpWebRequest request;
  10451. //如果是发送HTTPS请求
  10452. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10453. {
  10454. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10455. request = WebRequest.Create(url) as HttpWebRequest;
  10456. request.ProtocolVersion = HttpVersion.Version10;
  10457. }
  10458. else
  10459. {
  10460. request = WebRequest.Create(url) as HttpWebRequest;
  10461. }
  10462. request.Method = "POST";
  10463. request.ContentType = "application/json";
  10464. request.Accept = "*/*";
  10465. request.Timeout = 120000;
  10466. request.AllowAutoRedirect = false;
  10467. StreamWriter requestStream = null;
  10468. WebResponse response = null;
  10469. string responseStr = null;
  10470. try
  10471. {
  10472. requestStream = new StreamWriter(request.GetRequestStream());
  10473. requestStream.Write(param);
  10474. requestStream.Close();
  10475. response = request.GetResponse();
  10476. if (response != null)
  10477. {
  10478. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10479. responseStr = reader.ReadToEnd();
  10480. reader.Close();
  10481. }
  10482. }
  10483. catch (Exception ex)
  10484. {
  10485. return ex.Message;
  10486. }
  10487. finally
  10488. {
  10489. request = null;
  10490. requestStream = null;
  10491. response = null;
  10492. }
  10493. return responseStr;
  10494. }
  10495. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10496. {
  10497. string base64FileContent;
  10498. string fileName;
  10499. using (WebClient webClient = new WebClient())
  10500. {
  10501. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10502. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10503. {
  10504. using (Stream stream = response.GetResponseStream())
  10505. {
  10506. using (MemoryStream memoryStream = new MemoryStream())
  10507. {
  10508. stream.CopyTo(memoryStream);
  10509. byte[] fileBytes = memoryStream.ToArray();
  10510. base64FileContent = Convert.ToBase64String(fileBytes);
  10511. fileName = response.Headers["Content-Disposition"];
  10512. if (!string.IsNullOrEmpty(fileName))
  10513. {
  10514. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10515. if (index >= 0)
  10516. {
  10517. fileName = fileName.Substring(index + 9).Trim('\"');
  10518. }
  10519. }
  10520. else
  10521. {
  10522. fileName = Path.GetFileName(downloadUrl);
  10523. }
  10524. }
  10525. }
  10526. }
  10527. }
  10528. return (fileName, base64FileContent);
  10529. }
  10530. //新增
  10531. public void order_batch_caiyingtong(string[] downloadUrls)
  10532. {
  10533. try
  10534. {
  10535. //遍历文件
  10536. DataStruct dStruct = GetPostStruct();
  10537. DataTable dt = null;
  10538. int userid = CurrentUser.UserID;
  10539. List<string> ids = new List<string>();//失败组
  10540. List<string> tids = new List<string>();
  10541. using (WebClient webClient = new WebClient())
  10542. {
  10543. foreach (var url in downloadUrls)
  10544. {
  10545. try
  10546. {
  10547. tids.Add("'" + url + "'");
  10548. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10549. if (entity != null)
  10550. {
  10551. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10552. if (cp == null)
  10553. {
  10554. JObject jsonObject = new JObject
  10555. {
  10556. { "Userid", "77886" },
  10557. { "pwd", "lt666888" },
  10558. { "Filename",entity.seller_memo }
  10559. };
  10560. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10561. JObject jsonObjects = JObject.Parse(response);
  10562. string msg = (string)jsonObjects["msg"];
  10563. if (msg == "报价成功")
  10564. {
  10565. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10566. DownloadAndConvertToBase64(url1);
  10567. }
  10568. else
  10569. {
  10570. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10571. }
  10572. }
  10573. else
  10574. {
  10575. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10576. JObject jsonObject = new JObject
  10577. {
  10578. { "Userid", "77886" },
  10579. { "pwd", "lt666888" },
  10580. { "Filename",chanp }
  10581. };
  10582. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10583. JObject jsonObjects = JObject.Parse(response);
  10584. string msg = (string)jsonObjects["msg"];
  10585. if (msg == "报价成功")
  10586. {
  10587. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10588. DownloadAndConvertToBase64(url1);
  10589. }
  10590. else
  10591. {
  10592. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10593. }
  10594. }
  10595. }
  10596. // 上传文件到FTP
  10597. }
  10598. catch (Exception ex)
  10599. {
  10600. Console.WriteLine($"An error occurred: {ex.Message}");
  10601. }
  10602. }
  10603. List<string> lw = new List<string>();
  10604. lw.Add(string.Format("( OrderState < 6 )"));
  10605. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10607. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10608. if (dt.Rows.Count > 0)
  10609. {
  10610. foreach (DataRow dr in dt.Rows)
  10611. {
  10612. ids.Add(dr["ctid"].ToString());
  10613. }
  10614. }
  10615. String ErrorMsgs = "";
  10616. foreach (String id in ids)
  10617. {
  10618. ErrorMsgs += id + ",";
  10619. }
  10620. if (ErrorMsgs.Length > 1)
  10621. {
  10622. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10623. }
  10624. if (ErrorMsgs.Length < 1)
  10625. {
  10626. ErrorMsgs = "上传成功";
  10627. returnSuccessMsg(ErrorMsgs);
  10628. }
  10629. else
  10630. {
  10631. returnErrorMsg("以下订单" + ErrorMsgs);
  10632. }
  10633. }
  10634. // 删除文件夹及其内容
  10635. /* Directory.Delete(localDirectory, true);*/
  10636. }
  10637. catch { }
  10638. }
  10639. public void get_center_data()
  10640. {
  10641. int userId = CurrentUser.UserID;
  10642. string postCode = CurrentUser.UserPost.Post.Code;
  10643. List<string> lw = new List<string>();
  10644. List<string> ww = new List<string>();
  10645. DateTime currentTime = DateTime.Now;
  10646. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10647. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10648. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10649. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10650. string sql = " SELECT ";
  10651. string startTime = "2023-10-01 11:22:31";
  10652. //设计
  10653. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10654. {
  10655. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10656. 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));
  10657. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10658. 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));
  10659. }
  10660. //客服
  10661. else if (postCode == "CustomerService" || postCode == "Director")
  10662. {
  10663. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10664. 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));
  10665. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10666. 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));
  10667. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10668. 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));
  10669. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10670. 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));
  10671. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10672. 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));
  10673. }
  10674. //售后
  10675. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10676. {
  10677. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10678. 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));
  10679. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10680. 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));
  10681. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10682. 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));
  10683. }
  10684. //下单部
  10685. else if (postCode == "Place" || postCode == "PlaceMr")
  10686. {
  10687. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10688. 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));
  10689. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10690. 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));
  10691. }
  10692. //车间
  10693. else if (postCode == "Supplier")
  10694. {
  10695. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10696. 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));
  10697. }
  10698. DataTable dt = new DataTable();
  10699. if (lw.Count > 0)
  10700. {
  10701. sql += string.Join(" , ", lw);
  10702. sql += " FROM ";
  10703. sql += string.Join(" , ", ww);
  10704. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10705. }
  10706. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10707. }
  10708. public void get_center_data_list()
  10709. {
  10710. int userId = CurrentUser.UserID;
  10711. string postCode = CurrentUser.UserPost.Post.Code;
  10712. string shopIds = CurrentUser.User.pemShop;
  10713. DataStruct dStruct = GetPostStruct();
  10714. List<string> lw = new List<string>();
  10715. DateTime currentTime = DateTime.Now;
  10716. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10717. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10718. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10719. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10720. string startTime = "2023-10-01 11:22:31";
  10721. int order_type = GetPostInt("order_type");
  10722. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10723. {
  10724. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10725. if (order_type == 0)
  10726. {
  10727. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10728. }
  10729. else if (order_type == 3)
  10730. {
  10731. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10732. }
  10733. else
  10734. {
  10735. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10736. }
  10737. }
  10738. //客服
  10739. if (postCode == "CustomerService" || postCode == "Director")
  10740. {
  10741. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10742. if (order_type == 0)
  10743. {
  10744. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10745. }
  10746. else if (order_type == 1)
  10747. {
  10748. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10749. }
  10750. else if (order_type == 2)
  10751. {
  10752. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10753. }
  10754. else if (order_type == 3)
  10755. {
  10756. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10757. }
  10758. else if (order_type == 4)
  10759. {
  10760. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10761. }
  10762. else
  10763. {
  10764. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10765. }
  10766. }
  10767. //售后
  10768. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10769. {
  10770. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10771. if (shopIds != "")
  10772. {
  10773. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10774. }
  10775. if (order_type == 2)
  10776. {
  10777. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10778. }
  10779. else if (order_type == 4)
  10780. {
  10781. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10782. }
  10783. else if (order_type == 5)
  10784. {
  10785. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10786. }
  10787. else
  10788. {
  10789. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10790. }
  10791. }
  10792. //下单部
  10793. if (postCode == "Place" || postCode == "PlaceMr")
  10794. {
  10795. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10796. if (shopIds != "")
  10797. {
  10798. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10799. }
  10800. else if (order_type == 1)
  10801. {
  10802. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10803. }
  10804. else if (order_type == 2)
  10805. {
  10806. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10807. }
  10808. else
  10809. {
  10810. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10811. }
  10812. }
  10813. //车间
  10814. if (postCode == "Supplier")
  10815. {
  10816. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10817. if (order_type == 5)
  10818. {
  10819. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10820. }
  10821. else
  10822. {
  10823. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10824. }
  10825. }
  10826. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10827. dStruct.Fileds = "tid,ctid";
  10828. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10829. writeGridDataTableJson(dStruct.TotalCount, dt);
  10830. }
  10831. public void aftersale_audit_master()
  10832. {
  10833. if (UrlPostParmsCheck("ctid"))
  10834. {
  10835. string ctid = GetPostString("ctid");
  10836. if (ctid.Length > 0)
  10837. {
  10838. bool result = aftersale_data_change(ctid);
  10839. if (result)
  10840. {
  10841. returnSuccessMsg("修改成功!");
  10842. return;
  10843. }
  10844. }
  10845. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10846. }
  10847. }
  10848. public void aftersale_batch_audit_master()
  10849. {
  10850. if (UrlPostParmsCheck("ctids"))
  10851. {
  10852. string ctids = GetPostString("ctids");
  10853. if (ctids.Length > 0)
  10854. {
  10855. List<string> list = new List<string>();
  10856. string[] ctid_list = ctids.Split(',');
  10857. foreach (var item in ctid_list)
  10858. {
  10859. bool result = aftersale_data_change(item);
  10860. if (!result)
  10861. {
  10862. list.Add(item);
  10863. }
  10864. }
  10865. if (list.Count > 0)
  10866. {
  10867. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10868. return;
  10869. }
  10870. returnSuccessMsg("修改成功!");
  10871. return;
  10872. }
  10873. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10874. }
  10875. }
  10876. public bool aftersale_data_change(string ctid)
  10877. {
  10878. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10879. if (ceErpTradeCell != null)
  10880. {
  10881. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10882. ceErpTradeCell.AfterSaleSupplierState = 0;
  10883. StringBuilder sql = new StringBuilder();
  10884. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10885. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10886. CeErpTradeResponsible.DelByTid(ctid, 0);
  10887. if ((ceErpTradeCell.AfterSaleResponsible.IndexOf("客户问题") != -1 && ceErpTradeCell.AfterSaleResponsible.IndexOf(",客户问题") == -1) || (ceErpTradeCell.AfterSaleResponsible.IndexOf("系统问题") != -1 && ceErpTradeCell.AfterSaleResponsible.IndexOf(",系统问题") == -1) || ceErpTradeCell.supRefundType == "正常损耗" || ceErpTradeCell.supRefundType == "车间不售后" || ceErpTradeCell.supRefundType == "不售后" || ceErpTradeCell.supRefundType == "不理赔")
  10888. {
  10889. CeErpTradeResponsible.DelByTid(ctid, 1);
  10890. ceErpTradeCell.AfterSaleSupplierState = 1;
  10891. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10892. ceErpTradeCell.AfterSaleState = 4;
  10893. }
  10894. else
  10895. {
  10896. ceErpTradeCell.AfterSaleState = 3;
  10897. }
  10898. bool needCyt = false;
  10899. if (dt != null)
  10900. {
  10901. if (dt.Rows.Count == 1)
  10902. {
  10903. bool isEnd = false;
  10904. foreach (DataRow dr in dt.Rows)
  10905. {
  10906. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10907. {
  10908. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10909. isEnd = true;
  10910. }
  10911. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10912. {
  10913. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10914. isEnd = true;
  10915. }
  10916. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10917. {
  10918. needCyt = true;
  10919. }
  10920. }
  10921. if (isEnd)
  10922. {
  10923. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10924. ceErpTradeCell.AfterSaleState = 4;
  10925. ceErpTradeCell.AfterSaleSupplierState = 1;
  10926. }
  10927. }
  10928. else
  10929. {
  10930. bool isAll = true;
  10931. foreach (DataRow dr in dt.Rows)
  10932. {
  10933. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10934. {
  10935. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10936. continue;
  10937. }
  10938. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10939. {
  10940. string path = "";
  10941. int OrgID = 0;
  10942. if (!Convert.IsDBNull(dr["OrgPath"]))
  10943. {
  10944. path = dr["OrgPath"].ToString();
  10945. }
  10946. if (!Convert.IsDBNull(dr["OrgID"]))
  10947. {
  10948. OrgID = Convert.ToInt32(dr["OrgID"]);
  10949. }
  10950. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10951. {
  10952. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10953. continue;
  10954. }
  10955. }
  10956. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10957. {
  10958. needCyt = true;
  10959. }
  10960. isAll = false;
  10961. }
  10962. if (isAll)
  10963. {
  10964. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10965. ceErpTradeCell.AfterSaleState = 4;
  10966. ceErpTradeCell.AfterSaleSupplierState = 1;
  10967. }
  10968. }
  10969. }
  10970. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10971. {
  10972. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10973. }
  10974. if (ceErpTradeCell.AfterSaleState == 4)
  10975. {
  10976. ApiVo apiVo = new ApiVo();
  10977. apiVo.orderNumber = ceErpTradeCell.ctid;
  10978. apiVo.actionName = "afterOver";
  10979. designHelper.API_WorkCore(apiVo); //afterOver
  10980. }
  10981. ceErpTradeCell.Update();
  10982. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10983. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10984. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10985. return true;
  10986. }
  10987. return false;
  10988. }
  10989. public void get_erp_wechatorder()
  10990. {
  10991. DataStruct dStruct = GetPostStruct();
  10992. List<string> lw = new List<string>();
  10993. string tid = GetPostString("tid");
  10994. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10995. string shopname = GetPostString("shopname");
  10996. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10997. string buyernick = GetPostString("buyer_nick");
  10998. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10999. string customer = GetPostString("customer");
  11000. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11001. string returndate1 = GetPostString("returndate1");
  11002. string returndate2 = GetPostString("returndate2");
  11003. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11004. if (dw.Length > 0) lw.Add(dw);
  11005. string finishDate1 = GetPostString("finishdate1");
  11006. string finishDate2 = GetPostString("finishdate2");
  11007. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11008. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11009. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11010. dStruct.Order = "created desc";
  11011. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11012. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11013. writeGridDataTableJson(dStruct.TotalCount, dt);
  11014. }
  11015. public void get_erp_wechatlist_sumprice()
  11016. {
  11017. DataStruct dStruct = GetPostStruct();
  11018. List<string> lw = new List<string>();
  11019. string tid = GetPostString("tid");
  11020. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11021. string shopname = GetPostString("shopname");
  11022. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11023. string buyernick = GetPostString("buyer_nick");
  11024. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11025. string customer = GetPostString("customer");
  11026. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11027. string returndate1 = GetPostString("returndate1");
  11028. string returndate2 = GetPostString("returndate2");
  11029. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11030. if (dw.Length > 0) lw.Add(dw);
  11031. string finishDate1 = GetPostString("finishdate1");
  11032. string finishDate2 = GetPostString("finishdate2");
  11033. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11034. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11035. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11036. string mainWhere = string.Join(" and ", lw.ToArray());
  11037. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11038. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11039. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11040. decimal total = 0;
  11041. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11042. {
  11043. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11044. }
  11045. var res = new
  11046. {
  11047. data = total
  11048. };
  11049. string ro_jsond = JsonConvert.SerializeObject(res);
  11050. returnSuccess(ro_jsond);
  11051. return;
  11052. }
  11053. public void get_erp_qr_waitdeliverylist()
  11054. {
  11055. DataStruct dStruct = GetPostStruct();
  11056. List<string> lw = new List<string>();
  11057. string tid = GetPostString("ctid");
  11058. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11059. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11060. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11061. var res_objz = new
  11062. {
  11063. restype = 1,
  11064. data = dt
  11065. };
  11066. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11067. returnSuccess(ro_jsonz);
  11068. }
  11069. public void get_erp_yield_list()
  11070. {
  11071. DataStruct dStruct = GetPostStruct();
  11072. List<string> lw = new List<string>();
  11073. string tid = GetPostString("ctid");
  11074. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11075. string shopname = GetPostString("shopname");
  11076. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11077. string buyernick = GetPostString("buyer_nick");
  11078. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11079. //if (tid.Length == 0 && buyernick.Length == 0)
  11080. //{
  11081. // lw.Add(string.Format("IsRefund<={0}", 1));
  11082. //}
  11083. string customer = GetPostString("customer");
  11084. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11085. string design = GetPostString("design");
  11086. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11087. string orderState = GetPostString("orderState");
  11088. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11089. string address = GetPostString("address");
  11090. 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));
  11091. string sellermemo = GetPostString("seller_memo");
  11092. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11093. string supplier = GetPostString("supplier");
  11094. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11095. string OrderArea = GetPostString("order_area");
  11096. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11097. string placedate1 = GetPostString("placedate1");
  11098. string placedate2 = GetPostString("placedate2");
  11099. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11100. if (fdw.Length > 0) lw.Add(fdw);
  11101. string price1 = GetPostString("price1");
  11102. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11103. string price2 = GetPostString("price2");
  11104. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11105. string unusualCon = GetPostString("unusualcon");
  11106. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11107. string posTag = CurrentUser.UserPost.Post.Code;
  11108. if (posTag == "Supplier")
  11109. {
  11110. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11111. }
  11112. lw.Add(string.Format("OrderState = 6 "));
  11113. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11114. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11116. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11117. writeGridDataTableJson(dStruct.TotalCount, dt);
  11118. }
  11119. public void change_erp_sup_state()
  11120. {
  11121. if (UrlPostParmsCheck("ctid"))
  11122. {
  11123. string ctid = GetPostString("ctid");
  11124. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11125. if (ceErpTradeCell != null)
  11126. {
  11127. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11128. if (ceErpTradeCellExtend == null)
  11129. {
  11130. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11131. ceErpTradeCellExtend.ctid = ctid;
  11132. ceErpTradeCellExtend.SupState = 1;
  11133. ceErpTradeCellExtend.Create();
  11134. }
  11135. else
  11136. {
  11137. ceErpTradeCellExtend.SupState = 1;
  11138. ceErpTradeCellExtend.Update();
  11139. }
  11140. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11141. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11142. return;
  11143. }
  11144. returnErrorMsg("找不到订单");
  11145. }
  11146. }
  11147. public void supplier_all_downs()
  11148. {
  11149. if (UrlPostParmsCheck("tids"))
  11150. {
  11151. string tids = GetPostString("tids");
  11152. if (tids != null && tids.Length > 0)
  11153. {
  11154. StringBuilder sql = new StringBuilder();
  11155. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11156. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11157. sql = new StringBuilder();
  11158. 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, "下载设计文件");
  11159. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11160. string[] list = tids.Split(',');
  11161. foreach (string ctid in list)
  11162. {
  11163. CeErpSukuraData.createInfo(ctid, 3);
  11164. }
  11165. designHelper.api_approveDesign(tids); //approveDesign
  11166. returnSuccessMsg("下载成功!");
  11167. return;
  11168. }
  11169. returnErrorMsg("下载订单更新失败");
  11170. }
  11171. }
  11172. public void uploaderFileSuccess()
  11173. {
  11174. if (UrlPostParmsCheck("fileName"))
  11175. {
  11176. string fileName = GetPostString("fileName");
  11177. ApiVo apiVo = new ApiVo();
  11178. apiVo.orderNumber = fileName;
  11179. apiVo.actionName = "finishDesign";
  11180. designHelper.API_WorkCore(apiVo);//finishDesign
  11181. returnSuccessMsg("");
  11182. }
  11183. }
  11184. public void get_sample2_order()
  11185. {
  11186. if (UrlPostParmsCheck("ctid"))
  11187. {
  11188. string ctid = GetPostString("ctid");
  11189. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11190. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11191. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11192. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11193. double total = 0.0;
  11194. double order_price = 0.0;
  11195. if (dt_bu.Rows.Count > 0)
  11196. {
  11197. foreach (DataRow dr in dt_bu.Rows)
  11198. {
  11199. total += Convert.ToDouble(dr["payment"]);
  11200. }
  11201. }
  11202. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11203. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11204. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11205. string tid = ctid.Replace("S_", "");
  11206. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11207. double paymant = 0.0;
  11208. if (entity != null)
  11209. {
  11210. paymant = entity.payment;
  11211. }
  11212. string return_reason = "";
  11213. if (dt_after != null && dt_after.Rows.Count > 0)
  11214. {
  11215. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11216. }
  11217. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11218. }
  11219. }
  11220. public void get_erp_design_status()
  11221. {
  11222. string designName = GetPostString("designName");
  11223. DataStruct dStruct = GetPostStruct();
  11224. if (designName.Length > 0)
  11225. {
  11226. 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";
  11227. sql_user += " and Name like '%" + designName + "%'";
  11228. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11229. List<string> ids_list = new List<string>();
  11230. if (user_table.Rows.Count > 0)
  11231. {
  11232. foreach (DataRow item in user_table.Rows)
  11233. {
  11234. ids_list.Add(item["id"].ToString());
  11235. string ids_s = item["TeamIds"].ToString();
  11236. if (ids_s.Length > 0)
  11237. {
  11238. ids_list.AddRange(ids_s.Split(','));
  11239. }
  11240. }
  11241. }
  11242. HashSet<string> set = new HashSet<string>(ids_list);
  11243. ids_list = set.ToList();
  11244. if (ids_list.Count > 0)
  11245. {
  11246. 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));
  11247. dStruct.MainWhere = sql;
  11248. DataTable dt = null;
  11249. dt = WebCache.GetData("view_ErpUser", dStruct);
  11250. writeGridDataTableJson(dStruct.TotalCount, dt);
  11251. }
  11252. }
  11253. }
  11254. public void change_erp_order_price()
  11255. {
  11256. string ctid = GetPostString("ctid");
  11257. double price = GetPostDouble("price");
  11258. if (ctid.Length > 0)
  11259. {
  11260. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11261. if (ceErpTradeCellExtend == null)
  11262. {
  11263. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11264. ceErpTradeCellExtend.ctid = ctid;
  11265. ceErpTradeCellExtend.payment_cyt = price;
  11266. ceErpTradeCellExtend.Create();
  11267. }
  11268. else
  11269. {
  11270. ceErpTradeCellExtend.payment_cyt = price;
  11271. ceErpTradeCellExtend.Update();
  11272. }
  11273. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11274. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11275. {
  11276. ceErpDataSendOrderInfo.isSync = false;
  11277. ceErpDataSendOrderInfo.Update();
  11278. }
  11279. if (ceErpDataSendOrderInfo == null)
  11280. {
  11281. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11282. ceErpDataSendOrderInfo.isSync = false;
  11283. ceErpDataSendOrderInfo.ctid = ctid;
  11284. ceErpDataSendOrderInfo.Create();
  11285. }
  11286. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11287. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11288. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11289. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11290. {
  11291. dataSendOrderBean dataSendOrderBean = null;
  11292. foreach (DataRow item in dth.Rows)
  11293. {
  11294. try
  11295. {
  11296. dataSendOrderBean = new dataSendOrderBean();
  11297. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11298. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11299. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11300. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11301. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11302. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11303. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11304. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11305. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11306. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11307. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11308. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11309. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11310. if (result != null)
  11311. {
  11312. if ("0".Equals(result.errcode))
  11313. {
  11314. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11315. }
  11316. else
  11317. {
  11318. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11319. }
  11320. }
  11321. }
  11322. catch (Exception ex)
  11323. {
  11324. }
  11325. }
  11326. }
  11327. returnSuccessMsg("修改成功!");
  11328. return;
  11329. }
  11330. returnErrorMsg("找不到订单");
  11331. }
  11332. public void find_he_together()
  11333. {
  11334. string ctid = GetPostString("ctid");
  11335. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11336. List<string> list = new List<string>();
  11337. if (ceErpTradeCell != null)
  11338. {
  11339. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11340. {
  11341. 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);
  11342. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11343. if (table != null && table.Rows.Count > 0)
  11344. {
  11345. foreach (TableRow row in table.Rows)
  11346. {
  11347. }
  11348. }
  11349. }
  11350. }
  11351. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11352. }
  11353. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11354. {
  11355. //chy----19
  11356. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11357. //GD-CYT-----64
  11358. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11359. //ZHX----3
  11360. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11361. //JK----97
  11362. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11363. //ZT----70
  11364. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11365. //LHCY-----98
  11366. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11367. //XD-----90
  11368. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11369. //CYCY-----14
  11370. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11371. };
  11372. //其他改名
  11373. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11374. {
  11375. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11376. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11377. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11378. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11379. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11380. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11381. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11382. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11383. };
  11384. //不统计
  11385. List<int> no_suppliers = new List<int>()
  11386. {
  11387. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11388. };
  11389. //配件单
  11390. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11391. {
  11392. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11393. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11394. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11395. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11396. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11397. {"旗杆",new List<string>(){ "班旗" } },
  11398. {"牙签",new List<string>(){ "不干胶" } }
  11399. };
  11400. public void get_place_order_data()
  11401. {
  11402. string date1 = GetPostString("date1");
  11403. string date2 = GetPostString("date2");
  11404. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11405. DateTime start = DateTime.Parse(starttime);
  11406. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11407. DateTime end = DateTime.Parse(endtime);
  11408. if (date1 != null && date1.Length > 0)
  11409. {
  11410. DateTime dateTime = DateTime.Parse(date1);
  11411. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11412. start = DateTime.Parse(starttime);
  11413. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11414. end = DateTime.Parse(endtime);
  11415. }
  11416. if (date2 != null && date2.Length > 0)
  11417. {
  11418. DateTime dateTime = DateTime.Parse(date2);
  11419. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11420. end = DateTime.Parse(endtime);
  11421. }
  11422. 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);
  11423. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11424. //不干胶-----1,卡片-----29
  11425. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11426. foreach (DataRow row in data.Rows)
  11427. {
  11428. int productId = Convert.ToInt32(row["ProductId"]);
  11429. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11430. if (no_suppliers.Contains(supplierId))
  11431. {
  11432. continue;
  11433. }
  11434. string seller_memo = row["seller_memo"].ToString();
  11435. bool ispj = false;//是否配件单
  11436. bool isfirst = true;//第一个配
  11437. maps.Keys.ForEach(key =>
  11438. {
  11439. //备注包含配件
  11440. if (seller_memo.Contains(key) && isfirst)
  11441. {
  11442. List<string> list = maps[key];
  11443. ispj = true;
  11444. isfirst = false;
  11445. for (int i = 0; i < list.Count; i++)
  11446. {
  11447. if (seller_memo.Contains(list[i]))
  11448. {
  11449. ispj = false;
  11450. break;
  11451. }
  11452. }
  11453. }
  11454. });
  11455. if (ispj)
  11456. {
  11457. continue;
  11458. }
  11459. seller_memo = seller_memo.Replace("UV", "uv");
  11460. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11461. //吊牌归到卡片
  11462. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11463. seller_memo = seller_memo.Replace("卡套", "卡片");
  11464. seller_memo = seller_memo.Replace("封套", "卡片");
  11465. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11466. seller_memo = seller_memo.Replace("腰封", "卡片");
  11467. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11468. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11469. seller_memo = seller_memo.Replace("横幅", "条幅");
  11470. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11471. string map_key = "";
  11472. string type = "";
  11473. if (supplierMap.ContainsKey(supplierId))
  11474. {
  11475. foreach (var kvp in supplierMap[supplierId])
  11476. {
  11477. if (seller_memo.Contains(kvp.Key))
  11478. {
  11479. map_key = kvp.Value;
  11480. type = kvp.Value;
  11481. break;
  11482. }
  11483. }
  11484. }
  11485. if (map_key == "")
  11486. {
  11487. type = "其他";
  11488. map_key = "其他";
  11489. }
  11490. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11491. {
  11492. map_key = suppliers[supplierId];
  11493. }
  11494. if (supplierId == 70)
  11495. {
  11496. supplierId = 70;
  11497. }
  11498. map_key += "_" + row["SupplierName"].ToString();
  11499. Dictionary<string, int> map = null;
  11500. if (other_map.ContainsKey(map_key))
  11501. {
  11502. other_map.TryGetValue(map_key, out map);
  11503. }
  11504. else
  11505. {
  11506. map = new Dictionary<string, int>();
  11507. map.Add("dayDev", 0);//当天出货
  11508. map.Add("dayTotal", 0);//下单总数
  11509. map.Add("payTotal", 0);//500以上
  11510. map.Add("today", 0);//当天出货数量
  11511. map.Add("unusua", 0);//异常数
  11512. other_map.Add(map_key, map);
  11513. other_map.TryGetValue(map_key, out map);
  11514. }
  11515. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11516. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11517. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11518. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11519. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11520. {
  11521. map["dayTotal"]++;
  11522. if (supplierId == 97)
  11523. {
  11524. supplierId = 97;
  11525. }
  11526. }
  11527. if (Convert.ToDecimal(row["payment"]) >= 500)
  11528. {
  11529. map["payTotal"]++;
  11530. }
  11531. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11532. {
  11533. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11534. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11535. {
  11536. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11537. {
  11538. map["today"]++;
  11539. }
  11540. }
  11541. else
  11542. {
  11543. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11544. {
  11545. map["today"]++;
  11546. }
  11547. else
  11548. {
  11549. if (supplierId == 119)
  11550. {
  11551. Debug.WriteLine(row["seller_memo"].ToString());
  11552. }
  11553. }
  11554. }
  11555. }
  11556. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11557. {
  11558. map["unusua"]++;
  11559. }
  11560. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11561. //GD-CYT-----64
  11562. DateTime two = palceTimeStart.AddHours(14);
  11563. DateTime three = palceTimeStart.AddHours(15);
  11564. DateTime four = palceTimeStart.AddHours(16);
  11565. DateTime six = palceTimeStart.AddHours(18);
  11566. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11567. {
  11568. //下午四点前 500-1000
  11569. string count = row["ProductCount"].ToString();
  11570. if (count != null && count.Length > 0)
  11571. {
  11572. int productCount = commonHelper.getPlaceProductCount(count);
  11573. if (productCount >= 500 && productCount <= 1000)
  11574. {
  11575. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11576. {
  11577. map["dayDev"]++;
  11578. }
  11579. }
  11580. }
  11581. }
  11582. //UV
  11583. else if ("uv".Equals(type))
  11584. {
  11585. //ZT----70
  11586. //ZHX----3
  11587. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11588. {
  11589. map["dayDev"]++;
  11590. }
  11591. //JK----97
  11592. //HZX----105
  11593. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11594. {
  11595. map["dayDev"]++;
  11596. }
  11597. }
  11598. //帆布---52|条幅---27
  11599. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11600. {
  11601. //LHCY-----98
  11602. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11603. {
  11604. map["dayDev"]++;
  11605. }
  11606. }
  11607. //条幅
  11608. else if ("条幅".Equals(type))
  11609. {
  11610. //XD-----90
  11611. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11612. {
  11613. map["dayDev"]++;
  11614. }
  11615. }
  11616. //桌布
  11617. else if ("桌布".Equals(type))
  11618. {
  11619. //XD-----90
  11620. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11621. {
  11622. map["dayDev"]++;
  11623. }
  11624. }
  11625. //DL---10
  11626. //AYTW---119
  11627. //FS-CYT-DY ----80
  11628. //JK----97
  11629. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11630. {
  11631. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11632. {
  11633. map["dayDev"]++;
  11634. }
  11635. }
  11636. // QC---121
  11637. else if (supplierId == 121)
  11638. {
  11639. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11640. {
  11641. map["dayDev"]++;
  11642. }
  11643. }
  11644. }
  11645. DataTable dt = new DataTable();
  11646. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11647. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11648. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11649. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11650. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11651. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11652. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11653. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11654. other_map.Keys.ForEach(key =>
  11655. {
  11656. DataRow dr = dt.NewRow();
  11657. Dictionary<string, int> map = other_map[key];
  11658. string[] key_list = key.Split('_');
  11659. dr[0] = key_list[0];
  11660. dr[1] = key_list[1];
  11661. if (key_list.Length > 2)
  11662. {
  11663. dr[1] += "(" + key_list[2] + ")";
  11664. }
  11665. dr[2] = map["dayTotal"];
  11666. dr[3] = map["payTotal"];
  11667. dr[4] = map["today"];
  11668. dr[5] = map["unusua"];
  11669. dr[6] = map["dayDev"];
  11670. double rate = 0.00;
  11671. if (map["dayDev"] > 0)
  11672. {
  11673. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11674. }
  11675. dr[7] = rate.ToString();
  11676. dt.Rows.Add(dr);
  11677. });
  11678. DataView dv = new DataView(dt);
  11679. dv.Sort = "SupplierName";
  11680. //dv.Sort = "AllOrder desc";
  11681. DataTable dtNew = dv.ToTable();
  11682. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11683. }
  11684. public void check_order_desing_info()
  11685. {
  11686. string ctid = GetPostString("ctid");
  11687. if (!string.IsNullOrEmpty(ctid))
  11688. {
  11689. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11690. if (ceErpTradeCell != null)
  11691. {
  11692. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11693. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11694. return;
  11695. }
  11696. returnErrorMsg("找不到订单");
  11697. return;
  11698. }
  11699. returnErrorMsg("找不到订单");
  11700. }
  11701. public void get_timeout_detail()
  11702. {
  11703. string poscode = CurrentUser.UserPost.Post.Code;
  11704. DataStruct dStruct = GetPostStruct();
  11705. List<string> lw = new List<string>();
  11706. string id = GetPostString("id");
  11707. string pay_date1 = GetPostString("pay_date1");
  11708. string pay_date2 = GetPostString("pay_date2");
  11709. int type = GetPostInt("type");
  11710. if (type == 0)
  11711. {
  11712. if (pay_date1.Length > 0)
  11713. {
  11714. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11715. }
  11716. if (pay_date2.Length > 0)
  11717. {
  11718. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11719. }
  11720. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11721. }
  11722. if (type == 1)
  11723. {
  11724. if (pay_date1.Length > 0)
  11725. {
  11726. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11727. }
  11728. if (pay_date2.Length > 0)
  11729. {
  11730. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11731. }
  11732. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11733. }
  11734. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11735. DataTable dt = null;
  11736. dt = WebCache.GetData("view_orderlist", dStruct);
  11737. writeGridDataTableJson(dStruct.TotalCount, dt);
  11738. }
  11739. public void saveUrgentChargePrice()
  11740. {
  11741. string ctid = GetPostString("ctid");
  11742. if (!string.IsNullOrEmpty(ctid))
  11743. {
  11744. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11745. if (ceErpTradeCell != null)
  11746. {
  11747. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11748. if (prices <= 100)
  11749. {
  11750. returnErrorMsg("此订单金额不足100元,无法加急。");
  11751. return;
  11752. }
  11753. double price = GetPostDouble("price");
  11754. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11755. if (ceErpTradeCellExtend == null)
  11756. {
  11757. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11758. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11759. }
  11760. ceErpTradeCellExtend.urgentCharge = price;
  11761. if (ceErpTradeCellExtend.ID > 0)
  11762. {
  11763. ceErpTradeCellExtend.Update();
  11764. }
  11765. else
  11766. {
  11767. ceErpTradeCellExtend.Save();
  11768. }
  11769. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11770. returnSuccessMsg("修改成功!");
  11771. return;
  11772. }
  11773. returnErrorMsg("找不到订单");
  11774. return;
  11775. }
  11776. returnErrorMsg("找不到订单");
  11777. }
  11778. public void finish_erp_order()
  11779. {
  11780. string ctid = GetPostString("ctid");
  11781. if (!string.IsNullOrEmpty(ctid))
  11782. {
  11783. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11784. {
  11785. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11786. if (ceErpTradeCell != null)
  11787. {
  11788. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11789. ceErpTradeCell.Update();
  11790. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11791. returnSuccessMsg("修改成功!");
  11792. return;
  11793. }
  11794. }
  11795. }
  11796. returnErrorMsg("找不到订单");
  11797. }
  11798. public void get_trade_order_list()
  11799. {
  11800. string tid = GetPostString("tid");
  11801. if (!string.IsNullOrEmpty(tid))
  11802. {
  11803. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11804. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11805. writeGridDataTableJson(data.Rows.Count, data);
  11806. return;
  11807. }
  11808. returnErrorMsg("找不到订单");
  11809. }
  11810. public void save_cell_spu()
  11811. {
  11812. string ctid = GetPostString("ctid");
  11813. string spu_id = GetPostString("spu_id");
  11814. if (!string.IsNullOrEmpty(ctid))
  11815. {
  11816. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11817. if (ceErpTradeCellExtend == null)
  11818. {
  11819. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11820. ceErpTradeCellExtend.ctid = ctid;
  11821. }
  11822. ceErpTradeCellExtend.spu_id = spu_id;
  11823. if (!string.IsNullOrEmpty(spu_id))
  11824. {
  11825. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11826. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11827. }
  11828. if (ceErpTradeCellExtend.ID == 0)
  11829. {
  11830. ceErpTradeCellExtend.Create();
  11831. }
  11832. else
  11833. {
  11834. ceErpTradeCellExtend.Update();
  11835. }
  11836. returnSuccessMsg("修改成功!");
  11837. return;
  11838. }
  11839. returnErrorMsg("找不到订单");
  11840. }
  11841. public void change_express_info()
  11842. {
  11843. string ctid = GetPostString("ctid");
  11844. string transNo = GetPostString("transNo");
  11845. string transCom = GetPostString("transCom");
  11846. if (!string.IsNullOrEmpty(ctid))
  11847. {
  11848. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11849. if (ceErpTradeCellExtend == null)
  11850. {
  11851. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11852. ceErpTradeCellExtend.ctid = ctid;
  11853. }
  11854. ceErpTradeCellExtend.modExpressNo = transNo;
  11855. ceErpTradeCellExtend.modExpressCom = transCom;
  11856. ceErpTradeCellExtend.readMod = 2;
  11857. if (ceErpTradeCellExtend.ID == 0)
  11858. {
  11859. ceErpTradeCellExtend.Create();
  11860. }
  11861. else
  11862. {
  11863. ceErpTradeCellExtend.Update();
  11864. }
  11865. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11866. returnSuccessMsg("修改成功!");
  11867. return;
  11868. }
  11869. returnErrorMsg("找不到订单");
  11870. }
  11871. public void get_change_express_list()
  11872. {
  11873. DataStruct dStruct = GetPostStruct();
  11874. List<string> lw = new List<string>();
  11875. int st = 2;
  11876. string tid = GetPostString("ctid");
  11877. if (tid.Length > 0)
  11878. {
  11879. string select_tid = getTidByCtid(tid);
  11880. lw.Add(string.Format("tid='{0}'", select_tid));
  11881. }
  11882. string shopname = GetPostString("shopname");
  11883. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11884. string buyernick = GetPostString("buyer_nick");
  11885. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11886. string sellermemo = GetPostString("seller_memo");
  11887. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11888. string supplier = GetPostString("supplier");
  11889. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11890. string customer = GetPostString("customer");
  11891. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11892. string design = GetPostString("design");
  11893. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11894. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11895. string poscode = CurrentUser.UserPost.Post.Code;
  11896. if (poscode != "SysAdmin")
  11897. {
  11898. string shopid = CurrentUser.User.pemShop;
  11899. lw.Add(string.Format("shopId in ({0})", shopid));
  11900. }
  11901. lw.Add("readMod = 2");
  11902. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11903. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11904. writeGridDataTableJson(dStruct.TotalCount, dt);
  11905. }
  11906. public void deal_express_complete()
  11907. {
  11908. string ctid = GetPostString("ctid");
  11909. if (!string.IsNullOrEmpty(ctid))
  11910. {
  11911. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11912. if (ceErpTradeCellExtend == null)
  11913. {
  11914. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11915. ceErpTradeCellExtend.ctid = ctid;
  11916. }
  11917. ceErpTradeCellExtend.readMod = 1;
  11918. if (ceErpTradeCellExtend.ID == 0)
  11919. {
  11920. ceErpTradeCellExtend.Create();
  11921. }
  11922. else
  11923. {
  11924. ceErpTradeCellExtend.Update();
  11925. }
  11926. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11927. returnSuccessMsg("修改成功!");
  11928. return;
  11929. }
  11930. returnErrorMsg("找不到订单");
  11931. }
  11932. public void aftersale_return_visit()
  11933. {
  11934. string ctid = GetPostString("ctid");
  11935. if (!string.IsNullOrEmpty(ctid))
  11936. {
  11937. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11938. if (ceErpTradeCellExtend == null)
  11939. {
  11940. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11941. ceErpTradeCellExtend.ctid = ctid;
  11942. }
  11943. ceErpTradeCellExtend.returnVisit = 1;
  11944. if (ceErpTradeCellExtend.ID == 0)
  11945. {
  11946. ceErpTradeCellExtend.Create();
  11947. }
  11948. else
  11949. {
  11950. ceErpTradeCellExtend.Update();
  11951. }
  11952. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11953. if (ceErpTradeAfterSaleExtend != null)
  11954. {
  11955. ceErpTradeAfterSaleExtend.TextResult = "";
  11956. ceErpTradeAfterSaleExtend.Update();
  11957. }
  11958. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11959. returnSuccessMsg("修改成功!");
  11960. return;
  11961. }
  11962. returnErrorMsg("找不到订单");
  11963. }
  11964. public void orderPlaceInfo()
  11965. {
  11966. string ctids = GetPostString("ctids");
  11967. string[] list = ctids.Split(',');
  11968. foreach (string ctid in list)
  11969. {
  11970. CeErpSukuraData.createInfo(ctid, 3);
  11971. }
  11972. StringBuilder sql = new StringBuilder();
  11973. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11974. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11975. designHelper.api_approveDesign(ctids); //approveDesign
  11976. returnSuccessMsg("");
  11977. }
  11978. public void get_issue_list()
  11979. {
  11980. DataStruct dStruct = GetPostStruct();
  11981. List<string> lw = new List<string>();
  11982. int st = 2;
  11983. string tid = GetPostString("ctid");
  11984. if (tid.Length > 0)
  11985. {
  11986. string select_tid = getTidByCtid(tid);
  11987. lw.Add(string.Format("tid='{0}'", select_tid));
  11988. }
  11989. string shopname = GetPostString("shopname");
  11990. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11991. string buyernick = GetPostString("buyer_nick");
  11992. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11993. string sellermemo = GetPostString("seller_memo");
  11994. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11995. string supplier = GetPostString("supplier");
  11996. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11997. string customer = GetPostString("customer");
  11998. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11999. string design = GetPostString("design");
  12000. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12001. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12002. string poscode = CurrentUser.UserPost.Post.Code;
  12003. if (poscode != "SysAdmin")
  12004. {
  12005. string shopid = CurrentUser.User.pemShop;
  12006. lw.Add(string.Format("shopId in ({0})", shopid));
  12007. }
  12008. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12009. {
  12010. lw.Add("IssueState = 1");
  12011. }
  12012. else
  12013. {
  12014. string iisstate = GetPostString("iisstate");
  12015. if ("1".Equals(iisstate))
  12016. {
  12017. lw.Add("IssueState =1");
  12018. }
  12019. else if ("2".Equals(iisstate))
  12020. {
  12021. lw.Add("IssueState = 2");
  12022. }
  12023. else
  12024. {
  12025. lw.Add("IssueState > 0");
  12026. }
  12027. }
  12028. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12029. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12030. writeGridDataTableJson(dStruct.TotalCount, dt);
  12031. }
  12032. public void saveIssueContent()
  12033. {
  12034. string ctid = GetPostString("ctid");
  12035. if (!string.IsNullOrEmpty(ctid))
  12036. {
  12037. string content = GetPostString("content");
  12038. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12039. if (ceErpTradeAfterSaleExtend == null)
  12040. {
  12041. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12042. ceErpTradeAfterSaleExtend.tid = ctid;
  12043. }
  12044. ceErpTradeAfterSaleExtend.IssueContent = content;
  12045. ceErpTradeAfterSaleExtend.IssueState = 1;
  12046. if (ceErpTradeAfterSaleExtend.ID > 0)
  12047. {
  12048. ceErpTradeAfterSaleExtend.Update();
  12049. }
  12050. else
  12051. {
  12052. ceErpTradeAfterSaleExtend.Create();
  12053. }
  12054. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12055. returnSuccessMsg("添加成功!");
  12056. return;
  12057. }
  12058. returnErrorMsg("找不到订单");
  12059. }
  12060. public void dealIssueContent()
  12061. {
  12062. string ctid = GetPostString("ctid");
  12063. if (!string.IsNullOrEmpty(ctid))
  12064. {
  12065. string content = GetPostString("content");
  12066. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12067. if (ceErpTradeAfterSaleExtend != null)
  12068. {
  12069. ceErpTradeAfterSaleExtend.IssueState = 2;
  12070. ceErpTradeAfterSaleExtend.Update();
  12071. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12072. returnSuccessMsg("修改完成!");
  12073. return;
  12074. }
  12075. }
  12076. returnErrorMsg("找不到订单");
  12077. }
  12078. public void set_tid_attachments()
  12079. {
  12080. string tid = GetPostString("tid");
  12081. string atta = GetPostString("atta");
  12082. if (!string.IsNullOrEmpty(tid))
  12083. {
  12084. if (string.IsNullOrEmpty(atta))
  12085. {
  12086. returnErrorMsg("文件地址为空");
  12087. return;
  12088. }
  12089. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12090. if (ceErpTradeCell != null)
  12091. {
  12092. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12093. if (ceErpTrade == null)
  12094. {
  12095. returnErrorMsg("找不到订单");
  12096. return;
  12097. }
  12098. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12099. bool isSend = false;
  12100. if (dt != null && dt.Rows.Count > 0)
  12101. {
  12102. foreach (DataRow row in dt.Rows)
  12103. {
  12104. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12105. {
  12106. isSend = true;
  12107. }
  12108. }
  12109. if (isSend)
  12110. {
  12111. returnErrorMsg("已发货无法修改");
  12112. return;
  12113. }
  12114. ceErpTrade.Attachments = atta;
  12115. ceErpTrade.Update();
  12116. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12117. returnSuccessMsg("上传成功!");
  12118. return;
  12119. }
  12120. }
  12121. }
  12122. returnErrorMsg("找不到订单");
  12123. }
  12124. public void get_tid_attachments()
  12125. {
  12126. string tid = GetPostString("tid");
  12127. if (!string.IsNullOrEmpty(tid))
  12128. {
  12129. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12130. if (ceErpTradeCell != null)
  12131. {
  12132. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12133. if (ceErpTrade == null)
  12134. {
  12135. returnErrorMsg("找不到订单");
  12136. return;
  12137. }
  12138. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12139. return;
  12140. }
  12141. }
  12142. returnErrorMsg("找不到订单");
  12143. }
  12144. public void check_erp_sameorders()
  12145. {
  12146. if (UrlPostParmsCheck("ctid"))
  12147. {
  12148. string eid = GetPostString("ctid");
  12149. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12150. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12151. if (entity != null && ceErpTrade != null)
  12152. {
  12153. if (entity.OrderState > 6)
  12154. {
  12155. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12156. return;
  12157. }
  12158. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12159. List<string> ids = new List<string>();
  12160. if (dt != null && dt.Rows.Count > 1)
  12161. {
  12162. bool needhe = true;
  12163. foreach (DataRow dr in dt.Rows)
  12164. {
  12165. ids.Add("'" + dr["ctid"] + "'");
  12166. /* //备注有合包
  12167. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12168. {
  12169. needhe = true;
  12170. }
  12171. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12172. {
  12173. needhe = true;
  12174. }
  12175. //顺丰快递
  12176. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12177. {
  12178. needhe = true;
  12179. }*/
  12180. }
  12181. if (!needhe)
  12182. {
  12183. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12184. return;
  12185. }
  12186. StringBuilder sql = new StringBuilder();
  12187. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12188. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12189. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12190. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12191. foreach (DataRow dr in dt.Rows)
  12192. {
  12193. dr["dstate"] = 0;
  12194. dr["dnumber"] = 0;
  12195. foreach (DataRow row in dt1.Rows)
  12196. {
  12197. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12198. {
  12199. dr["dstate"] = 2;
  12200. dr["default"] = 1;
  12201. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12202. }
  12203. }
  12204. if (eid.Equals(dr["ctid"].ToString()))
  12205. {
  12206. dr["dstate"] = 1;
  12207. dr["default"] = 1;
  12208. }
  12209. }
  12210. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12211. return;
  12212. }
  12213. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12214. return;
  12215. }
  12216. returnErrorMsg("未找到订单");
  12217. return;
  12218. }
  12219. returnErrorMsg("缺少必要的参数");
  12220. }
  12221. public void get_mark_number()
  12222. {
  12223. string eid = GetPostString("ctid");
  12224. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12225. if (entity != null)
  12226. {
  12227. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12228. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12229. int current = 1;
  12230. if (ceErpDeliverMark == null)
  12231. {
  12232. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12233. List<string> ids = new List<string>();
  12234. if (dt != null && dt.Rows.Count > 1)
  12235. {
  12236. foreach (DataRow dr in dt.Rows)
  12237. {
  12238. ids.Add("'" + dr["ctid"] + "'");
  12239. }
  12240. //查询已有的编号
  12241. StringBuilder sql = new StringBuilder();
  12242. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12243. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12244. if (dt1 == null || dt1.Rows.Count == 0)
  12245. {
  12246. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12247. List<int> list_number = new List<int>();
  12248. foreach (DataRow row in numbers.Rows)
  12249. {
  12250. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12251. }
  12252. //查询空余编号
  12253. for (int i = 0; i < list_number.Count + 2; i++)
  12254. {
  12255. if (!list_number.Contains(current))
  12256. {
  12257. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12258. //防止查询过程中有新数据生成
  12259. if (ceErpDeliverMark1 == null)
  12260. {
  12261. break;
  12262. }
  12263. }
  12264. current++;
  12265. }
  12266. }
  12267. else
  12268. {
  12269. foreach (DataRow row in dt1.Rows)
  12270. {
  12271. current = Convert.ToInt32(row["markNumber"]);
  12272. }
  12273. }
  12274. ceErpDeliverMark = new CeErpDeliverMark();
  12275. ceErpDeliverMark.ctid = eid;
  12276. ceErpDeliverMark.createtime = DateTime.Now;
  12277. if (ceErpTrade != null)
  12278. {
  12279. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12280. }
  12281. ceErpDeliverMark.markNumber = current;
  12282. ceErpDeliverMark.Create();
  12283. }
  12284. }
  12285. else
  12286. {
  12287. current = ceErpDeliverMark.markNumber;
  12288. }
  12289. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12290. return;
  12291. }
  12292. }
  12293. public void aftersaleCytSend()
  12294. {
  12295. string ctid = GetPostString("ctid");
  12296. if (!string.IsNullOrEmpty(ctid))
  12297. {
  12298. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12299. if (ceErpTradeCell != null)
  12300. {
  12301. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12302. }
  12303. returnSuccessMsg("推送成功");
  12304. return;
  12305. }
  12306. returnErrorMsg("缺少必要的参数");
  12307. }
  12308. public void packOrderInfo()
  12309. {
  12310. string ctids = GetPostString("ctids");
  12311. if (!string.IsNullOrEmpty(ctids))
  12312. {
  12313. string[] ctid_list = ctids.Split(',');
  12314. if (ctid_list.Length > 20)
  12315. {
  12316. returnErrorMsg("单次下载次数不能超过20个");
  12317. return;
  12318. }
  12319. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12320. StringBuilder sql = new StringBuilder();
  12321. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12322. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12323. int supplierId = 0;
  12324. StringBuilder insterSql = new StringBuilder();
  12325. for (int i = 0; i < dt.Rows.Count; i++)
  12326. {
  12327. DataRow row = dt.Rows[i];
  12328. if (i == 0)
  12329. {
  12330. supplierId = Convert.ToInt32(row["SupplierId"]);
  12331. }
  12332. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12333. {
  12334. returnErrorMsg("同车间的订单才能一起打包");
  12335. return;
  12336. }
  12337. int orderState = Convert.ToInt32(row["OrderState"]);
  12338. if (orderState != 5)
  12339. {
  12340. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12341. return;
  12342. }
  12343. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12344. }
  12345. CeErpPackData ceErpPackData = new CeErpPackData();
  12346. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12347. ceErpPackData.supplierId = supplierId;
  12348. ceErpPackData.createtime = DateTime.Now;
  12349. ceErpPackData.createBy = CurrentUser.UserID;
  12350. ceErpPackData.createName = CurrentUser.UserName;
  12351. ceErpPackData.Create();
  12352. if (ceErpPackData.ID > 0)
  12353. {
  12354. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12355. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12356. }
  12357. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12358. returnSuccessMsg("打包成功");
  12359. return;
  12360. }
  12361. returnErrorMsg("缺少必要的参数");
  12362. }
  12363. public void rePackOrderInfo()
  12364. {
  12365. string id = GetPostString("id");
  12366. if (!string.IsNullOrEmpty(id))
  12367. {
  12368. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12369. if (ceErpPackData == null)
  12370. {
  12371. returnSuccessMsg("查无数据");
  12372. return;
  12373. }
  12374. ceErpPackData.upStatus = 0;
  12375. ceErpPackData.message = "";
  12376. ceErpPackData.Update();
  12377. returnSuccessMsg("打包成功");
  12378. return;
  12379. }
  12380. returnErrorMsg("缺少必要的参数");
  12381. }
  12382. public void backPackOrderInfo()
  12383. {
  12384. string id = GetPostString("id");
  12385. if (!string.IsNullOrEmpty(id))
  12386. {
  12387. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12388. if (ceErpPackData == null)
  12389. {
  12390. returnSuccessMsg("查无数据");
  12391. return;
  12392. }
  12393. ceErpPackData.upStatus = 4;
  12394. ceErpPackData.Update();
  12395. List<string> list = new List<string>();
  12396. StringBuilder sql = new StringBuilder();
  12397. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12398. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12399. for (int i = 0; i < dt.Rows.Count; i++)
  12400. {
  12401. DataRow row = dt.Rows[i];
  12402. list.Add("'" + row["ctid"].ToString() + "'");
  12403. }
  12404. string textCtids = string.Join(",", list);
  12405. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12406. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12407. returnSuccessMsg("退回成功");
  12408. return;
  12409. }
  12410. returnErrorMsg("缺少必要的参数");
  12411. }
  12412. public void addPackDownNum()
  12413. {
  12414. string id = GetPostString("id");
  12415. if (!string.IsNullOrEmpty(id))
  12416. {
  12417. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12418. returnSuccessMsg("下载成功");
  12419. return;
  12420. }
  12421. returnErrorMsg("缺少必要的参数");
  12422. }
  12423. public void get_pack_list()
  12424. {
  12425. DataStruct dStruct = GetPostStruct();
  12426. List<string> lw = new List<string>();
  12427. string supplier = GetPostString("supplier");
  12428. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12429. string posTag = CurrentUser.UserPost.Post.Code;
  12430. if (posTag == "Supplier")
  12431. {
  12432. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12433. }
  12434. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12435. dStruct.Order = "createtime desc";
  12436. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12437. writeGridDataTableJson(dStruct.TotalCount, dt);
  12438. }
  12439. public void get_pack_order_list()
  12440. {
  12441. string packId = GetPostString("packId");
  12442. if (string.IsNullOrEmpty(packId))
  12443. {
  12444. returnErrorMsg("缺少必要的参数");
  12445. return;
  12446. }
  12447. StringBuilder sql = new StringBuilder();
  12448. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12449. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12450. if (dt == null || dt.Rows.Count == 0)
  12451. {
  12452. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12453. return;
  12454. }
  12455. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12456. return;
  12457. }
  12458. public void get_supplier_product_time_list()
  12459. {
  12460. DataStruct dStruct = GetPostStruct();
  12461. List<string> lw = new List<string>();
  12462. string supplier = GetPostString("supplier");
  12463. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12464. string posTag = CurrentUser.UserPost.Post.Code;
  12465. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12466. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12467. writeGridDataTableJson(dStruct.TotalCount, dt);
  12468. }
  12469. public void saveSupplierProductTime()
  12470. {
  12471. string productId = GetPostString("productId");
  12472. if (string.IsNullOrEmpty(productId))
  12473. {
  12474. returnErrorMsg("缺少必要的参数");
  12475. return;
  12476. }
  12477. string productName = GetPostString("productName");
  12478. int supplierId = GetPostInt("supplierId");
  12479. if (supplierId == 0)
  12480. {
  12481. returnErrorMsg("缺少必要的参数");
  12482. return;
  12483. }
  12484. int quantity = GetPostInt("quantity");
  12485. int sendDay = GetPostInt("sendTime");
  12486. string supplierName = GetPostString("supplierName");
  12487. string craft = GetPostString("craft");
  12488. string deadLine = GetPostString("deadLine");
  12489. string dayDeadLine = GetPostString("dayDeadLine");
  12490. try
  12491. {
  12492. int eid = GetPostInt("eid");
  12493. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12494. if (ceErpSupplierProductTime == null)
  12495. {
  12496. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12497. }
  12498. ceErpSupplierProductTime.productId = productId;
  12499. ceErpSupplierProductTime.productName = productName;
  12500. ceErpSupplierProductTime.supplierId = supplierId;
  12501. ceErpSupplierProductTime.supplierName = supplierName;
  12502. ceErpSupplierProductTime.craft = craft;
  12503. ceErpSupplierProductTime.sendDay = sendDay;
  12504. ceErpSupplierProductTime.quantity = quantity;
  12505. if (!string.IsNullOrEmpty(deadLine))
  12506. {
  12507. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12508. }
  12509. if (!string.IsNullOrEmpty(dayDeadLine))
  12510. {
  12511. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12512. }
  12513. if (ceErpSupplierProductTime.ID == 0)
  12514. {
  12515. ceErpSupplierProductTime.Save();
  12516. }
  12517. else
  12518. {
  12519. ceErpSupplierProductTime.Update();
  12520. }
  12521. }
  12522. catch (Exception e)
  12523. {
  12524. }
  12525. returnSuccessMsg("保存成功");
  12526. return;
  12527. }
  12528. public void delSupplierProductTime()
  12529. {
  12530. int eid = GetPostInt("eid");
  12531. if (eid > 0)
  12532. {
  12533. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12534. if (ceErpSupplierProductTime == null)
  12535. {
  12536. returnErrorMsg("查无数据");
  12537. return;
  12538. }
  12539. ceErpSupplierProductTime.Delete();
  12540. returnSuccessMsg("保存成功");
  12541. return;
  12542. }
  12543. returnErrorMsg("缺少必要的参数");
  12544. }
  12545. public void getExpressInfo()
  12546. {
  12547. string ctid = GetPostString("ctid");
  12548. if (!string.IsNullOrEmpty(ctid))
  12549. {
  12550. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12551. if (ceErpTradeCell != null)
  12552. {
  12553. string outSid = ceErpTradeCell.OutSid;
  12554. if (outSid.Length > 0)
  12555. {
  12556. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12557. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12558. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12559. return;
  12560. }
  12561. }
  12562. returnErrorMsg("查无记录");
  12563. return;
  12564. }
  12565. returnErrorMsg("缺少必要的参数");
  12566. }
  12567. public void getExpressPostData()
  12568. {
  12569. string express = GetPostString("express");
  12570. if (!string.IsNullOrEmpty(express))
  12571. {
  12572. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12573. if (ceErpExpressInfo != null)
  12574. {
  12575. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12576. return;
  12577. }
  12578. }
  12579. returnErrorMsg("缺少必要的参数");
  12580. }
  12581. public void checkSupplierOrder()
  12582. {
  12583. string ctids = GetPostString("ctids");
  12584. if (ctids != null)
  12585. {
  12586. List<string> list = new List<string>();
  12587. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12588. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12589. for (int i = 0; i < dt.Rows.Count; i++)
  12590. {
  12591. DataRow row = dt.Rows[i];
  12592. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12593. {
  12594. continue;
  12595. }
  12596. list.Add(row["seller_memo"].ToString());
  12597. }
  12598. if (list.Count > 0)
  12599. {
  12600. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12601. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12602. return;
  12603. }
  12604. }
  12605. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12606. return;
  12607. }
  12608. public void addPersonId()
  12609. {
  12610. string tid = GetPostString("tid");
  12611. string personId = GetPostString("personId");
  12612. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12613. if (ceErpTrade != null)
  12614. {
  12615. ceErpTrade.receiver_zip = personId;
  12616. ceErpTrade.Update();
  12617. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12618. returnSuccessMsg("保存成功");
  12619. return;
  12620. }
  12621. returnErrorMsg("缺少必要的参数");
  12622. }
  12623. public void addDeliveryPaymant()
  12624. {
  12625. string tid = GetPostString("tid");
  12626. string paymant = GetPostString("paymant");
  12627. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12628. if (ceErpTrade != null)
  12629. {
  12630. if (!string.IsNullOrEmpty(paymant))
  12631. {
  12632. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12633. }
  12634. ceErpTrade.Update();
  12635. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12636. returnSuccessMsg("保存成功");
  12637. return;
  12638. }
  12639. returnErrorMsg("缺少必要的参数");
  12640. }
  12641. public void saveCellFile()
  12642. {
  12643. string tid = GetPostString("tid");
  12644. string ctid = GetPostString("ctid");
  12645. string urls = GetPostString("urls");
  12646. string type = GetPostString("type");
  12647. string del = GetPostString("del");
  12648. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12649. {
  12650. if ("1".Equals(del))
  12651. {
  12652. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12653. }
  12654. string[] list = urls.Split(',');
  12655. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12656. {
  12657. foreach (string item in list)
  12658. {
  12659. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12660. ceErpTradeCellFile.Create();
  12661. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12662. }
  12663. }
  12664. returnSuccessMsg("保存成功");
  12665. return;
  12666. }
  12667. returnErrorMsg("缺少必要的参数");
  12668. }
  12669. public void getCellFile()
  12670. {
  12671. string tid = GetPostString("tid");
  12672. string ctid = GetPostString("ctid");
  12673. string type = GetPostString("type");
  12674. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12675. {
  12676. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12677. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12678. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12679. return;
  12680. }
  12681. returnErrorMsg("缺少必要的参数");
  12682. }
  12683. public void delCellFile()
  12684. {
  12685. string id = GetPostString("id");
  12686. if (string.IsNullOrEmpty(id))
  12687. {
  12688. returnErrorMsg("缺少必要的参数");
  12689. return;
  12690. }
  12691. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12692. CeErpTradeCellFile.delByID(id);
  12693. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12694. returnSuccessMsg("保存成功");
  12695. }
  12696. }
  12697. }