sync.order.cs 654 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010
  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. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. namespace SiteCore.Handler
  54. {
  55. public partial class sync
  56. {
  57. public void get_erp_orderlist()
  58. {
  59. string poscode = CurrentUser.UserPost.Post.Code;
  60. DataStruct dStruct = GetPostStruct();
  61. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\opp袋.xlsx");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{ \"content\":{ \"businessType\":\"RECEIPT\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1754976830000,\"deliveryType\":\"DUMMY\",\"discountFee\":0.0,\"flag\":\"YELLOW\",\"lines\":[{ \"mark2\":[\"DELIVERED\"],\"num\":1900,\"outerId\":\"\",\"payment\":19.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded///gw.alicdn.com/imgextra/i2/O1CN01MkKGcP1DAC83Qzv0g_!!6000000000175-2-tps-664-664.png\",\"platServiceFee\":0.0,\"price\":0.01,\"refOlId\":\"4680447879925908321\",\"refSkuId\":\"0\",\"refSpuId\":\"718974148282\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.01,\"singleFee\":0.01,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"SHIPPED\",\"title\":\"补差价专用\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.0}],\"logisticsOrderNo\":\"0000\",\"mark2\":[],\"modifyTime\":1754979750000,\"openBuyerId\":\"AAH5RHraABkUZRPgSx37tfjU\",\"openBuyerNick\":\"w**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1754976823000,\"payTime\":1754976826000,\"payment\":19.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{ \"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{ \"logisticNo\":\"0000\",\"logisticName\":\"VIRTUAL\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"09ab2cbe3d9209cfa8b5e0c4727a01cf\",\"receiverState\":\"\",\"receiverTown\":\"\",\"refOid\":\"4680447879925908321\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"补差价:4680342074074908321-wangjie7409\",\"serviceFee\":0.0,\"shippingTime\":1754976827000,\"status\":\"SHIPPED\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.0,\"type\":\"SALE\"} }");
  74. //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}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //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}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. 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);
  89. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  90. {
  91. sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (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);
  92. }
  93. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. List<string> tidList = new List<string>();
  95. if (dataTable != null && dataTable.Rows.Count > 0)
  96. {
  97. foreach (DataRow row in dataTable.Rows)
  98. {
  99. tidList.Add("'" + row["tid"].ToString() + "'");
  100. }
  101. }
  102. if (tidList.Count > 0)
  103. {
  104. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  105. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  106. if (dataTable != null && dataTable.Rows.Count > 0)
  107. {
  108. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  109. if (count > 0)
  110. {
  111. Debug.WriteLine(index++);
  112. continue;
  113. }
  114. }
  115. }
  116. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  117. }
  118. catch (Exception e)
  119. {
  120. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  121. }
  122. Debug.WriteLine(index++);
  123. }*/
  124. List<string> lw = new List<string>();
  125. string tid = GetPostString("ctid");
  126. string date1 = GetPostString("date1");
  127. //12-1 修改
  128. string urgent = GetPostString("urgent");
  129. string back = GetPostString("back");
  130. string offlineSearch = GetPostString("offlineSearch");
  131. int paramsCount = 0;
  132. if (!string.IsNullOrWhiteSpace(urgent))
  133. {
  134. if (urgent.Equals("true"))
  135. {
  136. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  137. }
  138. }
  139. if (!string.IsNullOrWhiteSpace(back))
  140. {
  141. if (back.Equals("true"))
  142. {
  143. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  144. }
  145. }
  146. if (!string.IsNullOrWhiteSpace(offlineSearch))
  147. {
  148. if (offlineSearch.Equals("true"))
  149. {
  150. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  151. }
  152. }
  153. //end
  154. string date2 = GetPostString("date2");
  155. string buyernick = GetPostString("buyer_nick");
  156. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  157. {
  158. if (tid.Length <= 0 && buyernick.Length <= 0)
  159. {
  160. return;
  161. }
  162. }
  163. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  164. {
  165. if (tid.Length > 0)
  166. {
  167. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  168. if (ceErpTradeCell != null)
  169. {
  170. tid = ceErpTradeCell.tid;
  171. }
  172. List<string> select_tid = getTidByCtidMore(tid);
  173. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  174. }
  175. if (buyernick.Length > 0)
  176. {
  177. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  178. }
  179. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  180. if (dw.Length > 0)
  181. {
  182. lw.Add(dw);
  183. }
  184. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  185. {
  186. string usershop = CurrentUser.User.pemShop;
  187. lw.Add(string.Format("ShopId in ({0})", usershop));
  188. }
  189. }
  190. else
  191. {
  192. if (ex_psize == 0)
  193. {
  194. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  195. }
  196. if (PKey != "admin" && poscode != "SysAdmin")
  197. {
  198. string usershop = CurrentUser.User.pemShop;
  199. lw.Add(string.Format("ShopId in ({0})", usershop));
  200. paramsCount++;
  201. }
  202. }
  203. string uploaddate1 = GetPostString("uploaddate1");
  204. string uploaddate2 = GetPostString("uploaddate2");
  205. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  206. if (update.Length > 0) lw.Add(update);
  207. string deliverydate1 = GetPostString("deliverydate1");
  208. string deliverydate2 = GetPostString("deliverydate2");
  209. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  210. if (deliverydate.Length > 0)
  211. {
  212. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  213. };
  214. string shopname = GetPostString("shopname");
  215. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  216. string addwechat = GetPostString("addwechat");
  217. if (addwechat.Length > 0)
  218. {
  219. int addWt = Convert.ToInt32(addwechat);
  220. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  221. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  222. }
  223. string customer = GetPostString("customer");
  224. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  225. string design = GetPostString("design");
  226. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  227. string orderState = GetPostString("orderState");
  228. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  229. string address = GetPostString("address");
  230. 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));
  231. string sellermemo = GetPostString("seller_memo");
  232. if (sellermemo.Length > 0)
  233. {
  234. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  235. }
  236. string backReason = GetPostString("backReason");
  237. if (backReason.Length > 0)
  238. {
  239. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  240. }
  241. string apdate1 = GetPostString("apdate1");
  242. string apdate2 = GetPostString("apdate2");
  243. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  244. if (dwap.Length > 0) lw.Add(dwap);
  245. string price1 = GetPostString("price1");
  246. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  247. string price2 = GetPostString("price2");
  248. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  249. string isoldcustomer = GetPostString("isoldcus");
  250. string spudata = GetPostString("spudata");
  251. if ("0".Equals(spudata))
  252. {
  253. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  254. }
  255. if ("1".Equals(spudata))
  256. {
  257. lw.Add(string.Format("spu_id <> ''"));
  258. }
  259. string finishdate1 = GetPostString("finishdate1");
  260. string finishdate2 = GetPostString("finishdate2");
  261. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  262. bool isFinish = false;
  263. if (finishdate.Length > 0)
  264. {
  265. lw.Add(finishdate);
  266. isFinish = true;
  267. paramsCount++;
  268. }
  269. if (isoldcustomer.Length > 0)
  270. {
  271. if ("2".Equals(isoldcustomer))
  272. {
  273. lw.Add(string.Format("VipCustomer=1"));
  274. }
  275. else
  276. {
  277. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  278. }
  279. }
  280. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  281. if (ex_psize > 0)
  282. {
  283. int UserID = CurrentUser.UserID;
  284. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  285. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  286. {
  287. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  288. }
  289. dStruct.Order = "pay_time desc";
  290. }
  291. string isNew = GetPostString("isNew");
  292. if (isNew == "true")
  293. {
  294. lw.Add(string.Format("IsNew = {0}", 1));
  295. }
  296. string overtime = GetPostString("overtime");
  297. if (overtime == "1")
  298. {
  299. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  300. }
  301. String usePost = CurrentUser.UserPost.Post.Code;
  302. if (usePost.Equals("Operation") == true)
  303. {
  304. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  305. }
  306. else
  307. {
  308. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  309. }
  310. //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";
  311. if (dStruct.PageSize == 100000)
  312. {
  313. dStruct.Order = "";
  314. }
  315. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  316. DataTable dt = null;
  317. string tablename = "view_orderlist";
  318. if (isFinish)
  319. {
  320. tablename = "view_orderlist_end";
  321. }
  322. dt = WebCache.GetData(tablename, dStruct);
  323. if (dt != null && dt.Rows.Count > 0)
  324. {
  325. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  326. foreach (DataRow dr in dt.Rows)
  327. {
  328. try
  329. {
  330. if (dr["refund_fees"] != null)
  331. {
  332. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  333. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  334. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  335. if (payment == refund_fees)
  336. {
  337. dr["refund_fees"] = Math.Round(refund_fees, 2);
  338. }
  339. else if (refund_fees == total_fee)
  340. {
  341. dr["refund_fees"] = payment;
  342. }
  343. else
  344. {
  345. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  346. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  347. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  348. }
  349. }
  350. // 对象操作
  351. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  352. ceErpTradeCell.ctid = dr["ctid"].ToString();
  353. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  354. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  355. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  356. if (dStruct.PageSize != 100000)
  357. {
  358. if (dr["DispatchSort"].ToString() == "2")
  359. {
  360. dr["gongchuang"] = 200;
  361. }
  362. else if ("外协".Equals(dr["ToType"].ToString()))
  363. {
  364. dr["gongchuang"] = 200;
  365. }
  366. else if ("内部".Equals(dr["ToType"].ToString()))
  367. {
  368. dr["gongchuang"] = -1;
  369. }
  370. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  371. {
  372. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  373. dr["gongchuang"] = response.code;
  374. }
  375. }
  376. }
  377. catch (NullReferenceException ex)
  378. {
  379. // 处理空引用异常
  380. dr["refund_fees"] = "0.00";
  381. }
  382. }
  383. }
  384. writeGridDataTableJson(dStruct.TotalCount, dt);
  385. }
  386. public void get_erp_orderlist_sumprice()
  387. {
  388. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  389. return;
  390. List<string> lw = new List<string>();
  391. string tid = GetPostString("ctid");
  392. string date1 = GetPostString("date1");
  393. string date2 = GetPostString("date2");
  394. if (tid.Length > 0 || date1.Length > 0)
  395. {
  396. lw.Add(string.Format("ctid like '%{0}%'", tid));
  397. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  398. if (dw.Length > 0) lw.Add(dw);
  399. }
  400. else
  401. {
  402. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  403. }
  404. string shopname = GetPostString("shopname");
  405. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  406. string buyernick = GetPostString("buyer_nick");
  407. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  408. string customer = GetPostString("customer");
  409. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  410. string design = GetPostString("design");
  411. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  412. string orderState = GetPostString("orderState");
  413. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  414. string address = GetPostString("address");
  415. 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));
  416. string sellermemo = GetPostString("seller_memo");
  417. if (sellermemo.Length > 0)
  418. {
  419. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  420. }
  421. string apdate1 = GetPostString("apdate1");
  422. string apdate2 = GetPostString("apdate2");
  423. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  424. if (dwap.Length > 0) lw.Add(dwap);
  425. string price1 = GetPostString("price1");
  426. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  427. string price2 = GetPostString("price2");
  428. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  429. string isoldcustomer = GetPostString("isoldcus");
  430. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  431. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  432. if (PKey != "admin")
  433. {
  434. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  435. lw.Add(string.Format("shopId in ({0})", usershop));
  436. }
  437. //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";
  438. string mainWhere = string.Join(" and ", lw.ToArray());
  439. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  440. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  441. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  442. decimal total = 0;
  443. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  444. {
  445. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  446. }
  447. var res = new
  448. {
  449. data = total
  450. };
  451. string ro_jsond = JsonConvert.SerializeObject(res);
  452. returnSuccess(ro_jsond);
  453. return;
  454. }
  455. public void get_erp_CustomerServiceGather()
  456. {
  457. string userWhere = "", orderWhere = "";
  458. List<string> lw = new List<string>();
  459. string customer = GetPostString("customer");
  460. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  461. string shopname = GetPostString("shopname");
  462. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  463. string date1 = GetPostString("date1");
  464. string date2 = GetPostString("date2");
  465. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  466. if (dw.Length > 0) lw.Add(dw);
  467. orderWhere = string.Join(" and ", lw.ToArray());
  468. 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 " +
  469. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  470. "left join " +
  471. "( " +
  472. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  473. ") as b on a.ID = b.CustomerUserId " +
  474. "left join " +
  475. "( " +
  476. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  477. ") as d on a.ID = d.CustomerUserId " +
  478. "left join " +
  479. "( " +
  480. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  481. ") as e on a.ID = e.CustomerUserId " +
  482. "left join " +
  483. "( " +
  484. " select CustomerUserId, RefundCount, RefundSum from " +
  485. " ( " +
  486. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  487. " from CE_ErpTradeRefund a " +
  488. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  489. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  490. " group by CustomerUserId " +
  491. " ) as a " +
  492. ") as f on a.ID = f.CustomerUserId " +
  493. "where a.PostCode = 'CustomerService'",
  494. userWhere, orderWhere);
  495. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  496. writeGridDataTableJson(dt.Rows.Count, dt);
  497. //writeGridDataTableJson(dt.Rows.Count, dt);
  498. }
  499. //设计汇总
  500. public void get_erp_DesignerGather()
  501. {
  502. string userWhere = "", orderWhere = "";
  503. List<string> lw = new List<string>();
  504. string Designer = GetPostString("designer");
  505. int org = GetPostInt("org");
  506. if (Designer.Length > 0)
  507. {
  508. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  509. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  510. }
  511. else if (org > 0)
  512. {
  513. userWhere = string.Format(" where OrgID ={0}", org);
  514. }
  515. string shopname = GetPostString("shopname");
  516. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  517. string state = GetPostString("state");
  518. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  519. string OrderArea = GetPostString("order_area");
  520. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  521. string date1 = GetPostString("date1");
  522. string date2 = GetPostString("date2");
  523. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  524. if (dw.Length > 0) lw.Add(dw);
  525. string UpDate1 = GetPostString("UpDate1");
  526. string UpDate2 = GetPostString("UpDate2");
  527. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  528. if (dw.Length > 0) lw.Add(dw);
  529. orderWhere = string.Join(" and ", lw.ToArray());
  530. 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 (" +
  531. "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 " +
  532. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  533. "left join " +
  534. "( " +
  535. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  536. ") as b on a.ID = b.DesignUserId " +
  537. "left join " +
  538. "( " +
  539. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  540. ") as d on a.ID = d.DesignUserId " +
  541. "left join " +
  542. "( " +
  543. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  544. ") as e on a.ID = e.DesignUserId " +
  545. "left join " +
  546. "( " +
  547. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  548. ") as g on a.ID = g.DesignUserId " +
  549. "left join " +
  550. "( " +
  551. " select CustomerUserId, RefundCount, RefundSum from " +
  552. " ( " +
  553. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  554. " from CE_ErpTradeRefund a " +
  555. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  556. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  557. " group by CustomerUserId " +
  558. " ) as a " +
  559. ") as f on a.ID = f.CustomerUserId " +
  560. "where a.PostCode = 'Designer') as z",
  561. userWhere, orderWhere);
  562. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  563. writeGridDataTableJson(dt.Rows.Count, dt);
  564. }
  565. //删除tradecell的订单
  566. public void del_erp_cellorder()
  567. {
  568. if (UrlPostParmsCheck("ctid"))
  569. {
  570. string eid = GetPostString("ctid");
  571. CeErpTradeCell.DelByCtid(eid);
  572. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  573. returnSuccessMsg("删除成功");
  574. }
  575. }
  576. public void clear_erp_refundstate()
  577. {
  578. if (UrlPostParmsCheck("ids"))
  579. {
  580. string eids = GetPostString("ids");
  581. string[] ctidList = eids.Split(',');
  582. foreach (string ctid in ctidList)
  583. {
  584. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  585. if (entity != null)
  586. {
  587. entity.IsRefund = 0;
  588. entity.Update();
  589. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  590. }
  591. else
  592. continue;
  593. }
  594. returnSuccessMsg("操作成功");
  595. return;
  596. }
  597. returnErrorMsg("缺少必要参数");
  598. }
  599. public void set_erp_urgency()
  600. {
  601. if (UrlPostParmsCheck("ctid"))
  602. {
  603. string eid = GetPostString("ctid");
  604. CeErpTradeCell entity = null;
  605. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  606. if (entity != null)
  607. {
  608. double prices = commonHelper.calculationPrice(entity);
  609. if (prices <= 100)
  610. {
  611. returnErrorMsg("此订单金额不足100元,无法加急。");
  612. return;
  613. }
  614. string utime = GetPostString("urgencytime");
  615. if (utime.Length > 0)
  616. {
  617. entity.UrgencyTime = Convert.ToDateTime(utime);
  618. }
  619. else
  620. {
  621. returnErrorMsg("请选择加急时间");
  622. return;
  623. }
  624. if (entity.OrderState <= 4)
  625. {
  626. //entity.seller_memo = entity.seller_memo + "-加急";
  627. string smemo = entity.seller_memo;
  628. int kindex = smemo.IndexOf(")");
  629. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  630. if (lastoneStr != "-")
  631. {
  632. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  633. }
  634. string prememo = smemo.Substring(0, kindex + 2);
  635. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  636. int lastkindex = lastmemo.IndexOf("(");
  637. DateTime urgtime = Convert.ToDateTime(utime);
  638. string newlastmemo = "";
  639. if (lastkindex == 0)
  640. {
  641. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  642. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  643. }
  644. else
  645. {
  646. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  647. }
  648. entity.seller_memo = prememo + newlastmemo;
  649. }
  650. entity.IsUrgency = true;
  651. entity.UpdateTime = DateTime.Now;
  652. entity.Update();
  653. ApiVo apiVo = new ApiVo();
  654. apiVo.orderNumber = entity.ctid;
  655. apiVo.actionName = "changeDesign";
  656. apiVo.orderRemarks = entity.seller_memo;
  657. apiVo.remarkSign = 3;
  658. designHelper.API_WorkCore(apiVo); //changeDesign
  659. CeErpSukuraData.createInfo(entity.ctid, 7);
  660. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  661. returnSuccessMsg("设置成功!");
  662. return;
  663. }
  664. returnErrorMsg("找不到记录");
  665. }
  666. }
  667. public void set_erp_reset()
  668. {
  669. if (UrlPostParmsCheck("ctid"))
  670. {
  671. string eid = GetPostString("ctid");
  672. CeErpTradeCell entity = null;
  673. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  674. if (entity != null)
  675. {
  676. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  677. {
  678. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  679. {
  680. returnErrorMsg("财务要求已下单已发货无法重置");
  681. return;
  682. }
  683. }
  684. entity.IsUrgency = false;
  685. entity.seller_memo = "";
  686. entity.OtherMemo = "";
  687. entity.OrderState = 0;
  688. entity.IsReturn = 0;
  689. //entity.IsRefund = 0;
  690. entity.MemoOpt = 0;
  691. entity.AfterSaleState = 0;
  692. entity.AfterSaleResponsible = "";
  693. entity.AfterSaleUserId = 0;
  694. entity.IsNeedBill = 0;
  695. entity.CustomerUserId = 0;
  696. entity.DesignUserId = 0;
  697. entity.SupplierId = 0;
  698. entity.PlaceUserId = 0;
  699. entity.ptid = "";
  700. entity.IsSample = 0;
  701. entity.IsXianHuo = 0;
  702. entity.isDianziOrder = 0;
  703. entity.DispatchSort = 0;
  704. entity.IsVerifyToSupplier = false;
  705. entity.FinishPlaceTime = null;
  706. entity.Update();
  707. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  708. if (trade != null)
  709. {
  710. trade.seller_memo = "";
  711. trade.Update();
  712. }
  713. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  714. returnSuccessMsg("重置成功!");
  715. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  716. if (desginBill != null)
  717. {
  718. desginBill.isDel = 1;
  719. desginBill.Update();
  720. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  721. }
  722. ApiVo apiVo = new ApiVo();
  723. apiVo.orderNumber = entity.ctid;
  724. apiVo.actionName = "resetDesign";
  725. designHelper.API_WorkCore(apiVo);//resetDesign
  726. return;
  727. }
  728. returnErrorMsg("找不到记录");
  729. }
  730. }
  731. public void save_erp_sellermemo()
  732. {
  733. if (UrlPostParmsCheck("ctid"))
  734. {
  735. string ctid = GetPostString("ctid");
  736. CeErpTradeCell entity = null;
  737. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  738. if (entity != null)
  739. {
  740. string memo = GetPostString("seller_memo");
  741. memo = memo.Replace(" ", "");
  742. if (memo.Contains("补差"))
  743. {
  744. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  745. return;
  746. }
  747. List<string> bitList = new List<string>
  748. {
  749. "\\","/",":","*","?", "\"","<" ,">","|"
  750. };
  751. bool isIn = false;
  752. foreach (string bit in bitList)
  753. {
  754. if (memo.Contains(bit))
  755. {
  756. isIn = true;
  757. }
  758. }
  759. if (isIn)
  760. {
  761. returnErrorMsg("不能使用 一些符合作为文件名");
  762. return;
  763. }
  764. if (entity.seller_memo != memo)
  765. {
  766. if (entity.IsSample == 2)
  767. {
  768. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  769. return;
  770. }
  771. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  772. {
  773. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  774. {
  775. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  776. return;
  777. }
  778. /*if (CurrentUser.UserPost.Post.Code != "Place")
  779. {
  780. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  781. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  782. {
  783. returnErrorMsg("售前系统订单无法再此修改!");
  784. return;
  785. }
  786. }*/
  787. }
  788. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  789. }
  790. commonHelper.getCytPrice(entity);
  791. int memoopt = GetPostInt("MemoOpt");
  792. Boolean ismemoopt = false;
  793. if (memoopt > 0)
  794. {
  795. string stropt = "";
  796. if (memoopt == 1)
  797. {
  798. stropt = "“改稿”";
  799. ismemoopt = true;
  800. }
  801. else if (memoopt == 2)
  802. {
  803. stropt = "“定稿”";
  804. }
  805. else if (memoopt == 3)
  806. {
  807. stropt = "“查货”";
  808. CeErpSukuraData.createInfo(entity.ctid, 6);
  809. }
  810. entity.MemoOpt = Convert.ToInt32(memoopt);
  811. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  812. }
  813. if (entity.OrderState < 5)
  814. {
  815. memo = memo.Replace("(", "(");
  816. memo = memo.Replace(")", ")");
  817. }
  818. /* if (entity.OrderState < 3)
  819. {
  820. entity.DispatchSort = 0;
  821. }*/
  822. entity.seller_memo = memo;
  823. entity.UpdateTime = DateTime.Now;
  824. entity.Update();
  825. ApiVo apiVo = new ApiVo();
  826. apiVo.orderNumber = entity.ctid;
  827. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  828. apiVo.orderRemarks = memo;
  829. apiVo.remarkSign = memoopt;
  830. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  831. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  832. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  833. {
  834. dataHelper.api_orderBack(entity.ctid, "0", "");
  835. }
  836. if (entity.seller_memo.Contains("改稿"))
  837. {
  838. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  839. }
  840. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  841. returnSuccessMsg("保存成功!");
  842. return;
  843. }
  844. returnErrorMsg("找不到记录");
  845. }
  846. }
  847. public void ins_erp_checkorder()
  848. {
  849. if (UrlPostParmsCheck("ctid"))
  850. {
  851. string ctid = GetPostString("ctid");
  852. CeErpTradeCell entity = null;
  853. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  854. if (entity != null)
  855. {
  856. if (entity.OrderState < 6)
  857. {
  858. returnErrorMsg("下单完成后才可查货");
  859. return;
  860. }
  861. /*if (entity.OrderState > 6)
  862. {
  863. returnErrorMsg("订单已发货");
  864. return;
  865. }*/
  866. if (entity.FinishPlaceTime != null)
  867. {
  868. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  869. {
  870. returnErrorMsg("下单时间不足,无法查货");
  871. return;
  872. }
  873. }
  874. entity.MemoOpt = 3;
  875. entity.CheckOrderTime = DateTime.Now;
  876. entity.UpdateTime = DateTime.Now;
  877. entity.Update();
  878. CeErpSukuraData.createInfo(entity.ctid, 6);
  879. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  880. returnSuccessMsg("操作成功!");
  881. return;
  882. }
  883. returnErrorMsg("找不到记录");
  884. }
  885. }
  886. public void save_erp_othermemo()
  887. {
  888. if (UrlPostParmsCheck("ctid"))
  889. {
  890. string ctid = GetPostString("ctid");
  891. CeErpTradeCell entity = null;
  892. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  893. if (entity != null)
  894. {
  895. entity.OtherMemo = GetPostString("otherMemo");
  896. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  897. {
  898. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  899. StringBuilder sql = new StringBuilder();
  900. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  901. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  902. if (dt != null && dt.Rows.Count > 0)
  903. {
  904. foreach (DataRow dr in dt.Rows)
  905. {
  906. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  907. {
  908. //品类一直
  909. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  910. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  911. if (ceErpSampleCustomer == null)
  912. {
  913. ceErpSampleCustomer = new CeErpSampleCustomer();
  914. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  915. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  916. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  917. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  918. ceErpSampleCustomer.shopId = entity.ShopId;
  919. }
  920. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  921. ceErpSampleCustomer.lastTid = entity.tid;
  922. if (ceErpSampleCustomer.ID > 0)
  923. {
  924. ceErpSampleCustomer.Update();
  925. }
  926. else
  927. {
  928. ceErpSampleCustomer.Create();
  929. }
  930. }
  931. }
  932. }
  933. }
  934. //if (entity.IsOldCustomer == 1)
  935. //{
  936. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  937. //{
  938. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  939. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  940. //}
  941. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  942. //{
  943. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  944. // {
  945. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  946. // {
  947. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  948. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  949. // }
  950. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  951. // {
  952. // entity.OrderState = 2;
  953. // entity.DesignUserId = 0;
  954. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  955. // }
  956. // else
  957. // {
  958. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  959. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  960. // }
  961. // }
  962. //}
  963. //}
  964. entity.UpdateTime = DateTime.Now;
  965. entity.Update();
  966. returnSuccessMsg("保存成功!");
  967. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  968. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  969. if (entity.OtherMemo.Contains("改稿"))
  970. {
  971. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  972. }
  973. return;
  974. }
  975. returnErrorMsg("找不到记录");
  976. }
  977. }
  978. public void save_erp_customermemo()
  979. {
  980. if (UrlPostParmsCheck("ctid"))
  981. {
  982. string ctid = GetPostString("ctid");
  983. CeErpTradeCell entity = null;
  984. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  985. if (entity != null)
  986. {
  987. entity.UpdateTime = DateTime.Now;
  988. entity.CustomerMemo = GetPostString("CustomerMemo");
  989. entity.Update();
  990. ApiVo apiVo = new ApiVo();
  991. apiVo.orderNumber = entity.ctid;
  992. apiVo.actionName = "followRemarks";
  993. apiVo.orderRemarks = entity.CustomerMemo;
  994. designHelper.API_WorkCore(apiVo);//followRemarks
  995. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  996. returnSuccessMsg("保存成功!");
  997. return;
  998. }
  999. returnErrorMsg("找不到记录");
  1000. }
  1001. }
  1002. public void upd_erp_addmemotag()
  1003. {
  1004. if (UrlPostParmsCheck("ctid"))
  1005. {
  1006. ;
  1007. string eid = GetPostString("ctid");
  1008. string sfTagstr = GetPostString("memotag");
  1009. CeErpTradeCell entity = null;
  1010. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1011. if (entity != null)
  1012. {
  1013. ApiVo apiVo = new ApiVo();
  1014. if (entity.OrderState == 0)
  1015. {
  1016. returnErrorMsg("请先领单");
  1017. return;
  1018. }
  1019. //撤销顺丰
  1020. if (sfTagstr == "撤销顺丰")
  1021. {
  1022. entity.IsSF = 0;
  1023. string reMsg = "";
  1024. string oldmemo = entity.seller_memo;
  1025. if (entity.OrderState < 5)
  1026. {
  1027. oldmemo = oldmemo.Replace("顺丰到付", "");
  1028. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1029. entity.seller_memo = oldmemo;
  1030. }
  1031. else
  1032. {
  1033. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1034. {
  1035. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1036. }
  1037. }
  1038. entity.Update();
  1039. apiVo.orderNumber = entity.ctid;
  1040. apiVo.actionName = "orderRemarks";
  1041. apiVo.orderRemarks = entity.seller_memo;
  1042. apiVo.isSf = entity.IsSF.ToString();
  1043. designHelper.API_WorkCore(apiVo);//orderRemarks
  1044. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1045. returnSuccessMsg("撤销成功!" + reMsg);
  1046. return;
  1047. }
  1048. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1049. {
  1050. //string oldmemo = entity.seller_memo;
  1051. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1052. string sfStr = GetPostString("memotag");
  1053. string smemo = entity.seller_memo;
  1054. int kindex = smemo.IndexOf(")");
  1055. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1056. if (lastoneStr != "-")
  1057. {
  1058. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1059. }
  1060. string prememo = smemo.Substring(0, kindex + 2);
  1061. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1062. int lastkindex = lastmemo.IndexOf("(");
  1063. string newlastmemo = "";
  1064. if (lastkindex == 0)
  1065. {
  1066. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1067. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1068. }
  1069. else
  1070. {
  1071. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1072. }
  1073. entity.seller_memo = prememo + newlastmemo;
  1074. }
  1075. string sfTagMSg = "";
  1076. if (sfTagstr == "顺丰寄付")
  1077. {
  1078. entity.IsSF = 1;
  1079. sfTagMSg = "顺丰寄付";
  1080. }
  1081. else if (sfTagstr == "顺丰到付")
  1082. {
  1083. entity.IsSF = 2;
  1084. sfTagMSg = "顺丰到付";
  1085. }
  1086. entity.Update();
  1087. apiVo = new ApiVo();
  1088. apiVo.orderNumber = entity.ctid;
  1089. apiVo.actionName = "orderRemarks";
  1090. apiVo.orderRemarks = entity.seller_memo;
  1091. apiVo.isSf = entity.IsSF.ToString();
  1092. designHelper.API_WorkCore(apiVo);//orderRemarks
  1093. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1094. returnSuccessMsg("标记成功!");
  1095. return;
  1096. }
  1097. returnErrorMsg("找不到记录");
  1098. }
  1099. }
  1100. public void upd_erp_ordertag()
  1101. {
  1102. if (UrlPostParmsCheck("ctid"))
  1103. {
  1104. string eid = GetPostString("ctid");
  1105. CeErpTradeCell entity = null;
  1106. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1107. if (entity != null)
  1108. {
  1109. int tag = GetPostInt("wechattag");
  1110. //if(tag==4 && entity.IsSample == 2)
  1111. //{
  1112. // returnErrorMsg("补差价单不能标记微信单");
  1113. // return;
  1114. //}
  1115. entity.wechatTag = tag;
  1116. entity.Update();
  1117. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1118. if (tag == 1)
  1119. {
  1120. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1121. if (cash == null)
  1122. {
  1123. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1124. cash = new CeErpReturnCash();
  1125. cash.tid = entity.tid;
  1126. cash.seller_nick = main.seller_nick;
  1127. cash.payment = trade.payment;
  1128. cash.buyer_nick = main.buyer_nick;
  1129. cash.cashstate = 0;
  1130. cash.rtype = "微信返现";
  1131. cash.returnprice = 0;
  1132. cash.created = DateTime.Now;
  1133. cash.con = "订单标记微信单";
  1134. cash.img = "";
  1135. cash.applyuserid = CurrentUser.UserID;
  1136. cash.Create();
  1137. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1138. }
  1139. else
  1140. {
  1141. cash.cashstate = 0;
  1142. cash.Update();
  1143. }
  1144. CeErpSukuraData.createInfo(entity.ctid, 9);
  1145. }
  1146. else if (tag == 2)
  1147. {
  1148. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1149. if (cash == null)
  1150. {
  1151. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1152. cash = new CeErpReturnCash();
  1153. cash.tid = entity.tid;
  1154. cash.seller_nick = main.seller_nick;
  1155. cash.payment = trade.payment;
  1156. cash.buyer_nick = main.buyer_nick;
  1157. cash.cashstate = 0;
  1158. cash.rtype = "推购返现";
  1159. cash.returnprice = 5;
  1160. cash.created = DateTime.Now;
  1161. cash.con = "订单标记推购单";
  1162. cash.img = "";
  1163. cash.applyuserid = CurrentUser.UserID;
  1164. cash.Create();
  1165. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1166. }
  1167. else
  1168. {
  1169. cash.cashstate = 0;
  1170. cash.Update();
  1171. }
  1172. CeErpSukuraData.createInfo(entity.ctid, 9);
  1173. }
  1174. else if (tag == 3)
  1175. {
  1176. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1177. if (pers == null)
  1178. {
  1179. pers = new CeErpPersuade();
  1180. pers.ctid = entity.ctid;
  1181. pers.pstate = 0;
  1182. pers.created = DateTime.Now;
  1183. pers.applyuserid = CurrentUser.UserID;
  1184. pers.Create();
  1185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1186. }
  1187. else
  1188. {
  1189. pers.pstate = 0;
  1190. pers.Update();
  1191. }
  1192. }
  1193. else if (tag == 4 || tag == 5)
  1194. {
  1195. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1196. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1197. if (pers == null)
  1198. {
  1199. pers = CeErpStayGoods.GetByTid(entity.tid);
  1200. }
  1201. if (pers == null)
  1202. {
  1203. pers = new CeErpStayGoods();
  1204. pers.t_id = entity.tid;
  1205. pers.ctid = entity.ctid;
  1206. pers.status = "待审核";
  1207. pers.audit_type = 0;
  1208. if (tag == 4)
  1209. {
  1210. pers.stay_type = "微信推购";
  1211. }
  1212. else
  1213. {
  1214. pers.stay_type = "旺旺推购";
  1215. }
  1216. if (entity.IsXianHuo == 0)
  1217. {
  1218. pers.product_id = entity.ProductId;
  1219. }
  1220. pers.wangwang = main.buyer_nick;
  1221. pers.shop_name = main.seller_nick;
  1222. pers.creata_time = DateTime.Now;
  1223. pers.create_u_id = CurrentUser.UserID;
  1224. pers.create_u_name = CurrentUser.UserName;
  1225. pers.Create();
  1226. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1227. }
  1228. else
  1229. {
  1230. pers.ctid = entity.ctid;
  1231. pers.audit_type = 0;
  1232. pers.Update();
  1233. }
  1234. CeErpSukuraData.createInfo(entity.ctid, 10);
  1235. }
  1236. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1237. returnSuccessMsg("标记成功!");
  1238. return;
  1239. }
  1240. returnErrorMsg("找不到记录");
  1241. }
  1242. }
  1243. public void upd_erp_ordertag_cancel()
  1244. {
  1245. if (UrlPostParmsCheck("ctid"))
  1246. {
  1247. string eid = GetPostString("ctid");
  1248. CeErpTradeCell entity = null;
  1249. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1250. if (entity != null)
  1251. {
  1252. entity.wechatTag = 0;
  1253. entity.Update();
  1254. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1255. if (pers != null)
  1256. {
  1257. pers.status = "取消推购";
  1258. pers.audit_type = 3;
  1259. pers.Update();
  1260. }
  1261. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1262. returnSuccessMsg("标记成功!");
  1263. return;
  1264. }
  1265. returnErrorMsg("找不到记录");
  1266. }
  1267. }
  1268. public void upd_erp_addweichattag()
  1269. {
  1270. if (UrlPostParmsCheck("ctid"))
  1271. {
  1272. ;
  1273. string eid = GetPostString("ctid");
  1274. CeErpTradeCell entity = null;
  1275. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1276. if (entity != null)
  1277. {
  1278. if (entity.IsAddWechat > 0)
  1279. {
  1280. returnErrorMsg("此单已经标记过了");
  1281. return;
  1282. }
  1283. 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);
  1284. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1285. if (dt.Rows.Count > 0)
  1286. {
  1287. entity.IsAddWechat = 2;
  1288. }
  1289. else
  1290. {
  1291. entity.IsAddWechat = 1;
  1292. }
  1293. entity.Update();
  1294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1295. returnSuccessMsg("标记成功!");
  1296. return;
  1297. }
  1298. returnErrorMsg("找不到记录");
  1299. }
  1300. }
  1301. public void upd_erp_getmyorder()
  1302. {
  1303. if (UrlPostParmsCheck("ctid"))
  1304. {
  1305. string eid = GetPostString("ctid");
  1306. CeErpTradeCell entity = null;
  1307. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1308. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1309. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1310. {
  1311. returnErrorMsg("台湾客户需填写身份证号!");
  1312. return;
  1313. }
  1314. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1315. {
  1316. returnErrorMsg("偏远地区需要填写物流费!");
  1317. return;
  1318. }
  1319. if (entity != null)
  1320. {
  1321. if (entity.ctid.IndexOf("C") != -1)
  1322. {
  1323. StringBuilder sql = new StringBuilder();
  1324. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1325. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1326. if (dt.Rows.Count > 0)
  1327. {
  1328. decimal total = 0;
  1329. foreach (DataRow dr in dt.Rows)
  1330. {
  1331. total += Convert.ToDecimal(dr["payment"]);
  1332. }
  1333. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1334. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1335. {
  1336. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1337. return;
  1338. }
  1339. }
  1340. }
  1341. if (entity.OrderState == -1)
  1342. {
  1343. returnErrorMsg("待审核订单无法领取!");
  1344. return;
  1345. }
  1346. entity.CustomerUserId = CurrentUser.UserID;
  1347. if (entity.OrderState < 2)
  1348. {
  1349. entity.OrderState = 2;
  1350. if (entity.ShopId != 0)
  1351. {
  1352. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1353. }
  1354. }
  1355. entity.UpdateTime = DateTime.Now;
  1356. entity.Update();
  1357. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1358. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1359. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1360. {
  1361. dataHelper.api_orderBack(entity.ctid, "0", "");
  1362. }
  1363. returnSuccessMsg("领单成功!");
  1364. return;
  1365. }
  1366. returnErrorMsg("找不到记录");
  1367. }
  1368. }
  1369. public void getmyorder_from_init()
  1370. {
  1371. if (UrlPostParmsCheck("ctid"))
  1372. {
  1373. string eid = GetPostString("ctid");
  1374. CeErpTradeCell entity = null;
  1375. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1376. if (entity != null)
  1377. {
  1378. string sellerMemo = GetPostString("sellerMemo");
  1379. if (sellerMemo.Length > 0)
  1380. {
  1381. entity.seller_memo = sellerMemo;
  1382. }
  1383. string oterhMemo = GetPostString("otherMemo");
  1384. if (oterhMemo.Length > 0)
  1385. {
  1386. entity.OtherMemo = oterhMemo;
  1387. }
  1388. int urg = GetPostInt("urgency");
  1389. entity.IsUrgency = (urg == 1 ? true : false);
  1390. int wechat = GetPostInt("wechat");
  1391. int command = GetPostInt("command");
  1392. if (wechat == 1)
  1393. {
  1394. entity.wechatTag = 1;
  1395. }
  1396. if (command == 1)
  1397. {
  1398. entity.wechatTag = 2;
  1399. }
  1400. string pPro = GetPostString("pprofession");
  1401. if (pPro.Length > 0)
  1402. {
  1403. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1404. string spro = GetPostString("profession");
  1405. if (spro.Length > 0)
  1406. {
  1407. entity.ProfessionId = Convert.ToInt32(spro);
  1408. }
  1409. }
  1410. string proId = GetPostString("productId");
  1411. if (proId.Length > 0)
  1412. {
  1413. entity.ProductId = Convert.ToInt32(proId);
  1414. }
  1415. entity.Material = GetPostString("material");
  1416. entity.Craft = GetPostString("craft");
  1417. entity.CustomerUserId = CurrentUser.UserID;
  1418. if (entity.OrderState < 2)
  1419. {
  1420. entity.OrderState = 2;
  1421. if (entity.ShopId != 0)
  1422. {
  1423. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1424. }
  1425. }
  1426. entity.Update();
  1427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1428. returnSuccessMsg("领单成功!");
  1429. return;
  1430. }
  1431. returnErrorMsg("找不到记录");
  1432. }
  1433. }
  1434. public void upd_erp_setrelationorder()
  1435. {
  1436. if (UrlPostParmsCheck("ctid"))
  1437. {
  1438. ;
  1439. string eid = GetPostString("ctid");
  1440. string ftid = GetPostString("ftid");
  1441. CeErpTradeCell entity = null;
  1442. CeErpTradeCell fentity = null;
  1443. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1444. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1445. if (fentity == null)
  1446. {
  1447. returnErrorMsg("找不到关联的主订单");
  1448. return;
  1449. }
  1450. if (entity != null)
  1451. {
  1452. if (entity.OrderState >= 5)
  1453. {
  1454. returnErrorMsg("本单已经设计完成无法关联");
  1455. return;
  1456. }
  1457. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1458. {
  1459. returnErrorMsg("线下单续审核后才能关联!");
  1460. return;
  1461. }
  1462. entity.ptid = ftid;
  1463. entity.OrderState = fentity.OrderState;
  1464. //entity.status = fentity.status;
  1465. entity.CustomerUserId = fentity.CustomerUserId;
  1466. entity.DesignUserId = fentity.DesignUserId;
  1467. entity.seller_memo = "补差价单:" + ftid;
  1468. entity.IsSample = 2;
  1469. entity.Update();
  1470. ApiVo apiVo = new ApiVo();
  1471. apiVo.orderNumber = ftid;
  1472. apiVo.payment = entity.payment;
  1473. apiVo.actionName = "repairDesign";
  1474. designHelper.API_WorkCore(apiVo);//repairDesign
  1475. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1476. returnSuccessMsg("关联成功!");
  1477. return;
  1478. }
  1479. else
  1480. returnErrorMsg("找不到记录");
  1481. }
  1482. }
  1483. public void download_erp_neworder()
  1484. {
  1485. string seller = GetPostString("seller_nick");
  1486. string tid = GetPostString("tid");
  1487. if (seller.Length <= 0 || tid.Length <= 0)
  1488. {
  1489. returnErrorMsg("数据错误");
  1490. }
  1491. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1492. //{
  1493. // returnErrorMsg("找不到店铺Sessionkey");
  1494. //}
  1495. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1496. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1497. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1498. if (res.IndexOf("refOid") == -1)
  1499. {
  1500. returnErrorMsg("下载订单数据失败");
  1501. return;
  1502. }
  1503. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1504. returnSuccessMsg("下载完成");
  1505. //tmcHelper.createNewOrder(res);
  1506. //CeErpTrade entr = null;
  1507. //entr = CeErpTrade.Get(tid);
  1508. //if (entr != null)
  1509. //{
  1510. // returnSuccess("下载成功");
  1511. // //下载成功之后,Cell表生成对应的订单;
  1512. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1513. //}
  1514. //else
  1515. //{
  1516. // returnErrorMsg("下载失败或者创建订单失败");
  1517. //}
  1518. }
  1519. public void set_erp_atersale()
  1520. {
  1521. if (UrlPostParmsCheck("ctid"))
  1522. {
  1523. string eid = GetPostString("ctid");
  1524. string reason = GetPostString("AfterSaleReason");
  1525. CeErpTradeCell entity = null;
  1526. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1527. if (entity != null)
  1528. {
  1529. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1530. {
  1531. returnErrorMsg("此订单已经在售后");
  1532. return;
  1533. }*/
  1534. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1535. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1536. entity.AfterSaleTime = DateTime.Now;
  1537. entity.HandleTime = null;
  1538. entity.Update();
  1539. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1540. returnSuccessMsg("转售后成功!");
  1541. return;
  1542. }
  1543. returnErrorMsg("找不到记录");
  1544. }
  1545. }
  1546. public void set_erp_withdraw()
  1547. {
  1548. if (UrlPostParmsCheck("ctid"))
  1549. {
  1550. try
  1551. {
  1552. string eid = GetPostString("ctid");//商品id
  1553. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1554. CeWithdraw ceWithdrawSelect = null;
  1555. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1556. if (ceWithdrawSelect != null)
  1557. {
  1558. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1559. {
  1560. ceWithdrawSelect.status = -1;
  1561. ceWithdrawSelect.Update();
  1562. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1563. returnSuccessMsg("重新发起审核成功");
  1564. return;
  1565. }
  1566. else
  1567. {
  1568. returnSuccessMsg("请勿重复申请!");
  1569. return;
  1570. }
  1571. }
  1572. else
  1573. {
  1574. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1575. if (string.IsNullOrEmpty(CustomerUserId))
  1576. {
  1577. CustomerUserId = "-1";
  1578. }
  1579. int Userid = CurrentUser.UserID;//用户id
  1580. CeWithdraw ceWithdraw = new CeWithdraw();
  1581. ceWithdraw.tid = eid;
  1582. ceWithdraw.userid = Userid;
  1583. ceWithdraw.providerid = CustomerUserId;
  1584. ceWithdraw.status = 3;
  1585. ceWithdraw.creationtime = DateTime.Now;
  1586. ceWithdraw.Create();
  1587. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1588. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1589. return;
  1590. }
  1591. }
  1592. catch
  1593. {
  1594. returnErrorMsg("申请撤回订单失败");
  1595. return;
  1596. }
  1597. }
  1598. }
  1599. public void ins_erp_billinfo()
  1600. {
  1601. if (UrlPostParmsCheck("ctid"))
  1602. {
  1603. string eid = GetPostString("ctid");
  1604. CeErpTradeCell entity = null;
  1605. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1606. if (entity != null)
  1607. {
  1608. CeErpBill bill = CeErpBill.GetByTid(eid);
  1609. bool isHave = false;
  1610. if (bill != null)
  1611. {
  1612. isHave = true;
  1613. if (bill.state != 4)
  1614. {
  1615. returnErrorMsg("此单已经申请过发票了");
  1616. return;
  1617. }
  1618. }
  1619. if (entity.IsNeedBill == 0)
  1620. {
  1621. entity.IsNeedBill = 1;
  1622. }
  1623. entity.Update();
  1624. string errjson = "";
  1625. try
  1626. {
  1627. CeErpBill bill_entity = new CeErpBill();
  1628. bill_entity.tid = entity.tid;
  1629. bill_entity.title = GetPostString("title");
  1630. string taxstr = GetPostString("tax");
  1631. taxstr = taxstr.Replace(" ", "");
  1632. bill_entity.tax = taxstr;
  1633. bill_entity.bank = GetPostString("bank");
  1634. string bankacstr = GetPostString("bankac");
  1635. bankacstr = bankacstr.Replace(" ", "");
  1636. bill_entity.bankac = bankacstr;
  1637. bill_entity.address = GetPostString("address");
  1638. bill_entity.phone = GetPostString("phone");
  1639. bill_entity.price = GetPostString("price");
  1640. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1641. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1642. {
  1643. billCount += 1;
  1644. }
  1645. string prebill = "ltb";
  1646. for (int idx = 1; idx <= billCount; idx++)
  1647. {
  1648. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1649. string billoid = prebill + idx + dtstr;
  1650. bill_entity.billOrderId += billoid;
  1651. if (idx < billCount)
  1652. {
  1653. bill_entity.billOrderId += ",";
  1654. }
  1655. }
  1656. bill_entity.productId = GetPostInt("ProductName");
  1657. bill_entity.num = GetPostInt("num");
  1658. bill_entity.unit = GetPostString("unit");
  1659. bill_entity.type = GetPostString("type");
  1660. bill_entity.sendType = GetPostString("SendType");
  1661. bill_entity.email = GetPostString("email");
  1662. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1663. bill_entity.shopName = GetPostString("ShopName");
  1664. bill_entity.applymemo = GetPostString("applyMemo");
  1665. bill_entity.createTime = DateTime.Now;
  1666. bill_entity.state = 0;
  1667. bill_entity.userId = CurrentUser.UserID;
  1668. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1669. bill_entity.Create();
  1670. }
  1671. catch (Exception ex)
  1672. {
  1673. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1674. returnErrorMsg("创建发票出错!");
  1675. return;
  1676. }
  1677. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1678. returnSuccessMsg("发票申请成功!");
  1679. return;
  1680. }
  1681. returnErrorMsg("找不到记录");
  1682. }
  1683. }
  1684. public void ins_erp_neworder()
  1685. {
  1686. if (UrlPostParmsCheck("receiver_name"))
  1687. {
  1688. CeErpTrade entity = new CeErpTrade();
  1689. string plat_form = GetPostString("platform");
  1690. string preStr = "N_";
  1691. if (plat_form == "拼多多")
  1692. {
  1693. preStr = "P_";
  1694. }
  1695. else if (plat_form == "阿里巴巴")
  1696. {
  1697. preStr = "A_";
  1698. }
  1699. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1700. entity.seller_nick = GetPostString("seller_nick");
  1701. entity.buyer_nick = GetPostString("buyer_nick");
  1702. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1703. entity.total_fee = entity.payment;
  1704. entity.pay_time = DateTime.Now;
  1705. entity.status = "NOT_SHIPPED";
  1706. entity.receiver_name = GetPostString("receiver_name");
  1707. entity.receiver_mobile = GetPostString("receiver_mobile");
  1708. entity.receiver_state = GetPostString("receiver_state");
  1709. entity.receiver_city = GetPostString("receiver_city");
  1710. entity.receiver_district = GetPostString("receiver_district");
  1711. entity.receiver_address = GetPostString("receiver_address");
  1712. if (entity.receiver_state == "" || entity.receiver_city == "")
  1713. {
  1714. returnErrorMsg("收件地址不能为空");
  1715. return;
  1716. }
  1717. int shopId = 0;
  1718. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1719. if (nShop != null)
  1720. {
  1721. shopId = nShop.ID;
  1722. }
  1723. if (shopId != 34 && entity.payment == 0)
  1724. {
  1725. returnErrorMsg("公司自用的单金额才能为0");
  1726. return;
  1727. }
  1728. entity.Create();
  1729. CeErpTradeCell entitycell = new CeErpTradeCell();
  1730. entitycell.ctid = entity.tid;
  1731. entitycell.tid = entity.tid;
  1732. entitycell.ShopId = shopId;
  1733. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1734. entitycell.OrderState = 0;
  1735. entitycell.pay_time = entity.pay_time;
  1736. entitycell.IsOffLineOrder = 1;
  1737. entitycell.Create();
  1738. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1739. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1740. return;
  1741. }
  1742. }
  1743. public void ins_erp_neworder2()
  1744. {
  1745. if (UrlPostParmsCheck("receiver_name"))
  1746. {
  1747. //string plat_form = GetPostString("platform");
  1748. string preStr = "X_";
  1749. string memo = GetPostString("memo");
  1750. string productId = GetPostString("productId");
  1751. string primg = GetPostString("proofimg");
  1752. string sellerNick = GetPostString("seller_nick");
  1753. string addFrom = GetPostString("addfrom");
  1754. if (addFrom == "1")
  1755. {
  1756. preStr = "N_";
  1757. }
  1758. int shopId = 0;
  1759. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1760. if (nShop != null)
  1761. {
  1762. shopId = nShop.ID;
  1763. }
  1764. else
  1765. {
  1766. returnErrorMsg("找不到对应店铺");
  1767. return;
  1768. }
  1769. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1770. {
  1771. returnErrorMsg("必须上传付款凭证");
  1772. return;
  1773. }
  1774. CeErpTrade entity = new CeErpTrade();
  1775. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1776. entity.seller_nick = sellerNick;
  1777. entity.buyer_nick = GetPostString("buyer_nick");
  1778. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1779. entity.total_fee = entity.payment;
  1780. entity.pay_time = DateTime.Now;
  1781. entity.status = "NOT_SHIPPED";
  1782. entity.receiver_name = GetPostString("receiver_name");
  1783. entity.receiver_mobile = GetPostString("receiver_mobile");
  1784. entity.receiver_state = GetPostString("receiver_state");
  1785. entity.receiver_city = GetPostString("receiver_city");
  1786. entity.receiver_district = GetPostString("receiver_district");
  1787. entity.receiver_address = GetPostString("receiver_address");
  1788. entity.seller_memo = memo;
  1789. entity.orderFrom = 20;
  1790. entity.orderType = 15;
  1791. if (entity.receiver_state == "" || entity.receiver_city == "")
  1792. {
  1793. returnErrorMsg("收件地址不能为空");
  1794. return;
  1795. }
  1796. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1797. {
  1798. returnErrorMsg("公司自用的单金额才能为0");
  1799. return;
  1800. }
  1801. entity.Create();
  1802. string toWhere = GetPostString("towhere");
  1803. CeErpTradeCell entitycell = new CeErpTradeCell();
  1804. entitycell.ctid = entity.tid;
  1805. //唯一标识
  1806. entitycell.OrderSn = entity.tid;
  1807. string orderSn = dataHelper.getSaleOrderSn();
  1808. if (orderSn != "")
  1809. {
  1810. entitycell.OrderSn = orderSn;
  1811. }
  1812. entitycell.tid = entity.tid;
  1813. //if (preStr == "X_")
  1814. //{
  1815. entitycell.IsOffLineOrder = 1;
  1816. //}
  1817. entitycell.CustomerUserId = CurrentUser.UserID;
  1818. entitycell.PayProofImg = primg;
  1819. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1820. entitycell.ProductId = Convert.ToInt32(productId);
  1821. entitycell.ShopId = shopId;
  1822. entitycell.UpdateTime = DateTime.Now;
  1823. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1824. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1825. {
  1826. entitycell.IsXianHuo = 1;
  1827. }
  1828. entitycell.pay_time = entity.pay_time;
  1829. if (toWhere == "1")
  1830. {
  1831. entitycell.OrderState = 2;
  1832. }
  1833. else
  1834. {
  1835. entitycell.OrderState = 6;
  1836. entitycell.FinishPlaceTime = entitycell.pay_time;
  1837. }
  1838. if (shopId == 94)
  1839. {
  1840. entitycell.OrderState = 4;
  1841. entitycell.WaitDesignTime = entitycell.pay_time;
  1842. entitycell.StartDesignTime = entitycell.pay_time;
  1843. entitycell.DesignUserId = 218;
  1844. }
  1845. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1846. {
  1847. entitycell.OrderState = -1;//修改12-5
  1848. CeWithdraw ceWithdraw = new CeWithdraw();
  1849. ceWithdraw.tid = entity.tid;
  1850. ceWithdraw.providerid = "-1";
  1851. ceWithdraw.status = -1;
  1852. ceWithdraw.creationtime = DateTime.Now;
  1853. ceWithdraw.userid = 742;
  1854. ceWithdraw.Create();
  1855. }
  1856. entitycell.Create();
  1857. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1858. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1859. {
  1860. addPlaceRegist(entitycell, CurrentUser.UserID);
  1861. }
  1862. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1863. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1864. return;
  1865. }
  1866. }
  1867. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1868. {
  1869. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1870. entity.PlactTime = tradecell.pay_time;
  1871. entity.AddUserId = userid;
  1872. entity.FileName = tradecell.seller_memo;
  1873. entity.Supplier = 24;
  1874. entity.CreateTime = DateTime.Now;
  1875. entity.Did = tradecell.ctid;
  1876. entity.tid = tradecell.tid;
  1877. entity.splitTag = tradecell.SplitTag;
  1878. entity.CurState = "未完成";
  1879. entity.Create();
  1880. }
  1881. public void get_erp_offlinelist()
  1882. {
  1883. DataStruct dStruct = GetPostStruct();
  1884. List<string> lw = new List<string>();
  1885. string tid = GetPostString("ctid");
  1886. string date1 = GetPostString("date1");
  1887. string date2 = GetPostString("date2");
  1888. if (tid.Length > 0 || date1.Length > 0)
  1889. {
  1890. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1891. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1892. if (dw.Length > 0) lw.Add(dw);
  1893. }
  1894. else
  1895. {
  1896. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1897. }
  1898. string shopname = GetPostString("shopname");
  1899. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1900. string buyernick = GetPostString("buyer_nick");
  1901. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1902. string customer = GetPostString("customer");
  1903. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1904. string design = GetPostString("design");
  1905. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1906. string orderState = GetPostString("orderState");
  1907. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1908. string address = GetPostString("address");
  1909. 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));
  1910. string sellermemo = GetPostString("seller_memo");
  1911. if (sellermemo.Length > 0)
  1912. {
  1913. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1914. }
  1915. string price1 = GetPostString("price1");
  1916. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1917. string price2 = GetPostString("price2");
  1918. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1919. //if (PKey != "admin")
  1920. //{
  1921. // string usershop = CurrentUser.User.pemShop;
  1922. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1923. //}
  1924. //if (ex_psize > 0)
  1925. //{
  1926. dStruct.Order = "pay_time desc";
  1927. //}
  1928. //else
  1929. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1930. lw.Add(string.Format("IsOffLineOrder=1"));
  1931. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1932. DataTable dt = null;
  1933. dt = WebCache.GetData("view_erptradecell", dStruct);
  1934. writeGridDataTableJson(dStruct.TotalCount, dt);
  1935. }
  1936. public void get_erp_returncashrecord()
  1937. {
  1938. DataStruct dStruct = GetPostStruct();
  1939. List<string> lw = new List<string>();
  1940. string tid = GetPostString("ctid");
  1941. if (tid.Length > 0)
  1942. {
  1943. lw.Add(string.Format("tid like '%{0}%'", tid));
  1944. dStruct.Order = "id desc";
  1945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1946. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1947. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1948. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1949. return;
  1950. }
  1951. returnErrorMsg("id数据错误!");
  1952. }
  1953. public void ins_erp_returncashrecord()
  1954. {
  1955. if (UrlPostParmsCheck("tid"))
  1956. {
  1957. string tid = GetPostString("tid");
  1958. string retype = GetPostString("type");
  1959. StringBuilder sql = new StringBuilder();
  1960. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1961. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1962. if (dt.Rows.Count > 0)
  1963. {
  1964. returnErrorMsg("相同返现类型记录已存在");
  1965. return;
  1966. }
  1967. CeErpReturnCash entity = new CeErpReturnCash();
  1968. entity.tid = tid;
  1969. entity.seller_nick = GetPostString("seller_nick");
  1970. string pment = GetPostString("payment");
  1971. if (pment.Length > 0)
  1972. {
  1973. entity.payment = Convert.ToDouble(pment);
  1974. }
  1975. entity.buyer_nick = GetPostString("buyer_nick");
  1976. entity.cashstate = 0;
  1977. entity.rtype = retype;
  1978. string rPrice = GetPostString("returnprice");
  1979. if (rPrice.Length > 0)
  1980. {
  1981. entity.returnprice = Convert.ToDouble(rPrice);
  1982. }
  1983. entity.created = DateTime.Now;
  1984. entity.con = GetPostString("con");
  1985. entity.img = GetPostString("img");
  1986. entity.applyuserid = CurrentUser.UserID;
  1987. entity.Create();
  1988. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1989. returnSuccessMsg("操作成功!");
  1990. return;
  1991. }
  1992. }
  1993. public void set_erp_predelivery()
  1994. {
  1995. if (UrlPostParmsCheck("ctid"))
  1996. {
  1997. string eid = GetPostString("ctid");
  1998. CeErpTradeCell entity = null;
  1999. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2000. if (entity != null)
  2001. {
  2002. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2003. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2004. //{
  2005. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2006. // return;
  2007. //}
  2008. entity.IsPreDelivery = 1;
  2009. entity.Update();
  2010. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2011. returnSuccessMsg("预发货成功!");
  2012. return;
  2013. //string shop = GetPostString("seller_nick");
  2014. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2015. //string comName = GetPostString("comName");
  2016. //string comCode = GetPostString("comCode");
  2017. //string outSid = GetPostString("outSid");//运单号
  2018. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2019. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2020. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2021. //string apires = "";
  2022. //if (deliveryType == "虚拟发货")
  2023. //{
  2024. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2025. //}
  2026. //else
  2027. //{
  2028. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2029. //}
  2030. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2031. ////{
  2032. //if (apires.IndexOf("发货成功") != -1)
  2033. //{
  2034. // if (deliveryType != "虚拟发货")
  2035. // {
  2036. // //还要插入快递信息到 快递信息表
  2037. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2038. // exinfo.tid = eid;
  2039. // exinfo.out_sid = outSid;
  2040. // exinfo.company_code = comCode;
  2041. // exinfo.company_name = comName;
  2042. // exinfo.delivery_memo = deliveryMemo;
  2043. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2044. // exinfo.deliveryType = deliveryType;
  2045. // exinfo.Create();
  2046. // }
  2047. // returnSuccessMsg("发货成功!");
  2048. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2049. //}
  2050. //else
  2051. //{
  2052. // returnErrorMsg("淘宝发货失败!!");
  2053. //}
  2054. //return;
  2055. }
  2056. returnErrorMsg("找不到订单记录");
  2057. }
  2058. }
  2059. public void get_erp_unusuallist()
  2060. {
  2061. DataStruct dStruct = GetPostStruct();
  2062. List<string> lw = new List<string>();
  2063. string tid = GetPostString("ctid");
  2064. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2065. string shopname = GetPostString("shopname");
  2066. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2067. string buyernick = GetPostString("buyer_nick");
  2068. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2069. string ResponsibleMan = GetPostString("responsible");
  2070. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2071. string date1 = GetPostString("date1");
  2072. string date2 = GetPostString("date2");
  2073. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2074. if (dw.Length > 0) lw.Add(dw);
  2075. string price1 = GetPostString("price1");
  2076. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2077. string price2 = GetPostString("price2");
  2078. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2079. string orderState = GetPostString("orderState");
  2080. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2081. string sellermemo = GetPostString("seller_memo");
  2082. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2083. lw.Add(string.Format("UnusualTag > 0"));
  2084. lw.Add(string.Format("IsRefund<={0}", 1));
  2085. dStruct.Order = "pay_time desc";
  2086. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2087. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2088. writeGridDataTableJson(dStruct.TotalCount, dt);
  2089. }
  2090. public void set_erp_unusualtonomal()
  2091. {
  2092. if (UrlPostParmsCheck("ctid"))
  2093. {
  2094. string eid = GetPostString("ctid");
  2095. CeErpTradeCell entity = null;
  2096. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2097. if (entity != null)
  2098. {
  2099. entity.UnusualTag = -1;
  2100. entity.Update();
  2101. returnSuccessMsg("忽略成功!");
  2102. return;
  2103. }
  2104. returnErrorMsg("找不到记录");
  2105. }
  2106. }
  2107. public void ins_erp_unusualreason()
  2108. {
  2109. if (UrlPostParmsCheck("ctid"))
  2110. {
  2111. string eid = GetPostString("ctid");
  2112. CeErpTradeCell entity = null;
  2113. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2114. if (entity != null)
  2115. {
  2116. entity.MemoOpt = 4;
  2117. entity.UnusualCon = GetPostString("con");
  2118. entity.Update();
  2119. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2120. if (trade != null)
  2121. {
  2122. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2123. }
  2124. //查货是否超时
  2125. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2126. if (ceErpTradeCellExtend == null)
  2127. {
  2128. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2129. ceErpTradeCellExtend.ctid = entity.ctid;
  2130. }
  2131. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2132. {
  2133. ceErpTradeCellExtend.CheckOut += 1;
  2134. }
  2135. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2136. if (ceErpTradeCellExtend.ID > 0)
  2137. {
  2138. ceErpTradeCellExtend.Update();
  2139. }
  2140. else
  2141. {
  2142. ceErpTradeCellExtend.Create();
  2143. }
  2144. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2145. returnSuccessMsg("操作成功!");
  2146. return;
  2147. }
  2148. returnErrorMsg("找不到记录");
  2149. }
  2150. }
  2151. public void upd_erp_sampleorder()
  2152. {
  2153. if (UrlPostParmsCheck("ctid"))
  2154. {
  2155. string eid = GetPostString("ctid");
  2156. string[] eArr = eid.Split(',');
  2157. if (eArr.Length > 1)
  2158. {
  2159. List<string> eLst = new List<string>();
  2160. for (int i = 0; i < eArr.Length; i++)
  2161. {
  2162. eLst.Add("'" + eArr[i] + "'");
  2163. }
  2164. eid = string.Join(",", eLst.ToArray());
  2165. }
  2166. else
  2167. {
  2168. eid = "'" + eid + "'";
  2169. }
  2170. StringBuilder sql = new StringBuilder();
  2171. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2172. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2173. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2174. if (dt.Rows.Count > 0)
  2175. {
  2176. string errmsg = "";
  2177. foreach (DataRow dr in dt.Rows)
  2178. {
  2179. StringBuilder sqlsb = new StringBuilder();
  2180. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2181. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2182. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2183. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2184. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2185. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2186. {
  2187. continue;
  2188. }
  2189. else
  2190. {
  2191. string emsg = commonHelper.KeepChinese(apires);
  2192. errmsg += emsg;
  2193. }
  2194. }
  2195. if (errmsg.Length > 0)
  2196. {
  2197. returnErrorMsg(errmsg);
  2198. return;
  2199. }
  2200. returnSuccessMsg("操作成功");
  2201. return;
  2202. }
  2203. returnErrorMsg("找不到记录");
  2204. }
  2205. }
  2206. public void upd_erp_transcustomer()
  2207. {
  2208. if (UrlPostParmsCheck("ctid"))
  2209. {
  2210. string eid = GetPostString("ctid");
  2211. int userid = GetPostInt("CustomerUserId");
  2212. CeErpTradeCell entity = null;
  2213. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2214. if (entity != null)
  2215. {
  2216. //string[] mlist = entity.seller_memo.Split('-');
  2217. //string sql = "select * from view_erpuser where id=" + userid;
  2218. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2219. //if (dt != null && dt.Rows.Count > 0)
  2220. //{
  2221. // string nmemo = "";
  2222. // for(int i = 0; i < mlist.Length - 1; i++)
  2223. // {
  2224. // nmemo += mlist[i];
  2225. // nmemo += "-";
  2226. // }
  2227. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2228. // entity.seller_memo = nmemo;
  2229. //}
  2230. entity.CustomerUserId = userid;
  2231. entity.Update();
  2232. returnSuccessMsg("操作成功!");
  2233. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2234. return;
  2235. }
  2236. returnErrorMsg("找不到记录");
  2237. }
  2238. }
  2239. public void upd_erp_transdesigner()
  2240. {
  2241. if (UrlPostParmsCheck("ctid"))
  2242. {
  2243. string eids = GetPostString("ctid");
  2244. string[] ctidList = eids.Split(',');
  2245. int userid = GetPostInt("DesignUserId");
  2246. foreach (string ctid in ctidList)
  2247. {
  2248. CeErpTradeCell entity = null;
  2249. CeErpDesignerBill entitys = null;
  2250. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2251. entitys = CeErpDesignerBill.GetByTid(ctid);
  2252. if (entity != null)
  2253. {
  2254. if (entity.OrderState > 4)
  2255. {
  2256. continue;
  2257. }
  2258. //存在退款不能流转
  2259. if (entity.IsRefund > 0)
  2260. {
  2261. continue;
  2262. }
  2263. entity.DesignUserId = userid;
  2264. entity.WaitDesignTime = DateTime.Now;
  2265. entity.Update();
  2266. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2267. }
  2268. }
  2269. returnSuccessMsg("操作成功!");
  2270. }
  2271. }
  2272. public void upd_erp_distributedesigner()
  2273. {
  2274. if (UrlPostParmsCheck("ctid"))
  2275. {
  2276. string eid = GetPostString("ctid");
  2277. int userid = GetPostInt("DesignUserId");
  2278. string[] idlist = eid.Split(',');
  2279. if (idlist.Length <= 0)
  2280. {
  2281. returnErrorMsg("订单不能为空");
  2282. return;
  2283. }
  2284. foreach (string ctid in idlist)
  2285. {
  2286. CeErpTradeCell entity = null;
  2287. CeErpDesignerBill entitys = null;
  2288. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2289. else continue;
  2290. if (entity != null)
  2291. {
  2292. if (userid == 2125 || userid == 3542)
  2293. { }
  2294. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2295. {
  2296. returnErrorMsg("金额错误的订单无法指派");
  2297. return;
  2298. }
  2299. if (entity.OrderState >= 5)
  2300. {
  2301. returnErrorMsg("已经设计完成无法指派");
  2302. return;
  2303. }
  2304. if (entity.OrderState == -1)
  2305. {
  2306. returnErrorMsg("审核中的订单无法指派");
  2307. return;
  2308. }
  2309. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2310. {
  2311. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2312. return;
  2313. }
  2314. //157赖橙帆 159林晨 73 静之颖
  2315. 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)
  2316. {
  2317. returnErrorMsg("指派设计共创无法再次指派!");
  2318. return;
  2319. }
  2320. entity.OrderState = 3;
  2321. if (entity.SupplierId == 0)
  2322. {
  2323. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2324. entity.SupplierId = suid;
  2325. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2326. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2327. }
  2328. if (userid == 2125 && entity.seller_memo != "")
  2329. {
  2330. apiDesign.API_GetPrintData_CreateOrder(entity);
  2331. }
  2332. if (userid == 3542 && entity.seller_memo != "")
  2333. {
  2334. string userPost = CurrentUser.UserPost.Post.Code;
  2335. if (CurrentUser.UserID == 73)
  2336. {
  2337. userPost = "SysAdmin";
  2338. }
  2339. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2340. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2341. if (response.msg != "设计共创:成功")
  2342. {
  2343. returnErrorMsg(response.msg);
  2344. return;
  2345. }
  2346. entity.DispatchSort = 2;
  2347. }
  2348. else
  2349. {
  2350. if (entity.DispatchSort == 2)
  2351. {
  2352. ApiVo apiVo = new ApiVo();
  2353. apiVo.actionName = "closeDesign";
  2354. apiVo.orderNumber = entity.ctid;
  2355. designHelper.API_WorkCore(apiVo);//closeDesign
  2356. }
  2357. entity.DispatchSort = 0;
  2358. }
  2359. entity.DesignUserId = userid;
  2360. entity.WaitDesignTime = DateTime.Now;
  2361. entity.UpdateTime = DateTime.Now;
  2362. entity.Update();
  2363. string name = commonHelper.getUserNameById(userid);
  2364. commonHelper.UpdateRelationOrder(entity.ctid);
  2365. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2366. }
  2367. }
  2368. returnSuccessMsg("操作成功!");
  2369. return;
  2370. }
  2371. }
  2372. public string getTidByCtid(string ctid)
  2373. {
  2374. string tid = "";
  2375. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2376. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2377. if (dataTable != null && dataTable.Rows.Count > 0)
  2378. {
  2379. tid = dataTable.Rows[0]["tid"].ToString();
  2380. }
  2381. return tid;
  2382. }
  2383. public List<string> getTidByCtidMore(string ctid)
  2384. {
  2385. 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);
  2386. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2387. List<string> list = new List<string>();
  2388. if (dataTable != null && dataTable.Rows.Count > 0)
  2389. {
  2390. foreach (DataRow item in dataTable.Rows)
  2391. {
  2392. list.Add("'" + item["tid"].ToString() + "'");
  2393. }
  2394. }
  2395. return list;
  2396. }
  2397. public List<string> getTidByCtidLike(string ctid)
  2398. {
  2399. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2400. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2401. List<string> list = new List<string>();
  2402. if (dataTable != null && dataTable.Rows.Count > 0)
  2403. {
  2404. foreach (DataRow item in dataTable.Rows)
  2405. {
  2406. list.Add("'" + item["tid"].ToString() + "'");
  2407. }
  2408. }
  2409. return list;
  2410. }
  2411. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2412. {
  2413. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2414. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2415. List<string> list = new List<string>();
  2416. if (dataTable != null && dataTable.Rows.Count > 0)
  2417. {
  2418. foreach (DataRow item in dataTable.Rows)
  2419. {
  2420. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2421. {
  2422. continue;
  2423. }
  2424. list.Add("'" + item["receiverId"].ToString() + "'");
  2425. }
  2426. }
  2427. return list;
  2428. }
  2429. public void get_erp_myorderlist()
  2430. {
  2431. DataStruct dStruct = GetPostStruct();
  2432. List<string> lw = new List<string>();
  2433. string tid = GetPostString("ctid");
  2434. if (tid.Length > 0)
  2435. {
  2436. string select_tid = getTidByCtid(tid);
  2437. lw.Add(string.Format("tid='{0}'", select_tid));
  2438. }
  2439. else
  2440. {
  2441. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2442. }
  2443. //12-1 修改
  2444. string urgent = GetPostString("urgent");
  2445. string back = GetPostString("back");
  2446. string offlineSearch = GetPostString("offlineSearch");
  2447. if (!string.IsNullOrWhiteSpace(urgent))
  2448. {
  2449. if (urgent.Equals("true"))
  2450. {
  2451. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2452. }
  2453. }
  2454. if (!string.IsNullOrWhiteSpace(back))
  2455. {
  2456. if (back.Equals("true"))
  2457. {
  2458. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2459. }
  2460. }
  2461. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2462. {
  2463. if (offlineSearch.Equals("true"))
  2464. {
  2465. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2466. }
  2467. }
  2468. //end
  2469. string shopname = GetPostString("shopname");
  2470. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2471. string buyernick = GetPostString("buyer_nick");
  2472. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2473. string design = GetPostString("design");
  2474. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2475. string orderState = GetPostString("orderState");
  2476. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2477. string sellermemo = GetPostString("seller_memo");
  2478. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2479. string date1 = GetPostString("date1");
  2480. string date2 = GetPostString("date2");
  2481. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2482. if (dw.Length > 0) lw.Add(dw);
  2483. string price1 = GetPostString("price1");
  2484. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2485. string price2 = GetPostString("price2");
  2486. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2487. string urgency = GetPostString("urgency");
  2488. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2489. string after = GetPostString("after");
  2490. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2491. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2492. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2493. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2494. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2495. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2496. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2497. if (dt != null && dt.Rows.Count > 0)
  2498. {
  2499. foreach (DataRow dr in dt.Rows)
  2500. {
  2501. try
  2502. {
  2503. // 对象操作
  2504. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2505. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2506. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2507. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2508. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2509. if (dStruct.PageSize != 100000)
  2510. {
  2511. if (dr["DispatchSort"].ToString() == "2")
  2512. {
  2513. dr["gongchuang"] = 200;
  2514. }
  2515. else if ("外协".Equals(dr["ToType"].ToString()))
  2516. {
  2517. dr["gongchuang"] = 200;
  2518. }
  2519. else if ("内部".Equals(dr["ToType"].ToString()))
  2520. {
  2521. dr["gongchuang"] = -1;
  2522. }
  2523. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2524. {
  2525. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2526. dr["gongchuang"] = response.code;
  2527. }
  2528. }
  2529. }
  2530. catch (NullReferenceException ex)
  2531. {
  2532. }
  2533. }
  2534. }
  2535. writeGridDataTableJson(dStruct.TotalCount, dt);
  2536. }
  2537. public void get_erp_myreturnorderlist()
  2538. {
  2539. DataStruct dStruct = GetPostStruct();
  2540. List<string> lw = new List<string>();
  2541. string tid = GetPostString("ctid");
  2542. if (tid.Length > 0)
  2543. {
  2544. string select_tid = getTidByCtid(tid);
  2545. lw.Add(string.Format("tid='{0}'", select_tid));
  2546. }
  2547. else
  2548. {
  2549. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2550. }
  2551. string shopname = GetPostString("shopname");
  2552. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2553. string buyernick = GetPostString("buyer_nick");
  2554. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2555. string design = GetPostString("design");
  2556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2557. string orderState = GetPostString("orderState");
  2558. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2559. string sellermemo = GetPostString("seller_memo");
  2560. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2561. string date1 = GetPostString("date1");
  2562. string date2 = GetPostString("date2");
  2563. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2564. if (dw.Length > 0) lw.Add(dw);
  2565. string price1 = GetPostString("price1");
  2566. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2567. string price2 = GetPostString("price2");
  2568. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2569. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2570. {
  2571. lw.Add(string.Format("CusOrgID = 94"));
  2572. }
  2573. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2574. {
  2575. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2576. }
  2577. else
  2578. {
  2579. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2580. }
  2581. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2582. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2583. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2584. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2585. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2586. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2587. if (dt != null && dt.Rows.Count > 0)
  2588. {
  2589. foreach (DataRow dr in dt.Rows)
  2590. {
  2591. try
  2592. {
  2593. // 对象操作
  2594. if (dStruct.PageSize != 100000)
  2595. {
  2596. if (dr["DispatchSort"].ToString() == "2")
  2597. {
  2598. dr["gongchuang"] = 200;
  2599. }
  2600. else if ("外协".Equals(dr["ToType"].ToString()))
  2601. {
  2602. dr["gongchuang"] = 200;
  2603. }
  2604. else if ("内部".Equals(dr["ToType"].ToString()))
  2605. {
  2606. dr["gongchuang"] = -1;
  2607. }
  2608. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2609. {
  2610. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2611. dr["gongchuang"] = response.code;
  2612. }
  2613. }
  2614. }
  2615. catch (NullReferenceException ex)
  2616. {
  2617. // 处理空引用异常
  2618. }
  2619. }
  2620. }
  2621. writeGridDataTableJson(dStruct.TotalCount, dt);
  2622. }
  2623. public void get_erp_myorderlist_pregather()
  2624. {
  2625. string date1 = GetPostString("date1");
  2626. string date2 = GetPostString("date2");
  2627. int userId = CurrentUser.UserID; //客服id
  2628. string orderWhere = "";
  2629. List<string> lw = new List<string>();
  2630. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2631. if (dw.Length > 0) lw.Add(dw);
  2632. lw.Add(string.Format("CustomerUserId={0}", userId));
  2633. lw.Add(string.Format("OrderState<9"));
  2634. orderWhere = string.Join(" and ", lw.ToArray());
  2635. string orderWhere2 = "";
  2636. List<string> lw2 = new List<string>();
  2637. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2638. if (dw2.Length > 0) lw2.Add(dw2);
  2639. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2640. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2641. string sql = string.Format("select *" +
  2642. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2643. "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 " +
  2644. "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 " +
  2645. "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");
  2646. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2647. //writeGridDataTableJson(dt.Rows.Count, dt);
  2648. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2649. }
  2650. public void upd_erp_publishorder()
  2651. {
  2652. if (UrlPostParmsCheck("ctid"))
  2653. {
  2654. string eid = GetPostString("ctid");
  2655. CeErpTradeCell entity = null;
  2656. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2657. if (entity != null)
  2658. {
  2659. entity.OrderState = 0; //发布后,变为待抢单
  2660. entity.Update();
  2661. commonHelper.UpdateRelationOrder(entity.ctid);
  2662. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2663. returnSuccessMsg("发布成功!");
  2664. return;
  2665. }
  2666. returnErrorMsg("找不到记录");
  2667. }
  2668. }
  2669. public void get_erp_my_tiporder()
  2670. {
  2671. StringBuilder sql = new StringBuilder();
  2672. int userId = 0;
  2673. if (CurrentUser != null) userId = CurrentUser.UserID;
  2674. string posCode = CurrentUser.UserPost.Post.Code;
  2675. string isTipedAfterSaleVerify = GetPostString("af");
  2676. DataTable dt = new DataTable();
  2677. if (posCode != "Supplier")
  2678. {
  2679. if (posCode == "CustomerService" || posCode == "Director")
  2680. {
  2681. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2682. }
  2683. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2684. {
  2685. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2686. }
  2687. else
  2688. {
  2689. string teamIds = CurrentUser.User.TeamIds;
  2690. if (teamIds == "")
  2691. {
  2692. teamIds = "0";
  2693. }
  2694. 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);
  2695. }
  2696. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2697. }
  2698. if (dt.Rows.Count <= 0)
  2699. {
  2700. string key = "aftersale_order_" + userId;
  2701. if (RedisHelper.HasKey(key))
  2702. {
  2703. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2704. dt.Columns.Add("ctid", typeof(string));
  2705. dt.Columns.Add("IsReadTag", typeof(int));
  2706. foreach (var i in list)
  2707. {
  2708. DataRow data = dt.NewRow();
  2709. data["ctid"] = i;
  2710. data["IsReadTag"] = 4;
  2711. dt.Rows.Add(data);
  2712. }
  2713. RedisHelper.StringDelete(key);
  2714. }
  2715. }
  2716. if (dt.Rows.Count <= 0)
  2717. {
  2718. sql = new StringBuilder();
  2719. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2720. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2721. }
  2722. if (posCode == "Supplier")
  2723. {
  2724. string ids = CurrentUser.User.pemVend;
  2725. if (ids != null && ids.Length > 0)
  2726. {
  2727. string[] ids_list = ids.Split(',');
  2728. foreach (var item in ids_list)
  2729. {
  2730. string key = "return_order_" + item;
  2731. if (RedisHelper.HasKey(key))
  2732. {
  2733. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2734. dt.Columns.Add("ctid", typeof(string));
  2735. dt.Columns.Add("IsReadTag", typeof(int));
  2736. foreach (var i in list)
  2737. {
  2738. DataRow data = dt.NewRow();
  2739. data["ctid"] = i;
  2740. data["IsReadTag"] = 1;
  2741. dt.Rows.Add(data);
  2742. }
  2743. RedisHelper.StringDelete(key);
  2744. }
  2745. }
  2746. }
  2747. if (dt.Rows.Count <= 0)
  2748. {
  2749. sql = new StringBuilder();
  2750. 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);
  2751. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2752. }
  2753. }
  2754. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2755. }
  2756. public void reset_erp_tiporder()
  2757. {
  2758. string ids = GetPostString("ids");
  2759. string[] ctidList = ids.Split(',');
  2760. foreach (string ctid in ctidList)
  2761. {
  2762. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2763. if (enty != null)
  2764. {
  2765. enty.IsReadTag = 0;
  2766. enty.Update();
  2767. }
  2768. }
  2769. returnSuccessMsg("成功!");
  2770. return;
  2771. }
  2772. public void get_erp_designlist()
  2773. {
  2774. DataStruct dStruct = GetPostStruct();
  2775. List<string> lw = new List<string>();
  2776. string tid = GetPostString("ctid");
  2777. if (tid.Length > 0)
  2778. {
  2779. string select_tid = getTidByCtid(tid);
  2780. lw.Add(string.Format("tid='{0}'", select_tid));
  2781. }
  2782. string shopname = GetPostString("shopname");
  2783. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2784. string buyernick = GetPostString("buyer_nick");
  2785. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2786. string customer = GetPostString("customer");
  2787. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2788. string design = GetPostString("design");
  2789. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2790. string orderState = GetPostString("orderState");
  2791. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2792. lw.Add(string.Format("OrderState<6"));
  2793. string address = GetPostString("address");
  2794. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2795. string sellermemo = GetPostString("seller_memo");
  2796. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2797. string date1 = GetPostString("date1");
  2798. string date2 = GetPostString("date2");
  2799. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2800. if (dw.Length > 0) lw.Add(dw);
  2801. string apdate1 = GetPostString("apdate1");
  2802. string apdate2 = GetPostString("apdate2");
  2803. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2804. if (dwap.Length > 0) lw.Add(dwap);
  2805. string price1 = GetPostString("price1");
  2806. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2807. string price2 = GetPostString("price2");
  2808. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2809. string designTime = GetPostString("designtime");
  2810. if (designTime.Length > 0)
  2811. {
  2812. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2813. }
  2814. string usershop = CurrentUser.User.pemShop;
  2815. if (usershop.Length > 0)
  2816. {
  2817. lw.Add(string.Format("shopId in ({0})", usershop));
  2818. }
  2819. int myOrgid = CurrentUser.UserPost.OrgID;
  2820. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2821. if (myOrgCode.IndexOf("Designer") != -1)
  2822. {
  2823. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2824. {
  2825. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2826. }
  2827. else
  2828. {
  2829. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2830. }
  2831. }
  2832. else
  2833. {
  2834. string orgId = GetPostString("designerhd");
  2835. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2836. }
  2837. if (tid.Length > 0 || buyernick.Length > 0)
  2838. {
  2839. lw.Add(string.Format("OrderState >= 3"));
  2840. }
  2841. else
  2842. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2843. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2844. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2845. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2846. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2847. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2848. if (dt != null && dt.Rows.Count > 0)
  2849. {
  2850. foreach (DataRow dr in dt.Rows)
  2851. {
  2852. try
  2853. {
  2854. // 对象操作
  2855. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2856. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2857. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2858. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2859. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2860. if (dStruct.PageSize != 100000)
  2861. {
  2862. if (dr["DispatchSort"].ToString() == "2")
  2863. {
  2864. dr["gongchuang"] = 200;
  2865. }
  2866. else if ("外协".Equals(dr["ToType"].ToString()))
  2867. {
  2868. dr["gongchuang"] = 200;
  2869. }
  2870. else if ("内部".Equals(dr["ToType"].ToString()))
  2871. {
  2872. dr["gongchuang"] = -1;
  2873. }
  2874. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2875. {
  2876. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2877. dr["gongchuang"] = response.code;
  2878. }
  2879. }
  2880. }
  2881. catch (NullReferenceException ex)
  2882. {
  2883. }
  2884. }
  2885. }
  2886. writeGridDataTableJson(dStruct.TotalCount, dt);
  2887. }
  2888. public void get_erp_mydesignlist()
  2889. {
  2890. DataStruct dStruct = GetPostStruct();
  2891. List<string> lw = new List<string>();
  2892. string tid = GetPostString("ctid");
  2893. if (tid.Length > 0)
  2894. {
  2895. string select_tid = getTidByCtid(tid);
  2896. lw.Add(string.Format("tid='{0}'", select_tid));
  2897. }
  2898. string shopname = GetPostString("shopname");
  2899. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2900. string buyernick = GetPostString("buyer_nick");
  2901. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2902. string customer = GetPostString("customer");
  2903. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2904. string orderState = GetPostString("orderState");
  2905. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2906. //lw.Add(string.Format("OrderState<6"));
  2907. string date1 = GetPostString("date1");
  2908. string date2 = GetPostString("date2");
  2909. string dw = GetDateWhere("pay_time", date1, date2);
  2910. if (dw.Length > 0) lw.Add(dw);
  2911. string apdate1 = GetPostString("apdate1");
  2912. string apdate2 = GetPostString("apdate2");
  2913. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2914. if (dwap.Length > 0) lw.Add(dwap);
  2915. string price1 = GetPostString("price1");
  2916. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2917. string price2 = GetPostString("price2");
  2918. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2919. string olddownload = GetPostString("olddown");
  2920. if (olddownload == "1")
  2921. {
  2922. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2923. }
  2924. else if (olddownload == "2")
  2925. {
  2926. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2927. }
  2928. string sellermemo = GetPostString("seller_memo");
  2929. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2930. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2931. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2932. {
  2933. if (CurrentUser.User.TeamIds.Length > 0)
  2934. {
  2935. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2936. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2937. else
  2938. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2939. }
  2940. else
  2941. {
  2942. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2943. }
  2944. }
  2945. if (tid.Length <= 0)
  2946. {
  2947. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2948. }
  2949. lw.Add(string.Format("IsReturn!=3"));
  2950. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2951. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2952. string teamids = CurrentUser.User.TeamIds.ToString();
  2953. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2954. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2955. if (dt != null && dt.Rows.Count > 0)
  2956. {
  2957. foreach (DataRow dr in dt.Rows)
  2958. {
  2959. try
  2960. {
  2961. // 对象操作
  2962. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2963. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2964. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2965. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2966. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2967. if (dStruct.PageSize != 100000)
  2968. {
  2969. if (dr["DispatchSort"].ToString() == "2")
  2970. {
  2971. dr["gongchuang"] = 200;
  2972. }
  2973. else if ("外协".Equals(dr["ToType"].ToString()))
  2974. {
  2975. dr["gongchuang"] = 200;
  2976. }
  2977. else if ("内部".Equals(dr["ToType"].ToString()))
  2978. {
  2979. dr["gongchuang"] = -1;
  2980. }
  2981. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2982. {
  2983. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2984. dr["gongchuang"] = response.code;
  2985. }
  2986. }
  2987. }
  2988. catch (NullReferenceException ex)
  2989. {
  2990. }
  2991. }
  2992. }
  2993. writeGridDataTableJson(dStruct.TotalCount, dt);
  2994. }
  2995. public void set_erp_startdesign()
  2996. {
  2997. if (UrlPostParmsCheck("ctid"))
  2998. {
  2999. string eid = GetPostString("ctid");
  3000. CeErpTradeCell entity = null;
  3001. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3002. if (entity != null)
  3003. {
  3004. if (entity.OrderState != 3)
  3005. {
  3006. returnErrorMsg("请刷新,订单已经设计了");
  3007. return;
  3008. }
  3009. entity.StartDesignTime = DateTime.Now;
  3010. entity.OrderState = 4;
  3011. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3012. {
  3013. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3014. entity.SupplierId = suid;
  3015. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3016. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3017. }
  3018. entity.UpdateTime = DateTime.Now;
  3019. //entity.MakeSupplier = suname;
  3020. entity.Update();
  3021. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3023. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3024. commonHelper.getCytPrice(entity);
  3025. returnSuccessMsg("操作成功!");
  3026. return;
  3027. }
  3028. returnErrorMsg("找不到记录");
  3029. }
  3030. }
  3031. public void ins_erp_designselfmemo()
  3032. {
  3033. if (UrlPostParmsCheck("ctid"))
  3034. {
  3035. string eid = GetPostString("ctid");
  3036. string con = GetPostString("con");
  3037. CeErpTradeCell entity = null;
  3038. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3039. if (entity != null)
  3040. {
  3041. entity.DesignSelfMemo = con;
  3042. entity.Update();
  3043. returnSuccessMsg("操作成功!");
  3044. return;
  3045. }
  3046. returnErrorMsg("找不到记录");
  3047. }
  3048. }
  3049. public void ins_erp_designprice()
  3050. {
  3051. if (UrlPostParmsCheck("ctid"))
  3052. {
  3053. string eid = GetPostString("ctid");
  3054. int uid = CurrentUser.UserID;
  3055. string userName = CurrentUser.UserName;
  3056. CeErpTradeCell entity = null;
  3057. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3058. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3059. if (entitys == null)
  3060. {
  3061. entitys = new CeErpDesignerBill();
  3062. }
  3063. if (entity != null)
  3064. {
  3065. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3066. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3067. entity.StartDesignTime = DateTime.Now;
  3068. entity.OrderState = 4;
  3069. string suname = "";
  3070. if (entity.SupplierId == 0)
  3071. {
  3072. int sid = commonHelper.autoDistributeToSupplier(entity);
  3073. entity.SupplierId = sid;
  3074. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3075. }
  3076. entity.Update();
  3077. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3078. if (ceErpUserPost != null)
  3079. {
  3080. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3081. if (ceErpPost != null)
  3082. {
  3083. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3084. {
  3085. entitys.tid = entity.ctid;
  3086. entitys.oid = entity.tid;
  3087. entitys.uid = uid;
  3088. entitys.userName = userName;
  3089. entitys.designerType = 1;
  3090. entitys.designerTypeText = "内部设计师";
  3091. entitys.price = Convert.ToDouble(GetPostString("price"));
  3092. entitys.designNum = GetPostInt("designNum");
  3093. entitys.modifyNum = GetPostInt("modifyNum");
  3094. entitys.designSize = GetPostString("designSize");
  3095. entitys.modifySize = GetPostString("modifySize");
  3096. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3097. {
  3098. entitys.create_time = DateTime.Now;
  3099. entitys.create_u_id = uid;
  3100. entitys.create_u_name = userName;
  3101. entitys.Save();
  3102. }
  3103. else
  3104. {
  3105. entitys.update_time = DateTime.Now;
  3106. entitys.update_u_id = uid;
  3107. entitys.update_u_name = userName;
  3108. entitys.Update();
  3109. }
  3110. }
  3111. }
  3112. }
  3113. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3114. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3115. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3116. if (suname != "")
  3117. {
  3118. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3119. }
  3120. commonHelper.getCytPrice(entity);
  3121. returnSuccessMsg("操作成功!");
  3122. return;
  3123. }
  3124. returnErrorMsg("找不到记录");
  3125. }
  3126. }
  3127. public void upload_erp_filecomplete()
  3128. {
  3129. if (UrlPostParmsCheck("ctid"))
  3130. {
  3131. string eid = GetPostString("ctid");
  3132. CeErpTradeCell entity = null;
  3133. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3134. if (entity != null)
  3135. {
  3136. entity.OrderState = 5; //设计完成
  3137. entity.Update();
  3138. returnSuccessMsg(eid + "上传成功,设计完成!");
  3139. return;
  3140. }
  3141. returnErrorMsg("找不到订单记录");
  3142. }
  3143. }
  3144. public void get_erp_designovertimelist()
  3145. {
  3146. DataStruct dStruct = GetPostStruct();
  3147. List<string> lw = new List<string>();
  3148. string tid = GetPostString("ctid");
  3149. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3150. string shopname = GetPostString("shopname");
  3151. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3152. string buyernick = GetPostString("buyer_nick");
  3153. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3154. string ResponsibleMan = GetPostString("responsible");
  3155. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3156. string date1 = GetPostString("date1");
  3157. string date2 = GetPostString("date2");
  3158. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3159. if (dw.Length > 0) lw.Add(dw);
  3160. string price1 = GetPostString("price1");
  3161. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3162. string price2 = GetPostString("price2");
  3163. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3164. string orderState = GetPostString("orderState");
  3165. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3166. string sellermemo = GetPostString("seller_memo");
  3167. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3168. lw.Add(string.Format("UnusualTag=3"));
  3169. lw.Add(string.Format("IsRefund<={0}", 1));
  3170. dStruct.Order = "WaitDesignTime desc";
  3171. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3172. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3173. writeGridDataTableJson(dStruct.TotalCount, dt);
  3174. }
  3175. //设计管理 获取抢单大厅列表
  3176. public void get_erp_grabinglist()
  3177. {
  3178. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3179. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3180. bool oldOrder = false;
  3181. if (org != null)
  3182. {
  3183. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3184. }
  3185. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3186. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3187. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3188. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3189. //先处理订单数据
  3190. if (dt.Rows.Count > 0)
  3191. {
  3192. Dictionary<string, int> design = null;
  3193. int count = 0;
  3194. foreach (DataRow row in dt.Rows)
  3195. {
  3196. if (map.ContainsKey(row["ShopId"].ToString()))
  3197. {
  3198. map.TryGetValue(row["ShopId"].ToString(), out design);
  3199. }
  3200. else
  3201. {
  3202. design = new Dictionary<string, int>();
  3203. }
  3204. if (design.ContainsKey(row["ProductId"].ToString()))
  3205. {
  3206. design.TryGetValue(row["ProductId"].ToString(), out count);
  3207. }
  3208. count++;
  3209. design[row["ProductId"].ToString()] = count;
  3210. map[row["ShopId"].ToString()] = design;
  3211. }
  3212. }
  3213. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3214. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3215. //把店铺排序和技能排序分类
  3216. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3217. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3218. if (design_dt.Rows.Count > 0)
  3219. {
  3220. Dictionary<string, string> design = null;
  3221. List<string> shopIds = null;
  3222. foreach (DataRow row in design_dt.Rows)
  3223. {
  3224. if ("0".Equals(row["designId"].ToString()))
  3225. {
  3226. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3227. {
  3228. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3229. }
  3230. else
  3231. {
  3232. shopIds = new List<string>();
  3233. }
  3234. shopIds.Add(row["shopId"].ToString());
  3235. shop_orders[row["orders"].ToString()] = shopIds;
  3236. }
  3237. else
  3238. {
  3239. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3240. {
  3241. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3242. }
  3243. else
  3244. {
  3245. design = new Dictionary<string, string>();
  3246. }
  3247. design[row["orders"].ToString()] = row["designId"].ToString();
  3248. design_orders[row["shopId"].ToString()] = design;
  3249. }
  3250. }
  3251. //处理成key value后根据key排序
  3252. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3253. foreach (List<string> val in shop_orders.Values)
  3254. {
  3255. if (val != null)
  3256. {
  3257. foreach (string key in val)
  3258. {
  3259. if (design_orders.ContainsKey(key.ToString()))
  3260. {
  3261. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3262. }
  3263. }
  3264. }
  3265. }
  3266. }
  3267. //校验哪个优先级有订单
  3268. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3269. foreach (string key in shop_orders.Keys)
  3270. {
  3271. List<string> ids = null;
  3272. shop_orders.TryGetValue(key, out ids);
  3273. //id为shopid
  3274. foreach (string id in ids)
  3275. {
  3276. Dictionary<string, int> list = null;
  3277. Dictionary<string, string> desing = null;
  3278. map.TryGetValue(id, out list);
  3279. design_orders.TryGetValue(id, out desing);
  3280. if (list != null && desing != null)
  3281. {
  3282. foreach (var item in desing)
  3283. {
  3284. int count = 0;
  3285. if (list.ContainsKey(item.Value))
  3286. {
  3287. list.TryGetValue(item.Value, out count);
  3288. if (count > 0)
  3289. {
  3290. designIds[id] = item.Value;
  3291. break;
  3292. }
  3293. }
  3294. }
  3295. }
  3296. }
  3297. if (designIds.Count > 0)
  3298. {
  3299. break;
  3300. }
  3301. }
  3302. DataTable table = new DataTable();
  3303. table.Columns.Add("tid", typeof(string));
  3304. table.Columns.Add("ctid", typeof(string));
  3305. table.Columns.Add("seller_nick", typeof(string));
  3306. table.Columns.Add("productName", typeof(string));
  3307. table.Columns.Add("pay_time", typeof(string));
  3308. table.Columns.Add("seller_memo", typeof(string));
  3309. if (designIds.Count > 0)
  3310. {
  3311. string shopId = "";
  3312. string productId = "";
  3313. foreach (var designInfo in designIds)
  3314. {
  3315. shopId = designInfo.Key;
  3316. productId = designInfo.Value;
  3317. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3318. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3319. if (dt.Rows.Count > 0)
  3320. {
  3321. foreach (DataRow row in dt.Rows)
  3322. {
  3323. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3324. {
  3325. DataRow data = table.NewRow();
  3326. data["ctid"] = row["ctid"].ToString();
  3327. data["tid"] = row["tid"].ToString();
  3328. data["seller_nick"] = ceErpShop.ShopName;
  3329. data["pay_time"] = row["pay_time"].ToString();
  3330. data["seller_memo"] = row["seller_memo"].ToString();
  3331. data["productName"] = ceErpProduct.PType;
  3332. table.Rows.Add(data);
  3333. }
  3334. }
  3335. }
  3336. }
  3337. }
  3338. writeGridDataTableJson(table.Rows.Count, table);
  3339. }
  3340. private object rushLockObject = new object();
  3341. public void set_erp_grabingorder()
  3342. {
  3343. if (UrlPostParmsCheck("ctid"))
  3344. {
  3345. int total = CurrentUser.User.Person.Total;
  3346. int userId = CurrentUser.User.ID;
  3347. int noFinish = CurrentUser.User.Person.NoFinish;
  3348. int finalization = CurrentUser.User.Person.Finalization;
  3349. string eids = GetPostString("ctid");
  3350. string key = "RushKey_" + userId;
  3351. int count = 0;
  3352. if (erpRedis.RedisHelper.KeyExists(key))
  3353. {
  3354. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3355. if (redisCount != null)
  3356. {
  3357. count = Convert.ToInt32(redisCount);
  3358. }
  3359. }
  3360. if (count >= total)
  3361. {
  3362. returnErrorMsg("半小时内已经抢" + total + "单");
  3363. return;
  3364. }
  3365. string[] ctidlist = eids.Split(',');
  3366. if (count + ctidlist.Length > total)
  3367. {
  3368. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3369. return;
  3370. }
  3371. int itag = 0;
  3372. lock (rushLockObject)
  3373. {
  3374. if (ctidlist.Length > 0)
  3375. {
  3376. string[] dtList = new string[ctidlist.Length];
  3377. for (int i = 0; i < ctidlist.Length; i++)
  3378. {
  3379. dtList[i] = "'" + ctidlist[i] + "'";
  3380. }
  3381. 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"));
  3382. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3383. if (dt_user.Rows.Count > 0)
  3384. {
  3385. int doing = 0;//未定稿
  3386. int finish = 0;//已完成
  3387. foreach (DataRow dr in dt_user.Rows)
  3388. {
  3389. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3390. {
  3391. doing++;
  3392. }
  3393. else
  3394. {
  3395. finish++;
  3396. }
  3397. }
  3398. if (doing >= noFinish)
  3399. {
  3400. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3401. return;
  3402. }
  3403. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3404. {
  3405. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3406. return;
  3407. }
  3408. }
  3409. //校验选择单子状态
  3410. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3411. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3412. if (dt.Rows.Count > 0)
  3413. {
  3414. List<string> list = new List<string>();
  3415. foreach (DataRow dr in dt.Rows)
  3416. {
  3417. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3418. {
  3419. list.Add(dr["ctid"].ToString());
  3420. }
  3421. }
  3422. if (list.Count > 0)
  3423. {
  3424. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3425. return;
  3426. }
  3427. }
  3428. foreach (string ctid in ctidlist)
  3429. {
  3430. CeErpTradeCell entity = null;
  3431. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3432. if (entity != null)
  3433. {
  3434. entity.OrderState = 3;
  3435. entity.DesignUserId = CurrentUser.UserID;
  3436. entity.WaitDesignTime = DateTime.Now;
  3437. entity.StartDesignTime = DateTime.Now;
  3438. entity.Update();
  3439. commonHelper.UpdateRelationOrder(entity.ctid);
  3440. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3441. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3442. itag++;
  3443. }
  3444. }
  3445. }
  3446. }
  3447. count += ctidlist.Length;
  3448. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3449. if (itag == 0)
  3450. returnErrorMsg("没有找到相关订单");
  3451. else
  3452. returnSuccessMsg("抢单成功!");
  3453. return;
  3454. }
  3455. }
  3456. public void get_erp_waitorderlist()
  3457. {
  3458. DataStruct dStruct = GetPostStruct();
  3459. List<string> lw = new List<string>();
  3460. string tid = GetPostString("ctid");
  3461. if (tid.Length > 0)
  3462. {
  3463. string select_tid = getTidByCtid(tid);
  3464. lw.Add(string.Format("tid='{0}'", select_tid));
  3465. }
  3466. string shopname = GetPostString("shopname");
  3467. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3468. string buyernick = GetPostString("buyer_nick");
  3469. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3470. string customer = GetPostString("customer");
  3471. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3472. string design = GetPostString("design");
  3473. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3474. string orderState = GetPostString("orderState");
  3475. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3476. string supplier = GetPostString("supplier");
  3477. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3478. string sellermemo = GetPostString("seller_memo");
  3479. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3480. string otherMemo = GetPostString("otherMemo");
  3481. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3482. string address = GetPostString("address");
  3483. 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));
  3484. string date1 = GetPostString("date1");
  3485. string date2 = GetPostString("date2");
  3486. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3487. if (dw.Length > 0) lw.Add(dw);
  3488. string price1 = GetPostString("price1");
  3489. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3490. string price2 = GetPostString("price2");
  3491. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3492. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3493. lw.Add(string.Format("IsSample != 2 "));
  3494. lw.Add(string.Format("OrderState = 5 "));
  3495. lw.Add(string.Format("IsRefund<={0}", 1));
  3496. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3497. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3498. string pagesize = GetPostString("pagesize");
  3499. if (pagesize != null)
  3500. {
  3501. dStruct.PageSize = 200;
  3502. }
  3503. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3504. List<string> tids = new List<string>();
  3505. if (dt != null)
  3506. {
  3507. dt.Columns.Add("compenPrice", typeof(double));
  3508. foreach (DataRow dr in dt.Rows)
  3509. {
  3510. if (Convert.IsDBNull(dr["compenPrice"]))
  3511. {
  3512. dr["compenPrice"] = 0;
  3513. }
  3514. tids.Add("'" + dr["tid"].ToString() + "'");
  3515. 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();
  3516. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3517. {
  3518. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3519. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3520. entity.SupplierId = suid;
  3521. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3522. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3523. entity.Update();
  3524. }
  3525. }
  3526. }
  3527. if (tids.Count > 0)
  3528. {
  3529. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3530. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3531. if (dt_price != null && dt_price.Rows.Count > 0)
  3532. {
  3533. foreach (DataRow dr in dt_price.Rows)
  3534. {
  3535. foreach (DataRow row in dt.Rows)
  3536. {
  3537. if (row["tid"].Equals(dr["ptid"]))
  3538. {
  3539. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3540. break;
  3541. }
  3542. }
  3543. }
  3544. }
  3545. }
  3546. writeGridDataTableJson(dStruct.TotalCount, dt);
  3547. }
  3548. public void get_erp_supplierwaitorderlist()
  3549. {
  3550. DataStruct dStruct = GetPostStruct();
  3551. List<string> lw = new List<string>();
  3552. string tid = GetPostString("ctid");
  3553. if (tid.Length > 0)
  3554. {
  3555. string select_tid = getTidByCtid(tid);
  3556. lw.Add(string.Format("tid='{0}'", select_tid));
  3557. }
  3558. string shopname = GetPostString("shopname");
  3559. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3560. string sellermemo = GetPostString("seller_memo");
  3561. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3562. string date1 = GetPostString("date1");
  3563. string date2 = GetPostString("date2");
  3564. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3565. if (dw.Length > 0) lw.Add(dw);
  3566. lw.Add(string.Format("OrderState = 5 "));
  3567. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3568. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3569. {
  3570. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3571. }
  3572. string supplier = GetPostString("supplier");
  3573. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3574. {
  3575. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3576. }
  3577. lw.Add(string.Format("IsRefund<={0}", 1));
  3578. dStruct.Order = "FinishDesignTime desc";
  3579. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3580. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3581. if (dt != null)
  3582. {
  3583. foreach (DataRow dr in dt.Rows)
  3584. {
  3585. 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();
  3586. }
  3587. }
  3588. writeGridDataTableJson(dStruct.TotalCount, dt);
  3589. }
  3590. public void upd_erp_verifytosupplier()
  3591. {
  3592. if (UrlPostParmsCheck("ctid"))
  3593. {
  3594. string eids = GetPostString("ctid");
  3595. CeErpTradeCell entity = null;
  3596. string[] eidsList = eids.Split(',');
  3597. if (eidsList.Length <= 0)
  3598. {
  3599. returnErrorMsg("订单号不能空");
  3600. return;
  3601. }
  3602. List<string> tLst = new List<string>();
  3603. foreach (string ctidstr in eidsList)
  3604. {
  3605. tLst.Add("'" + ctidstr + "'");
  3606. CeErpDataSendOrderInfo.createObject(ctidstr);
  3607. }
  3608. string needtids = string.Join(",", tLst.ToArray());
  3609. StringBuilder sql = new StringBuilder();
  3610. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3611. 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);
  3612. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3613. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3614. returnSuccessMsg("操作成功!");
  3615. return;
  3616. /**foreach (string ctidstr in eidsList)
  3617. {
  3618. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3619. if (entity != null)
  3620. {
  3621. if (entity.SupplierId == 0)
  3622. {
  3623. continue;
  3624. }
  3625. entity.IsVerifyToSupplier = true;
  3626. if (entity.IsReturn == 1) //1是供应商打回
  3627. {
  3628. entity.IsReturn = 0;
  3629. }
  3630. entity.FinishPlaceTime = DateTime.Now;
  3631. entity.PlaceUserId = CurrentUser.UserID;
  3632. entity.Update();
  3633. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3634. }
  3635. }
  3636. returnSuccessMsg("操作成功!");
  3637. return;**/
  3638. }
  3639. }
  3640. public void upd_erp_supplierback()
  3641. {
  3642. if (UrlPostParmsCheck("ctid"))
  3643. {
  3644. string eid = GetPostString("ctid");
  3645. string reason = GetPostString("returnreason");
  3646. CeErpTradeCell entity = null;
  3647. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3648. if (entity != null)
  3649. {
  3650. string message = "操作成功!";
  3651. string isDown = "";
  3652. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3653. {
  3654. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3655. isDown = "被点击下载";
  3656. }
  3657. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3658. {
  3659. string key = "return_order_" + entity.SupplierId;
  3660. List<string> list = new List<string>();
  3661. if (RedisHelper.HasKey(key))
  3662. {
  3663. object data = RedisHelper.StringGet(key);
  3664. list = Convert.ToString(data).Split(',').ToList();
  3665. }
  3666. list.Add(eid);
  3667. RedisHelper.StringSet(key, string.Join(",", list));
  3668. }
  3669. entity.IsVerifyToSupplier = false;
  3670. entity.IsReturn = 1;
  3671. entity.IsHaveNewOrder = 0;
  3672. entity.ReturnTime = DateTime.Now;
  3673. entity.ReturnReason = reason;
  3674. if (entity.OrderState == 6)
  3675. {
  3676. entity.OrderState = 5;
  3677. }
  3678. entity.Update();
  3679. CeErpSukuraData.createInfo(entity.ctid, 5);
  3680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3681. returnSuccessMsg(message);
  3682. return;
  3683. }
  3684. returnErrorMsg("找不到订单记录");
  3685. }
  3686. }
  3687. public void upd_erp_toaftersaleorder()
  3688. {
  3689. if (UrlPostParmsCheck("ctid"))
  3690. {
  3691. string eid = GetPostString("ctid");
  3692. string reason = GetPostString("returnreason");
  3693. CeErpTradeCell entity = null;
  3694. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3695. if (entity != null)
  3696. {
  3697. if (entity.isAfterSaleOrder != 1)
  3698. {
  3699. returnErrorMsg("带S的售后单才能打回给售后");
  3700. return;
  3701. }
  3702. if (entity.OrderState >= 5)
  3703. {
  3704. returnErrorMsg("已经设计完成了不能打回给售后");
  3705. return;
  3706. }
  3707. entity.OrderState = 0;
  3708. entity.IsReturn = 3;
  3709. entity.ReturnTime = DateTime.Now;
  3710. entity.UpdateTime = DateTime.Now;
  3711. entity.ReturnReason = reason;
  3712. entity.Update();
  3713. CeErpSukuraData.createInfo(entity.ctid, 5);
  3714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3715. returnSuccessMsg("操作成功!");
  3716. return;
  3717. }
  3718. returnErrorMsg("找不到订单记录");
  3719. }
  3720. }
  3721. public void upd_erp_aftersaletodesign()
  3722. {
  3723. if (UrlPostParmsCheck("ctid"))
  3724. {
  3725. string eid = GetPostString("ctid");
  3726. CeErpTradeCell entity = null;
  3727. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3728. if (entity != null)
  3729. {
  3730. entity.OrderState = 3;
  3731. entity.IsReturn = 0;
  3732. entity.UpdateTime = DateTime.Now;
  3733. entity.Update();
  3734. CeErpSukuraData.createInfo(entity.ctid, 5);
  3735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3736. returnSuccessMsg("操作成功!");
  3737. return;
  3738. }
  3739. returnErrorMsg("找不到订单记录");
  3740. }
  3741. }
  3742. public void assign_erp_supplier()
  3743. {
  3744. if (UrlPostParmsCheck("ctid"))
  3745. {
  3746. string eids = GetPostString("ctid");
  3747. int sid = GetPostInt("SupplierName");
  3748. string fromTag = GetPostString("tag");
  3749. string[] eidList = eids.Split(',');
  3750. if (eidList.Length <= 0)
  3751. {
  3752. returnErrorMsg("指派不能为空");
  3753. return;
  3754. }
  3755. string errMsg = "";
  3756. string suname = commonHelper.getSupplierNameById(sid);
  3757. foreach (string ctid in eidList)
  3758. {
  3759. CeErpTradeCell entity = null;
  3760. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3761. if (entity != null)
  3762. {
  3763. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3764. {
  3765. errMsg += (ctid + "指派失败!!!");
  3766. continue;
  3767. }
  3768. entity.SupplierId = sid;
  3769. entity.Update();
  3770. commonHelper.UpdateRelationOrder(entity.ctid);
  3771. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3772. if (entity.OrderState >= 6)
  3773. {
  3774. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3775. //{
  3776. // string msl = entity.MakeSupplier;
  3777. // string[] mslist = msl.Split(',');
  3778. // 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);
  3779. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3780. //}
  3781. //else
  3782. //{
  3783. StringBuilder sql = new StringBuilder();
  3784. 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);
  3785. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3786. //}
  3787. }
  3788. }
  3789. else
  3790. {
  3791. continue;
  3792. }
  3793. }
  3794. if (errMsg.Length > 0)
  3795. {
  3796. returnErrorMsg(errMsg);
  3797. return;
  3798. }
  3799. returnSuccessMsg("操作成功!");
  3800. return;
  3801. }
  3802. }
  3803. public void assign_erp_makesupplier()
  3804. {
  3805. if (UrlPostParmsCheck("ctid"))
  3806. {
  3807. string eids = GetPostString("ctid");
  3808. string sname = GetPostString("SupplierName");
  3809. string[] eidList = eids.Split(',');
  3810. if (eidList.Length <= 0)
  3811. {
  3812. returnErrorMsg("指派不能为空");
  3813. return;
  3814. }
  3815. List<string> tLst = new List<string>();
  3816. foreach (string ctid in eidList)
  3817. {
  3818. CeErpTradeCell entity = null;
  3819. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3820. if (entity != null)
  3821. {
  3822. entity.MakeSupplier = sname;
  3823. entity.Update();
  3824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3825. tLst.Add("'" + ctid + "'");
  3826. }
  3827. else
  3828. {
  3829. continue;
  3830. }
  3831. }
  3832. string ctids = string.Join(",", tLst.ToArray());
  3833. StringBuilder sql2 = new StringBuilder();
  3834. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3835. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3836. returnSuccessMsg("操作成功!");
  3837. return;
  3838. }
  3839. }
  3840. public void ins_erp_returnreason()
  3841. {
  3842. if (UrlPostParmsCheck("ctid"))
  3843. {
  3844. string eid = GetPostString("ctid");
  3845. CeErpTradeCell entity = null;
  3846. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3847. string userpost = CurrentUser.UserPost.Post.Code;
  3848. if (entity != null)
  3849. {
  3850. bool isPlace = false;
  3851. if (entity.OrderState > 6)
  3852. {
  3853. returnErrorMsg("已发货无法打回!");
  3854. return;
  3855. }
  3856. if (entity.OrderState == 6)
  3857. {
  3858. isPlace = true;
  3859. }
  3860. bool isNeedUpdateCell2 = false;
  3861. if (entity.OrderState >= 6)
  3862. {
  3863. isNeedUpdateCell2 = true;
  3864. }
  3865. int returnTag = 2;
  3866. if (userpost == "Supplier")
  3867. {
  3868. returnTag = 1;
  3869. }
  3870. int toType = GetPostInt("totype");
  3871. string fromType = "3";
  3872. if (entity.OrderState < 5)
  3873. {
  3874. fromType = "3";
  3875. }
  3876. else
  3877. {
  3878. fromType = "4";
  3879. }
  3880. if (entity.IsXianHuo == 0)
  3881. {
  3882. if (returnTag == 2)
  3883. {
  3884. if (toType == 1)
  3885. {
  3886. entity.OrderState = 0;
  3887. entity.ReturnUserType = 1;
  3888. string clearman = GetPostString("clearman");
  3889. if (!string.IsNullOrEmpty(clearman))
  3890. {
  3891. entity.DesignUserId = 0;
  3892. }
  3893. }
  3894. else
  3895. {
  3896. entity.OrderState = 3;
  3897. entity.ReturnUserType = 2;
  3898. }
  3899. entity.IsReadTag = 1;
  3900. }
  3901. else if (returnTag == 1)
  3902. {
  3903. entity.OrderState = 5;
  3904. }
  3905. entity.IsVerifyToSupplier = false;
  3906. }
  3907. if (entity.IsXianHuo == 1)
  3908. {
  3909. entity.OrderState = 5;
  3910. }
  3911. entity.UnusualTag = 0;
  3912. entity.UnusualTime = null;
  3913. entity.UnusualCon = "";
  3914. entity.IsReturn = returnTag;
  3915. entity.ReturnTime = DateTime.Now;
  3916. entity.UpdateTime = DateTime.Now;
  3917. entity.ReturnReason = GetPostString("returnreason");
  3918. entity.Update();
  3919. if (entity.OrderState == 3)
  3920. {
  3921. ApiVo apiVo = new ApiVo();
  3922. apiVo.orderNumber = entity.ctid;
  3923. apiVo.actionName = "rebutDesign";
  3924. apiVo.orderRemarks = entity.ReturnReason;
  3925. designHelper.API_WorkCore(apiVo);//rebutDesign
  3926. }
  3927. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3928. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3929. {
  3930. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3931. }
  3932. CeErpSukuraData.createInfo(entity.ctid, 5);
  3933. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3934. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3935. if (isPlace)
  3936. {
  3937. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3938. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3939. if (dth != null && dth.Rows.Count > 0)
  3940. {
  3941. dataSendOrderBean dataSendOrderBean = null;
  3942. foreach (DataRow item in dth.Rows)
  3943. {
  3944. try
  3945. {
  3946. dataSendOrderBean = new dataSendOrderBean();
  3947. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3948. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3949. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3950. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3951. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3952. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3953. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3954. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3955. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3956. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3957. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3958. dataSendOrderBean.Radio1723534706288 = "打回";
  3959. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3960. if (result != null)
  3961. {
  3962. if ("0".Equals(result.errcode))
  3963. {
  3964. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3965. }
  3966. else
  3967. {
  3968. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3969. }
  3970. }
  3971. }
  3972. catch (Exception ex)
  3973. {
  3974. }
  3975. }
  3976. }
  3977. }
  3978. if (isNeedUpdateCell2)
  3979. {
  3980. if (entity.MakeSupplier.IndexOf(",") != -1)
  3981. {
  3982. StringBuilder sql2 = new StringBuilder();
  3983. 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);
  3984. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3985. }
  3986. else
  3987. {
  3988. StringBuilder sql2 = new StringBuilder();
  3989. 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);
  3990. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3991. }
  3992. }
  3993. returnSuccessMsg("操作成功!");
  3994. return;
  3995. }
  3996. returnErrorMsg("找不到订单记录");
  3997. }
  3998. }
  3999. public void cyt_erp_returnreason()
  4000. {
  4001. if (UrlPostParmsCheck("ctid"))
  4002. {
  4003. string eid = GetPostString("ctid");
  4004. CeErpTradeCell entity = null;
  4005. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4006. string userpost = CurrentUser.UserPost.Post.Code;
  4007. if (entity != null)
  4008. {
  4009. if (entity.OrderState > 6)
  4010. {
  4011. returnErrorMsg("已发货无法打回!");
  4012. return;
  4013. }
  4014. JObject jsonObject = new JObject
  4015. {
  4016. { "Userid", "77886" },
  4017. { "Pwd", "lt666888" },
  4018. { "LTOrderId",eid }
  4019. };
  4020. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4021. JObject jsonObjects = JObject.Parse(response);
  4022. string msg = (string)jsonObjects["msg"];
  4023. if (msg != "取消成功")
  4024. {
  4025. returnErrorMsg(msg);
  4026. return;
  4027. }
  4028. bool isNeedUpdateCell2 = false;
  4029. if (entity.OrderState >= 6)
  4030. {
  4031. isNeedUpdateCell2 = true;
  4032. }
  4033. int returnTag = 2;
  4034. if (userpost == "Supplier")
  4035. {
  4036. returnTag = 1;
  4037. }
  4038. if (entity.IsXianHuo == 0)
  4039. {
  4040. if (returnTag == 2)
  4041. {
  4042. int toType = GetPostInt("totype");
  4043. if (toType == 1)
  4044. {
  4045. entity.OrderState = 0;
  4046. entity.ReturnUserType = 1;
  4047. }
  4048. else
  4049. {
  4050. entity.OrderState = 4;
  4051. entity.ReturnUserType = 2;
  4052. }
  4053. entity.IsReadTag = 1;
  4054. }
  4055. else if (returnTag == 1)
  4056. {
  4057. entity.OrderState = 5;
  4058. }
  4059. entity.IsVerifyToSupplier = false;
  4060. }
  4061. entity.UnusualTag = 0;
  4062. entity.UnusualTime = null;
  4063. entity.UnusualCon = "";
  4064. entity.IsReturn = returnTag;
  4065. entity.ReturnTime = DateTime.Now;
  4066. entity.ReturnReason = GetPostString("returnreason");
  4067. entity.Update();
  4068. if (entity.OrderState == 4)
  4069. {
  4070. ApiVo apiVo = new ApiVo();
  4071. apiVo.orderNumber = entity.ctid;
  4072. apiVo.actionName = "rebutDesign";
  4073. apiVo.orderRemarks = entity.ReturnReason;
  4074. designHelper.API_WorkCore(apiVo);//rebutDesign
  4075. }
  4076. CeErpSukuraData.createInfo(entity.ctid, 5);
  4077. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4079. if (isNeedUpdateCell2)
  4080. {
  4081. if (entity.MakeSupplier.IndexOf(",") != -1)
  4082. {
  4083. StringBuilder sql2 = new StringBuilder();
  4084. 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);
  4085. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4086. }
  4087. else
  4088. {
  4089. StringBuilder sql2 = new StringBuilder();
  4090. 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);
  4091. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4092. }
  4093. }
  4094. returnSuccessMsg("操作成功!");
  4095. return;
  4096. }
  4097. returnErrorMsg("找不到订单记录");
  4098. }
  4099. }
  4100. public void upd_erp_xianhuoreturntag()
  4101. {
  4102. if (UrlPostParmsCheck("ctid"))
  4103. {
  4104. string eids = GetPostString("ctid");
  4105. string[] ctids = eids.Split(',');
  4106. foreach (string ctid in ctids)
  4107. {
  4108. CeErpTradeCell entity = null;
  4109. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4110. if (entity != null)
  4111. {
  4112. entity.IsReturn = 0;
  4113. entity.Update();
  4114. CeErpSukuraData.createInfo(entity.ctid, 5);
  4115. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4116. }
  4117. }
  4118. returnSuccessMsg("操作成功!");
  4119. return;
  4120. }
  4121. }
  4122. public void get_erp_waitdeliverylist()
  4123. {
  4124. DataStruct dStruct = GetPostStruct();
  4125. List<string> lw = new List<string>();
  4126. string tid = GetPostString("ctid");
  4127. if (tid.Length > 0)
  4128. {
  4129. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4130. if (tid.Length > 5)
  4131. {
  4132. List<string> tids = getTidByCtidLike(tid);
  4133. if (tids.Count > 0 && tids.Count < 10)
  4134. {
  4135. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4136. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4137. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4138. {
  4139. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4140. }*/
  4141. }
  4142. }
  4143. lw.Add(tid_sql);
  4144. }
  4145. string shopname = GetPostString("shopname");
  4146. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4147. string buyernick = GetPostString("buyer_nick");
  4148. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4149. //if (tid.Length == 0 && buyernick.Length == 0)
  4150. //{
  4151. // lw.Add(string.Format("IsRefund<={0}", 1));
  4152. //}
  4153. string customer = GetPostString("customer");
  4154. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4155. string design = GetPostString("design");
  4156. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4157. string orderState = GetPostString("orderState");
  4158. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4159. string address = GetPostString("address");
  4160. 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));
  4161. string sellermemo = GetPostString("seller_memo");
  4162. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4163. string supplier = GetPostString("supplier");
  4164. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4165. string OrderArea = GetPostString("order_area");
  4166. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4167. string placedate1 = GetPostString("placedate1");
  4168. string placedate2 = GetPostString("placedate2");
  4169. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4170. if (fdw.Length > 0) lw.Add(fdw);
  4171. string price1 = GetPostString("price1");
  4172. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4173. string price2 = GetPostString("price2");
  4174. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4175. string unusualCon = GetPostString("unusualcon");
  4176. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4177. string otherMemo = GetPostString("otherMemo");
  4178. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4179. string posTag = CurrentUser.UserPost.Post.Code;
  4180. if (posTag == "Supplier")
  4181. {
  4182. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4183. }
  4184. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4185. lw.Add(string.Format("type != 'PDD' "));
  4186. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4187. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4188. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4189. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4190. writeGridDataTableJson(dStruct.TotalCount, dt);
  4191. }
  4192. public void get_erp_changedeliverylist()
  4193. {
  4194. DataStruct dStruct = GetPostStruct();
  4195. List<string> lw = new List<string>();
  4196. string tid = GetPostString("ctid");
  4197. if (tid.Length > 0)
  4198. {
  4199. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4200. if (tid.Length > 5)
  4201. {
  4202. List<string> tids = getTidByCtidLike(tid);
  4203. if (tids.Count > 0 && tids.Count < 10)
  4204. {
  4205. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4206. }
  4207. }
  4208. lw.Add(tid_sql);
  4209. }
  4210. string shopname = GetPostString("shopname");
  4211. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4212. string buyernick = GetPostString("buyer_nick");
  4213. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4214. //if (tid.Length == 0 && buyernick.Length == 0)
  4215. //{
  4216. // lw.Add(string.Format("IsRefund<={0}", 1));
  4217. //}
  4218. string customer = GetPostString("customer");
  4219. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4220. string design = GetPostString("design");
  4221. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4222. string orderState = GetPostString("orderState");
  4223. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4224. string address = GetPostString("address");
  4225. 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));
  4226. string sellermemo = GetPostString("seller_memo");
  4227. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4228. string supplier = GetPostString("supplier");
  4229. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4230. string OrderArea = GetPostString("order_area");
  4231. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4232. string placedate1 = GetPostString("placedate1");
  4233. string placedate2 = GetPostString("placedate2");
  4234. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4235. if (fdw.Length > 0) lw.Add(fdw);
  4236. string price1 = GetPostString("price1");
  4237. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4238. string price2 = GetPostString("price2");
  4239. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4240. string unusualCon = GetPostString("unusualcon");
  4241. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4242. string otherMemo = GetPostString("otherMemo");
  4243. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4244. string posTag = CurrentUser.UserPost.Post.Code;
  4245. if (posTag == "Supplier")
  4246. {
  4247. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4248. }
  4249. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4250. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4251. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4253. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4254. /*if (tid.Length > 0)
  4255. {
  4256. List<string> tids = new List<string>();
  4257. if (dt != null && dt.Rows.Count > 0)
  4258. {
  4259. foreach (DataRow item in dt.Rows)
  4260. {
  4261. tids.Add("'" + item["tid"] + "'");
  4262. }
  4263. }
  4264. if (tids.Count > 0)
  4265. {
  4266. lw.RemoveAt(0);
  4267. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4269. dt = WebCache.GetData("view_erptradecell", dStruct);
  4270. }
  4271. }*/
  4272. writeGridDataTableJson(dStruct.TotalCount, dt);
  4273. }
  4274. public void get_erp_pddderiving()
  4275. {
  4276. DataStruct dStruct = GetPostStruct();
  4277. List<string> lw = new List<string>();
  4278. string tid = GetPostString("ctid");
  4279. if (tid.Length > 0)
  4280. {
  4281. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4282. if (tid.Length > 5)
  4283. {
  4284. List<string> tids = getTidByCtidLike(tid);
  4285. if (tids.Count > 0 && tids.Count < 10)
  4286. {
  4287. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4288. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4289. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4290. {
  4291. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4292. }*/
  4293. }
  4294. }
  4295. lw.Add(tid_sql);
  4296. }
  4297. string shopname = GetPostString("shopname");
  4298. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4299. string buyernick = GetPostString("buyer_nick");
  4300. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4301. //if (tid.Length == 0 && buyernick.Length == 0)
  4302. //{
  4303. // lw.Add(string.Format("IsRefund<={0}", 1));
  4304. //}
  4305. string customer = GetPostString("customer");
  4306. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4307. string design = GetPostString("design");
  4308. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4309. string orderState = GetPostString("orderState");
  4310. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4311. string address = GetPostString("address");
  4312. 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));
  4313. string sellermemo = GetPostString("seller_memo");
  4314. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4315. string supplier = GetPostString("supplier");
  4316. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4317. string OrderArea = GetPostString("order_area");
  4318. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4319. string placedate1 = GetPostString("placedate1");
  4320. string placedate2 = GetPostString("placedate2");
  4321. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4322. if (fdw.Length > 0) lw.Add(fdw);
  4323. string price1 = GetPostString("price1");
  4324. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4325. string price2 = GetPostString("price2");
  4326. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4327. string unusualCon = GetPostString("unusualcon");
  4328. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4329. string posTag = CurrentUser.UserPost.Post.Code;
  4330. if (posTag == "Supplier")
  4331. {
  4332. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4333. }
  4334. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4335. lw.Add(string.Format("type = 'PDD' "));
  4336. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4337. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4338. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4339. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4340. /*if (tid.Length > 0)
  4341. {
  4342. List<string> tids = new List<string>();
  4343. if (dt != null && dt.Rows.Count > 0)
  4344. {
  4345. foreach (DataRow item in dt.Rows)
  4346. {
  4347. tids.Add("'" + item["tid"] + "'");
  4348. }
  4349. }
  4350. if (tids.Count > 0)
  4351. {
  4352. lw.RemoveAt(0);
  4353. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4354. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4355. dt = WebCache.GetData("view_erptradecell", dStruct);
  4356. }
  4357. }*/
  4358. writeGridDataTableJson(dStruct.TotalCount, dt);
  4359. }
  4360. public void get_erp_jdderiving()
  4361. {
  4362. DataStruct dStruct = GetPostStruct();
  4363. List<string> lw = new List<string>();
  4364. string tid = GetPostString("ctid");
  4365. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4366. string shopname = GetPostString("shopname");
  4367. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4368. string buyernick = GetPostString("buyer_nick");
  4369. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4370. //if (tid.Length == 0 && buyernick.Length == 0)
  4371. //{
  4372. // lw.Add(string.Format("IsRefund<={0}", 1));
  4373. //}
  4374. string customer = GetPostString("customer");
  4375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4376. string design = GetPostString("design");
  4377. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4378. string orderState = GetPostString("orderState");
  4379. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4380. string address = GetPostString("address");
  4381. 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));
  4382. string sellermemo = GetPostString("seller_memo");
  4383. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4384. string supplier = GetPostString("supplier");
  4385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4386. string OrderArea = GetPostString("order_area");
  4387. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4388. string placedate1 = GetPostString("placedate1");
  4389. string placedate2 = GetPostString("placedate2");
  4390. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4391. if (fdw.Length > 0) lw.Add(fdw);
  4392. string price1 = GetPostString("price1");
  4393. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4394. string price2 = GetPostString("price2");
  4395. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4396. string unusualCon = GetPostString("unusualcon");
  4397. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4398. string posTag = CurrentUser.UserPost.Post.Code;
  4399. if (posTag == "Supplier")
  4400. {
  4401. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4402. }
  4403. lw.Add(string.Format("OrderState = 6 "));
  4404. lw.Add(string.Format("type = 'JD' "));
  4405. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4406. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4407. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4408. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4409. writeGridDataTableJson(dStruct.TotalCount, dt);
  4410. }
  4411. public void get_erp_demoorderlist()
  4412. {
  4413. DataStruct dStruct = GetPostStruct();
  4414. List<string> lw = new List<string>();
  4415. string tid = GetPostString("ctid");
  4416. if (tid.Length > 0)
  4417. {
  4418. string select_tid = getTidByCtid(tid);
  4419. lw.Add(string.Format("tid='{0}'", select_tid));
  4420. }
  4421. string shopname = GetPostString("shopname");
  4422. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4423. string buyernick = GetPostString("buyer_nick");
  4424. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4425. string customer = GetPostString("customer");
  4426. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4427. string design = GetPostString("design");
  4428. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4429. string orderState = GetPostString("orderState");
  4430. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4431. string address = GetPostString("address");
  4432. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4433. string sellermemo = GetPostString("seller_memo");
  4434. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4435. string supplier = GetPostString("supplier");
  4436. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4437. string OrderArea = GetPostString("order_area");
  4438. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4439. string date1 = GetPostString("date1");
  4440. string date2 = GetPostString("date2");
  4441. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4442. if (dw.Length > 0) lw.Add(dw);
  4443. string price1 = GetPostString("price1");
  4444. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4445. string price2 = GetPostString("price2");
  4446. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4447. string posTag = CurrentUser.UserPost.Post.Code;
  4448. if (posTag == "Supplier")
  4449. {
  4450. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4451. }
  4452. //lw.Add(string.Format("OrderState = 6 "));
  4453. lw.Add(string.Format("IsSample={0}", 3));
  4454. lw.Add(string.Format("IsRefund<={0}", 1));
  4455. dStruct.Order = "pay_time desc";
  4456. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4457. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4458. writeGridDataTableJson(dStruct.TotalCount, dt);
  4459. }
  4460. public void save_erp_checkmemo()
  4461. {
  4462. if (UrlPostParmsCheck("ctid"))
  4463. {
  4464. string ctid = GetPostString("ctid");
  4465. CeErpTradeCell entity = null;
  4466. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4467. if (entity != null)
  4468. {
  4469. entity.CheckMemo = GetPostString("CheckMemo");
  4470. entity.Update();
  4471. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4472. if (trade != null)
  4473. {
  4474. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4475. }
  4476. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4477. returnSuccessMsg("保存成功!");
  4478. return;
  4479. }
  4480. returnErrorMsg("找不到记录");
  4481. }
  4482. }
  4483. public void get_erp_returnlist()
  4484. {
  4485. DataStruct dStruct = GetPostStruct();
  4486. List<string> lw = new List<string>();
  4487. string tid = GetPostString("ctid");
  4488. if (tid.Length > 0)
  4489. {
  4490. string select_tid = getTidByCtid(tid);
  4491. lw.Add(string.Format("tid='{0}'", select_tid));
  4492. }
  4493. string shopname = GetPostString("shopname");
  4494. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4495. string buyernick = GetPostString("buyer_nick");
  4496. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4497. string customer = GetPostString("customer");
  4498. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4499. string design = GetPostString("design");
  4500. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4501. string orderState = GetPostString("orderState");
  4502. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4503. string address = GetPostString("address");
  4504. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4505. string sellermemo = GetPostString("seller_memo");
  4506. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4507. string supplier = GetPostString("supplier");
  4508. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4509. string date1 = GetPostString("date1");
  4510. string date2 = GetPostString("date2");
  4511. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4512. if (dw.Length > 0) lw.Add(dw);
  4513. string bdate1 = GetPostString("backdate1");
  4514. string bdate2 = GetPostString("backdate2");
  4515. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4516. if (dw_back.Length > 0) lw.Add(dw_back);
  4517. string price1 = GetPostString("price1");
  4518. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4519. string price2 = GetPostString("price2");
  4520. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4521. lw.Add(string.Format("IsReturn>0"));
  4522. lw.Add(string.Format("IsXianHuo=0"));
  4523. lw.Add(string.Format("IsReturn!=3"));
  4524. string backtype = GetPostString("backtype");
  4525. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4526. dStruct.Order = "FinishDesignTime desc";
  4527. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4528. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4529. writeGridDataTableJson(dStruct.TotalCount, dt);
  4530. }
  4531. public void get_erp_today_sumreturn()
  4532. {
  4533. DataStruct dStruct = GetPostStruct();
  4534. List<string> lw = new List<string>();
  4535. string bdate1 = GetPostString("returnTimeS");
  4536. string bdate2 = GetPostString("returnTimeE");
  4537. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4538. if (dw_back.Length > 0) lw.Add(dw_back);
  4539. lw.Add(string.Format("IsReturn=0"));
  4540. lw.Add(string.Format("IsXianHuo=0"));
  4541. string mainWhere = string.Join(" and ", lw.ToArray());
  4542. string sql = "";
  4543. if (dw_back.Length > 0)
  4544. {
  4545. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4546. }
  4547. else
  4548. {
  4549. 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 + "'";
  4550. }
  4551. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4552. decimal total = 0, today_finish = 0;
  4553. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4554. {
  4555. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4556. }
  4557. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4558. {
  4559. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4560. }
  4561. var res = new
  4562. {
  4563. data = total,
  4564. data1 = today_finish,
  4565. };
  4566. string ro_jsond = JsonConvert.SerializeObject(res);
  4567. returnSuccess(ro_jsond);
  4568. return;
  4569. }
  4570. public void get_erp_allreturnlist()
  4571. {
  4572. DataStruct dStruct = GetPostStruct();
  4573. List<string> lw = new List<string>();
  4574. string tid = GetPostString("ctid");
  4575. if (tid.Length > 0)
  4576. {
  4577. string select_tid = getTidByCtid(tid);
  4578. lw.Add(string.Format("tid='{0}'", select_tid));
  4579. }
  4580. string shopname = GetPostString("shopname");
  4581. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4582. string buyernick = GetPostString("buyer_nick");
  4583. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4584. string customer = GetPostString("customer");
  4585. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4586. string design = GetPostString("design");
  4587. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4588. string orderState = GetPostString("orderState");
  4589. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4590. string address = GetPostString("address");
  4591. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4592. string sellermemo = GetPostString("seller_memo");
  4593. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4594. string supplier = GetPostString("supplier");
  4595. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4596. string date1 = GetPostString("date1");
  4597. string date2 = GetPostString("date2");
  4598. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4599. if (dw.Length > 0) lw.Add(dw);
  4600. string bdate1 = GetPostString("backdate1");
  4601. string bdate2 = GetPostString("backdate2");
  4602. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4603. if (dw_back.Length > 0) lw.Add(dw_back);
  4604. string price1 = GetPostString("price1");
  4605. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4606. string price2 = GetPostString("price2");
  4607. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4608. string backreason = GetPostString("backreason");
  4609. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4610. lw.Add(string.Format("IsXianHuo=0"));
  4611. lw.Add(string.Format("ReturnTime != ''"));
  4612. string backtype = GetPostString("backtype");
  4613. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4614. dStruct.Order = "FinishDesignTime desc";
  4615. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4616. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4617. writeGridDataTableJson(dStruct.TotalCount, dt);
  4618. }
  4619. public void get_erp_aftersalereturnlist()
  4620. {
  4621. DataStruct dStruct = GetPostStruct();
  4622. List<string> lw = new List<string>();
  4623. string tid = GetPostString("ctid");
  4624. if (tid.Length > 0)
  4625. {
  4626. string select_tid = getTidByCtid(tid);
  4627. lw.Add(string.Format("tid='{0}'", select_tid));
  4628. }
  4629. string shopname = GetPostString("shopname");
  4630. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4631. string buyernick = GetPostString("buyer_nick");
  4632. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4633. string customer = GetPostString("customer");
  4634. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4635. string design = GetPostString("design");
  4636. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4637. string orderState = GetPostString("orderState");
  4638. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4639. string address = GetPostString("address");
  4640. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4641. string sellermemo = GetPostString("seller_memo");
  4642. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4643. string supplier = GetPostString("supplier");
  4644. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4645. string date1 = GetPostString("date1");
  4646. string date2 = GetPostString("date2");
  4647. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4648. if (dw.Length > 0) lw.Add(dw);
  4649. string bdate1 = GetPostString("backdate1");
  4650. string bdate2 = GetPostString("backdate2");
  4651. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4652. if (dw_back.Length > 0) lw.Add(dw_back);
  4653. string price1 = GetPostString("price1");
  4654. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4655. string price2 = GetPostString("price2");
  4656. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4657. lw.Add(string.Format("IsReturn=3"));
  4658. string backtype = GetPostString("backtype");
  4659. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4660. string backreason = GetPostString("backreason");
  4661. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4662. dStruct.Order = "ReturnTime desc";
  4663. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4664. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4665. writeGridDataTableJson(dStruct.TotalCount, dt);
  4666. }
  4667. public void get_erp_xianhuoreturnlist()
  4668. {
  4669. DataStruct dStruct = GetPostStruct();
  4670. List<string> lw = new List<string>();
  4671. string tid = GetPostString("ctid");
  4672. if (tid.Length > 0)
  4673. {
  4674. string select_tid = getTidByCtid(tid);
  4675. lw.Add(string.Format("tid='{0}'", select_tid));
  4676. }
  4677. string shopname = GetPostString("shopname");
  4678. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4679. string buyernick = GetPostString("buyer_nick");
  4680. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4681. string customer = GetPostString("customer");
  4682. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4683. string design = GetPostString("design");
  4684. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4685. string orderState = GetPostString("orderState");
  4686. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4687. string address = GetPostString("address");
  4688. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4689. string sellermemo = GetPostString("seller_memo");
  4690. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4691. string supplier = GetPostString("supplier");
  4692. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4693. string OrderArea = GetPostString("order_area");
  4694. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4695. string date1 = GetPostString("date1");
  4696. string date2 = GetPostString("date2");
  4697. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4698. if (dw.Length > 0) lw.Add(dw);
  4699. string price1 = GetPostString("price1");
  4700. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4701. string price2 = GetPostString("price2");
  4702. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4703. string posTag = CurrentUser.UserPost.Post.Code;
  4704. if (posTag == "Supplier")
  4705. {
  4706. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4707. }
  4708. lw.Add(string.Format("OrderState=6 "));
  4709. lw.Add(string.Format("IsXianHuo=1 "));
  4710. lw.Add(string.Format("IsReturn>0 "));
  4711. lw.Add(string.Format("IsReturn!=3"));
  4712. lw.Add(string.Format("IsRefund<={0}", 1));
  4713. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4714. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4715. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4716. writeGridDataTableJson(dStruct.TotalCount, dt);
  4717. }
  4718. public void set_erp_orderdelivery()
  4719. {
  4720. if (UrlPostParmsCheck("ctid"))
  4721. {
  4722. string eid = GetPostString("ctid");
  4723. CeErpTradeCell entity = null;
  4724. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4725. if (entity != null)
  4726. {
  4727. if (entity.OrderState >= 7)
  4728. {
  4729. returnErrorMsg("此单已发货,无需重复发货");
  4730. return;
  4731. }
  4732. if (entity.OrderState != 6)
  4733. {
  4734. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4735. return;
  4736. }
  4737. string shop = GetPostString("seller_nick");
  4738. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4739. string comName = GetPostString("comName");
  4740. string comCode = GetPostString("comCode");
  4741. string outSid = GetPostString("outSid");
  4742. string deliveryType = GetPostString("deliveryType");
  4743. string deliveryMemo = GetPostString("deliveryMemo");
  4744. outSid = outSid.Trim();
  4745. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4746. if (mainEn == null)
  4747. {
  4748. returnErrorMsg("找不到原始订单记录");
  4749. return;
  4750. }
  4751. bool isInitOrderDeliv = false;
  4752. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4753. {
  4754. isInitOrderDeliv = true;
  4755. }
  4756. string apires = "";
  4757. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4758. 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)
  4759. {
  4760. apires = "发货成功true";
  4761. }
  4762. else
  4763. {
  4764. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4765. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4766. }
  4767. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4768. {
  4769. entity.OrderState = 7;//发货后订单已发货
  4770. entity.OutSid = outSid;
  4771. entity.MemoOpt = 0;
  4772. entity.UpdateTime = DateTime.Now;
  4773. entity.FinishDeliveryTime = DateTime.Now;
  4774. entity.Update();
  4775. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4776. commonHelper.UpdateRelationOrder(entity.ctid);
  4777. //还要插入快递信息到 快递信息表
  4778. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4779. exinfo.tid = eid;
  4780. exinfo.out_sid = outSid;
  4781. exinfo.company_code = comCode;
  4782. exinfo.company_name = comName;
  4783. exinfo.delivery_memo = deliveryMemo;
  4784. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4785. exinfo.deliveryType = deliveryType;
  4786. exinfo.Create();
  4787. returnSuccessMsg("发货操作成功!");
  4788. commonHelper.UpdateRelationOrder(entity.ctid);
  4789. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4790. CeErpSukuraData.createInfo(entity.ctid, 4);
  4791. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4792. {
  4793. commonHelper.sendCytExpress(exinfo);
  4794. }
  4795. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4796. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4797. }
  4798. else
  4799. {
  4800. string errmsg = commonHelper.KeepChinese(apires);
  4801. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4802. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4803. }
  4804. return;
  4805. }
  4806. returnErrorMsg("找不到订单记录");
  4807. }
  4808. }
  4809. public void set_erp_multidelivery()
  4810. {
  4811. string eids = GetPostString("tids");
  4812. string[] eidList = eids.Split(',');
  4813. if (eidList.Length <= 0)
  4814. {
  4815. returnErrorMsg("发货不能为空");
  4816. return;
  4817. }
  4818. foreach (string ctid in eidList)
  4819. {
  4820. if (ctid.Length <= 0) continue;
  4821. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4822. if (expInfo != null)
  4823. {
  4824. StringBuilder sql = new StringBuilder();
  4825. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4826. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4827. if (dt.Rows.Count > 0)
  4828. {
  4829. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4830. {
  4831. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4832. expInfo.state = "异常";
  4833. expInfo.isMultiDelivery = 1;
  4834. expInfo.Update();
  4835. continue;
  4836. }
  4837. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4838. {
  4839. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4840. expInfo.state = "异常";
  4841. expInfo.Update();
  4842. continue;
  4843. }
  4844. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4845. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4846. bool isInitOrderDeliv = false;
  4847. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4848. {
  4849. isInitOrderDeliv = true;
  4850. expInfo.isMultiDelivery = 1;
  4851. }
  4852. if (ctid.IndexOf("N") != -1)
  4853. {
  4854. StringBuilder sqlbucha = new StringBuilder();
  4855. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4856. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4857. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4858. commonHelper.UpdateRelationOrder(ctid);
  4859. expInfo.delivery_memo = "发货成功";
  4860. expInfo.state = "发货成功";
  4861. expInfo.isMultiDelivery = 1;
  4862. expInfo.Update();
  4863. }
  4864. else
  4865. {
  4866. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4867. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4868. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4869. {
  4870. expInfo.delivery_memo = "发货成功";
  4871. expInfo.state = "发货成功";
  4872. expInfo.isMultiDelivery = 1;
  4873. expInfo.Update();
  4874. commonHelper.UpdateRelationOrder(ctid);
  4875. CeErpSukuraData.createInfo(ctid, 4);
  4876. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4877. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4878. }
  4879. else
  4880. {
  4881. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4882. expInfo.state = "异常";
  4883. expInfo.Update();
  4884. }
  4885. }
  4886. }
  4887. }
  4888. }
  4889. returnSuccessMsg("操作完成");
  4890. }
  4891. public void reset_erp_memoopt()
  4892. {
  4893. if (UrlPostParmsCheck("ctid"))
  4894. {
  4895. string eid = GetPostString("ctid");
  4896. CeErpTradeCell entity = null;
  4897. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4898. if (entity != null)
  4899. {
  4900. string stropt = "";
  4901. if (entity.MemoOpt == 1)
  4902. {
  4903. stropt = "“改稿”";
  4904. }
  4905. else if (entity.MemoOpt == 2)
  4906. {
  4907. stropt = "“定稿”";
  4908. }
  4909. else if (entity.MemoOpt == 3)
  4910. {
  4911. stropt = "“完成查货”";
  4912. CeErpSukuraData.createInfo(entity.ctid, 6);
  4913. }
  4914. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4915. entity.UpdateTime = DateTime.Now;
  4916. entity.MemoOpt = 0;
  4917. entity.Update();
  4918. returnSuccessMsg("操作成功!");
  4919. return;
  4920. }
  4921. returnErrorMsg("找不到记录");
  4922. }
  4923. }
  4924. public void get_erp_deliveryunusual()
  4925. {
  4926. DataStruct dStruct = GetPostStruct();
  4927. List<string> lw = new List<string>();
  4928. string tid = GetPostString("ctid");
  4929. if (tid.Length > 0)
  4930. {
  4931. string select_tid = getTidByCtid(tid);
  4932. lw.Add(string.Format("tid='{0}'", select_tid));
  4933. }
  4934. string shopname = GetPostString("shopname");
  4935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4936. string buyernick = GetPostString("buyer_nick");
  4937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4938. string customer = GetPostString("customer");
  4939. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4940. string design = GetPostString("design");
  4941. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4942. string sellermemo = GetPostString("seller_memo");
  4943. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4944. string supplier = GetPostString("supplier");
  4945. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4946. string date1 = GetPostString("date1");
  4947. string date2 = GetPostString("date2");
  4948. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4949. if (dw.Length > 0) lw.Add(dw);
  4950. string placedate1 = GetPostString("placedate1");
  4951. string placedate2 = GetPostString("placedate2");
  4952. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4953. if (dw_place.Length > 0) lw.Add(dw_place);
  4954. string price1 = GetPostString("price1");
  4955. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4956. string price2 = GetPostString("price2");
  4957. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4958. string unusualCon = GetPostString("unusualcon");
  4959. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4960. string posTag = CurrentUser.UserPost.Post.Code;
  4961. if (posTag == "Supplier")
  4962. {
  4963. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4964. }
  4965. lw.Add(string.Format("OrderState = 6"));
  4966. lw.Add(string.Format("UnusualTag = 5"));
  4967. lw.Add(string.Format("IsRefund<={0}", 1));
  4968. dStruct.Order = "FinishPlaceTime desc";
  4969. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4970. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4971. writeGridDataTableJson(dStruct.TotalCount, dt);
  4972. }
  4973. public void get_erp_deliveryedlist()
  4974. {
  4975. DataStruct dStruct = GetPostStruct();
  4976. List<string> lw = new List<string>();
  4977. string tid = GetPostString("ctid");
  4978. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4979. string shopname = GetPostString("shopname");
  4980. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4981. string buyernick = GetPostString("buyer_nick");
  4982. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4983. string customer = GetPostString("customer");
  4984. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4985. string design = GetPostString("design");
  4986. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4987. string sellermemo = GetPostString("seller_memo");
  4988. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4989. string logistics = GetPostString("logistics");
  4990. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4991. string date1 = GetPostString("date1");
  4992. string date2 = GetPostString("date2");
  4993. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4994. //if (dw.Length > 0) lw.Add(dw);
  4995. string placedate1 = GetPostString("placedate1");
  4996. string placedate2 = GetPostString("placedate2");
  4997. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4998. if (fdw.Length > 0) lw.Add(fdw);
  4999. string devdate1 = GetPostString("deliverydate1");
  5000. string devdate2 = GetPostString("deliverydate2");
  5001. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5002. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5003. string price1 = GetPostString("price1");
  5004. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5005. string price2 = GetPostString("price2");
  5006. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5007. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5008. {
  5009. if (tid.Length > 0)
  5010. {
  5011. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5012. if (tid.Length > 5)
  5013. {
  5014. List<string> tids = getTidByCtidLike(tid);
  5015. if (tids.Count > 0 && tids.Count < 10)
  5016. {
  5017. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5018. }
  5019. }
  5020. lw.Add(tid_sql);
  5021. }
  5022. if (buyernick.Length > 0)
  5023. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5024. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5025. if (dw.Length > 0) lw.Add(dw);
  5026. }
  5027. else
  5028. {
  5029. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5030. }
  5031. string posTag = CurrentUser.UserPost.Post.Code;
  5032. if (posTag == "Supplier")
  5033. {
  5034. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5035. }
  5036. else
  5037. {
  5038. string supplier = GetPostString("supplier");
  5039. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5040. }
  5041. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5042. lw.Add(string.Format("type != 'PDD' "));
  5043. lw.Add(string.Format("IsRefund!={0}", 2));
  5044. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5046. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5047. /*if (tid.Length > 0)
  5048. {
  5049. List<string> tids = new List<string>();
  5050. if (dt != null && dt.Rows.Count > 0)
  5051. {
  5052. foreach (DataRow item in dt.Rows)
  5053. {
  5054. tids.Add("'" + item["tid"] + "'");
  5055. }
  5056. }
  5057. if (tids.Count > 0)
  5058. {
  5059. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5060. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5061. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5062. dt = WebCache.GetData("view_erptradecell", dStruct);
  5063. }
  5064. }*/
  5065. if (dt != null)
  5066. {
  5067. foreach (DataRow dr in dt.Rows)
  5068. {
  5069. 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();
  5070. }
  5071. }
  5072. writeGridDataTableJson(dStruct.TotalCount, dt);
  5073. }
  5074. public void get_erp_pdddeliveryed()
  5075. {
  5076. DataStruct dStruct = GetPostStruct();
  5077. List<string> lw = new List<string>();
  5078. string tid = GetPostString("ctid");
  5079. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5080. string shopname = GetPostString("shopname");
  5081. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5082. string buyernick = GetPostString("buyer_nick");
  5083. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5084. string customer = GetPostString("customer");
  5085. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5086. string design = GetPostString("design");
  5087. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5088. string sellermemo = GetPostString("seller_memo");
  5089. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5090. string logistics = GetPostString("logistics");
  5091. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5092. string date1 = GetPostString("date1");
  5093. string date2 = GetPostString("date2");
  5094. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5095. //if (dw.Length > 0) lw.Add(dw);
  5096. string placedate1 = GetPostString("placedate1");
  5097. string placedate2 = GetPostString("placedate2");
  5098. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5099. if (fdw.Length > 0) lw.Add(fdw);
  5100. string devdate1 = GetPostString("deliverydate1");
  5101. string devdate2 = GetPostString("deliverydate2");
  5102. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5103. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5104. string price1 = GetPostString("price1");
  5105. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5106. string price2 = GetPostString("price2");
  5107. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5108. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5109. {
  5110. if (tid.Length > 0)
  5111. {
  5112. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5113. if (tid.Length > 5)
  5114. {
  5115. List<string> tids = getTidByCtidLike(tid);
  5116. if (tids.Count > 0 && tids.Count < 10)
  5117. {
  5118. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5119. }
  5120. }
  5121. lw.Add(tid_sql);
  5122. }
  5123. if (buyernick.Length > 0)
  5124. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5125. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5126. if (dw.Length > 0) lw.Add(dw);
  5127. }
  5128. else
  5129. {
  5130. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5131. }
  5132. string posTag = CurrentUser.UserPost.Post.Code;
  5133. if (posTag == "Supplier")
  5134. {
  5135. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5136. }
  5137. else
  5138. {
  5139. string supplier = GetPostString("supplier");
  5140. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5141. }
  5142. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5143. lw.Add(string.Format("type = 'PDD' "));
  5144. lw.Add(string.Format("IsRefund!={0}", 2));
  5145. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5146. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5147. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5148. /* if (tid.Length > 0)
  5149. {
  5150. List<string> tids = new List<string>();
  5151. if (dt != null && dt.Rows.Count > 0)
  5152. {
  5153. foreach (DataRow item in dt.Rows)
  5154. {
  5155. tids.Add("'" + item["tid"] + "'");
  5156. }
  5157. }
  5158. if (tids.Count > 0)
  5159. {
  5160. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5161. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5162. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5163. dt = WebCache.GetData("view_erptradecell", dStruct);
  5164. }
  5165. }*/
  5166. foreach (DataRow dr in dt.Rows)
  5167. {
  5168. 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();
  5169. }
  5170. writeGridDataTableJson(dStruct.TotalCount, dt);
  5171. }
  5172. public void get_erp_jddeliveryed()
  5173. {
  5174. DataStruct dStruct = GetPostStruct();
  5175. List<string> lw = new List<string>();
  5176. string tid = GetPostString("ctid");
  5177. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5178. string shopname = GetPostString("shopname");
  5179. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5180. string buyernick = GetPostString("buyer_nick");
  5181. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5182. string customer = GetPostString("customer");
  5183. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5184. string design = GetPostString("design");
  5185. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5186. string sellermemo = GetPostString("seller_memo");
  5187. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5188. string date1 = GetPostString("date1");
  5189. string date2 = GetPostString("date2");
  5190. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5191. //if (dw.Length > 0) lw.Add(dw);
  5192. string placedate1 = GetPostString("placedate1");
  5193. string placedate2 = GetPostString("placedate2");
  5194. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5195. if (fdw.Length > 0) lw.Add(fdw);
  5196. string devdate1 = GetPostString("deliverydate1");
  5197. string devdate2 = GetPostString("deliverydate2");
  5198. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5199. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5200. string price1 = GetPostString("price1");
  5201. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5202. string price2 = GetPostString("price2");
  5203. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5204. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5205. {
  5206. if (tid.Length > 0)
  5207. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5208. if (buyernick.Length > 0)
  5209. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5210. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5211. if (dw.Length > 0) lw.Add(dw);
  5212. }
  5213. else
  5214. {
  5215. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5216. }
  5217. string posTag = CurrentUser.UserPost.Post.Code;
  5218. if (posTag == "Supplier")
  5219. {
  5220. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5221. }
  5222. else
  5223. {
  5224. string supplier = GetPostString("supplier");
  5225. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5226. }
  5227. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5228. lw.Add(string.Format("type = 'JD' "));
  5229. lw.Add(string.Format("IsRefund!={0}", 2));
  5230. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5231. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5232. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5233. foreach (DataRow dr in dt.Rows)
  5234. {
  5235. 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();
  5236. }
  5237. writeGridDataTableJson(dStruct.TotalCount, dt);
  5238. }
  5239. public void get_erp_allplacelist()
  5240. {
  5241. DataStruct dStruct = GetPostStruct();
  5242. List<string> lw = new List<string>();
  5243. string tid = GetPostString("ctid");
  5244. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5245. string shopname = GetPostString("shopname");
  5246. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5247. string buyernick = GetPostString("buyer_nick");
  5248. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5249. string customer = GetPostString("customer");
  5250. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5251. string design = GetPostString("design");
  5252. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5253. string sellermemo = GetPostString("seller_memo");
  5254. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5255. string supplier = GetPostString("supplier");
  5256. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5257. string date1 = GetPostString("date1");
  5258. string date2 = GetPostString("date2");
  5259. string pldate1 = GetPostString("placedate1");
  5260. string pldate2 = GetPostString("placedate2");
  5261. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5262. //if (dw.Length > 0) lw.Add(dw);
  5263. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5264. {
  5265. if (tid.Length > 0)
  5266. {
  5267. string select_tid = getTidByCtid(tid);
  5268. lw.Add(string.Format("tid='{0}'", select_tid));
  5269. }
  5270. if (buyernick.Length > 0)
  5271. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5272. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5273. if (dw.Length > 0) lw.Add(dw);
  5274. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5275. if (dw_place.Length > 0) lw.Add(dw_place);
  5276. }
  5277. else
  5278. {
  5279. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5280. {
  5281. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5282. }
  5283. }
  5284. string price1 = GetPostString("price1");
  5285. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5286. string price2 = GetPostString("price2");
  5287. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5288. string posTag = CurrentUser.UserPost.Post.Code;
  5289. if (posTag == "Supplier")
  5290. {
  5291. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5292. }
  5293. lw.Add(string.Format("OrderState >= 6"));
  5294. lw.Add(string.Format("IsSample != 2 "));
  5295. //lw.Add(string.Format("isDianziOrder = 0 "));
  5296. lw.Add(string.Format("SupplierId > 0 "));
  5297. //lw.Add(string.Format("IsRefund<={0}", 1));
  5298. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5299. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5300. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5301. foreach (DataRow dr in dt.Rows)
  5302. {
  5303. 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();
  5304. }
  5305. writeGridDataTableJson(dStruct.TotalCount, dt);
  5306. }
  5307. public void get_erp_financeallplacelist()
  5308. {
  5309. DataStruct dStruct = GetPostStruct();
  5310. List<string> lw = new List<string>();
  5311. string tid = GetPostString("ctid");
  5312. string shopname = GetPostString("shopname");
  5313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5314. string buyernick = GetPostString("buyer_nick");
  5315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5316. string customer = GetPostString("customer");
  5317. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5318. string design = GetPostString("design");
  5319. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5320. string sellermemo = GetPostString("seller_memo");
  5321. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5322. string supplier = GetPostString("supplier");
  5323. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5324. string date1 = GetPostString("date1");
  5325. string date2 = GetPostString("date2");
  5326. string pldate1 = GetPostString("placedate1");
  5327. string pldate2 = GetPostString("placedate2");
  5328. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5329. {
  5330. if (tid.Length > 0)
  5331. {
  5332. string select_tid = getTidByCtid(tid);
  5333. lw.Add(string.Format("tid='{0}'", select_tid));
  5334. }
  5335. if (buyernick.Length > 0)
  5336. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5337. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5338. if (dw.Length > 0) lw.Add(dw);
  5339. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5340. if (dw_place.Length > 0) lw.Add(dw_place);
  5341. }
  5342. else
  5343. {
  5344. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5345. {
  5346. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5347. }
  5348. }
  5349. string price1 = GetPostString("price1");
  5350. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5351. string price2 = GetPostString("price2");
  5352. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5353. string posTag = CurrentUser.UserPost.Post.Code;
  5354. if (posTag == "Supplier")
  5355. {
  5356. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5357. }
  5358. //lw.Add(string.Format("OrderState >= 6"));
  5359. lw.Add(string.Format("IsSample != 2 "));
  5360. lw.Add(string.Format("isDianziOrder = 0 "));
  5361. //lw.Add(string.Format("IsRefund<={0}", 1));
  5362. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5363. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5364. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5365. foreach (DataRow dr in dt.Rows)
  5366. {
  5367. 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();
  5368. }
  5369. writeGridDataTableJson(dStruct.TotalCount, dt);
  5370. }
  5371. public void get_erp_expresslist()
  5372. {
  5373. int listtype = GetInt("ltype");
  5374. DataStruct dStruct = GetPostStruct();
  5375. List<string> lw = new List<string>();
  5376. string tid = GetPostString("tid");
  5377. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5378. string outsid = GetPostString("out_sid");
  5379. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5380. string importer = GetPostString("ImportUserName");
  5381. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5382. string file = GetPostString("import_file");
  5383. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5384. string printman = GetPostString("printman");
  5385. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5386. string date1 = GetPostString("date1");
  5387. string date2 = GetPostString("date2");
  5388. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5389. if (dw.Length > 0) lw.Add(dw);
  5390. string fdate1 = GetPostString("finishdate1");
  5391. string fdate2 = GetPostString("finishdate2");
  5392. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5393. if (fdw.Length > 0) lw.Add(fdw);
  5394. string supplierId = GetPostString("supplierId");
  5395. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5396. if (listtype == 1)
  5397. {
  5398. lw.Add(string.Format("importUserId !=0"));
  5399. }
  5400. string posTag = CurrentUser.UserPost.Post.Code;
  5401. if (posTag == "Supplier")
  5402. {
  5403. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5404. }
  5405. if (dStruct.PageSize != 100000)
  5406. {
  5407. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5408. }
  5409. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5410. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5411. writeGridDataTableJson(dStruct.TotalCount, dt);
  5412. }
  5413. public void set_erp_buchaorderdelivery()
  5414. {
  5415. if (UrlPostParmsCheck("ctid"))
  5416. {
  5417. string eid = GetPostString("ctid");
  5418. CeErpTradeCell entity = null;
  5419. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5420. if (entity != null)
  5421. {
  5422. if (entity.IsSample != 2)
  5423. {
  5424. returnErrorMsg("补差价单才能标记为已发货");
  5425. return;
  5426. }
  5427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5428. entity.OrderState = 7;
  5429. entity.Update();
  5430. returnSuccessMsg("操作成功!");
  5431. return;
  5432. }
  5433. returnErrorMsg("找不到记录");
  5434. }
  5435. }
  5436. public void get_stdtemplates()
  5437. {
  5438. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5439. //string res = taobaoHelper.test();
  5440. string res = apiHelper.API_PrintTemplate();
  5441. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5442. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5443. {
  5444. int sidx = res.IndexOf("error_code");
  5445. int eidx = res.IndexOf("success");
  5446. string msg = res.Substring(sidx, eidx - sidx);
  5447. returnErrorMsg(msg);
  5448. return;
  5449. }
  5450. if (res.Length <= 0)
  5451. {
  5452. returnErrorMsg("模板数据为空!");
  5453. return;
  5454. }
  5455. ReturnSuccess(res);
  5456. }
  5457. public void cancel_print_order()
  5458. {
  5459. if (UrlPostParmsCheck("ctid"))
  5460. {
  5461. string ctid = GetPostString("ctid");
  5462. CeErpTradeCell entity = null;
  5463. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5464. if (entity != null)
  5465. {
  5466. string res = "";
  5467. string code = entity.LastBillWaybillCode;
  5468. if (code == "")
  5469. {
  5470. code = entity.OutSid;
  5471. }
  5472. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5473. XLog.SaveLog(0, "取消面单" + res);
  5474. }
  5475. }
  5476. }
  5477. public void set_erp_printwaybill()
  5478. {
  5479. if (UrlPostParmsCheck("ctid"))
  5480. {
  5481. string ctid = GetPostString("ctid");
  5482. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5483. string cpName = GetPostString("cpname");
  5484. string isTogether = GetPostString("together");
  5485. string printType = GetPostString("printType");
  5486. //var res_obj = new
  5487. //{
  5488. // restype = 1,
  5489. // 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\"}"
  5490. //};
  5491. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5492. //ReturnSuccess(ro_json);
  5493. //return;
  5494. bool isUseLastWayBillCode = false;
  5495. CeErpTradeCell entity = null;
  5496. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5497. if (entity != null)
  5498. {
  5499. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5500. {
  5501. isUseLastWayBillCode = true;
  5502. }
  5503. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5504. {
  5505. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5506. return;
  5507. }
  5508. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5509. {
  5510. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5511. return;
  5512. }
  5513. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5514. {
  5515. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5516. return;
  5517. }
  5518. }
  5519. string res = "";
  5520. Api_waybill_code_response_Obj fullObj = null;
  5521. string pData_str = "";
  5522. string curUseWayBillCode = "";
  5523. if (isUseLastWayBillCode == false)
  5524. {
  5525. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5526. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5527. if (res.IndexOf("failure") != -1)
  5528. {
  5529. //int idx = res.IndexOf("sub_message");
  5530. //int idx2 = res.IndexOf("flag");
  5531. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5532. string errMsgNeed = commonHelper.KeepChinese(res);
  5533. var res_objd = new
  5534. {
  5535. restype = 0,
  5536. data = "获取面单失败" + errMsgNeed
  5537. };
  5538. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5539. returnSuccess(ro_jsond);
  5540. if (res.IndexOf("停发") != -1)
  5541. {
  5542. entity.UnusualCon = "物流停发";
  5543. entity.Update();
  5544. }
  5545. //returnErrorMsg("获取面单失败,"+emsg);
  5546. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5547. return;
  5548. }
  5549. else if (res.IndexOf("errorMsg") != -1)
  5550. {
  5551. //int idx = res.IndexOf("errorMsg");
  5552. //int idx2 = res.IndexOf("}]}");
  5553. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5554. string errMsgNeed = commonHelper.KeepChinese(res);
  5555. var res_objf = new
  5556. {
  5557. restype = 0,
  5558. data = "获取面单失败2" + errMsgNeed
  5559. };
  5560. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5561. if (res.IndexOf("停发") != -1)
  5562. {
  5563. entity.UnusualCon = "物流停发";
  5564. entity.Update();
  5565. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5566. if (trade != null)
  5567. {
  5568. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5569. }
  5570. }
  5571. returnSuccess(ro_jsonf);
  5572. //returnErrorMsg("获取面单失败," + emsg);
  5573. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5574. return;
  5575. }
  5576. try
  5577. {
  5578. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5579. //res = res.Replace(" ", "");
  5580. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5581. }
  5582. catch (Exception ex)
  5583. {
  5584. XLog.SaveLog(0, "生成fullObj" + res);
  5585. var res_objf = new
  5586. {
  5587. restype = 0,
  5588. data = "生成fullObj发生错误" + ex.Message
  5589. };
  5590. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5591. returnSuccess(ro_jsonf);
  5592. return;
  5593. }
  5594. if (fullObj.response.data.content.Count > 0)
  5595. {
  5596. ContentItem codeObj = fullObj.response.data.content[0];
  5597. if (cpCode.IndexOf("SFFQ-") != -1)
  5598. {
  5599. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5600. }
  5601. else
  5602. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5603. curUseWayBillCode = codeObj.waybillCode;
  5604. }
  5605. else
  5606. {
  5607. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5608. var res_objf = new
  5609. {
  5610. restype = 0,
  5611. data = "生成fullObj找不到快递单号waybillCode"
  5612. };
  5613. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5614. returnSuccess(ro_jsonf);
  5615. return;
  5616. }
  5617. }
  5618. else
  5619. {
  5620. //使用上次打印的快递单号
  5621. if (cpCode == "SFFQ-LY")
  5622. {
  5623. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5624. }
  5625. else
  5626. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5627. curUseWayBillCode = entity.LastBillWaybillCode;
  5628. }
  5629. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5630. {
  5631. var res_obje = new
  5632. {
  5633. restype = 0,
  5634. data = "获取加密打印数据失败"
  5635. };
  5636. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5637. returnSuccess(ro_jsone);
  5638. entity.LastBillCpCode = cpCode;
  5639. entity.LastBillWaybillCode = curUseWayBillCode;
  5640. entity.Update();
  5641. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5642. //returnErrorMsg("获取加密打印数据失败");
  5643. return;
  5644. }
  5645. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5646. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5647. string btnType = "";
  5648. string errorMsg = "";
  5649. if (entity != null)
  5650. {
  5651. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5652. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5653. //cpcode是 YTO-CAINIAO
  5654. //string comCode = cpCode.Split('-')[0].ToString();
  5655. string apires = "";
  5656. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5657. //isTogether=2是新的合包弹窗
  5658. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5659. {
  5660. if (ctid.IndexOf("N") != -1)
  5661. {
  5662. apires = "发货成功";
  5663. }
  5664. else
  5665. {
  5666. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5667. }
  5668. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5669. //打单后发货
  5670. StringBuilder sql = new StringBuilder();
  5671. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5672. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5673. {
  5674. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5675. }
  5676. else
  5677. {
  5678. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5679. }
  5680. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5681. foreach (DataRow row in dt.Rows)
  5682. {
  5683. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5684. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5685. {
  5686. try
  5687. {
  5688. btnType = "待发货";
  5689. entity.OutSid = curUseWayBillCode;
  5690. entity.OrderState = 7;
  5691. entity.IsUrgency = false;
  5692. entity.LastBillCpCode = "";
  5693. entity.LastBillWaybillCode = "";
  5694. entity.FinishDeliveryTime = DateTime.Now;
  5695. entity.IsReturn = 0;
  5696. entity.MemoOpt = 0;
  5697. entity.UpdateTime = DateTime.Now;
  5698. entity.Update();
  5699. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5700. //还要插入快递信息到 快递信息表
  5701. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5702. exinfo.tid = entity.ctid;
  5703. exinfo.out_sid = curUseWayBillCode;
  5704. exinfo.company_code = cpCode;
  5705. exinfo.company_name = cpName;
  5706. exinfo.supplierUserName = supplierName;
  5707. exinfo.deliveryType = "发货成功";
  5708. exinfo.print_time = DateTime.Now;
  5709. exinfo.printUser = CurrentUser.UserName;
  5710. exinfo.postData = pData_str;
  5711. exinfo.Create();
  5712. commonHelper.UpdateRelationOrder(entity.ctid);
  5713. CeErpSukuraData.createInfo(ctid, 4);
  5714. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5715. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5716. {
  5717. commonHelper.sendCytExpress(exinfo);
  5718. }
  5719. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5720. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5721. }
  5722. catch (Exception ex)
  5723. {
  5724. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5725. }
  5726. }
  5727. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5728. {
  5729. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5730. if (entity.OrderState == 6)
  5731. {
  5732. entity.OrderState = 7;
  5733. }
  5734. entity.UpdateTime = DateTime.Now;
  5735. entity.FinishDeliveryTime = DateTime.Now;
  5736. btnType = "已发货";
  5737. entity.Update();
  5738. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5739. exinfo.tid = entity.ctid;
  5740. exinfo.out_sid = curUseWayBillCode;
  5741. exinfo.company_code = cpCode;
  5742. exinfo.company_name = cpName;
  5743. exinfo.supplierUserName = supplierName;
  5744. exinfo.deliveryType = "发货成功";
  5745. exinfo.print_time = DateTime.Now;
  5746. exinfo.printUser = CurrentUser.UserName;
  5747. exinfo.postData = pData_str;
  5748. exinfo.Create();
  5749. commonHelper.UpdateRelationOrder(entity.ctid);
  5750. CeErpSukuraData.createInfo(entity.ctid, 4);
  5751. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5752. {
  5753. commonHelper.sendCytExpress(exinfo);
  5754. }
  5755. //不处理
  5756. }
  5757. else
  5758. {
  5759. entity.UpdateTime = DateTime.Now;
  5760. entity.LastBillCpCode = cpCode;
  5761. entity.LastBillWaybillCode = curUseWayBillCode;
  5762. entity.Update();
  5763. string errmsg = commonHelper.KeepChinese(apires);
  5764. var res_objz = new
  5765. {
  5766. restype = 0,
  5767. data = "打单后发货失败"
  5768. };
  5769. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5770. returnSuccess(ro_jsonz);
  5771. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5772. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5773. return;
  5774. }
  5775. }
  5776. }
  5777. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5778. {
  5779. string ctids = GetPostString("ctids");
  5780. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5781. List<string> list = new List<string>();
  5782. List<string> send_list = new List<string>();
  5783. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5784. CeErpTrade ceErpTrade = new CeErpTrade();
  5785. //可合包的合并一起发货
  5786. if (dt == null && string.IsNullOrEmpty(ctids))
  5787. {
  5788. var res_objz = new
  5789. {
  5790. restype = 0,
  5791. data = "打单后发货失败"
  5792. };
  5793. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5794. returnSuccess(ro_jsonz);
  5795. return;
  5796. }
  5797. if (!string.IsNullOrEmpty(ctids))
  5798. {
  5799. StringBuilder sql = new StringBuilder();
  5800. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5801. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5802. }
  5803. foreach (DataRow row in dt.Rows)
  5804. {
  5805. list.Add("'" + row["ctid"] + "'");
  5806. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5807. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5808. if (ctid.IndexOf("N") != -1)
  5809. {
  5810. apires = "发货成功";
  5811. }
  5812. else
  5813. {
  5814. if (!send_list.Contains(ceErpTrade.tid))
  5815. {
  5816. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5817. }
  5818. else
  5819. {
  5820. apires = "发货成功";
  5821. }
  5822. }
  5823. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5824. {
  5825. send_list.Add(ceErpTrade.tid);
  5826. try
  5827. {
  5828. btnType = "待发货";
  5829. ceErpTradeCell.OutSid = curUseWayBillCode;
  5830. ceErpTradeCell.OrderState = 7;
  5831. ceErpTradeCell.IsUrgency = false;
  5832. ceErpTradeCell.LastBillCpCode = "";
  5833. ceErpTradeCell.LastBillWaybillCode = "";
  5834. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5835. ceErpTradeCell.IsReturn = 0;
  5836. ceErpTradeCell.MemoOpt = 0;
  5837. ceErpTradeCell.UpdateTime = DateTime.Now;
  5838. ceErpTradeCell.Update();
  5839. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5840. //还要插入快递信息到 快递信息表
  5841. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5842. exinfo.tid = ceErpTradeCell.ctid;
  5843. exinfo.out_sid = curUseWayBillCode;
  5844. exinfo.company_code = cpCode;
  5845. exinfo.company_name = cpName;
  5846. exinfo.supplierUserName = supplierName;
  5847. exinfo.deliveryType = "发货成功";
  5848. exinfo.print_time = DateTime.Now;
  5849. exinfo.printUser = CurrentUser.UserName;
  5850. exinfo.postData = pData_str;
  5851. exinfo.Create();
  5852. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5853. CeErpSukuraData.createInfo(ctid, 4);
  5854. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5855. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5856. {
  5857. commonHelper.sendCytExpress(exinfo);
  5858. }
  5859. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5860. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5861. }
  5862. catch (Exception ex)
  5863. {
  5864. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5865. }
  5866. }
  5867. else
  5868. {
  5869. ceErpTradeCell.UpdateTime = DateTime.Now;
  5870. ceErpTradeCell.LastBillCpCode = cpCode;
  5871. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5872. ceErpTradeCell.Update();
  5873. string errmsg = commonHelper.KeepChinese(apires);
  5874. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5875. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5876. }
  5877. }
  5878. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5879. }
  5880. }
  5881. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5882. var res_obj = new
  5883. {
  5884. restype = 1,
  5885. data = pData_str,
  5886. errorMsg
  5887. };
  5888. string ro_json = JsonConvert.SerializeObject(res_obj);
  5889. ReturnSuccess(ro_json);
  5890. return;
  5891. }
  5892. }
  5893. private string GetUTF8String(byte[] vs)
  5894. {
  5895. throw new NotImplementedException();
  5896. }
  5897. public void set_erp_printwaybill_cn()
  5898. {
  5899. if (UrlPostParmsCheck("ctid"))
  5900. {
  5901. string ctid = GetPostString("ctid");
  5902. string cpCode = GetPostString("cpcode");
  5903. string cpName = GetPostString("cpname");
  5904. string tempUrl = GetPostString("tempurl");
  5905. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5906. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5907. //string res = taobaoHelper.test();
  5908. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5909. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5910. {
  5911. int sidx = res.IndexOf("errorMsg");
  5912. int eidx = res.IndexOf("}");
  5913. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5914. var res_objzxx = new
  5915. {
  5916. restype = 0,
  5917. data = msg
  5918. };
  5919. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5920. returnSuccess(ro_jsonzxx);
  5921. //returnErrorMsg(msg);
  5922. return;
  5923. }
  5924. int idx = res.IndexOf("waybillCode");
  5925. int idx2 = res.IndexOf("printData");
  5926. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5927. string eid = GetPostString("ctid");
  5928. CeErpTradeCell entity = null;
  5929. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5930. if (entity != null)
  5931. {
  5932. string osid = entity.OutSid;
  5933. entity.OutSid = osid + "," + outsid;
  5934. entity.FinishDeliveryTime = DateTime.Now;
  5935. entity.OrderState = 7;
  5936. entity.UpdateTime = DateTime.Now;
  5937. entity.IsReturn = 0;
  5938. entity.Update();
  5939. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5940. exinfo.tid = entity.ctid;
  5941. exinfo.out_sid = outsid;
  5942. exinfo.company_code = cpCode;
  5943. exinfo.company_name = cpName;
  5944. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5945. exinfo.deliveryType = "发货成功";
  5946. exinfo.print_time = DateTime.Now;
  5947. exinfo.printUser = CurrentUser.UserName;
  5948. exinfo.Create();
  5949. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5950. {
  5951. commonHelper.sendCytExpress(exinfo);
  5952. }
  5953. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5954. }
  5955. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5956. var res_objz = new
  5957. {
  5958. restype = 1,
  5959. data = res
  5960. };
  5961. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5962. returnSuccess(ro_jsonz);
  5963. //ReturnSuccess(res);
  5964. }
  5965. }
  5966. ////打单,打印面单 获取面单号
  5967. //public void set_erp_printwaybill()
  5968. //{
  5969. // if (UrlPostParmsCheck("ctid"))
  5970. // {
  5971. // string ctid = GetPostString("ctid");
  5972. // string cpCode = GetPostString("cpcode");
  5973. // string tempUrl = GetPostString("tempurl");
  5974. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5975. // //string res = taobaoHelper.test();
  5976. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5977. // if (res.IndexOf("error_response") != -1)
  5978. // {
  5979. // int sidx = res.IndexOf("sub_msg");
  5980. // int eidx = res.IndexOf("request_id");
  5981. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5982. // returnErrorMsg(msg);
  5983. // return;
  5984. // }
  5985. // int idx = res.IndexOf("waybill_code");
  5986. // int idx2 = res.IndexOf("}]}");
  5987. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5988. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5989. // ReturnSuccess(res);
  5990. // }
  5991. //}
  5992. public void cancel_erp_aftersale()
  5993. {
  5994. if (UrlPostParmsCheck("ctid"))
  5995. {
  5996. string eid = GetPostString("ctid");
  5997. CeErpTradeCell entity = null;
  5998. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5999. if (entity != null)
  6000. {
  6001. //有过处理的售后,取消也不能删除 售 字,保留
  6002. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6003. {
  6004. entity.AfterSaleState = 4;
  6005. }
  6006. else
  6007. entity.AfterSaleState = 0;
  6008. entity.UpdateTime = DateTime.Now;
  6009. entity.Update();
  6010. returnSuccessMsg("操作成功!");
  6011. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6012. return;
  6013. }
  6014. returnErrorMsg("找不到订单记录");
  6015. }
  6016. }
  6017. public void get_erp_aftersalelist()
  6018. {
  6019. DataStruct dStruct = GetPostStruct();
  6020. List<string> lw = new List<string>();
  6021. int st = GetInt("st");
  6022. string tid = GetPostString("ctid");
  6023. if (st == 3)
  6024. {
  6025. if (tid.Length > 0)
  6026. {
  6027. string select_tid = getTidByCtid(tid);
  6028. lw.Add(string.Format("tid='{0}'", select_tid));
  6029. }
  6030. }
  6031. else
  6032. {
  6033. if (tid.Length > 0)
  6034. {
  6035. string select_tid = getTidByCtid(tid);
  6036. lw.Add(string.Format("tid='{0}'", select_tid));
  6037. }
  6038. }
  6039. string shopname = GetPostString("shopname");
  6040. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6041. string buyernick = GetPostString("buyer_nick");
  6042. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6043. string sellermemo = GetPostString("seller_memo");
  6044. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6045. string orderState = GetPostString("orderState");
  6046. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6047. string afterState = GetPostString("afterstate");
  6048. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6049. string date1 = GetPostString("date1");
  6050. string date2 = GetPostString("date2");
  6051. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6052. if (dw.Length > 0) lw.Add(dw);
  6053. string price1 = GetPostString("price1");
  6054. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6055. string price2 = GetPostString("price2");
  6056. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6057. //lw.Add(string.Format("IsRefund!={0}", 1));
  6058. string reason = GetPostString("reason");
  6059. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6060. string method = GetPostString("method");
  6061. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6062. string handler = GetPostString("handler");
  6063. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6064. string handledate1 = GetPostString("handledate1");
  6065. string handledate2 = GetPostString("handledate2");
  6066. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6067. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6068. string finish1 = GetPostString("finishdate1");
  6069. string finish2 = GetPostString("finishdate2");
  6070. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6071. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6072. string afterdate1 = GetPostString("afterdate1");
  6073. string afterdate2 = GetPostString("afterdate2");
  6074. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6075. if (afterDate.Length > 0) lw.Add(afterDate);
  6076. string supplier = GetPostString("supplier");
  6077. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6078. string responsible = GetPostString("responsibleman");
  6079. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6080. string customer = GetPostString("customer");
  6081. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6082. string design = GetPostString("design");
  6083. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6084. string afterMemoType = GetPostString("aftermemotype");
  6085. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6086. string posCode = CurrentUser.UserPost.Post.Code;
  6087. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6088. //{
  6089. // string vstate = GetPostString("vstate");
  6090. // if (vstate.Length > 0)
  6091. // {
  6092. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6093. // }
  6094. // if (posCode == "Supplier")
  6095. // {
  6096. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6097. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6098. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6099. // }
  6100. // else
  6101. // {
  6102. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6103. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6104. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6105. // {
  6106. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6107. // }
  6108. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6109. // {
  6110. // int orgid = CurrentUser.UserPost.OrgID;
  6111. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6112. // }
  6113. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6114. // {
  6115. // string shopid = CurrentUser.User.pemShop;
  6116. // lw.Add(string.Format("shopId in ({0})", shopid));
  6117. // }
  6118. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6119. // //{
  6120. // // int org_id = CurrentUser.UserPost.OrgID;
  6121. // // lw.Add(string.Format("OrgID={0}", org_id));
  6122. // //}
  6123. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6124. // }
  6125. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6126. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6127. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6128. //}
  6129. if (st == 5)
  6130. {
  6131. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6132. {
  6133. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6134. {
  6135. string shopid = CurrentUser.User.pemShop;
  6136. lw.Add(string.Format("shopId in ({0})", shopid));
  6137. }
  6138. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6139. {
  6140. int mrOrgid = CurrentUser.UserPost.OrgID;
  6141. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6142. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6143. }
  6144. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6145. //{
  6146. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6147. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6148. //}
  6149. else
  6150. {
  6151. string userIdStr = "";
  6152. if (posCode == "CustomerService")
  6153. {
  6154. userIdStr = CurrentUser.UserID + "_k";
  6155. }
  6156. else if (posCode == "Designer" || posCode == "wxDesigner")
  6157. {
  6158. userIdStr = CurrentUser.UserID + "_s";
  6159. }
  6160. else if (posCode == "Place")
  6161. {
  6162. userIdStr = CurrentUser.UserID + "_x";
  6163. }
  6164. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6165. }
  6166. }
  6167. string placedate1 = GetPostString("placedate1");
  6168. string placedate2 = GetPostString("placedate2");
  6169. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6170. if (dwplace.Length > 0) lw.Add(dwplace);
  6171. string supState = GetPostString("supState");
  6172. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6173. string searchType = GetPostString("searchType");
  6174. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6175. {
  6176. lw.Add(string.Format("BackNum>1"));
  6177. }
  6178. lw.Add(string.Format("AfterSaleState>0"));
  6179. if (ex_psize > 0)
  6180. {
  6181. if (CurrentUser.UserPost.Post.Code == "Finance")
  6182. dStruct.Order = "pay_time desc";
  6183. else
  6184. dStruct.Order = "HandleTime desc";
  6185. }
  6186. else
  6187. dStruct.Order = "HandleTime desc";
  6188. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6189. DataTable dt = WebCache.GetData("view_test", dStruct);
  6190. writeGridDataTableJson(dStruct.TotalCount, dt);
  6191. }
  6192. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6193. //{
  6194. // lw.Add(string.Format("AfterSaleState=4"));
  6195. // string code = CurrentUser.UserPost.Post.Code;
  6196. // if (code == "CustomerService")
  6197. // {
  6198. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6199. // }
  6200. // else if (code == "Designer" || code == "DesignerMr")
  6201. // {
  6202. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6203. // }
  6204. // else if (code == "Place" || code == "PlaceMr")
  6205. // {
  6206. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6207. // }
  6208. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6209. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6210. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6211. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6212. //}
  6213. //else //处理中的售后,待处理和处理中合并
  6214. //{
  6215. // if (afterState.Length <= 0)
  6216. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6217. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6218. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6219. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6220. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6221. //}
  6222. }
  6223. public void get_erp_disagreeftersalelist()
  6224. {
  6225. DataStruct dStruct = GetPostStruct();
  6226. List<string> lw = new List<string>();
  6227. int st = 2;
  6228. string tid = GetPostString("ctid");
  6229. if (tid.Length > 0)
  6230. {
  6231. string select_tid = getTidByCtid(tid);
  6232. lw.Add(string.Format("tid='{0}'", select_tid));
  6233. }
  6234. string shopname = GetPostString("shopname");
  6235. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6236. string buyernick = GetPostString("buyer_nick");
  6237. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6238. string sellermemo = GetPostString("seller_memo");
  6239. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6240. string orderState = GetPostString("orderState");
  6241. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6242. string afterState = GetPostString("afterstate");
  6243. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6244. string date1 = GetPostString("date1");
  6245. string date2 = GetPostString("date2");
  6246. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6247. if (dw.Length > 0) lw.Add(dw);
  6248. string price1 = GetPostString("price1");
  6249. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6250. string price2 = GetPostString("price2");
  6251. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6252. //lw.Add(string.Format("IsRefund!={0}", 1));
  6253. string reason = GetPostString("reason");
  6254. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6255. string method = GetPostString("method");
  6256. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6257. string handler = GetPostString("handler");
  6258. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6259. string handledate1 = GetPostString("handledate1");
  6260. string handledate2 = GetPostString("handledate2");
  6261. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6262. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6263. string afterdate1 = GetPostString("afterdate1");
  6264. string afterdate2 = GetPostString("afterdate2");
  6265. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6266. if (afterDate.Length > 0) lw.Add(afterDate);
  6267. string backdate1 = GetPostString("backdate1");
  6268. string backdate2 = GetPostString("backdate2");
  6269. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6270. if (backDate.Length > 0) lw.Add(backDate);
  6271. string supplier = GetPostString("supplier");
  6272. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6273. string responsible = GetPostString("responsibleman");
  6274. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6275. string customer = GetPostString("customer");
  6276. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6277. string design = GetPostString("design");
  6278. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6279. string afterSaleMemo = GetPostString("afterSaleMemo");
  6280. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6281. string afterMemoType = GetPostString("aftermemotype");
  6282. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6283. string aftersakereason = GetPostString("aftersakereason");
  6284. if (aftersakereason.Length > 0)
  6285. {
  6286. if (aftersakereason == "1")
  6287. {
  6288. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6289. }
  6290. if (aftersakereason == "2")
  6291. {
  6292. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6293. }
  6294. }
  6295. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6296. string poscode = CurrentUser.UserPost.Post.Code;
  6297. if (poscode != "SysAdmin")
  6298. {
  6299. string shopid = CurrentUser.User.pemShop;
  6300. lw.Add(string.Format("shopId in ({0})", shopid));
  6301. }
  6302. string searchType = GetPostString("searchType");
  6303. if (searchType == "wait")
  6304. {
  6305. lw.Add(string.Format("HandleTime is null"));
  6306. }
  6307. if (searchType == "handling")
  6308. {
  6309. lw.Add(string.Format("HandleTime is not null "));
  6310. }
  6311. if (searchType == "back" || searchType == "puBack")
  6312. {
  6313. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6314. }
  6315. if (searchType == "reBack")
  6316. {
  6317. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6318. }
  6319. if (searchType == "moreBack")
  6320. {
  6321. lw.Add(string.Format("backNum > 1"));
  6322. }
  6323. lw.Add(string.Format("(AfterSaleState=5)"));
  6324. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6325. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6326. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6327. writeGridDataTableJson(dStruct.TotalCount, dt);
  6328. }
  6329. public void get_erp_handlingaftersalelist()
  6330. {
  6331. DataStruct dStruct = GetPostStruct();
  6332. List<string> lw = new List<string>();
  6333. int st = 2;
  6334. string tid = GetPostString("ctid");
  6335. if (tid.Length > 0)
  6336. {
  6337. string select_tid = getTidByCtid(tid);
  6338. lw.Add(string.Format("tid='{0}'", select_tid));
  6339. }
  6340. string shopname = GetPostString("shopname");
  6341. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6342. string buyernick = GetPostString("buyer_nick");
  6343. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6344. string sellermemo = GetPostString("seller_memo");
  6345. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6346. string orderState = GetPostString("orderState");
  6347. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6348. string afterState = GetPostString("afterstate");
  6349. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6350. string date1 = GetPostString("date1");
  6351. string date2 = GetPostString("date2");
  6352. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6353. if (dw.Length > 0) lw.Add(dw);
  6354. string price1 = GetPostString("price1");
  6355. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6356. string price2 = GetPostString("price2");
  6357. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6358. //lw.Add(string.Format("IsRefund!={0}", 1));
  6359. string reason = GetPostString("reason");
  6360. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6361. string method = GetPostString("method");
  6362. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6363. string handler = GetPostString("handler");
  6364. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6365. string handledate1 = GetPostString("handledate1");
  6366. string handledate2 = GetPostString("handledate2");
  6367. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6368. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6369. string afterdate1 = GetPostString("afterdate1");
  6370. string afterdate2 = GetPostString("afterdate2");
  6371. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6372. if (afterDate.Length > 0) lw.Add(afterDate);
  6373. string supplier = GetPostString("supplier");
  6374. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6375. string responsible = GetPostString("responsibleman");
  6376. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6377. string customer = GetPostString("customer");
  6378. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6379. string design = GetPostString("design");
  6380. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6381. string afterSaleMemo = GetPostString("afterSaleMemo");
  6382. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6383. string afterMemoType = GetPostString("aftermemotype");
  6384. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6385. string afterresult = GetPostString("afterresult");
  6386. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6387. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6388. string poscode = CurrentUser.UserPost.Post.Code;
  6389. if (poscode != "SysAdmin")
  6390. {
  6391. string shopid = CurrentUser.User.pemShop;
  6392. lw.Add(string.Format("shopId in ({0})", shopid));
  6393. }
  6394. string searchType = GetPostString("searchType");
  6395. if (searchType == "wait")
  6396. {
  6397. lw.Add(string.Format("HandleTime is null"));
  6398. }
  6399. if (searchType == "documentary")
  6400. {
  6401. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6402. }
  6403. if (searchType == "handling")
  6404. {
  6405. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6406. }
  6407. if (searchType == "back" || searchType == "puBack")
  6408. {
  6409. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6410. }
  6411. if (searchType == "reBack")
  6412. {
  6413. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6414. }
  6415. if (afterState.Length <= 0)
  6416. {
  6417. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6418. }
  6419. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6420. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6421. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6422. writeGridDataTableJson(dStruct.TotalCount, dt);
  6423. }
  6424. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6425. //public void get_erp_back_handlingaftersalelist()
  6426. //{
  6427. // DataStruct dStruct = GetPostStruct();
  6428. // List<string> lw = new List<string>();
  6429. // string tid = GetPostString("ctid");
  6430. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6431. // string shopname = GetPostString("shopname");
  6432. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6433. // string buyernick = GetPostString("buyer_nick");
  6434. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6435. // string sellermemo = GetPostString("seller_memo");
  6436. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6437. // string orderState = GetPostString("orderState");
  6438. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6439. // string afterState = GetPostString("afterstate");
  6440. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6441. // string date1 = GetPostString("date1");
  6442. // string date2 = GetPostString("date2");
  6443. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6444. // if (dw.Length > 0) lw.Add(dw);
  6445. // string price1 = GetPostString("price1");
  6446. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6447. // string price2 = GetPostString("price2");
  6448. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6449. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6450. // string reason = GetPostString("reason");
  6451. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6452. // string method = GetPostString("method");
  6453. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6454. // string handler = GetPostString("handler");
  6455. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6456. // string handledate1 = GetPostString("handledate1");
  6457. // string handledate2 = GetPostString("handledate2");
  6458. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6459. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6460. // string afterdate1 = GetPostString("afterdate1");
  6461. // string afterdate2 = GetPostString("afterdate2");
  6462. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6463. // if (afterDate.Length > 0) lw.Add(afterDate);
  6464. // string supplier = GetPostString("supplier");
  6465. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6466. // string responsible = GetPostString("responsibleman");
  6467. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6468. // string customer = GetPostString("customer");
  6469. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6470. // string design = GetPostString("design");
  6471. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6472. // string afterMemoType = GetPostString("aftermemotype");
  6473. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6474. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6475. // if (afterState.Length <= 0)
  6476. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6477. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6478. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6479. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6480. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6481. //}
  6482. public void get_erp_aftersaleverifylist()
  6483. {
  6484. DataStruct dStruct = GetPostStruct();
  6485. List<string> lw = new List<string>();
  6486. string tid = GetPostString("ctid");
  6487. if (tid.Length > 0)
  6488. {
  6489. string select_tid = getTidByCtid(tid);
  6490. lw.Add(string.Format("otid='{0}'", select_tid));
  6491. }
  6492. string shopname = GetPostString("shopname");
  6493. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6494. string buyernick = GetPostString("buyer_nick");
  6495. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6496. string sellermemo = GetPostString("seller_memo");
  6497. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6498. string orderState = GetPostString("orderState");
  6499. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6500. //lw.Add(string.Format("IsRefund!={0}", 1));
  6501. string reason = GetPostString("reason");
  6502. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6503. string method = GetPostString("method");
  6504. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6505. string handler = GetPostString("handler");
  6506. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6507. string handledate1 = GetPostString("handledate1");
  6508. string handledate2 = GetPostString("handledate2");
  6509. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6510. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6511. string finish1 = GetPostString("finishdate1");
  6512. string finish2 = GetPostString("finishdate2");
  6513. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6514. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6515. string supplier = GetPostString("supplier");
  6516. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6517. string responsible = GetPostString("responsibleman");
  6518. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6519. string posCode = CurrentUser.UserPost.Post.Code;
  6520. string vstate = GetPostString("vstate");
  6521. if (vstate.Length > 0)
  6522. {
  6523. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6524. }
  6525. if (posCode == "Supplier")
  6526. {
  6527. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6528. lw.Add(string.Format("VerifyState = 0"));
  6529. lw.Add("type = 1");
  6530. lw.Add(string.Format("AfterSaleState={0}", 3));
  6531. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6532. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6533. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6534. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6535. writeGridDataTableJson(dStruct.TotalCount, dt);
  6536. }
  6537. else if (posCode == "logistics")
  6538. {
  6539. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6540. lw.Add(string.Format("VerifyState = 0"));
  6541. lw.Add("type = 2");
  6542. lw.Add(string.Format("AfterSaleState={0}", 3));
  6543. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6544. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6545. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6546. writeGridDataTableJson(dStruct.TotalCount, dt);
  6547. }
  6548. else
  6549. {
  6550. lw.Add(string.Format("(AfterSaleState = 3)"));
  6551. lw.Add("type = 0");
  6552. string reasonState = GetPostString("reasonState");
  6553. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6554. {
  6555. if (reasonState == "2")
  6556. {
  6557. lw.Add("VerifyState = 3");
  6558. }
  6559. else if (reasonState == "1")
  6560. {
  6561. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6562. }
  6563. else
  6564. {
  6565. lw.Add("VerifyState in (0,3)");
  6566. }
  6567. //不加条件,可以看全部
  6568. }
  6569. 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")
  6570. {
  6571. int orgid = CurrentUser.UserPost.OrgID;
  6572. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6573. if (string.IsNullOrEmpty(manageOrgId))
  6574. {
  6575. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6576. }
  6577. else
  6578. {
  6579. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6580. }
  6581. if (reasonState == "1")
  6582. {
  6583. lw.Add("VerifyState = 3");
  6584. }
  6585. else if (reasonState == "2")
  6586. {
  6587. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6588. }
  6589. else
  6590. {
  6591. }
  6592. }
  6593. else
  6594. {
  6595. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6596. }
  6597. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6598. //{
  6599. // int org_id = CurrentUser.UserPost.OrgID;
  6600. // lw.Add(string.Format("OrgID={0}", org_id));
  6601. //}
  6602. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6603. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6604. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6605. writeGridDataTableJson(dStruct.TotalCount, dt);
  6606. }
  6607. }
  6608. public void get_erp_finishaftersalelist()
  6609. {
  6610. DataStruct dStruct = GetPostStruct();
  6611. List<string> lw = new List<string>();
  6612. int st = 4;
  6613. string tid = GetPostString("ctid");
  6614. if (tid.Length > 0)
  6615. {
  6616. string select_tid = getTidByCtid(tid);
  6617. lw.Add(string.Format("otid='{0}'", select_tid));
  6618. }
  6619. string shopname = GetPostString("shopname");
  6620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6621. //lw.Add(string.Format("IsRefund!={0}", 1));
  6622. string reason = GetPostString("reason");
  6623. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6624. string method = GetPostString("method");
  6625. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6626. string buyernick = GetPostString("buyer_nick");
  6627. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6628. string handler = GetPostString("handler");
  6629. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6630. string handledate1 = GetPostString("handledate1");
  6631. string handledate2 = GetPostString("handledate2");
  6632. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6633. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6634. string finish1 = GetPostString("finishdate1");
  6635. string finish2 = GetPostString("finishdate2");
  6636. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6637. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6638. string supplier = GetPostString("supplier");
  6639. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6640. string responsible = GetPostString("responsibleman");
  6641. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6642. string vstate = GetPostString("vstate");
  6643. if (vstate.Length > 0)
  6644. {
  6645. if ("3".Equals(vstate))
  6646. {
  6647. lw.Add(string.Format("IsTem=1"));
  6648. }
  6649. else
  6650. {
  6651. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6652. }
  6653. }
  6654. lw.Add(string.Format("AfterSaleState=4"));
  6655. string code = CurrentUser.UserPost.Post.Code;
  6656. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6657. {
  6658. //不加条件,可以看全部
  6659. }
  6660. else if (code == "Supplier")
  6661. {
  6662. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6663. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6664. lw.Add("type = 1");
  6665. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6666. }
  6667. else if (code == "logistics")
  6668. {
  6669. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6670. lw.Add("type = 2");
  6671. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6672. }
  6673. 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")
  6674. {
  6675. lw.Add("type = 0");
  6676. int orgid = CurrentUser.UserPost.OrgID;
  6677. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6678. if (string.IsNullOrEmpty(manageOrgIds))
  6679. {
  6680. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6681. }
  6682. else
  6683. {
  6684. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6685. }
  6686. }
  6687. else
  6688. {
  6689. lw.Add("type = 0");
  6690. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6691. }
  6692. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6693. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6694. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6695. writeGridDataTableJson(dStruct.TotalCount, dt);
  6696. }
  6697. public void handle_erp_aftersale()
  6698. {
  6699. if (UrlPostParmsCheck("ctid"))
  6700. {
  6701. string eid = GetPostString("ctid");
  6702. string responStr = GetPostString("AfterSaleResponsible");
  6703. if (responStr.Length <= 0)
  6704. {
  6705. returnErrorMsg("售后责任人不能为空");
  6706. return;
  6707. }
  6708. bool isDesign = false;
  6709. double designFree = 0.00;
  6710. int responsibleId = 0;
  6711. CeErpTradeCell entity = null;
  6712. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6713. if (entity != null)
  6714. {
  6715. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6716. string afterMethod = GetPostString("AfterSaleMethod");
  6717. if (isNeedNewOrder == 1)
  6718. {
  6719. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6720. bool ishav = true;
  6721. if (newentity == null)
  6722. {
  6723. newentity = entity.Clone() as CeErpTradeCell;
  6724. ishav = false;
  6725. newentity.ctid = "S_" + entity.ctid;
  6726. newentity.OrderState = 0;
  6727. //唯一标识
  6728. newentity.OrderSn = newentity.ctid;
  6729. string orderSn = dataHelper.getSaleOrderSn();
  6730. if (orderSn != "")
  6731. {
  6732. newentity.OrderSn = orderSn;
  6733. }
  6734. }
  6735. newentity.UpdateTime = DateTime.Now;
  6736. newentity.AfterSaleState = 0;
  6737. newentity.AfterSaleMethod = afterMethod;
  6738. if (!ishav)
  6739. {
  6740. string memo_str = newentity.seller_memo;
  6741. memo_str = memo_str.Replace("(", "(");
  6742. memo_str = memo_str.Replace(")", ")");
  6743. int sIndex = memo_str.IndexOf("(");
  6744. int eIndex = memo_str.IndexOf(")");
  6745. if (sIndex == -1 || eIndex == -1)
  6746. {
  6747. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6748. return;
  6749. }
  6750. string first = memo_str.Substring(0, sIndex + 1);
  6751. string memoCtid = newentity.OrderSn;
  6752. //if (memoCtid.IndexOf("C") != -1)
  6753. //{
  6754. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6755. //if (CIdx.IndexOf("+") != -1)
  6756. //{
  6757. //CIdx = "C" + CIdx.Split('+')[1];
  6758. //}
  6759. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6760. //}
  6761. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6762. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6763. string newMemo = first + memoCtid + last;
  6764. newentity.seller_memo = newMemo;
  6765. newentity.FinishPlaceTime = null;
  6766. newentity.UnusualTag = 0;
  6767. newentity.UnusualCon = "";
  6768. newentity.UnusualTime = null;
  6769. newentity.AfterSaleMemo = "";
  6770. newentity.AfterSaleMethod = afterMethod;
  6771. newentity.AfterSalePreTime = null;
  6772. newentity.AfterSaleReason = "";
  6773. newentity.AfterSaleResponsible = "";
  6774. newentity.AfterSaleState = 0;
  6775. newentity.AfterSaleTime = null;
  6776. newentity.AfterSaleUserId = 0;
  6777. newentity.AfterSaleSupplierState = 0;
  6778. newentity.LastBillWaybillCode = "";
  6779. newentity.LastBillCpCode = "";
  6780. newentity.FinishAfterSaleTime = null;
  6781. newentity.HandleTime = null;
  6782. newentity.IsSF = 0;
  6783. newentity.IsOldCustomer = 0;
  6784. newentity.UrgencyTime = null;
  6785. newentity.ResponsibleUserId = "";
  6786. newentity.IsVerifyToSupplier = false;
  6787. newentity.payment = 0;
  6788. newentity.CheckMemo = "";
  6789. newentity.OutSid = "";
  6790. newentity.CheckOrderTime = null;
  6791. newentity.MemoOpt = 0;
  6792. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6793. }
  6794. newentity.isAfterSaleOrder = 1;
  6795. newentity.IsRefund = 0;
  6796. string receiveMobile = GetPostString("receiver_mobile");
  6797. if (receiveMobile.Length > 0)
  6798. {
  6799. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6800. if (trade != null)
  6801. {
  6802. trade.receiver_name = GetPostString("receiver_name");
  6803. trade.receiver_mobile = receiveMobile;
  6804. trade.receiver_state = GetPostString("receiver_state");
  6805. trade.receiver_city = GetPostString("receiver_city");
  6806. trade.receiver_district = GetPostString("receiver_district");
  6807. trade.receiver_address = GetPostString("receiver_address");
  6808. newentity.IsOffLineOrder = 1;
  6809. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6810. }
  6811. }
  6812. string st = GetPostString("ToState");
  6813. if (st.Length > 0)
  6814. {
  6815. if (newentity.OrderState <= 3)
  6816. {
  6817. newentity.WaitDesignTime = DateTime.Now;
  6818. newentity.StartDesignTime = null;
  6819. newentity.FinishDesignTime = null;
  6820. newentity.OrderState = 3;
  6821. if (st == "下单员")
  6822. {
  6823. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6824. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6825. {
  6826. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6827. }
  6828. }
  6829. else
  6830. {
  6831. newentity.WaitDesignTime = DateTime.Now;
  6832. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6833. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6834. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6835. {
  6836. DataRow user = dt1.Rows[0];
  6837. //找主管
  6838. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6839. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6840. if (dt != null && dt.Rows.Count > 0)
  6841. {
  6842. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6843. newentity.DesignUserId = designMr;
  6844. string key = "aftersale_order_" + designMr;
  6845. if (RedisHelper.HasKey(key))
  6846. {
  6847. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6848. list.Add(newentity.ctid);
  6849. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6850. }
  6851. }
  6852. //账号正常
  6853. if (user["State"].ToString() == "0")
  6854. {
  6855. newentity.DesignUserId = entity.DesignUserId;
  6856. string key = "aftersale_order_" + entity.DesignUserId;
  6857. if (RedisHelper.HasKey(key))
  6858. {
  6859. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6860. list.Add(newentity.ctid);
  6861. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6862. }
  6863. }
  6864. }
  6865. }
  6866. }
  6867. if (entity.IsXianHuo == 1)
  6868. {
  6869. newentity.OrderState = 6;
  6870. entity.FinishPlaceTime = DateTime.Now;
  6871. }
  6872. }
  6873. if (ishav)
  6874. {
  6875. newentity.Update();
  6876. }
  6877. else
  6878. {
  6879. newentity.Create();
  6880. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6881. newCellExtend.ctid = newentity.ctid;
  6882. newCellExtend.orderFrom = 20;
  6883. newCellExtend.orderType = 30;
  6884. if (st == "下单员")
  6885. {
  6886. }
  6887. else
  6888. {
  6889. newCellExtend.ReprintTime = DateTime.Now;
  6890. }
  6891. newCellExtend.Create();
  6892. }
  6893. if (st != "下单员")
  6894. {
  6895. if (entity.DispatchSort == 2)
  6896. {
  6897. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6898. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6899. }
  6900. }
  6901. }
  6902. //处理售后扩展
  6903. string resIdStr = GetPostString("ResponsibleUserId");
  6904. string refundFees = GetPostString("refundFrees");
  6905. int IsComplain = GetPostInt("isComplain");
  6906. int IsBad = GetPostInt("isBad");
  6907. string IsOriginal = GetPostString("isOriginal");
  6908. double diffResultPrice = GetPostDouble("diffResultPrice");
  6909. string textResult = GetPostString("textResult");
  6910. string supplierResponsible = GetPostString("supplierResponsible");
  6911. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6912. if (ceErpTradeAfterSaleExtend == null)
  6913. {
  6914. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6915. ceErpTradeAfterSaleExtend.tid = eid;
  6916. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6917. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6918. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6919. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6920. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6921. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6922. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6923. ceErpTradeAfterSaleExtend.Create();
  6924. }
  6925. else
  6926. {
  6927. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6928. {
  6929. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6930. }
  6931. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6932. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6933. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6934. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6935. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6936. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6937. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6938. ceErpTradeAfterSaleExtend.Update();
  6939. }
  6940. int gysid = GetPostInt("ResponsibleSupId");
  6941. if (entity.AfterSaleUserId == 0)
  6942. {
  6943. entity.AfterSaleUserId = CurrentUser.UserID;
  6944. }
  6945. entity.ResponsibleUserId = resIdStr;
  6946. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6947. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6948. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6949. {
  6950. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6951. int backNum = 0;
  6952. if (number != null)
  6953. {
  6954. backNum = number.BackNum;
  6955. }
  6956. char[] separator = { ',' };
  6957. string[] sArray = resIdStr.Split(separator);
  6958. string[] refundFreeList = { };
  6959. if (refundFees.Length > 0)
  6960. {
  6961. refundFreeList = refundFees.Split(separator);
  6962. }
  6963. int index = -1;
  6964. List<int> responsibleIds = new List<int>();
  6965. foreach (string i in sArray)
  6966. {
  6967. index++;
  6968. if (i.Length <= 0) continue;
  6969. char[] separator2 = { '_' };
  6970. string idstr = i.Split(separator2)[0];
  6971. string idtype = i.Split(separator2)[1];
  6972. double refudFree = 0;
  6973. if (refundFreeList.Length > 0)
  6974. {
  6975. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6976. }
  6977. if (idtype == "s")
  6978. {
  6979. isDesign = true;
  6980. designFree = refudFree;
  6981. }
  6982. int userId = Convert.ToInt32(idstr);
  6983. int type = 0;
  6984. if (idtype == "g")
  6985. {
  6986. type = 1;
  6987. }
  6988. if (idtype == "w")
  6989. {
  6990. type = 2;
  6991. }
  6992. if (idtype == "t")
  6993. {
  6994. type = 3;
  6995. }
  6996. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6997. if (ceErpTradeResponsible == null)
  6998. {
  6999. ceErpTradeResponsible = new CeErpTradeResponsible();
  7000. ceErpTradeResponsible.tid = eid;
  7001. ceErpTradeResponsible.UserId = userId;
  7002. ceErpTradeResponsible.createdTime = DateTime.Now;
  7003. ceErpTradeResponsible.type = type;
  7004. if (type == 1)
  7005. {
  7006. ceErpTradeResponsible.IsSup = 1;
  7007. }
  7008. if (type == 2)
  7009. {
  7010. ceErpTradeResponsible.IsFlow = 1;
  7011. }
  7012. }
  7013. int state = 0;
  7014. //已认可的不需要再次认可
  7015. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7016. {
  7017. state = 1;
  7018. }
  7019. ceErpTradeResponsible.RefundFee = refudFree;
  7020. ceErpTradeResponsible.VerifyState = state;
  7021. if (userId == 2125 || idtype == "w")
  7022. {
  7023. ceErpTradeResponsible.VerifyState = 1;
  7024. }
  7025. if (idtype == "w" && userId == 101)
  7026. {
  7027. ceErpTradeResponsible.VerifyState = state;
  7028. }
  7029. if (ceErpTradeResponsible.ID > 0)
  7030. {
  7031. ceErpTradeResponsible.Update();
  7032. }
  7033. else
  7034. {
  7035. ceErpTradeResponsible.Create();
  7036. }
  7037. if (isDesign)
  7038. {
  7039. responsibleId = ceErpTradeResponsible.ID;
  7040. }
  7041. responsibleIds.Add(ceErpTradeResponsible.ID);
  7042. }
  7043. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7044. CeErpTradeResponsible.NumByTid(backNum, eid);
  7045. }
  7046. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7047. if (ceErpTradeCellExtend != null)
  7048. {
  7049. ceErpTradeCellExtend.returnVisit = 0;
  7050. ceErpTradeCellExtend.Update();
  7051. }
  7052. if (entity.HandleTime != null)
  7053. {
  7054. if (entity.AfterSaleState == 1)
  7055. {
  7056. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7057. }
  7058. else
  7059. {
  7060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7061. }
  7062. }
  7063. else
  7064. {
  7065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7066. entity.HandleTime = DateTime.Now;
  7067. }
  7068. bool isCompale = false;
  7069. if (entity.AfterSaleState == 5)
  7070. {
  7071. isCompale = true;
  7072. entity.AfterSaleState = 3;
  7073. }
  7074. entity.AfterSaleSupplierState = 0;
  7075. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7076. {
  7077. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7078. }
  7079. string sImgs = GetPostString("img");
  7080. entity.AfterSaleSupplierImg = sImgs;
  7081. entity.supRefundType = GetPostString("supRefundType");
  7082. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7083. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7084. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7085. entity.AfterSaleMemoType = GetPostString("MemoType");
  7086. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7087. {
  7088. //entity.AfterSaleSupplierState = 2;
  7089. }
  7090. string df = GetPostString("DeductFee");
  7091. if (df == "")
  7092. {
  7093. df = "0";
  7094. }
  7095. string rf = GetPostString("RefundFee");
  7096. if (rf == "")
  7097. {
  7098. rf = "0";
  7099. }
  7100. string pm = GetPostString("AfterSalePayment");
  7101. if (pm == "")
  7102. {
  7103. pm = "0";
  7104. }
  7105. entity.AfterSalePayment = Convert.ToDouble(pm);
  7106. entity.DeductFee = Convert.ToDouble(df);
  7107. entity.RefundFee = Convert.ToDouble(rf);
  7108. entity.UpdateTime = DateTime.Now;
  7109. entity.Update();
  7110. string toState = GetPostString("ToState");
  7111. string original = GetPostString("isOriginal");
  7112. ApiVo apiVo = new ApiVo();
  7113. apiVo.orderNumber = entity.ctid;
  7114. apiVo.actionName = "afterDesign";
  7115. apiVo.orderRemarks = entity.AfterSaleMethod;
  7116. apiVo.reasonRemarks = entity.AfterSaleReason;
  7117. apiVo.isDesign = isDesign;
  7118. apiVo.designFree = designFree;
  7119. apiVo.responsibleId = responsibleId;
  7120. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7121. if (toState == "设计师")
  7122. {
  7123. apiVo.isOriginal = Convert.ToBoolean(original);
  7124. }
  7125. designHelper.API_WorkCore(apiVo);//afterDesign
  7126. CeErpMethod methodSql = new CeErpMethod();
  7127. methodSql.con = entity.AfterSaleMethod;
  7128. methodSql.addTime = DateTime.Now;
  7129. methodSql.Create();
  7130. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7131. CeErpMethod.ExecuteNonQuery(delsql);
  7132. if (isCompale)
  7133. {
  7134. aftersale_data_change(entity.ctid);
  7135. }
  7136. returnSuccessMsg("操作成功!");
  7137. return;
  7138. }
  7139. returnErrorMsg("找不到订单记录");
  7140. }
  7141. }
  7142. public void ins_erp_toresponsible()
  7143. {
  7144. if (UrlPostParmsCheck("ctid"))
  7145. {
  7146. string eid = GetPostString("ctid");
  7147. CeErpTradeCell entity = null;
  7148. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7149. if (entity != null)
  7150. {
  7151. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7152. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7153. {
  7154. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7155. return;
  7156. }
  7157. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7158. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7159. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7160. if (entity.AfterSalePreTime == null)
  7161. {
  7162. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7163. {
  7164. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7165. }
  7166. }
  7167. entity.AfterSalePreTime = DateTime.Now;
  7168. //预完成给售后主管审核客户问题直接完成
  7169. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7170. {
  7171. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7172. {
  7173. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7174. }
  7175. }
  7176. ceErpTradeAfterSaleExtend.Update();
  7177. entity.AfterSaleState = 2;
  7178. entity.UpdateTime = DateTime.Now;
  7179. entity.Update();
  7180. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7181. aftersale_data_change(entity.ctid);
  7182. returnSuccessMsg("操作成功!");
  7183. return;
  7184. }
  7185. returnErrorMsg("找不到订单记录");
  7186. }
  7187. }
  7188. public void cancel_erp_aftersaleanddelnew()
  7189. {
  7190. if (UrlPostParmsCheck("ctid"))
  7191. {
  7192. string eid = GetPostString("ctid");
  7193. CeErpTradeCell entity = null;
  7194. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7195. if (entity != null)
  7196. {
  7197. entity.AfterSaleState = 0;
  7198. entity.AfterSaleReason = "";
  7199. entity.AfterSaleMethod = "";
  7200. entity.AfterSaleMemo = "";
  7201. entity.AfterSaleResponsible = "";
  7202. entity.ResponsibleUserId = "";
  7203. entity.DeductFee = 0;
  7204. entity.RefundFee = 0;
  7205. entity.IsArbitrate = 0;
  7206. CeErpTradeResponsible.DelByTid(eid, -1);
  7207. entity.Update();
  7208. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7209. if (after != null)
  7210. {
  7211. if (after.OrderState < 5)
  7212. CeErpTradeCell.DelByCtid("S_" + eid);
  7213. }
  7214. returnSuccessMsg("操作成功!");
  7215. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7216. return;
  7217. }
  7218. returnErrorMsg("找不到订单记录");
  7219. }
  7220. }
  7221. public void get_erp_aftersale_pregather()
  7222. {
  7223. List<string> lw = new List<string>();
  7224. int st = GetInt("st");
  7225. string tid = GetPostString("ctid");
  7226. if (tid.Length > 0)
  7227. {
  7228. string select_tid = getTidByCtid(tid);
  7229. lw.Add(string.Format("tid='{0}'", select_tid));
  7230. }
  7231. string shopname = GetPostString("shopname");
  7232. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7233. string buyernick = GetPostString("buyer_nick");
  7234. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7235. string sellermemo = GetPostString("seller_memo");
  7236. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7237. string orderState = GetPostString("orderState");
  7238. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7239. string reason = GetPostString("reason");
  7240. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7241. string method = GetPostString("method");
  7242. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7243. string handler = GetPostString("handler");
  7244. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7245. string handledate1 = GetPostString("handledate1");
  7246. string handledate2 = GetPostString("handledate2");
  7247. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7248. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7249. string supplier = GetPostString("supplier");
  7250. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7251. string responsible = GetPostString("responsibleman");
  7252. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7253. string customer = GetPostString("customer");
  7254. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7255. string design = GetPostString("design");
  7256. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7257. string afterMemoType = GetPostString("aftermemotype");
  7258. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7259. string afterSaleMemo = GetPostString("afterSaleMemo");
  7260. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7261. string afterresult = GetPostString("afterresult");
  7262. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7263. string poscode = CurrentUser.UserPost.Post.Code;
  7264. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7265. {
  7266. string shopid = CurrentUser.User.pemShop;
  7267. lw.Add(string.Format("shopId in ({0})", shopid));
  7268. }
  7269. var mainwhere = string.Join(" and ", lw.ToArray());
  7270. string ro_json = "";
  7271. string type = GetPostString("gather_type");
  7272. int number = 0;
  7273. if (poscode == "AfterSale")
  7274. {
  7275. //处理中
  7276. if (type == "Handling")
  7277. {
  7278. 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) : ""));
  7279. DataTable dt = null;
  7280. try
  7281. {
  7282. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7283. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7284. }
  7285. catch (Exception e)
  7286. {
  7287. dt = new DataTable();
  7288. }
  7289. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7290. return;
  7291. }
  7292. if (type == "Wait")
  7293. {
  7294. //待处理
  7295. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7296. DataTable dt1 = null;
  7297. try
  7298. {
  7299. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7300. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7301. }
  7302. catch (Exception e)
  7303. {
  7304. dt1 = new DataTable();
  7305. }
  7306. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7307. return;
  7308. }
  7309. if (type == "back")
  7310. {
  7311. //打回
  7312. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7313. DataTable dt2 = null;
  7314. try
  7315. {
  7316. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7317. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7318. }
  7319. catch (Exception e)
  7320. {
  7321. dt2 = new DataTable();
  7322. }
  7323. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7324. return;
  7325. }
  7326. if (type == "preCompletion")
  7327. {
  7328. //预完成
  7329. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7330. DataTable dt3 = null;
  7331. try
  7332. {
  7333. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7334. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7335. }
  7336. catch (Exception e)
  7337. {
  7338. dt3 = new DataTable();
  7339. }
  7340. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7341. return;
  7342. }
  7343. if (type == "documentary")
  7344. {
  7345. //跟单中
  7346. 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) : ""));
  7347. DataTable dt4 = null;
  7348. try
  7349. {
  7350. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7351. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7352. }
  7353. catch (Exception e)
  7354. {
  7355. dt4 = new DataTable();
  7356. }
  7357. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7358. return;
  7359. }
  7360. if (type == "reBack")
  7361. {
  7362. //被打回
  7363. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7364. DataTable dt1 = null;
  7365. try
  7366. {
  7367. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7368. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7369. }
  7370. catch (Exception e)
  7371. {
  7372. dt1 = new DataTable();
  7373. }
  7374. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7375. return;
  7376. }
  7377. }
  7378. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7379. {
  7380. if (type == "puBack")
  7381. {
  7382. //退回
  7383. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7384. DataTable dt = null;
  7385. try
  7386. {
  7387. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7388. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7389. }
  7390. catch (Exception e)
  7391. {
  7392. dt = new DataTable();
  7393. }
  7394. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7395. return;
  7396. }
  7397. if (type == "reBack")
  7398. {
  7399. //打回
  7400. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7401. DataTable dt1 = null;
  7402. try
  7403. {
  7404. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7405. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7406. }
  7407. catch (Exception e)
  7408. {
  7409. dt1 = new DataTable();
  7410. }
  7411. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7412. return;
  7413. }
  7414. if (type == "examEd")
  7415. {
  7416. //已审核
  7417. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7418. DataTable dt2 = null;
  7419. try
  7420. {
  7421. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7422. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7423. }
  7424. catch (Exception e)
  7425. {
  7426. dt2 = new DataTable();
  7427. }
  7428. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7429. return;
  7430. }
  7431. if (type == "waitExam")
  7432. {
  7433. //待审核
  7434. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7435. DataTable dt3 = null;
  7436. try
  7437. {
  7438. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7439. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7440. }
  7441. catch (Exception e)
  7442. {
  7443. dt3 = new DataTable();
  7444. }
  7445. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7446. return;
  7447. }
  7448. if (type == "Handling")
  7449. {
  7450. //处理中
  7451. 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) : ""));
  7452. DataTable dt4 = null;
  7453. try
  7454. {
  7455. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7456. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7457. }
  7458. catch (Exception e)
  7459. {
  7460. dt4 = new DataTable();
  7461. }
  7462. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7463. return;
  7464. }
  7465. if (type == "Wait")
  7466. {
  7467. //待处理
  7468. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7469. DataTable dt5 = null;
  7470. try
  7471. {
  7472. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7473. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7474. }
  7475. catch (Exception e)
  7476. {
  7477. dt5 = new DataTable();
  7478. }
  7479. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7480. return;
  7481. }
  7482. if (type == "documentary")
  7483. {
  7484. //跟单中
  7485. 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) : ""));
  7486. DataTable dt6 = null;
  7487. try
  7488. {
  7489. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7490. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7491. }
  7492. catch (Exception e)
  7493. {
  7494. dt6 = new DataTable();
  7495. }
  7496. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7497. return;
  7498. }
  7499. }
  7500. returnSuccess(ro_json);
  7501. }
  7502. public void end_erp_aftersale()
  7503. {
  7504. if (UrlPostParmsCheck("ctid"))
  7505. {
  7506. string eid = GetPostString("ctid");
  7507. CeErpTradeCell entity = null;
  7508. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7509. if (entity != null)
  7510. {
  7511. string stype = GetPostString("stype");
  7512. string typeStr = stype;
  7513. entity.AfterSaleState = 4;
  7514. entity.FinishAfterSaleTime = DateTime.Now;
  7515. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7516. entity.Update();
  7517. ApiVo apiVo = new ApiVo();
  7518. apiVo.orderNumber = entity.ctid;
  7519. apiVo.actionName = "afterOver";
  7520. designHelper.API_WorkCore(apiVo); //afterOver
  7521. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7522. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7523. CeErpSukuraData.createInfo(entity.ctid, 8);
  7524. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7525. returnSuccessMsg("操作成功!");
  7526. return;
  7527. }
  7528. returnErrorMsg("找不到订单记录");
  7529. }
  7530. }
  7531. public void ins_erp_finishaftersale()
  7532. {
  7533. if (UrlPostParmsCheck("id"))
  7534. {
  7535. string eid = GetPostString("id");
  7536. CeErpTradeResponsible entity = null;
  7537. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7538. if (entity != null)
  7539. {
  7540. entity.VerifyState = 1;
  7541. entity.VerifyTime = DateTime.Now;
  7542. entity.Update();
  7543. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7544. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7545. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7546. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7547. if (dt.Rows.Count <= 0)
  7548. {
  7549. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7550. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7551. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7552. CeErpSukuraData.createInfo(entity.tid, 8);
  7553. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7554. {
  7555. CeErpDesignerBill.Del(entity.tid);
  7556. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7557. }
  7558. }
  7559. returnSuccessMsg("操作成功!");
  7560. return;
  7561. }
  7562. returnErrorMsg("找不到订单记录");
  7563. }
  7564. }
  7565. public void upd_erp_arbitrateaftersale()
  7566. {
  7567. if (UrlPostParmsCheck("id"))
  7568. {
  7569. string eid = GetPostString("id");
  7570. CeErpTradeResponsible entity = null;
  7571. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7572. if (entity != null)
  7573. {
  7574. entity.IsArbitrate = 1;
  7575. entity.ArbitradeMemo = GetPostString("reason");
  7576. entity.VerifyState = 2;
  7577. entity.Update();
  7578. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7579. if (tradecell != null)
  7580. {
  7581. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7582. tradecell.IsArbitrate = 1;
  7583. tradecell.Update();
  7584. }
  7585. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7586. returnSuccessMsg("操作成功!");
  7587. return;
  7588. }
  7589. returnErrorMsg("找不到订单记录");
  7590. }
  7591. }
  7592. public void upd_erp_backaftersale()
  7593. {
  7594. if (UrlPostParmsCheck("tid"))
  7595. {
  7596. string eid = GetPostString("tid");
  7597. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7598. int backNum = 0;
  7599. if (number != null)
  7600. {
  7601. backNum = number.BackNum;
  7602. }
  7603. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7604. CeErpTradeCell entity = null;
  7605. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7606. if (entity != null)
  7607. {
  7608. entity.AfterSaleBackReason = GetPostString("backreason");
  7609. entity.AfterSaleState = 1;
  7610. entity.AfterSaleSupplierState = 0;
  7611. entity.UpdateTime = DateTime.Now;
  7612. entity.Update();
  7613. returnSuccessMsg("操作成功!");
  7614. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7615. return;
  7616. }
  7617. returnErrorMsg("找不到订单记录");
  7618. }
  7619. }
  7620. public void get_erp_supplieraftersalelist()
  7621. {
  7622. DataStruct dStruct = GetPostStruct();
  7623. List<string> lw = new List<string>();
  7624. string tid = GetPostString("ctid");
  7625. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7626. string shopname = GetPostString("shopname");
  7627. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7628. string buyernick = GetPostString("buyer_nick");
  7629. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7630. string sellermemo = GetPostString("seller_memo");
  7631. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7632. string orderState = GetPostString("orderState");
  7633. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7634. string afterState = GetPostString("afterstate");
  7635. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7636. string date1 = GetPostString("date1");
  7637. string date2 = GetPostString("date2");
  7638. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7639. if (dw.Length > 0) lw.Add(dw);
  7640. string price1 = GetPostString("price1");
  7641. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7642. string price2 = GetPostString("price2");
  7643. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7644. string reason = GetPostString("reason");
  7645. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7646. string method = GetPostString("method");
  7647. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7648. string handledate1 = GetPostString("handledate1");
  7649. string handledate2 = GetPostString("handledate2");
  7650. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7651. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7652. string handler = GetPostString("handler");
  7653. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7654. string afterdate1 = GetPostString("afterdate1");
  7655. string afterdate2 = GetPostString("afterdate2");
  7656. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7657. if (afterDate.Length > 0) lw.Add(afterDate);
  7658. string customer = GetPostString("customer");
  7659. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7660. string design = GetPostString("design");
  7661. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7662. string afterMemoType = GetPostString("aftermemotype");
  7663. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7664. string vstate = GetPostString("vstate");
  7665. if (vstate.Length > 0)
  7666. {
  7667. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7668. }
  7669. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7670. string supplier = GetPostString("supplier");
  7671. int supid = commonHelper.getSupplierIDByName(supplier);
  7672. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7673. string posCode = CurrentUser.UserPost.Post.Code;
  7674. if (posCode == "Supplier")
  7675. {
  7676. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7677. }
  7678. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7679. {
  7680. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7681. }
  7682. else
  7683. {
  7684. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7685. }
  7686. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7687. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7688. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7689. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7690. writeGridDataTableJson(dStruct.TotalCount, dt);
  7691. }
  7692. public void upd_erp_supverifyaftersale()
  7693. {
  7694. if (UrlPostParmsCheck("id"))
  7695. {
  7696. string id = GetPostString("id");
  7697. int st = GetPostInt("afterstate");
  7698. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7699. CeErpTradeCell entity = null;
  7700. if (ceErpTradeResponsible != null)
  7701. {
  7702. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7703. }
  7704. string afmemo = GetPostString("supmemo");
  7705. string image = GetPostString("image");
  7706. if (entity != null)
  7707. {
  7708. entity.AfterSaleSupplierState = st;
  7709. entity.AfterSaleSupplierMemo = afmemo;
  7710. if (st == 1)
  7711. {
  7712. ceErpTradeResponsible.VerifyState = 1;
  7713. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7714. ceErpTradeResponsible.Update();
  7715. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7716. if (isAll)
  7717. {
  7718. entity.AfterSaleState = 4;
  7719. entity.FinishAfterSaleTime = DateTime.Now;
  7720. }
  7721. }
  7722. else
  7723. {
  7724. CeErpTradeResponsible.dateByTid(entity.ctid);
  7725. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7726. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7727. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7728. if (num <= 1)
  7729. {
  7730. entity.AfterSaleState = 1;
  7731. }
  7732. else
  7733. {
  7734. entity.AfterSaleState = 5;
  7735. }
  7736. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7737. if (ceErpTradeAfterSaleExtend != null)
  7738. {
  7739. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7740. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7741. ceErpTradeAfterSaleExtend.Update();
  7742. }
  7743. else
  7744. {
  7745. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7746. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7747. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7748. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7749. ceErpTradeAfterSaleExtend.Create();
  7750. }
  7751. }
  7752. if (entity.AfterSaleState == 4)
  7753. {
  7754. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7755. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7756. {
  7757. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7758. }
  7759. ApiVo apiVo = new ApiVo();
  7760. apiVo.orderNumber = entity.ctid;
  7761. apiVo.actionName = "afterOver";
  7762. designHelper.API_WorkCore(apiVo); //afterOver
  7763. }
  7764. entity.UpdateTime = DateTime.Now;
  7765. entity.Update();
  7766. returnSuccessMsg("操作成功!");
  7767. CeErpSukuraData.createInfo(entity.ctid, 8);
  7768. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7769. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7770. return;
  7771. }
  7772. returnErrorMsg("找不到订单记录");
  7773. }
  7774. }
  7775. public void upd_erp_masteraftersale()
  7776. {
  7777. if (UrlPostParmsCheck("id"))
  7778. {
  7779. string id = GetPostString("id");
  7780. int st = GetPostInt("afterstate");
  7781. string afmemo = GetPostString("supmemo");
  7782. string image = GetPostString("image");
  7783. string textResult = GetPostString("textResult");
  7784. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7785. if (ceErpTradeResponsible != null)
  7786. {
  7787. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7788. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7789. ceErpTradeResponsible.Update();
  7790. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7791. if (entity != null)
  7792. {
  7793. entity.AfterSaleSupplierState = st;
  7794. entity.AfterSaleSupplierMemo = afmemo;
  7795. if (st == 1)
  7796. {
  7797. }
  7798. else
  7799. {
  7800. CeErpTradeResponsible.dateByTid(entity.ctid);
  7801. //退回到售后
  7802. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7803. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7804. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7805. if (num <= 1)
  7806. {
  7807. entity.AfterSaleState = 1;
  7808. }
  7809. else
  7810. {
  7811. entity.AfterSaleState = 5;
  7812. }
  7813. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7814. if (ceErpTradeAfterSaleExtend != null)
  7815. {
  7816. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7817. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7818. ceErpTradeAfterSaleExtend.Update();
  7819. }
  7820. else
  7821. {
  7822. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7823. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7824. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7825. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7826. ceErpTradeAfterSaleExtend.Create();
  7827. }
  7828. }
  7829. entity.UpdateTime = DateTime.Now;
  7830. entity.Update();
  7831. returnSuccessMsg("操作成功!");
  7832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7833. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7834. return;
  7835. }
  7836. }
  7837. returnErrorMsg("找不到订单记录");
  7838. }
  7839. }
  7840. public void upd_erp_personaftersale()
  7841. {
  7842. if (UrlPostParmsCheck("id"))
  7843. {
  7844. //林小连
  7845. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7846. {
  7847. upd_erp_masteraftersale();
  7848. return;
  7849. }
  7850. string id = GetPostString("id");
  7851. int st = GetPostInt("afterstate");
  7852. string afmemo = GetPostString("supmemo");
  7853. string image = GetPostString("image");
  7854. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7855. if (ceErpTradeResponsible != null)
  7856. {
  7857. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7858. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7859. ceErpTradeResponsible.Update();
  7860. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7861. if (entity != null)
  7862. {
  7863. entity.AfterSaleSupplierMemo = afmemo;
  7864. entity.AfterSaleSupplierState = st;
  7865. if (st == 1)
  7866. {
  7867. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7868. if (isAll)
  7869. {
  7870. entity.AfterSaleState = 4;
  7871. entity.FinishAfterSaleTime = DateTime.Now;
  7872. }
  7873. }
  7874. else
  7875. {
  7876. CeErpTradeResponsible.dateByTid(entity.ctid);
  7877. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7878. if (ceErpTradeAfterSaleExtend != null)
  7879. {
  7880. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7881. ceErpTradeAfterSaleExtend.Update();
  7882. }
  7883. else
  7884. {
  7885. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7886. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7887. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7888. ceErpTradeAfterSaleExtend.Create();
  7889. }
  7890. //退回到主管
  7891. //entity.AfterSaleState = 2;
  7892. }
  7893. if (entity.AfterSaleState == 4)
  7894. {
  7895. ApiVo apiVo = new ApiVo();
  7896. apiVo.orderNumber = entity.ctid;
  7897. apiVo.actionName = "afterOver";
  7898. designHelper.API_WorkCore(apiVo); //afterOver
  7899. }
  7900. entity.UpdateTime = DateTime.Now;
  7901. entity.Update();
  7902. returnSuccessMsg("操作成功!");
  7903. CeErpSukuraData.createInfo(entity.ctid, 8);
  7904. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7905. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7906. return;
  7907. }
  7908. }
  7909. returnErrorMsg("找不到订单记录");
  7910. }
  7911. }
  7912. public void set_erp_supplierrefundtag()
  7913. {
  7914. if (UrlPostParmsCheck("ctid"))
  7915. {
  7916. string eid = GetPostString("ctid");
  7917. CeErpTradeCell entity = null;
  7918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7919. if (entity != null)
  7920. {
  7921. entity.IsSupplierRefund = GetPostInt("tag");
  7922. entity.Update();
  7923. returnSuccessMsg("操作成功!");
  7924. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7925. return;
  7926. }
  7927. returnErrorMsg("找不到订单记录");
  7928. }
  7929. }
  7930. public void get_erp_refundlist()
  7931. {
  7932. DataStruct dStruct = GetPostStruct();
  7933. List<string> lw = new List<string>();
  7934. string tid = GetPostString("tid");
  7935. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7936. //string rid = GetPostString("refund_id");
  7937. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7938. string shopname = GetPostString("shopname");
  7939. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7940. string buyernick = GetPostString("buyer_nick");
  7941. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7942. string customer = GetPostString("customer");
  7943. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7944. string design = GetPostString("design");
  7945. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7946. string sellermemo = GetPostString("seller_memo");
  7947. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7948. //string date1 = GetPostString("date1");
  7949. //string date2 = GetPostString("date2");
  7950. //string dateType = GetPostString("dateType");
  7951. //if (dateType.Length > 0)
  7952. //{
  7953. // if (dateType == "1001") dateType = "0";
  7954. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7955. // if (searchDT.Count == 2)
  7956. // {
  7957. // date1 = searchDT[0].ToString();
  7958. // date2 = searchDT[1].ToString();
  7959. // }
  7960. //}
  7961. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7962. //if (dw.Length > 0) lw.Add(dw);
  7963. string redate1 = GetPostString("refunddate1");
  7964. string redate2 = GetPostString("refunddate2");
  7965. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7966. if (dwdate.Length > 0) lw.Add(dwdate);
  7967. string price1 = GetPostString("price1");
  7968. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7969. string price2 = GetPostString("price2");
  7970. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7971. string ispartrefund = GetPostString("ispartrefund");
  7972. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7973. string refundState = GetPostString("refundvstate");
  7974. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7975. int st = GetInt("st");
  7976. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7977. {
  7978. string responsible = GetPostString("responsibleman");
  7979. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7980. lw.Add(string.Format("RefundState>={0}", st));
  7981. string code = CurrentUser.UserPost.Post.Code;
  7982. if (code == "CustomerService")
  7983. {
  7984. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7985. }
  7986. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7987. {
  7988. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7989. }
  7990. else if (code == "Place" || code == "PlaceMr")
  7991. {
  7992. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7993. }
  7994. dStruct.Order = "RefundState asc,created desc";
  7995. }
  7996. else if (st == 10)
  7997. {
  7998. string responsible = GetPostString("responsibleman");
  7999. if (responsible == "空白")
  8000. {
  8001. lw.Add(string.Format("ResponsibleUserName = ''"));
  8002. }
  8003. else if (responsible.Length > 0)
  8004. {
  8005. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8006. }
  8007. lw.Add(string.Format("RefundState>=0"));
  8008. dStruct.Order = "created desc";
  8009. }
  8010. else
  8011. {
  8012. string responsible = GetPostString("responsibleman");
  8013. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8014. lw.Add(string.Format("RefundState={0}", st));
  8015. dStruct.Order = "created desc";
  8016. }
  8017. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8018. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8019. dt.Columns.Add("refund_fees");
  8020. foreach (DataRow dr in dt.Rows)
  8021. {
  8022. String status = dr["status"].ToString();
  8023. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8024. {
  8025. dr["refund_fees"] = dr["refund_fee"];
  8026. }
  8027. else
  8028. {
  8029. dr["refund_fees"] = "0.0";
  8030. }
  8031. }
  8032. writeGridDataTableJson(dStruct.TotalCount, dt);
  8033. }
  8034. public void get_erp_refunddesignlist()
  8035. {
  8036. DataStruct dStruct = GetPostStruct();
  8037. List<string> lw = new List<string>();
  8038. string tid = GetPostString("tid");
  8039. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8040. string shopname = GetPostString("shopname");
  8041. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8042. string buyernick = GetPostString("buyer_nick");
  8043. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8044. string customer = GetPostString("customer");
  8045. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8046. string design = GetPostString("design");
  8047. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8048. string sellermemo = GetPostString("seller_memo");
  8049. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8050. string redate1 = GetPostString("refunddate1");
  8051. string redate2 = GetPostString("refunddate2");
  8052. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8053. if (dwdate.Length > 0) lw.Add(dwdate);
  8054. string price1 = GetPostString("price1");
  8055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8056. string price2 = GetPostString("price2");
  8057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8058. string ispartrefund = GetPostString("ispartrefund");
  8059. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8060. string designerorg = GetPostString("designerorg");
  8061. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8062. string refundState = GetPostString("refundState");
  8063. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8064. int myOrgid = CurrentUser.UserPost.OrgID;
  8065. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8066. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8067. {
  8068. if (CurrentUser.User.TeamIds.Length > 0)
  8069. {
  8070. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8071. }
  8072. else
  8073. {
  8074. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8075. }
  8076. }
  8077. else if ("SysAdmin".Equals(myOrgCode))
  8078. {
  8079. }
  8080. else
  8081. {
  8082. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8083. {
  8084. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8085. }
  8086. else
  8087. {
  8088. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8089. }
  8090. }
  8091. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8092. dStruct.Order = "created desc";
  8093. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8094. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8095. dt.Columns.Add("refund_fees");
  8096. foreach (DataRow dr in dt.Rows)
  8097. {
  8098. String status = dr["status"].ToString();
  8099. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8100. {
  8101. dr["refund_fees"] = dr["refund_fee"];
  8102. }
  8103. else
  8104. {
  8105. dr["refund_fees"] = "0.0";
  8106. }
  8107. }
  8108. writeGridDataTableJson(dStruct.TotalCount, dt);
  8109. }
  8110. public void handle_erp_refundtag()
  8111. {
  8112. if (UrlPostParmsCheck("refund_id"))
  8113. {
  8114. string eid = GetPostString("refund_id");
  8115. string respMan = GetPostString("ResponsibleName");
  8116. if (respMan.Length <= 0)
  8117. {
  8118. returnErrorMsg("责任人不能为空");
  8119. return;
  8120. }
  8121. CeErpTradeRefund entity = null;
  8122. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8123. if (entity != null)
  8124. {
  8125. entity.ResponsibleUserName = respMan;
  8126. string userid = GetPostString("ResponsibleUserId");
  8127. if (userid.Length > 0)
  8128. {
  8129. entity.ResponsibleUserId = userid;
  8130. }
  8131. entity.Memo = GetPostString("Memo");
  8132. if (respMan.IndexOf("客服") != -1 ||
  8133. respMan.IndexOf("设计师") != -1 ||
  8134. respMan.IndexOf("下单员") != -1)
  8135. {
  8136. entity.RefundState = 2;
  8137. }
  8138. else
  8139. {
  8140. entity.RefundState = 3;
  8141. }
  8142. entity.modified = DateTime.Now;
  8143. entity.Update();
  8144. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8145. returnSuccessMsg("操作成功!");
  8146. return;
  8147. }
  8148. returnErrorMsg("找不到订单记录");
  8149. }
  8150. }
  8151. public void handle_erp_designrefundtag()
  8152. {
  8153. if (UrlPostParmsCheck("refund_id"))
  8154. {
  8155. string eid = GetPostString("refund_id");
  8156. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8157. if (ceErpTradeCellExtend == null)
  8158. {
  8159. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8160. ceErpTradeCellExtend.ctid = eid;
  8161. }
  8162. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8163. if (ceErpTradeCellExtend.ID > 0)
  8164. {
  8165. ceErpTradeCellExtend.Update();
  8166. }
  8167. else
  8168. {
  8169. ceErpTradeCellExtend.Create();
  8170. }
  8171. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8172. returnSuccessMsg("操作成功!");
  8173. return;
  8174. }
  8175. returnErrorMsg("找不到订单记录");
  8176. }
  8177. public void upd_erp_refundverify()
  8178. {
  8179. if (UrlPostParmsCheck("refund_id"))
  8180. {
  8181. string eid = GetPostString("refund_id");
  8182. CeErpTradeRefund entity = null;
  8183. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8184. if (entity != null)
  8185. {
  8186. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8187. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8188. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8189. {
  8190. entity.RefundState = 2;
  8191. }
  8192. else
  8193. {
  8194. entity.RefundState = 3;
  8195. }
  8196. entity.Update();
  8197. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8198. returnSuccessMsg("操作成功!");
  8199. return;
  8200. }
  8201. returnErrorMsg("找不到订单记录");
  8202. }
  8203. }
  8204. public void upd_erp_refundapprove()
  8205. {
  8206. if (UrlPostParmsCheck("refund_id"))
  8207. {
  8208. string eid = GetPostString("refund_id");
  8209. CeErpTradeRefund entity = null;
  8210. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8211. if (entity != null)
  8212. {
  8213. int apr = GetPostInt("approve");
  8214. if (apr == 0)
  8215. {
  8216. entity.RefundState = 1;
  8217. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8218. }
  8219. else if (apr == 1)
  8220. {
  8221. entity.RefundState = 3;
  8222. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8223. }
  8224. entity.modified = DateTime.Now;
  8225. entity.Update();
  8226. returnSuccessMsg("操作成功!");
  8227. return;
  8228. }
  8229. returnErrorMsg("找不到订单记录");
  8230. }
  8231. }
  8232. public void get_erp_billlist()
  8233. {
  8234. DataStruct dStruct = GetPostStruct();
  8235. List<string> lw = new List<string>();
  8236. string title = GetPostString("title");
  8237. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8238. string tid = GetPostString("tid");
  8239. string tids = GetPostString("tids");
  8240. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8241. if (tids.Length > 0)
  8242. {
  8243. tids = "'" + tids + "'";
  8244. tids = tids.Replace(",", "','");
  8245. lw.Add(string.Format("tid in ({0})", tids));
  8246. }
  8247. string shopname = GetPostString("shopname");
  8248. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8249. string buyernick = GetPostString("buyer_nick");
  8250. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8251. string customer = GetPostString("customer");
  8252. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8253. string date1 = GetPostString("date1");
  8254. string date2 = GetPostString("date2");
  8255. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8256. if (dw.Length > 0) lw.Add(dw);
  8257. string price1 = GetPostString("price1");
  8258. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8259. string price2 = GetPostString("price2");
  8260. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8261. string returndate1 = GetPostString("returndate1");
  8262. string returndate2 = GetPostString("returndate2");
  8263. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8264. if (dw1.Length > 0) lw.Add(dw1);
  8265. string billtype = GetPostString("billtype");
  8266. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8267. string billstate = GetPostString("billstate");
  8268. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8269. string usershop = CurrentUser.User.pemShop;
  8270. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8271. dStruct.Order = "createTime desc";
  8272. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8273. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8274. //foreach (DataRow dr in dt.Rows)
  8275. //{
  8276. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8277. //}
  8278. writeGridDataTableJson(dStruct.TotalCount, dt);
  8279. }
  8280. public void modify_erp_billinfo()
  8281. {
  8282. if (UrlPostParmsCheck("ID"))
  8283. {
  8284. string eid = GetPostString("ID");
  8285. CeErpBill bill_entity = null;
  8286. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8287. if (bill_entity != null)
  8288. {
  8289. bill_entity.tid = GetPostString("tid");
  8290. bill_entity.title = GetPostString("title");
  8291. bill_entity.tax = GetPostString("tax");
  8292. bill_entity.bank = GetPostString("bank");
  8293. bill_entity.bankac = GetPostString("bankac");
  8294. bill_entity.address = GetPostString("address");
  8295. bill_entity.phone = GetPostString("phone");
  8296. bill_entity.price = GetPostString("price");
  8297. bill_entity.productId = GetPostInt("ProductName");
  8298. bill_entity.num = GetPostInt("num");
  8299. bill_entity.unit = GetPostString("unit");
  8300. bill_entity.type = GetPostString("type");
  8301. bill_entity.sendType = GetPostString("SendType");
  8302. bill_entity.email = GetPostString("email");
  8303. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8304. bill_entity.shopName = GetPostString("ShopName");
  8305. bill_entity.applymemo = GetPostString("applymemo");
  8306. bill_entity.modifyTime = DateTime.Now;
  8307. bill_entity.createTime = DateTime.Now;
  8308. bill_entity.state = 0;
  8309. bill_entity.Update();
  8310. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8311. returnSuccessMsg("发票修改成功!");
  8312. return;
  8313. }
  8314. returnErrorMsg("找不到对应记录");
  8315. }
  8316. }
  8317. public void set_erp_invoicing()
  8318. {
  8319. if (UrlPostParmsCheck("id"))
  8320. {
  8321. try
  8322. {
  8323. string eid = GetPostString("id");
  8324. CeErpBill bill_entity = null;
  8325. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8326. if (bill_entity != null)
  8327. {
  8328. int ComId = GetPostInt("ComId");
  8329. //string memo = GetPostString("Memo");
  8330. int allInfo = GetPostInt("allinfo");
  8331. string clert = CurrentUser.User.Name;
  8332. //string detailValue = GetPostString("detailvalue");
  8333. string billId = bill_entity.billOrderId;
  8334. string[] billIdList = billId.Split(',');
  8335. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8336. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8337. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8338. {
  8339. billCount += 1;
  8340. }
  8341. if (billId.Length <= 0 || billIdList.Length != billCount)
  8342. {
  8343. bill_entity.billOrderId = "";
  8344. string prebill = "ltb";
  8345. for (int idx = 1; idx <= billCount; idx++)
  8346. {
  8347. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8348. string billoid = prebill + idx + dtstr;
  8349. bill_entity.billOrderId += billoid;
  8350. if (idx < billCount)
  8351. {
  8352. bill_entity.billOrderId += ",";
  8353. }
  8354. }
  8355. }
  8356. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8357. if (bill_entity.state == 5)
  8358. {
  8359. string errMsg = bill_entity.failerror;
  8360. string[] errlist = errMsg.Split('|');
  8361. string[] errTags = new string[errlist.Length];
  8362. for (int itag = 0; itag < errlist.Length; itag++)
  8363. {
  8364. if (errlist[itag].Length <= 0) continue;
  8365. errTags[itag] = errlist[itag].Split('&')[0];
  8366. }
  8367. for (int iii = 0; iii < errTags.Length; iii++)
  8368. {
  8369. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8370. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8371. if (billOrderList.Length >= erroBillOrderTag)
  8372. {
  8373. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8374. if (needModifyBillId.Length <= 19)
  8375. {
  8376. needModifyBillId = needModifyBillId + "1";
  8377. }
  8378. else
  8379. {
  8380. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8381. last = last + 1;
  8382. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8383. }
  8384. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8385. }
  8386. }
  8387. }
  8388. bool isHaveBillSucces = false;
  8389. string totalRes = "";
  8390. bill_entity.failerror = "";
  8391. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8392. {
  8393. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8394. totalRes += res;
  8395. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8396. {
  8397. isHaveBillSucces = true;
  8398. bill_entity.comId = ComId;
  8399. bill_entity.state = 1;
  8400. bill_entity.executeTime = DateTime.Now;
  8401. bill_entity.executeUser = clert;
  8402. }
  8403. else
  8404. {
  8405. bill_entity.state = 5;
  8406. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8407. }
  8408. }
  8409. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8410. bill_entity.Update();
  8411. if (isHaveBillSucces)
  8412. {
  8413. StringBuilder sql = new StringBuilder();
  8414. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8415. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8416. }
  8417. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8418. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8419. {
  8420. returnErrorMsg("开票失败");
  8421. }
  8422. else
  8423. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8424. return;
  8425. }
  8426. returnErrorMsg("找不到对应记录");
  8427. }
  8428. catch (Exception ex)
  8429. {
  8430. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8431. returnErrorMsg("操作失败");
  8432. }
  8433. }
  8434. }
  8435. public void get_erp_invoicing_back()
  8436. {
  8437. if (UrlPostParmsCheck("id"))
  8438. {
  8439. try
  8440. {
  8441. string id = GetPostString("id");
  8442. CeErpBill entiy = CeErpBill.Get(id);
  8443. if (entiy != null)
  8444. {
  8445. if (entiy.state == 0)
  8446. {
  8447. returnErrorMsg("发票还未开具");
  8448. return;
  8449. }
  8450. string[] billOrderList = entiy.billOrderId.Split(',');
  8451. int iTag = 0;
  8452. entiy.fplsh = "";
  8453. entiy.fpdm = "";
  8454. entiy.fphm = "";
  8455. foreach (string billOrderId in billOrderList)
  8456. {
  8457. iTag++;
  8458. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8459. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8460. {
  8461. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8462. try
  8463. {
  8464. Invoicing_get_response_Obj iObj = null;
  8465. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8466. if (iObj != null)
  8467. {
  8468. entiy.state = 2;
  8469. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8470. entiy.fpdm += iObj.list[0].c_fpdm;
  8471. entiy.fphm += iObj.list[0].c_fphm;
  8472. if (iTag < billOrderList.Length)
  8473. {
  8474. entiy.fplsh += ",";
  8475. entiy.fpdm += ",";
  8476. entiy.fphm += ",";
  8477. }
  8478. entiy.Update();
  8479. }
  8480. StringBuilder sql = new StringBuilder();
  8481. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8482. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8483. returnSuccessMsg("开票成功");
  8484. }
  8485. catch (Exception ex)
  8486. {
  8487. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8488. }
  8489. return;
  8490. }
  8491. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8492. {
  8493. var res_obj = new
  8494. {
  8495. data = "开票中"
  8496. };
  8497. string ro_json = JsonConvert.SerializeObject(res_obj);
  8498. returnSuccess(ro_json);
  8499. return;
  8500. }
  8501. else
  8502. {
  8503. int eidx = res.IndexOf("c_resultmsg");
  8504. int lidx = res.IndexOf("c_status");
  8505. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8506. entiy.state = 5;
  8507. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8508. entiy.Update();
  8509. returnErrorMsg("开票失败");
  8510. return;
  8511. }
  8512. }
  8513. }
  8514. }
  8515. catch (Exception ex)
  8516. {
  8517. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8518. }
  8519. return;
  8520. }
  8521. }
  8522. public void get_erp_invoicing()
  8523. {
  8524. if (UrlPostParmsCheck("id"))
  8525. {
  8526. try
  8527. {
  8528. string id = GetPostString("id");
  8529. CeErpBill entiy = CeErpBill.Get(id);
  8530. if (entiy != null)
  8531. {
  8532. if (entiy.state == 0)
  8533. {
  8534. returnErrorMsg("发票还未开具");
  8535. return;
  8536. }
  8537. if (entiy.sendType == "纸质发票")
  8538. {
  8539. if (entiy.img.Length <= 0)
  8540. {
  8541. returnErrorMsg("查无纸质发票");
  8542. return;
  8543. }
  8544. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8545. returnSuccess(returnres);
  8546. return;
  8547. }
  8548. string[] billOrderList = entiy.billOrderId.Split(',');
  8549. int iTag = 0;
  8550. string fpUrl = "";
  8551. entiy.fplsh = "";
  8552. entiy.fpdm = "";
  8553. entiy.fphm = "";
  8554. foreach (string billOrderId in billOrderList)
  8555. {
  8556. iTag++;
  8557. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8558. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8559. {
  8560. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8561. Invoicing_get_response_Obj iObj = null;
  8562. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8563. if (iObj != null)
  8564. {
  8565. //entiy.state = 2;
  8566. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8567. entiy.fpdm += iObj.list[0].c_fpdm;
  8568. entiy.fphm += iObj.list[0].c_fphm;
  8569. if (iTag < billOrderList.Length)
  8570. {
  8571. entiy.fplsh += ",";
  8572. entiy.fpdm += ",";
  8573. entiy.fphm += ",";
  8574. }
  8575. entiy.Update();
  8576. fpUrl += iObj.list[0].c_url + ",";
  8577. }
  8578. //returnSuccess(res);
  8579. StringBuilder sql = new StringBuilder();
  8580. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8581. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8582. }
  8583. else
  8584. {
  8585. int eidx = res.IndexOf("c_resultmsg");
  8586. //int lidx = res.IndexOf("c_status");
  8587. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8588. //开票失败
  8589. entiy.state = 5;
  8590. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8591. entiy.Update();
  8592. returnErrorMsg("开票失败");
  8593. return;
  8594. }
  8595. }
  8596. var returnObj = new
  8597. {
  8598. data = fpUrl
  8599. };
  8600. string ro_json = JsonConvert.SerializeObject(returnObj);
  8601. returnSuccess(ro_json);
  8602. }
  8603. }
  8604. catch (Exception ex)
  8605. {
  8606. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8607. }
  8608. return;
  8609. }
  8610. }
  8611. public void save_erp_billimg()
  8612. {
  8613. if (UrlPostParmsCheck("id"))
  8614. {
  8615. string eid = GetPostString("id");
  8616. CeErpBill bill_entity = null;
  8617. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8618. if (bill_entity != null)
  8619. {
  8620. bill_entity.img = GetPostString("img");
  8621. bill_entity.executeTime = DateTime.Now;
  8622. bill_entity.state = 2;
  8623. bill_entity.Update();
  8624. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8625. returnSuccessMsg("保存成功");
  8626. }
  8627. return;
  8628. }
  8629. }
  8630. public void upd_erp_billreturnback()
  8631. {
  8632. if (UrlPostParmsCheck("id"))
  8633. {
  8634. int eid = GetPostInt("id");
  8635. CeErpBill bill_entity = null;
  8636. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8637. if (bill_entity != null)
  8638. {
  8639. bill_entity.state = 3;
  8640. bill_entity.returnReason = GetPostString("reason");
  8641. bill_entity.Update();
  8642. returnSuccessMsg("驳回成功!");
  8643. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8644. }
  8645. return;
  8646. }
  8647. }
  8648. public void cancel_erp_bill()
  8649. {
  8650. if (UrlPostParmsCheck("id"))
  8651. {
  8652. int eid = GetPostInt("id");
  8653. int detailValue = GetPostInt("detailvalue");
  8654. CeErpBill bill_entity = null;
  8655. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8656. string cres = "";
  8657. string gres = "";
  8658. if (bill_entity != null)
  8659. {
  8660. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8661. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8662. {
  8663. int iTag = 0;
  8664. bill_entity.fplsh = "";
  8665. bill_entity.fpdm = "";
  8666. bill_entity.fphm = "";
  8667. foreach (string billOrderId in billOrderList)
  8668. {
  8669. iTag++;
  8670. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8671. if (gres.IndexOf("success") != -1)
  8672. {
  8673. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8674. Invoicing_get_response_Obj iObj = null;
  8675. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8676. if (iObj != null)
  8677. {
  8678. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8679. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8680. bill_entity.fphm += iObj.list[0].c_fphm;
  8681. if (iTag < billOrderList.Length)
  8682. {
  8683. bill_entity.fplsh += ",";
  8684. bill_entity.fpdm += ",";
  8685. bill_entity.fphm += ",";
  8686. }
  8687. bill_entity.Update();
  8688. }
  8689. }
  8690. else
  8691. {
  8692. returnErrorMsg(gres);
  8693. return;
  8694. }
  8695. }
  8696. }
  8697. if (bill_entity.sendType == "纸质发票")
  8698. {
  8699. //作废
  8700. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8701. //if (DateTime.Now.Month == extime.Month)
  8702. //{
  8703. //cres = taobaoHelper.cancel_invoicing(eid);
  8704. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8705. //{
  8706. bill_entity.state = 4;//已作废
  8707. bill_entity.Update();
  8708. returnSuccessMsg("发票已作废");
  8709. return;
  8710. //}
  8711. //else
  8712. //{
  8713. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8714. // bill_entity.Update();
  8715. // returnErrorMsg(cres);
  8716. // return;
  8717. //}
  8718. //}
  8719. //else
  8720. //{
  8721. // returnErrorMsg("纸质发票只能作废本月的发票");
  8722. // return;
  8723. //}
  8724. }
  8725. //红冲
  8726. int redTag = 0;
  8727. string[] fpdmList = bill_entity.fpdm.Split(',');
  8728. string[] fphmList = bill_entity.fphm.Split(',');
  8729. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8730. {
  8731. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8732. return;
  8733. }
  8734. foreach (string billOrderId in billOrderList)
  8735. {
  8736. redTag++;
  8737. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8738. cres += onecres;
  8739. cres += ",";
  8740. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8741. {
  8742. bill_entity.state = 4;//已作废
  8743. //bill_entity.Update();
  8744. //returnSuccessMsg("发票已红冲");
  8745. }
  8746. else if (onecres.IndexOf("重复冲红") != -1)
  8747. {
  8748. bill_entity.state = 4;//已作废
  8749. //bill_entity.Update();
  8750. //returnSuccessMsg("发票已红冲");
  8751. }
  8752. else
  8753. {
  8754. string errmsg = commonHelper.KeepChinese(onecres);
  8755. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8756. }
  8757. }
  8758. bill_entity.Update();
  8759. if (cres.IndexOf("失败") != -1)
  8760. returnErrorMsg("红冲失败");
  8761. else
  8762. returnSuccessMsg("发票已红冲");
  8763. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8764. return;
  8765. }
  8766. return;
  8767. }
  8768. }
  8769. public void del_erp_billorder()
  8770. {
  8771. if (UrlPostParmsCheck("id"))
  8772. {
  8773. string eid = GetPostString("id");
  8774. CeErpBill.Del(eid);
  8775. CeErpBill bill = CeErpBill.Get(eid);
  8776. if (bill != null)
  8777. {
  8778. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8779. }
  8780. returnSuccessMsg("删除成功");
  8781. }
  8782. }
  8783. public void finish_erp_bill()
  8784. {
  8785. if (UrlPostParmsCheck("ids"))
  8786. {
  8787. string eids = GetPostString("ids");
  8788. string[] list = eids.Split(',');
  8789. foreach (string eid in list)
  8790. {
  8791. CeErpBill bill = CeErpBill.Get(eid);
  8792. if (bill != null)
  8793. {
  8794. bill.state = 2;
  8795. bill.Update();
  8796. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8797. }
  8798. }
  8799. returnSuccessMsg("操作成功");
  8800. }
  8801. }
  8802. public void get_erp_returncash()
  8803. {
  8804. DataStruct dStruct = GetPostStruct();
  8805. List<string> lw = new List<string>();
  8806. string tid = GetPostString("tid");
  8807. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8808. string shopname = GetPostString("shopname");
  8809. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8810. string buyernick = GetPostString("buyer_nick");
  8811. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8812. string customer = GetPostString("customer");
  8813. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8814. string returndate1 = GetPostString("returndate1");
  8815. string returndate2 = GetPostString("returndate2");
  8816. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8817. if (dw.Length > 0) lw.Add(dw);
  8818. string finishDate1 = GetPostString("finishdate1");
  8819. string finishDate2 = GetPostString("finishdate2");
  8820. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8821. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8822. string returntype = GetPostString("returntype");
  8823. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8824. string returnvstate = GetPostString("returnvstate");
  8825. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8826. dStruct.Order = "created desc";
  8827. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8828. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8829. writeGridDataTableJson(dStruct.TotalCount, dt);
  8830. }
  8831. public void get_erp_staygoods()
  8832. {
  8833. DataStruct dStruct = GetPostStruct();
  8834. List<string> lw = new List<string>();
  8835. string tid = GetPostString("tid");
  8836. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8837. string shopname = GetPostString("shopname");
  8838. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8839. string wangwang = GetPostString("wangwang");
  8840. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8841. string customer = GetPostString("customer");
  8842. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8843. string returndate1 = GetPostString("returndate1");
  8844. string returndate2 = GetPostString("returndate2");
  8845. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8846. if (dw.Length > 0) lw.Add(dw);
  8847. string finishDate1 = GetPostString("finishdate1");
  8848. string finishDate2 = GetPostString("finishdate2");
  8849. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8850. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8851. string returnvstate = GetPostString("returnvstate");
  8852. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8853. string persuadetype = GetPostString("persuadetype");
  8854. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8855. string customerOrg = GetPostString("customerOrg");
  8856. if (customerOrg.Length > 0)
  8857. {
  8858. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8859. }
  8860. dStruct.Order = "creata_time desc";
  8861. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8862. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8863. writeGridDataTableJson(dStruct.TotalCount, dt);
  8864. }
  8865. public void upd_erp_staygoods()
  8866. {
  8867. if (UrlPostParmsCheck("id"))
  8868. {
  8869. int eid = GetPostInt("id");
  8870. CeErpStayGoods entity = null;
  8871. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8872. if (entity != null)
  8873. {
  8874. entity.audit_type = 1;
  8875. entity.audit_time = DateTime.Now;
  8876. entity.audit_u_id = CurrentUser.UserID;
  8877. entity.audit_u_name = CurrentUser.UserName;
  8878. entity.Update();
  8879. returnSuccessMsg("审核成功!");
  8880. return;
  8881. }
  8882. returnErrorMsg("找不到订单记录");
  8883. }
  8884. }
  8885. public void upd_erp_stayGoodsback()
  8886. {
  8887. if (UrlPostParmsCheck("id"))
  8888. {
  8889. int eid = GetPostInt("id");
  8890. CeErpStayGoods entity = null;
  8891. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8892. if (entity != null)
  8893. {
  8894. entity.audit_text = GetPostString("reason");
  8895. entity.audit_type = 2;
  8896. entity.audit_time = DateTime.Now;
  8897. entity.audit_u_id = CurrentUser.UserID;
  8898. entity.audit_u_name = CurrentUser.UserName;
  8899. entity.Update();
  8900. returnSuccessMsg("退回成功!");
  8901. return;
  8902. }
  8903. returnErrorMsg("找不到订单记录");
  8904. }
  8905. }
  8906. public void upd_erp_returncashverify()
  8907. {
  8908. if (UrlPostParmsCheck("ID"))
  8909. {
  8910. int eid = GetPostInt("ID");
  8911. CeErpReturnCash entity = null;
  8912. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8913. if (entity != null)
  8914. {
  8915. entity.cashstate = 1;
  8916. entity.verifytime = DateTime.Now;
  8917. entity.verifyuserid = CurrentUser.UserID;
  8918. entity.Update();
  8919. returnSuccessMsg("审核成功!");
  8920. return;
  8921. }
  8922. returnErrorMsg("找不到订单记录");
  8923. }
  8924. }
  8925. public void upd_all_erp_returncashverify()
  8926. {
  8927. if (UrlPostParmsCheck("ID"))
  8928. {
  8929. String[] list = GetPostString("ID").Split(',');
  8930. CeErpReturnCash entity = null;
  8931. for (int i = 0; i < list.Length; i++)
  8932. {
  8933. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8934. if (entity != null)
  8935. {
  8936. if (entity.cashstate == 1)
  8937. {
  8938. returnErrorMsg("已审核过的订单不需要在审核!");
  8939. return;
  8940. }
  8941. entity.cashstate = 1;
  8942. entity.verifytime = DateTime.Now;
  8943. entity.verifyuserid = CurrentUser.UserID;
  8944. entity.Update();
  8945. }
  8946. }
  8947. returnSuccessMsg("审核成功!");
  8948. return;
  8949. }
  8950. }
  8951. public void upd_erp_returncashback()
  8952. {
  8953. if (UrlPostParmsCheck("ID"))
  8954. {
  8955. int eid = GetPostInt("ID");
  8956. CeErpReturnCash entity = null;
  8957. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8958. if (entity != null)
  8959. {
  8960. entity.backreason = GetPostString("reason");
  8961. entity.cashstate = 2;
  8962. entity.verifytime = DateTime.Now;
  8963. entity.verifyuserid = CurrentUser.UserID;
  8964. entity.Update();
  8965. returnSuccessMsg("退回成功!");
  8966. return;
  8967. }
  8968. returnErrorMsg("找不到订单记录");
  8969. }
  8970. }
  8971. public void upd_erp_returnprice()
  8972. {
  8973. if (UrlPostParmsCheck("ID"))
  8974. {
  8975. int eid = GetPostInt("ID");
  8976. CeErpReturnCash entity = null;
  8977. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8978. if (entity != null)
  8979. {
  8980. if (entity.cashstate == 1)
  8981. {
  8982. returnErrorMsg("审核通过了不能改");
  8983. return;
  8984. }
  8985. entity.returnprice = GetPostDouble("returnprice");
  8986. entity.Update();
  8987. returnSuccessMsg("修改成功!");
  8988. return;
  8989. }
  8990. returnErrorMsg("找不到订单记录");
  8991. }
  8992. }
  8993. public void del_erp_returncash()
  8994. {
  8995. if (UrlPostParmsCheck("ID"))
  8996. {
  8997. int eid = GetPostInt("ID");
  8998. CeErpReturnCash.Del(eid);
  8999. returnSuccessMsg("操作成功");
  9000. return;
  9001. }
  9002. }
  9003. public void test_for_do_sql()
  9004. {
  9005. string sql = GetPostString("sqlstr");
  9006. if (sql.Length > 0)
  9007. {
  9008. try
  9009. {
  9010. DbHelper.DbConn.ExecuteNonQuery(sql);
  9011. var res_obj = new
  9012. {
  9013. data = "成功",
  9014. };
  9015. string ro_json = JsonConvert.SerializeObject(res_obj);
  9016. returnSuccess(ro_json);
  9017. }
  9018. catch (Exception ex)
  9019. {
  9020. var res_obj = new
  9021. {
  9022. data = ex.Message,
  9023. };
  9024. string ro_json = JsonConvert.SerializeObject(res_obj);
  9025. returnSuccess(ro_json);
  9026. }
  9027. }
  9028. }
  9029. public void get_user_info()
  9030. {
  9031. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9032. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9033. }
  9034. public void get_total_data()
  9035. {
  9036. int userId = CurrentUser.UserID;
  9037. string sql = "";
  9038. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9039. {
  9040. 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);
  9041. }
  9042. else
  9043. {
  9044. 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 " +
  9045. "(select ID from CE_ErpUser where ID = {0}) d " +
  9046. "left join " +
  9047. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9048. ") a on d.ID = a.id left join " +
  9049. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9050. ") b on a.id = b.id1 left join" +
  9051. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9052. ") c on a.id = c.id2;", userId);
  9053. }
  9054. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9055. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9056. }
  9057. public void get_date_area_total_data2()
  9058. {
  9059. int userId = CurrentUser.UserID;
  9060. string date_type = GetPostString("timetype");
  9061. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9062. string sql = "";
  9063. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9064. {
  9065. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9066. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9067. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9068. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9069. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9070. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9071. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9072. ") a on e.ID = a.id left join " +
  9073. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9074. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9075. ") b on a.id = b.id1 " +
  9076. "left join " +
  9077. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9078. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9079. ") c on a.id = c.id2 " +
  9080. "left join " +
  9081. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9082. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9083. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9084. }
  9085. else
  9086. {
  9087. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9088. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9089. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9090. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9091. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9092. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9093. ") a on e.ID = a.id left join " +
  9094. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9095. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9096. ") c on a.id = c.id2 " +
  9097. "left join " +
  9098. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9099. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9100. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9101. }
  9102. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9103. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9104. }
  9105. public void get_date_area_total_data()
  9106. {
  9107. int userId = CurrentUser.UserID;
  9108. string date_type = GetPostString("timetype");
  9109. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9110. string date1 = searchDT[0].ToString();
  9111. string date2 = searchDT[1].ToString();
  9112. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9113. {
  9114. SqlParameter[] sqlParameter ={
  9115. new SqlParameter("@userId", SqlDbType.Int,4),
  9116. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9117. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9118. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9119. };
  9120. sqlParameter[0].Value = userId;
  9121. sqlParameter[1].Value = date1;
  9122. sqlParameter[2].Value = date2;
  9123. sqlParameter[3].Direction = ParameterDirection.Output;
  9124. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9125. string res = sqlParameter[3].Value.ToString();
  9126. var res_obj = new
  9127. {
  9128. data = res
  9129. };
  9130. string ro_json = JsonConvert.SerializeObject(res_obj);
  9131. returnSuccess(ro_json);
  9132. }
  9133. else
  9134. {
  9135. SqlParameter[] sqlParameter ={
  9136. new SqlParameter("@userId", SqlDbType.Int,4),
  9137. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9138. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9139. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9140. };
  9141. sqlParameter[0].Value = userId;
  9142. sqlParameter[1].Value = date1;
  9143. sqlParameter[2].Value = date2;
  9144. sqlParameter[3].Direction = ParameterDirection.Output;
  9145. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9146. string res = sqlParameter[3].Value.ToString();
  9147. var res_obj = new
  9148. {
  9149. data = res
  9150. };
  9151. string ro_json = JsonConvert.SerializeObject(res_obj);
  9152. returnSuccess(ro_json);
  9153. }
  9154. //writeGridDataViewJson(dt.Rows.Count, dv);
  9155. }
  9156. public void get_order_list()
  9157. {
  9158. string strFields = GetPostString("paraFields");
  9159. string strOrder = GetPostString("paraOrder");
  9160. string strWhere = GetPostString("paraWhere");
  9161. string strPageSize = GetPostString("paraPageSize");
  9162. DataStruct dStruct = GetPostStruct();
  9163. dStruct.PageSize = int.Parse(strPageSize);
  9164. dStruct.Fileds = strFields;
  9165. dStruct.Order = strOrder;
  9166. dStruct.MainWhere = strWhere;
  9167. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9168. writeGridDataTableJson(dStruct.TotalCount, dt);
  9169. }
  9170. ////获取待开始订单列表
  9171. //public void get_wait_design_order_list()
  9172. //{
  9173. // string date_type = GetPostString("date_type");
  9174. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9175. // DataStruct dStruct = GetPostStruct();
  9176. // dStruct.PageSize = 1000;
  9177. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9178. // List<string> lw = new List<string>();
  9179. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9180. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9181. // dStruct.Order = "WaitDesignTime asc";
  9182. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9183. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9184. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9185. //}
  9186. //获取完成单量排名
  9187. public void get_finish_order_count_ranking()
  9188. {
  9189. /* string date_type = GetPostString("date_type");
  9190. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9191. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9192. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9193. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9194. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9195. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9196. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9197. writeGridDataTableJson(0, new DataTable());
  9198. }
  9199. public void get_finish_order_amount_ranking()
  9200. {
  9201. /*string date_type = GetPostString("date_type");
  9202. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9203. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9204. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9205. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9206. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9207. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9208. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9209. writeGridDataTableJson(0, new DataTable());
  9210. }
  9211. public void get_finish_refund_count_ranking()
  9212. {
  9213. string date_type = GetPostString("date_type");
  9214. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9215. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9216. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9217. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9218. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9219. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9220. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9221. writeGridDataTableJson(dt.Rows.Count, dt);
  9222. }
  9223. public void get_finish_refund_amount_ranking()
  9224. {
  9225. string date_type = GetPostString("date_type");
  9226. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9227. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9228. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9229. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9230. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9231. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9232. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9233. writeGridDataTableJson(dt.Rows.Count, dt);
  9234. }
  9235. public void set_erp_finishorder_director()
  9236. {
  9237. if (UrlPostParmsCheck("ctid"))
  9238. {
  9239. string eid = GetPostString("ctid");
  9240. CeErpTradeCell entity = null;
  9241. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9242. if (entity != null)
  9243. {
  9244. entity.OrderState = 8;
  9245. entity.Update();
  9246. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9247. returnSuccessMsg("操作成功!");
  9248. return;
  9249. }
  9250. returnErrorMsg("找不到记录");
  9251. }
  9252. }
  9253. public void get_erp_placeregistlist()
  9254. {
  9255. DataStruct dStruct = GetPostStruct();
  9256. List<string> lw = new List<string>();
  9257. string outsid = GetPostString("outsid");
  9258. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9259. string memo = GetPostString("memo");
  9260. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9261. string filename = GetPostString("filename");
  9262. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9263. string islate = GetPostString("islate");
  9264. if (islate.Length > 0)
  9265. {
  9266. if (islate == "1")
  9267. lw.Add(string.Format("OutLate>0"));
  9268. else
  9269. lw.Add(string.Format("OutLate=0"));
  9270. }
  9271. string placedate1 = GetPostString("placedate1");
  9272. string placedate2 = GetPostString("placedate2");
  9273. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9274. if (dw.Length > 0) lw.Add(dw);
  9275. string deliveryDate1 = GetPostString("deliverydate1");
  9276. string deliveryDate2 = GetPostString("deliverydate2");
  9277. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9278. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9279. dStruct.Order = "ID desc";
  9280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9281. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9282. writeGridDataTableJson(dStruct.TotalCount, dt);
  9283. }
  9284. public void ins_erp_placeregist()
  9285. {
  9286. if (UrlPostParmsCheck("id"))
  9287. {
  9288. string eid = GetPostString("id");
  9289. CeErpPlaceRegister entity = null;
  9290. if (eid == "0")//新增
  9291. {
  9292. entity = new CeErpPlaceRegister();
  9293. string xdTime = GetPostString("placeTime");
  9294. if (xdTime.Length > 0)
  9295. {
  9296. entity.PlactTime = Convert.ToDateTime(xdTime);
  9297. }
  9298. string fhTime = GetPostString("deliveryTime");
  9299. if (fhTime.Length > 0)
  9300. {
  9301. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9302. }
  9303. string preTime = GetPostString("preOutTime");
  9304. if (preTime.Length > 0)
  9305. {
  9306. entity.PreOutTime = Convert.ToDateTime(preTime);
  9307. }
  9308. entity.DeliveryCount = GetPostInt("deliveryCount");
  9309. entity.ReceiveCount = GetPostInt("receiveCount");
  9310. entity.OutSid = GetPostString("outSid");
  9311. entity.FileName = GetPostString("fileName");
  9312. entity.Memo = GetPostString("memo");
  9313. entity.AddUserId = CurrentUser.UserID;
  9314. entity.CreateTime = DateTime.Now;
  9315. entity.Img = GetPostString("img");
  9316. entity.Supplier = GetPostInt("supplier");
  9317. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9318. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9319. {
  9320. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9321. DateTime dt2 = (DateTime)entity.PreOutTime;
  9322. TimeSpan span = dt1.Subtract(dt2);
  9323. if (span.Days > 0)
  9324. {
  9325. entity.OutLate = span.Days;
  9326. }
  9327. }
  9328. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9329. entity.Create();
  9330. returnSuccessMsg("添加成功!");
  9331. return;
  9332. }
  9333. else //修改
  9334. {
  9335. entity = CeErpPlaceRegister.Get(eid);
  9336. if (entity != null)
  9337. {
  9338. string xdTime = GetPostString("placeTime");
  9339. if (xdTime.Length > 0)
  9340. {
  9341. entity.PlactTime = Convert.ToDateTime(xdTime);
  9342. }
  9343. string fhTime = GetPostString("deliveryTime");
  9344. if (fhTime.Length > 0)
  9345. {
  9346. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9347. }
  9348. string preTime = GetPostString("preOutTime");
  9349. if (preTime.Length > 0)
  9350. {
  9351. entity.PreOutTime = Convert.ToDateTime(preTime);
  9352. }
  9353. entity.DeliveryCount = GetPostInt("deliveryCount");
  9354. entity.ReceiveCount = GetPostInt("receiveCount");
  9355. if (entity.DeliveryCount == entity.ReceiveCount)
  9356. {
  9357. entity.CurState = "已完成";
  9358. }
  9359. else
  9360. {
  9361. entity.CurState = "未完成";
  9362. }
  9363. entity.OutSid = GetPostString("outSid");
  9364. entity.FileName = GetPostString("fileName");
  9365. entity.Memo = GetPostString("memo");
  9366. entity.Img = GetPostString("img");
  9367. entity.Supplier = GetPostInt("supplier");
  9368. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9369. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9370. {
  9371. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9372. DateTime dt2 = (DateTime)entity.PreOutTime;
  9373. TimeSpan span = dt1.Subtract(dt2);
  9374. if (span.Days > 0)
  9375. {
  9376. entity.OutLate = span.Days;
  9377. }
  9378. }
  9379. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9380. entity.Update();
  9381. returnSuccessMsg("修改成功");
  9382. return;
  9383. }
  9384. returnErrorMsg("找不到对应的记录");
  9385. return;
  9386. }
  9387. }
  9388. returnErrorMsg("缺少必要参数");
  9389. }
  9390. public void del_erp_placeregist()
  9391. {
  9392. string eid = GetPostString("id");
  9393. CeErpPlaceRegister.Del(eid);
  9394. returnSuccessMsg("删除成功!");
  9395. return;
  9396. }
  9397. public void ins_erp_placeregistbyorder()
  9398. {
  9399. string ctid = GetPostString("ctid");
  9400. if (ctid.Length > 0)
  9401. {
  9402. StringBuilder sql = new StringBuilder();
  9403. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9404. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9405. if (dt.Rows.Count > 0)
  9406. {
  9407. foreach (DataRow dr in dt.Rows)
  9408. {
  9409. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9410. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9411. entity.AddUserId = CurrentUser.UserID;
  9412. entity.tid = dr["tid"].ToString();
  9413. entity.Did = Convert.ToString(dr["ctid"]);
  9414. entity.splitTag = dr["SplitTag"].ToString();
  9415. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9416. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9417. if (pre_ctid.Length > 0)
  9418. {
  9419. sellmemo = sellmemo.Replace(pre_ctid, "");
  9420. }
  9421. sellmemo = sellmemo.Replace("[", "");
  9422. sellmemo = sellmemo.Replace("]", "");
  9423. entity.FileName = sellmemo;
  9424. string count = dr["ProductCount"].ToString();
  9425. int usecount = commonHelper.getIntCountFromString(count);
  9426. entity.DeliveryCount = usecount;
  9427. entity.CurState = "未完成";
  9428. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9429. {
  9430. entity.Supplier = 24;//dl手提袋定制
  9431. }
  9432. else
  9433. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9434. entity.CreateTime = DateTime.Now;
  9435. entity.Create();
  9436. }
  9437. returnSuccessMsg("操作成功");
  9438. return;
  9439. }
  9440. returnErrorMsg("没有找到对应订单");
  9441. return;
  9442. }
  9443. returnErrorMsg("缺少订单编号");
  9444. return;
  9445. }
  9446. public void get_erp_persuadelist()
  9447. {
  9448. DataStruct dStruct = GetPostStruct();
  9449. List<string> lw = new List<string>();
  9450. string ctid = GetPostString("ctid");
  9451. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9452. string shopname = GetPostString("shopname");
  9453. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9454. string buyernick = GetPostString("buyer_nick");
  9455. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9456. string customer = GetPostString("customer");
  9457. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9458. string returndate1 = GetPostString("returndate1");
  9459. string returndate2 = GetPostString("returndate2");
  9460. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9461. if (dw.Length > 0) lw.Add(dw);
  9462. string finishDate1 = GetPostString("finishdate1");
  9463. string finishDate2 = GetPostString("finishdate2");
  9464. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9465. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9466. string persuadetype = GetPostString("persuadetype");
  9467. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9468. string returnvstate = GetPostString("returnvstate");
  9469. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9470. dStruct.Order = "created desc";
  9471. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9472. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9473. writeGridDataTableJson(dStruct.TotalCount, dt);
  9474. }
  9475. public void upd_erp_returnpersuadeback()
  9476. {
  9477. if (UrlPostParmsCheck("ID"))
  9478. {
  9479. int eid = GetPostInt("ID");
  9480. CeErpPersuade entity = null;
  9481. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9482. if (entity != null)
  9483. {
  9484. entity.backreason = GetPostString("reason");
  9485. entity.pstate = 2;
  9486. entity.verifytime = DateTime.Now;
  9487. entity.verifyuserid = CurrentUser.UserID;
  9488. entity.Update();
  9489. returnSuccessMsg("退回成功!");
  9490. return;
  9491. }
  9492. returnErrorMsg("找不到订单记录");
  9493. }
  9494. }
  9495. public void upd_erp_returnpersuadeverify()
  9496. {
  9497. if (UrlPostParmsCheck("ID"))
  9498. {
  9499. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9500. {
  9501. returnErrorMsg("暂无权限审核");
  9502. return;
  9503. }
  9504. int eid = GetPostInt("ID");
  9505. CeErpPersuade entity = null;
  9506. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9507. if (entity != null)
  9508. {
  9509. entity.pstate = 1;
  9510. entity.verifytime = DateTime.Now;
  9511. entity.verifyuserid = CurrentUser.UserID;
  9512. entity.Update();
  9513. returnSuccessMsg("审核成功!");
  9514. return;
  9515. }
  9516. returnErrorMsg("找不到订单记录");
  9517. }
  9518. }
  9519. public void del_erp_persuade()
  9520. {
  9521. if (UrlPostParmsCheck("ID"))
  9522. {
  9523. int eid = GetPostInt("ID");
  9524. CeErpPersuade.Del(eid);
  9525. returnSuccessMsg("操作成功");
  9526. return;
  9527. }
  9528. }
  9529. public void get_erp_oldcustoupload()
  9530. {
  9531. DataStruct dStruct = GetPostStruct();
  9532. List<string> lw = new List<string>();
  9533. string buyernick = GetPostString("buyer_nick");
  9534. if (buyernick.Length > 0)
  9535. {
  9536. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9537. }
  9538. else
  9539. return;
  9540. dStruct.Order = "pay_time desc";
  9541. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9542. DataTable dt = null;
  9543. dt = WebCache.GetData("view_erptradecell", dStruct);
  9544. writeGridDataTableJson(dStruct.TotalCount, dt);
  9545. }
  9546. public void get_erp_checkorderlist()
  9547. {
  9548. DataStruct dStruct = GetPostStruct();
  9549. List<string> lw = new List<string>();
  9550. string tid = GetPostString("ctid");
  9551. if (tid.Length > 0)
  9552. {
  9553. string select_tid = getTidByCtid(tid);
  9554. lw.Add(string.Format("tid='{0}'", select_tid));
  9555. }
  9556. string shopname = GetPostString("shopname");
  9557. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9558. string buyernick = GetPostString("buyer_nick");
  9559. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9560. string customer = GetPostString("customer");
  9561. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9562. string design = GetPostString("design");
  9563. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9564. string orderState = GetPostString("orderState");
  9565. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9566. string address = GetPostString("address");
  9567. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9568. string sellermemo = GetPostString("seller_memo");
  9569. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9570. string supplier = GetPostString("supplier");
  9571. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9572. {
  9573. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9574. }
  9575. else
  9576. {
  9577. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9578. }
  9579. string date1 = GetPostString("date1");
  9580. string date2 = GetPostString("date2");
  9581. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9582. if (dw.Length > 0) lw.Add(dw);
  9583. string placedate1 = GetPostString("placedate1");
  9584. string placedate2 = GetPostString("placedate2");
  9585. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9586. if (fdw.Length > 0) lw.Add(fdw);
  9587. string price1 = GetPostString("price1");
  9588. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9589. string price2 = GetPostString("price2");
  9590. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9591. string checkst = GetPostString("checkstate");
  9592. if (checkst.Length > 0 && "10".Equals(checkst))
  9593. {
  9594. lw.Add(string.Format("CheckOut>0"));
  9595. }
  9596. else
  9597. {
  9598. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9599. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9600. }
  9601. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9602. {
  9603. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9604. }
  9605. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9607. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9608. writeGridDataTableJson(dStruct.TotalCount, dt);
  9609. }
  9610. public void ins_erp_startCheck()
  9611. {
  9612. if (UrlPostParmsCheck("ctid"))
  9613. {
  9614. string eid = GetPostString("ctid");
  9615. CeErpTradeCell entity = null;
  9616. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9617. if (entity != null)
  9618. {
  9619. entity.MemoOpt = 4;
  9620. entity.UpdateTime = DateTime.Now;
  9621. entity.Update();
  9622. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9623. CeErpSukuraData.createInfo(entity.ctid, 6);
  9624. returnSuccessMsg("操作成功!");
  9625. return;
  9626. }
  9627. returnErrorMsg("找不到记录");
  9628. }
  9629. }
  9630. public void upd_erp_sendXlw()
  9631. {
  9632. if (UrlPostParmsCheck("ctid"))
  9633. {
  9634. string eid = GetPostString("ctid");
  9635. CeErpTradeCell entity = null;
  9636. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9637. if (entity != null)
  9638. {
  9639. if (entity.IsSendGift == 1)
  9640. {
  9641. returnErrorMsg("请勿重复标记");
  9642. return;
  9643. }
  9644. entity.IsSendGift = 1;
  9645. entity.Update();
  9646. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9647. returnSuccessMsg("操作成功!");
  9648. return;
  9649. }
  9650. returnErrorMsg("找不到记录");
  9651. }
  9652. }
  9653. public void cancel_sendXlw()
  9654. {
  9655. if (UrlPostParmsCheck("ctid"))
  9656. {
  9657. string eid = GetPostString("ctid");
  9658. CeErpTradeCell entity = null;
  9659. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9660. if (entity != null)
  9661. {
  9662. if (entity.IsSendGift == 0)
  9663. {
  9664. returnErrorMsg("未标记小礼物");
  9665. return;
  9666. }
  9667. entity.IsSendGift = 0;
  9668. entity.Update();
  9669. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9670. returnSuccessMsg("操作成功!");
  9671. return;
  9672. }
  9673. returnErrorMsg("找不到记录");
  9674. }
  9675. }
  9676. public void get_erp_designbill()
  9677. {
  9678. DataStruct dStruct = GetPostStruct();
  9679. List<string> lw = new List<string>();
  9680. int isMy = GetInt("my");
  9681. if (isMy == 1)
  9682. {
  9683. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9684. }
  9685. string tid = GetPostString("tid");
  9686. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9687. string userName = GetPostString("design");
  9688. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9689. string price1 = GetPostString("price1");
  9690. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9691. string price2 = GetPostString("price2");
  9692. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9693. string rePrice1 = GetPostString("rePrice1");
  9694. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9695. string rePrice2 = GetPostString("rePrice2");
  9696. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9697. string designerType = GetPostString("designerType");
  9698. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9699. string orderState = GetPostString("orderState");
  9700. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9701. string endTime1 = GetPostString("endTime1");
  9702. string endTime2 = GetPostString("endTime2");
  9703. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9704. if (dw.Length > 0) lw.Add(dw);
  9705. string isDk = GetPostString("isDk");
  9706. if (isDk == "1")
  9707. {
  9708. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9709. }
  9710. else if (isDk == "0")
  9711. {
  9712. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9713. }
  9714. dStruct.Order = "oid, create_time desc";
  9715. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9716. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9717. writeGridDataTableJson(dStruct.TotalCount, dt);
  9718. }
  9719. public void upd_erp_designerbill()
  9720. {
  9721. if (UrlPostParmsCheck("ID"))
  9722. {
  9723. string eid = GetPostString("ID");
  9724. CeErpDesignerBill entity = null;
  9725. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9726. if (entity != null)
  9727. {
  9728. if (GetPostDouble("designerpirce") > 0)
  9729. {
  9730. entity.realPrice = GetPostDouble("designerpirce");
  9731. entity.update_time = DateTime.Now;
  9732. entity.update_u_id = CurrentUser.UserID;
  9733. entity.update_u_name = CurrentUser.UserName;
  9734. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9735. entity.Update();
  9736. returnSuccessMsg("操作成功!");
  9737. return;
  9738. }
  9739. else
  9740. {
  9741. entity.price = GetPostDouble("price");
  9742. entity.update_time = DateTime.Now;
  9743. entity.update_u_id = CurrentUser.UserID;
  9744. entity.update_u_name = CurrentUser.UserName;
  9745. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9746. entity.Update();
  9747. returnSuccessMsg("操作成功!");
  9748. return;
  9749. }
  9750. }
  9751. returnErrorMsg("找不到记录");
  9752. }
  9753. }
  9754. public void audit_erp_designerbill()
  9755. {
  9756. if (UrlPostParmsCheck("ID"))
  9757. {
  9758. string eid = GetPostString("ID");
  9759. CeErpDesignerBill entity = null;
  9760. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9761. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9762. if (entity != null)
  9763. {
  9764. entity.realPrice = GetPostDouble("designerpirce");
  9765. entity.update_time = DateTime.Now;
  9766. entity.update_u_id = CurrentUser.UserID;
  9767. entity.update_u_name = CurrentUser.UserName;
  9768. entity.isAudit = 1;
  9769. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9770. entity.Update();
  9771. if (orderEntity != null)
  9772. {
  9773. orderEntity.IsReadTag = 3;
  9774. orderEntity.Update();
  9775. }
  9776. returnSuccessMsg("操作成功!");
  9777. return;
  9778. }
  9779. returnErrorMsg("找不到记录");
  9780. }
  9781. }
  9782. public void all_audit_erp_designerbill()
  9783. {
  9784. if (UrlPostParmsCheck("idList"))
  9785. {
  9786. string[] list = GetPostString("idList").Split(',');
  9787. CeErpDesignerBill entity = null;
  9788. for (int i = 0; i < list.Length; i++)
  9789. {
  9790. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9791. if (entity == null) return;
  9792. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9793. if (orderEntity == null) return;
  9794. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9795. entity.update_time = DateTime.Now;
  9796. entity.update_u_id = CurrentUser.UserID;
  9797. entity.update_u_name = CurrentUser.UserName;
  9798. entity.isAudit = 1;
  9799. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9800. entity.Update();
  9801. orderEntity.IsReadTag = 3;
  9802. orderEntity.Update();
  9803. }
  9804. returnSuccessMsg("操作成功!");
  9805. return;
  9806. }
  9807. }
  9808. public void get_erp_sameorders()
  9809. {
  9810. if (UrlPostParmsCheck("ctid"))
  9811. {
  9812. string eid = GetPostString("ctid");
  9813. CeErpTradeCell entity = null;
  9814. entity = CeErpTradeCell.GetByCtid(eid);
  9815. if (entity != null)
  9816. {
  9817. StringBuilder sql = new StringBuilder();
  9818. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9819. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9820. var res = new
  9821. {
  9822. data = dt.Rows.Count
  9823. };
  9824. string ro_jsond = JsonConvert.SerializeObject(res);
  9825. returnSuccess(ro_jsond);
  9826. return;
  9827. }
  9828. returnErrorMsg("未找到订单");
  9829. return;
  9830. }
  9831. returnErrorMsg("缺少必要的参数");
  9832. }
  9833. public void get_erp_islasthavesameorder()
  9834. {
  9835. if (UrlPostParmsCheck("ctid"))
  9836. {
  9837. string eid = GetPostString("ctid");
  9838. string[] ctidList = eid.Split(',');
  9839. StringBuilder sql = new StringBuilder();
  9840. string tisCtid = "";
  9841. foreach (string ctid in ctidList)
  9842. {
  9843. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9844. if (entity != null)
  9845. {
  9846. sql = new StringBuilder();
  9847. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9848. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9849. if (dth.Rows.Count > 0)
  9850. {
  9851. tisCtid += entity.ctid;
  9852. tisCtid += ",";
  9853. }
  9854. }
  9855. }
  9856. if (tisCtid.Length > 0)
  9857. {
  9858. var res = new
  9859. {
  9860. data = tisCtid
  9861. };
  9862. string ro_jsond = JsonConvert.SerializeObject(res);
  9863. returnSuccess(ro_jsond);
  9864. }
  9865. else
  9866. {
  9867. var res = new
  9868. {
  9869. data = ""
  9870. };
  9871. string ro_jsond = JsonConvert.SerializeObject(res);
  9872. returnSuccess(ro_jsond);
  9873. }
  9874. return;
  9875. }
  9876. returnErrorMsg("缺少必要的参数");
  9877. }
  9878. public void file_client_down_url()
  9879. {
  9880. if (!UrlPostParmsCheck("userId"))
  9881. {
  9882. returnErrorMsg("缺少必要的参数");
  9883. }
  9884. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9885. }
  9886. public void checkout_form_data()
  9887. {
  9888. if (!UrlPostParmsCheck("tid"))
  9889. {
  9890. returnErrorMsg("缺少必要的参数");
  9891. }
  9892. string tid = GetPostString("tid");
  9893. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9894. if (ceErpOrderFormData != null)
  9895. {
  9896. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9897. returnSuccess(ro_jsond);
  9898. return;
  9899. }
  9900. returnErrorMsg("尚未有文件!");
  9901. }
  9902. public void back_supplier_audit()
  9903. {
  9904. int userId = CurrentUser.UserID;
  9905. StringBuilder sql = new StringBuilder();
  9906. 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);
  9907. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9908. if (dt.Rows.Count > 0)
  9909. {
  9910. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9911. }
  9912. else
  9913. {
  9914. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9915. }
  9916. }
  9917. public void back_supplier_query()
  9918. {
  9919. string eid = GetPostString("ctid");
  9920. if (eid != "")
  9921. {
  9922. StringBuilder sql = new StringBuilder();
  9923. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9924. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9925. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9926. }
  9927. else
  9928. {
  9929. returnErrorMsg("找不到订单记录");
  9930. return;
  9931. }
  9932. }
  9933. public void verified_to_order()
  9934. {
  9935. int userId = CurrentUser.UserID;
  9936. StringBuilder sql = new StringBuilder();
  9937. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9938. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9939. if (dt.Rows.Count > 0)
  9940. {
  9941. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9942. }
  9943. else
  9944. {
  9945. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9946. }
  9947. }
  9948. public void upd_supplier_audit()
  9949. {
  9950. if (UrlPostParmsCheck("ctid"))
  9951. {
  9952. string eid = GetPostString("ctid");
  9953. string reason = GetPostString("returnreason");
  9954. CeErpTradeCell entity = null;
  9955. CeWithdraw withdraw = null;
  9956. withdraw = CeWithdraw.GetByTid(eid);
  9957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9958. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9959. {
  9960. if (withdraw != null)
  9961. {
  9962. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9963. {
  9964. returnSuccessMsg("您没有权限操作!");
  9965. return;
  9966. }
  9967. else
  9968. {
  9969. if (reason.Equals("1"))
  9970. {
  9971. if (entity.OrderState == -1)
  9972. {
  9973. if (entity.FinishPlaceTime == null)
  9974. {
  9975. entity.OrderState = 2;
  9976. }
  9977. else
  9978. {
  9979. entity.OrderState = 6;
  9980. }
  9981. }
  9982. entity.Update();
  9983. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9984. if (withdraw != null)
  9985. {
  9986. withdraw.status = int.Parse(reason);
  9987. withdraw.Update();
  9988. }
  9989. returnSuccessMsg("操作成功!");
  9990. return;
  9991. }
  9992. else
  9993. {
  9994. withdraw.status = int.Parse(reason);
  9995. withdraw.acknowledgingtime = DateTime.Now;
  9996. withdraw.Update();
  9997. returnSuccessMsg("查看详细请点击线下订单查询");
  9998. return;
  9999. }
  10000. }
  10001. }
  10002. // 第一个字符是 'N'
  10003. }
  10004. if (eid[0] != 'N')
  10005. {
  10006. }
  10007. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10008. {
  10009. entity.IsVerifyToSupplier = false;
  10010. entity.IsReturn = 1;
  10011. entity.ReturnTime = DateTime.Now;
  10012. entity.ReturnReason = reason;
  10013. if (entity.OrderState == 6)
  10014. {
  10015. entity.OrderState = 5;
  10016. }
  10017. entity.Update();
  10018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10019. if (withdraw != null)
  10020. {
  10021. withdraw.status = int.Parse(reason);
  10022. withdraw.Update();
  10023. }
  10024. returnSuccessMsg("操作成功!");
  10025. return;
  10026. }
  10027. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10028. {
  10029. ;
  10030. if (withdraw != null)
  10031. {
  10032. withdraw.status = int.Parse(reason);
  10033. withdraw.acknowledgingtime = DateTime.Now;
  10034. withdraw.Update();
  10035. returnSuccessMsg("供应商取消撤回!");
  10036. return;
  10037. }
  10038. }
  10039. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10040. {
  10041. if (entity.OrderState == -1)
  10042. {
  10043. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10044. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10045. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10046. {
  10047. returnErrorMsg("台湾客户需填写身份证!");
  10048. return;
  10049. }
  10050. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10051. {
  10052. returnErrorMsg("偏远地区需要填写物流费!");
  10053. return;
  10054. }
  10055. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10056. {
  10057. returnErrorMsg("订单spu没有确认无法通过审核!");
  10058. return;
  10059. }
  10060. if (entity.FinishPlaceTime == null)
  10061. {
  10062. entity.OrderState = 2;
  10063. }
  10064. else
  10065. {
  10066. entity.OrderState = 3;
  10067. }
  10068. commonHelper.getCytPrice(entity);
  10069. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10070. {
  10071. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10072. }
  10073. }
  10074. entity.Update();
  10075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10076. if (withdraw != null)
  10077. {
  10078. withdraw.status = int.Parse(reason);
  10079. withdraw.Update();
  10080. }
  10081. returnSuccessMsg("操作成功!");
  10082. return;
  10083. }
  10084. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10085. {
  10086. if (withdraw == null)
  10087. {
  10088. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10089. return;
  10090. }
  10091. }
  10092. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10093. {
  10094. if (withdraw != null)
  10095. {
  10096. withdraw.status = int.Parse(reason);
  10097. withdraw.acknowledgingtime = DateTime.Now;
  10098. withdraw.Update();
  10099. returnSuccessMsg("查看详细请点击线下订单查询");
  10100. return;
  10101. }
  10102. }
  10103. return;
  10104. }
  10105. }
  10106. //校验报价
  10107. public void refund_order_tip()
  10108. {
  10109. int userid = CurrentUser.UserID;
  10110. int sectionId = CurrentUser.UserPost.OrgID;
  10111. StringBuilder sql = new StringBuilder();
  10112. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10113. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10114. List<string> ids = new List<string>();
  10115. if (dth.Rows.Count > 0)
  10116. {
  10117. foreach (DataRow dr in dth.Rows)
  10118. {
  10119. ids.Add(dr["ID"].ToString());
  10120. }
  10121. try
  10122. {
  10123. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10124. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10125. }
  10126. catch (Exception ex)
  10127. {
  10128. }
  10129. }
  10130. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10131. }
  10132. public void refund_order_Design()
  10133. {
  10134. int userid = CurrentUser.UserID;
  10135. int sectionId = CurrentUser.UserPost.OrgID;
  10136. StringBuilder sql = new StringBuilder();
  10137. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10138. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10139. List<string> ids = new List<string>();
  10140. if (dth.Rows.Count > 0)
  10141. {
  10142. foreach (DataRow dr in dth.Rows)
  10143. {
  10144. ids.Add(dr["ID"].ToString());
  10145. }
  10146. try
  10147. {
  10148. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10149. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10150. }
  10151. catch (Exception ex)
  10152. {
  10153. }
  10154. }
  10155. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10156. }
  10157. public void change_order_info()
  10158. {
  10159. int userid = CurrentUser.UserID;
  10160. StringBuilder sql = new StringBuilder();
  10161. 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);
  10162. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10163. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10164. }
  10165. public void change_win_mome()
  10166. {
  10167. if (UrlPostParmsCheck("id,ctid"))
  10168. {
  10169. string id = GetPostString("id");
  10170. string ctid = GetPostString("ctid");
  10171. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10172. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10173. if (ce == null || ceErpMessageTip == null)
  10174. {
  10175. returnSuccessMsg("未找到对应的订单!");
  10176. return;
  10177. }
  10178. if (ce.OrderState >= 5)
  10179. {
  10180. ceErpMessageTip.isVisit = true;
  10181. ceErpMessageTip.Update();
  10182. returnSuccessMsg("已上传文件无法修改!");
  10183. return;
  10184. }
  10185. int type = GetPostInt("type");
  10186. string content = GetPostString("content");
  10187. if (type == 0)
  10188. {
  10189. content = content.Replace("(", "(");
  10190. content = content.Replace(")", ")");
  10191. string check = MidStrEx(content, "(", ")").Trim();
  10192. if (string.IsNullOrEmpty(check))
  10193. {
  10194. returnSuccessMsg("文件名格式不正确");
  10195. return;
  10196. }
  10197. }
  10198. ce.seller_memo = content;
  10199. ce.Update();
  10200. ceErpMessageTip.isVisit = true;
  10201. ceErpMessageTip.Update();
  10202. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10203. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10204. ApiVo apiVo = new ApiVo();
  10205. apiVo.orderNumber = ce.ctid;
  10206. apiVo.actionName = "demandDesign";
  10207. apiVo.orderRemarks = content;
  10208. apiVo.demandExamine = type + 1;
  10209. designHelper.API_WorkCore(apiVo);//demandDesign
  10210. returnSuccessMsg("修改成功!");
  10211. }
  10212. }
  10213. public static string MidStrEx(string sourse, string startstr, string endstr)
  10214. {
  10215. string result = string.Empty;
  10216. int startindex, endindex;
  10217. try
  10218. {
  10219. startindex = sourse.IndexOf(startstr);
  10220. if (startindex == -1)
  10221. return result;
  10222. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10223. endindex = tmpstr.IndexOf(endstr);
  10224. if (endindex == -1)
  10225. return result;
  10226. result = tmpstr.Remove(endindex);
  10227. }
  10228. catch (Exception ex)
  10229. {
  10230. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10231. }
  10232. return result;
  10233. }
  10234. public void refund_order_list()
  10235. {
  10236. int userid = CurrentUser.UserID;
  10237. int sectionId = CurrentUser.UserPost.OrgID;
  10238. StringBuilder sql = new StringBuilder();
  10239. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10240. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10241. DataStruct dStruct = GetPostStruct();
  10242. DataTable dt = null;
  10243. List<string> ids = new List<string>();
  10244. List<string> tids = new List<string>();
  10245. if (dth.Rows.Count > 0)
  10246. {
  10247. foreach (DataRow dr in dth.Rows)
  10248. {
  10249. tids.Add("'" + dr["tid"].ToString() + "'");
  10250. ids.Add(dr["id"].ToString());
  10251. }
  10252. try
  10253. {
  10254. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10255. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10256. List<string> lw = new List<string>();
  10257. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10258. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10259. dt = WebCache.GetData("view_orderlist", dStruct);
  10260. }
  10261. catch (Exception ex)
  10262. {
  10263. }
  10264. }
  10265. writeGridDataTableJson(dStruct.TotalCount, dt);
  10266. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10267. }
  10268. //新增
  10269. public void order_batch_downloads()
  10270. {
  10271. string ceid = GetPostString("tid");
  10272. String[] tid = ceid.Split(',');
  10273. order_batch_caiyingtong(tid);
  10274. /* (string success, string errors) = UploadFiles(tid);
  10275. returnSuccessMsg(success + errors);*/
  10276. return;
  10277. }
  10278. //报价接口
  10279. public void Get_To_Quote()
  10280. {
  10281. string ceid = GetPostString("ctid");
  10282. if (ceid != null)
  10283. {
  10284. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10285. if (entity != null)
  10286. {
  10287. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10288. {
  10289. return;
  10290. }
  10291. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10292. double price = 0;
  10293. if (cp == null)
  10294. {
  10295. JObject jsonObject12 = new JObject
  10296. {
  10297. { "UserId", "77886" },
  10298. { "Pwd", "lt666888" },
  10299. { "Filename", entity.seller_memo }
  10300. };
  10301. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10302. JObject jsonObjects1 = JObject.Parse(response1);
  10303. string ms1g = (string)jsonObjects1["msg"];
  10304. if (ms1g == "报价成功")
  10305. {
  10306. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10307. string data = (string)jsonObject1["price"];
  10308. 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 + "');";
  10309. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10310. returnSuccessMsg("获取报价成功:" + data);
  10311. price = Convert.ToDouble(data);
  10312. }
  10313. else
  10314. {
  10315. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10316. return;
  10317. }
  10318. }
  10319. String[] beizhu = entity.seller_memo.Split('-');
  10320. String chanp = "";
  10321. if (beizhu.Length > 0)
  10322. {
  10323. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10324. }
  10325. else
  10326. {
  10327. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10328. }
  10329. JObject jsonObject = new JObject
  10330. {
  10331. { "UserId", "77886" },
  10332. { "Pwd", "lt666888" },
  10333. { "Filename", chanp }
  10334. };
  10335. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10336. JObject jsonObjects = JObject.Parse(response);
  10337. string msg = (string)jsonObjects["msg"];
  10338. if (msg == "报价成功")
  10339. {
  10340. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10341. string data = (string)jsonObject1["price"];
  10342. 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 + "');";
  10343. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10344. returnSuccessMsg("获取报价成功:" + data);
  10345. price = Convert.ToDouble(data);
  10346. }
  10347. else
  10348. {
  10349. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10350. return;
  10351. }
  10352. if (price > 0)
  10353. {
  10354. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10355. if (ceErpTradeCellExtend == null)
  10356. {
  10357. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10358. ceErpTradeCellExtend.ctid = entity.ctid;
  10359. ceErpTradeCellExtend.payment_cyt = price;
  10360. ceErpTradeCellExtend.Create();
  10361. }
  10362. else
  10363. {
  10364. ceErpTradeCellExtend.payment_cyt = price;
  10365. ceErpTradeCellExtend.Update();
  10366. }
  10367. }
  10368. return;
  10369. }
  10370. }
  10371. else
  10372. {
  10373. returnErrorMsg("请至少选择一条数据");
  10374. return;
  10375. }
  10376. }
  10377. //新增
  10378. public void order_To_Supplier()
  10379. {
  10380. string ceid = GetPostString("tid");
  10381. String[] tid = ceid.Split(',');
  10382. if (tid.Length > 0)
  10383. {
  10384. try
  10385. {
  10386. for (int i = 0; i < tid.Length; i++)
  10387. {
  10388. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10389. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10390. entity.SupplierId = suid;
  10391. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10392. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10393. entity.Update();
  10394. }
  10395. }
  10396. catch (Exception ex)
  10397. {
  10398. returnErrorMsg("自动匹配供应商失败");
  10399. return;
  10400. }
  10401. }
  10402. else
  10403. {
  10404. returnErrorMsg("请至少选择一条数据");
  10405. return;
  10406. }
  10407. returnSuccessMsg("自动匹配供应商成功");
  10408. return;
  10409. }
  10410. public (string, string) UploadFiles(string[] urls)
  10411. {
  10412. string success = "";
  10413. string errors = "";
  10414. int userid = CurrentUser.UserID;
  10415. foreach (string url in urls)
  10416. {
  10417. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10418. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10419. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10420. {
  10421. JObject jsonObject = new JObject
  10422. {
  10423. { "Userid", "77886" },
  10424. { "pwd", "cyt86435015" },
  10425. { "content", base64FileContent },
  10426. { "ext", Path.GetExtension(fileName) }
  10427. };
  10428. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10429. JObject jsonObjects = JObject.Parse(response);
  10430. string msg = (string)jsonObjects["msg"];
  10431. if (msg.Equals("上传成功"))
  10432. {
  10433. success += url + " 上传成功";
  10434. }
  10435. else
  10436. {
  10437. errors += url + " 上传失败";
  10438. }
  10439. }
  10440. else
  10441. {
  10442. errors += url + " 格式出现问题";
  10443. }
  10444. }
  10445. if (urls.Length == 0)
  10446. {
  10447. return (success, errors);
  10448. }
  10449. return (success, errors);
  10450. }
  10451. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10452. {
  10453. return true; //总是接受
  10454. }
  10455. public static string HttpPost(string url, string param = null)
  10456. {
  10457. HttpWebRequest request;
  10458. //如果是发送HTTPS请求
  10459. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10460. {
  10461. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10462. request = WebRequest.Create(url) as HttpWebRequest;
  10463. request.ProtocolVersion = HttpVersion.Version10;
  10464. }
  10465. else
  10466. {
  10467. request = WebRequest.Create(url) as HttpWebRequest;
  10468. }
  10469. request.Method = "POST";
  10470. request.ContentType = "application/json";
  10471. request.Accept = "*/*";
  10472. request.Timeout = 120000;
  10473. request.AllowAutoRedirect = false;
  10474. StreamWriter requestStream = null;
  10475. WebResponse response = null;
  10476. string responseStr = null;
  10477. try
  10478. {
  10479. requestStream = new StreamWriter(request.GetRequestStream());
  10480. requestStream.Write(param);
  10481. requestStream.Close();
  10482. response = request.GetResponse();
  10483. if (response != null)
  10484. {
  10485. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10486. responseStr = reader.ReadToEnd();
  10487. reader.Close();
  10488. }
  10489. }
  10490. catch (Exception ex)
  10491. {
  10492. return ex.Message;
  10493. }
  10494. finally
  10495. {
  10496. request = null;
  10497. requestStream = null;
  10498. response = null;
  10499. }
  10500. return responseStr;
  10501. }
  10502. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10503. {
  10504. string base64FileContent;
  10505. string fileName;
  10506. using (WebClient webClient = new WebClient())
  10507. {
  10508. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10509. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10510. {
  10511. using (Stream stream = response.GetResponseStream())
  10512. {
  10513. using (MemoryStream memoryStream = new MemoryStream())
  10514. {
  10515. stream.CopyTo(memoryStream);
  10516. byte[] fileBytes = memoryStream.ToArray();
  10517. base64FileContent = Convert.ToBase64String(fileBytes);
  10518. fileName = response.Headers["Content-Disposition"];
  10519. if (!string.IsNullOrEmpty(fileName))
  10520. {
  10521. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10522. if (index >= 0)
  10523. {
  10524. fileName = fileName.Substring(index + 9).Trim('\"');
  10525. }
  10526. }
  10527. else
  10528. {
  10529. fileName = Path.GetFileName(downloadUrl);
  10530. }
  10531. }
  10532. }
  10533. }
  10534. }
  10535. return (fileName, base64FileContent);
  10536. }
  10537. //新增
  10538. public void order_batch_caiyingtong(string[] downloadUrls)
  10539. {
  10540. try
  10541. {
  10542. //遍历文件
  10543. DataStruct dStruct = GetPostStruct();
  10544. DataTable dt = null;
  10545. int userid = CurrentUser.UserID;
  10546. List<string> ids = new List<string>();//失败组
  10547. List<string> tids = new List<string>();
  10548. using (WebClient webClient = new WebClient())
  10549. {
  10550. foreach (var url in downloadUrls)
  10551. {
  10552. try
  10553. {
  10554. tids.Add("'" + url + "'");
  10555. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10556. if (entity != null)
  10557. {
  10558. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10559. if (cp == null)
  10560. {
  10561. JObject jsonObject = new JObject
  10562. {
  10563. { "Userid", "77886" },
  10564. { "pwd", "lt666888" },
  10565. { "Filename",entity.seller_memo }
  10566. };
  10567. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10568. JObject jsonObjects = JObject.Parse(response);
  10569. string msg = (string)jsonObjects["msg"];
  10570. if (msg == "报价成功")
  10571. {
  10572. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10573. DownloadAndConvertToBase64(url1);
  10574. }
  10575. else
  10576. {
  10577. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10578. }
  10579. }
  10580. else
  10581. {
  10582. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10583. JObject jsonObject = new JObject
  10584. {
  10585. { "Userid", "77886" },
  10586. { "pwd", "lt666888" },
  10587. { "Filename",chanp }
  10588. };
  10589. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10590. JObject jsonObjects = JObject.Parse(response);
  10591. string msg = (string)jsonObjects["msg"];
  10592. if (msg == "报价成功")
  10593. {
  10594. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10595. DownloadAndConvertToBase64(url1);
  10596. }
  10597. else
  10598. {
  10599. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10600. }
  10601. }
  10602. }
  10603. // 上传文件到FTP
  10604. }
  10605. catch (Exception ex)
  10606. {
  10607. Console.WriteLine($"An error occurred: {ex.Message}");
  10608. }
  10609. }
  10610. List<string> lw = new List<string>();
  10611. lw.Add(string.Format("( OrderState < 6 )"));
  10612. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10613. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10614. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10615. if (dt.Rows.Count > 0)
  10616. {
  10617. foreach (DataRow dr in dt.Rows)
  10618. {
  10619. ids.Add(dr["ctid"].ToString());
  10620. }
  10621. }
  10622. String ErrorMsgs = "";
  10623. foreach (String id in ids)
  10624. {
  10625. ErrorMsgs += id + ",";
  10626. }
  10627. if (ErrorMsgs.Length > 1)
  10628. {
  10629. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10630. }
  10631. if (ErrorMsgs.Length < 1)
  10632. {
  10633. ErrorMsgs = "上传成功";
  10634. returnSuccessMsg(ErrorMsgs);
  10635. }
  10636. else
  10637. {
  10638. returnErrorMsg("以下订单" + ErrorMsgs);
  10639. }
  10640. }
  10641. // 删除文件夹及其内容
  10642. /* Directory.Delete(localDirectory, true);*/
  10643. }
  10644. catch { }
  10645. }
  10646. public void get_center_data()
  10647. {
  10648. int userId = CurrentUser.UserID;
  10649. string postCode = CurrentUser.UserPost.Post.Code;
  10650. List<string> lw = new List<string>();
  10651. List<string> ww = new List<string>();
  10652. DateTime currentTime = DateTime.Now;
  10653. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10654. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10655. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10656. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10657. string sql = " SELECT ";
  10658. string startTime = "2023-10-01 11:22:31";
  10659. //设计
  10660. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10661. {
  10662. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10663. 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));
  10664. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10665. 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));
  10666. }
  10667. //客服
  10668. else if (postCode == "CustomerService" || postCode == "Director")
  10669. {
  10670. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10671. 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));
  10672. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10673. 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));
  10674. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10675. 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));
  10676. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10677. 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));
  10678. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10679. 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));
  10680. }
  10681. //售后
  10682. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10683. {
  10684. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10685. 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));
  10686. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10687. 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));
  10688. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10689. 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));
  10690. }
  10691. //下单部
  10692. else if (postCode == "Place" || postCode == "PlaceMr")
  10693. {
  10694. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10695. 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));
  10696. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10697. 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));
  10698. }
  10699. //车间
  10700. else if (postCode == "Supplier")
  10701. {
  10702. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10703. 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));
  10704. }
  10705. DataTable dt = new DataTable();
  10706. if (lw.Count > 0)
  10707. {
  10708. sql += string.Join(" , ", lw);
  10709. sql += " FROM ";
  10710. sql += string.Join(" , ", ww);
  10711. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10712. }
  10713. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10714. }
  10715. public void get_center_data_list()
  10716. {
  10717. int userId = CurrentUser.UserID;
  10718. string postCode = CurrentUser.UserPost.Post.Code;
  10719. string shopIds = CurrentUser.User.pemShop;
  10720. DataStruct dStruct = GetPostStruct();
  10721. List<string> lw = new List<string>();
  10722. DateTime currentTime = DateTime.Now;
  10723. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10724. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10725. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10726. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10727. string startTime = "2023-10-01 11:22:31";
  10728. int order_type = GetPostInt("order_type");
  10729. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10730. {
  10731. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10732. if (order_type == 0)
  10733. {
  10734. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10735. }
  10736. else if (order_type == 3)
  10737. {
  10738. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10739. }
  10740. else
  10741. {
  10742. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10743. }
  10744. }
  10745. //客服
  10746. if (postCode == "CustomerService" || postCode == "Director")
  10747. {
  10748. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10749. if (order_type == 0)
  10750. {
  10751. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10752. }
  10753. else if (order_type == 1)
  10754. {
  10755. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10756. }
  10757. else if (order_type == 2)
  10758. {
  10759. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10760. }
  10761. else if (order_type == 3)
  10762. {
  10763. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10764. }
  10765. else if (order_type == 4)
  10766. {
  10767. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10768. }
  10769. else
  10770. {
  10771. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10772. }
  10773. }
  10774. //售后
  10775. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10776. {
  10777. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10778. if (shopIds != "")
  10779. {
  10780. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10781. }
  10782. if (order_type == 2)
  10783. {
  10784. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10785. }
  10786. else if (order_type == 4)
  10787. {
  10788. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10789. }
  10790. else if (order_type == 5)
  10791. {
  10792. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10793. }
  10794. else
  10795. {
  10796. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10797. }
  10798. }
  10799. //下单部
  10800. if (postCode == "Place" || postCode == "PlaceMr")
  10801. {
  10802. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10803. if (shopIds != "")
  10804. {
  10805. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10806. }
  10807. else if (order_type == 1)
  10808. {
  10809. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10810. }
  10811. else if (order_type == 2)
  10812. {
  10813. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10814. }
  10815. else
  10816. {
  10817. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10818. }
  10819. }
  10820. //车间
  10821. if (postCode == "Supplier")
  10822. {
  10823. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10824. if (order_type == 5)
  10825. {
  10826. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10827. }
  10828. else
  10829. {
  10830. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10831. }
  10832. }
  10833. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10834. dStruct.Fileds = "tid,ctid";
  10835. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10836. writeGridDataTableJson(dStruct.TotalCount, dt);
  10837. }
  10838. public void aftersale_audit_master()
  10839. {
  10840. if (UrlPostParmsCheck("ctid"))
  10841. {
  10842. string ctid = GetPostString("ctid");
  10843. if (ctid.Length > 0)
  10844. {
  10845. bool result = aftersale_data_change(ctid);
  10846. if (result)
  10847. {
  10848. returnSuccessMsg("修改成功!");
  10849. return;
  10850. }
  10851. }
  10852. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10853. }
  10854. }
  10855. public void aftersale_batch_audit_master()
  10856. {
  10857. if (UrlPostParmsCheck("ctids"))
  10858. {
  10859. string ctids = GetPostString("ctids");
  10860. if (ctids.Length > 0)
  10861. {
  10862. List<string> list = new List<string>();
  10863. string[] ctid_list = ctids.Split(',');
  10864. foreach (var item in ctid_list)
  10865. {
  10866. bool result = aftersale_data_change(item);
  10867. if (!result)
  10868. {
  10869. list.Add(item);
  10870. }
  10871. }
  10872. if (list.Count > 0)
  10873. {
  10874. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10875. return;
  10876. }
  10877. returnSuccessMsg("修改成功!");
  10878. return;
  10879. }
  10880. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10881. }
  10882. }
  10883. public bool aftersale_data_change(string ctid)
  10884. {
  10885. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10886. if (ceErpTradeCell != null)
  10887. {
  10888. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10889. ceErpTradeCell.AfterSaleSupplierState = 0;
  10890. StringBuilder sql = new StringBuilder();
  10891. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10892. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10893. CeErpTradeResponsible.DelByTid(ctid, 0);
  10894. 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 == "不理赔")
  10895. {
  10896. CeErpTradeResponsible.DelByTid(ctid, 1);
  10897. ceErpTradeCell.AfterSaleSupplierState = 1;
  10898. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10899. ceErpTradeCell.AfterSaleState = 4;
  10900. }
  10901. else
  10902. {
  10903. ceErpTradeCell.AfterSaleState = 3;
  10904. }
  10905. bool needCyt = false;
  10906. if (dt != null)
  10907. {
  10908. if (dt.Rows.Count == 1)
  10909. {
  10910. bool isEnd = false;
  10911. foreach (DataRow dr in dt.Rows)
  10912. {
  10913. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10914. {
  10915. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10916. isEnd = true;
  10917. }
  10918. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10919. {
  10920. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10921. isEnd = true;
  10922. }
  10923. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10924. {
  10925. needCyt = true;
  10926. }
  10927. }
  10928. if (isEnd)
  10929. {
  10930. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10931. ceErpTradeCell.AfterSaleState = 4;
  10932. ceErpTradeCell.AfterSaleSupplierState = 1;
  10933. }
  10934. }
  10935. else
  10936. {
  10937. bool isAll = true;
  10938. foreach (DataRow dr in dt.Rows)
  10939. {
  10940. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10941. {
  10942. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10943. continue;
  10944. }
  10945. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10946. {
  10947. string path = "";
  10948. int OrgID = 0;
  10949. if (!Convert.IsDBNull(dr["OrgPath"]))
  10950. {
  10951. path = dr["OrgPath"].ToString();
  10952. }
  10953. if (!Convert.IsDBNull(dr["OrgID"]))
  10954. {
  10955. OrgID = Convert.ToInt32(dr["OrgID"]);
  10956. }
  10957. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10958. {
  10959. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10960. continue;
  10961. }
  10962. }
  10963. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10964. {
  10965. needCyt = true;
  10966. }
  10967. isAll = false;
  10968. }
  10969. if (isAll)
  10970. {
  10971. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10972. ceErpTradeCell.AfterSaleState = 4;
  10973. ceErpTradeCell.AfterSaleSupplierState = 1;
  10974. }
  10975. }
  10976. }
  10977. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10978. {
  10979. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10980. }
  10981. if (ceErpTradeCell.AfterSaleState == 4)
  10982. {
  10983. ApiVo apiVo = new ApiVo();
  10984. apiVo.orderNumber = ceErpTradeCell.ctid;
  10985. apiVo.actionName = "afterOver";
  10986. designHelper.API_WorkCore(apiVo); //afterOver
  10987. }
  10988. ceErpTradeCell.Update();
  10989. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10990. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10991. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10992. return true;
  10993. }
  10994. return false;
  10995. }
  10996. public void get_erp_wechatorder()
  10997. {
  10998. DataStruct dStruct = GetPostStruct();
  10999. List<string> lw = new List<string>();
  11000. string tid = GetPostString("tid");
  11001. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11002. string shopname = GetPostString("shopname");
  11003. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11004. string buyernick = GetPostString("buyer_nick");
  11005. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11006. string customer = GetPostString("customer");
  11007. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11008. string returndate1 = GetPostString("returndate1");
  11009. string returndate2 = GetPostString("returndate2");
  11010. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11011. if (dw.Length > 0) lw.Add(dw);
  11012. string finishDate1 = GetPostString("finishdate1");
  11013. string finishDate2 = GetPostString("finishdate2");
  11014. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11015. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11016. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11017. dStruct.Order = "created desc";
  11018. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11019. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11020. writeGridDataTableJson(dStruct.TotalCount, dt);
  11021. }
  11022. public void get_erp_wechatlist_sumprice()
  11023. {
  11024. DataStruct dStruct = GetPostStruct();
  11025. List<string> lw = new List<string>();
  11026. string tid = GetPostString("tid");
  11027. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11028. string shopname = GetPostString("shopname");
  11029. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11030. string buyernick = GetPostString("buyer_nick");
  11031. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11032. string customer = GetPostString("customer");
  11033. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11034. string returndate1 = GetPostString("returndate1");
  11035. string returndate2 = GetPostString("returndate2");
  11036. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11037. if (dw.Length > 0) lw.Add(dw);
  11038. string finishDate1 = GetPostString("finishdate1");
  11039. string finishDate2 = GetPostString("finishdate2");
  11040. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11041. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11042. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11043. string mainWhere = string.Join(" and ", lw.ToArray());
  11044. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11045. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11046. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11047. decimal total = 0;
  11048. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11049. {
  11050. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11051. }
  11052. var res = new
  11053. {
  11054. data = total
  11055. };
  11056. string ro_jsond = JsonConvert.SerializeObject(res);
  11057. returnSuccess(ro_jsond);
  11058. return;
  11059. }
  11060. public void get_erp_qr_waitdeliverylist()
  11061. {
  11062. DataStruct dStruct = GetPostStruct();
  11063. List<string> lw = new List<string>();
  11064. string tid = GetPostString("ctid");
  11065. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11066. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11067. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11068. var res_objz = new
  11069. {
  11070. restype = 1,
  11071. data = dt
  11072. };
  11073. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11074. returnSuccess(ro_jsonz);
  11075. }
  11076. public void get_erp_yield_list()
  11077. {
  11078. DataStruct dStruct = GetPostStruct();
  11079. List<string> lw = new List<string>();
  11080. string tid = GetPostString("ctid");
  11081. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11082. string shopname = GetPostString("shopname");
  11083. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11084. string buyernick = GetPostString("buyer_nick");
  11085. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11086. //if (tid.Length == 0 && buyernick.Length == 0)
  11087. //{
  11088. // lw.Add(string.Format("IsRefund<={0}", 1));
  11089. //}
  11090. string customer = GetPostString("customer");
  11091. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11092. string design = GetPostString("design");
  11093. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11094. string orderState = GetPostString("orderState");
  11095. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11096. string address = GetPostString("address");
  11097. 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));
  11098. string sellermemo = GetPostString("seller_memo");
  11099. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11100. string supplier = GetPostString("supplier");
  11101. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11102. string OrderArea = GetPostString("order_area");
  11103. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11104. string placedate1 = GetPostString("placedate1");
  11105. string placedate2 = GetPostString("placedate2");
  11106. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11107. if (fdw.Length > 0) lw.Add(fdw);
  11108. string price1 = GetPostString("price1");
  11109. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11110. string price2 = GetPostString("price2");
  11111. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11112. string unusualCon = GetPostString("unusualcon");
  11113. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11114. string posTag = CurrentUser.UserPost.Post.Code;
  11115. if (posTag == "Supplier")
  11116. {
  11117. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11118. }
  11119. lw.Add(string.Format("OrderState = 6 "));
  11120. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11121. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11122. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11123. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11124. writeGridDataTableJson(dStruct.TotalCount, dt);
  11125. }
  11126. public void change_erp_sup_state()
  11127. {
  11128. if (UrlPostParmsCheck("ctid"))
  11129. {
  11130. string ctid = GetPostString("ctid");
  11131. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11132. if (ceErpTradeCell != null)
  11133. {
  11134. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11135. if (ceErpTradeCellExtend == null)
  11136. {
  11137. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11138. ceErpTradeCellExtend.ctid = ctid;
  11139. ceErpTradeCellExtend.SupState = 1;
  11140. ceErpTradeCellExtend.Create();
  11141. }
  11142. else
  11143. {
  11144. ceErpTradeCellExtend.SupState = 1;
  11145. ceErpTradeCellExtend.Update();
  11146. }
  11147. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11148. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11149. return;
  11150. }
  11151. returnErrorMsg("找不到订单");
  11152. }
  11153. }
  11154. public void supplier_all_downs()
  11155. {
  11156. if (UrlPostParmsCheck("tids"))
  11157. {
  11158. string tids = GetPostString("tids");
  11159. if (tids != null && tids.Length > 0)
  11160. {
  11161. StringBuilder sql = new StringBuilder();
  11162. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11163. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11164. sql = new StringBuilder();
  11165. 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, "下载设计文件");
  11166. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11167. string[] list = tids.Split(',');
  11168. foreach (string ctid in list)
  11169. {
  11170. CeErpSukuraData.createInfo(ctid, 3);
  11171. }
  11172. designHelper.api_approveDesign(tids); //approveDesign
  11173. returnSuccessMsg("下载成功!");
  11174. return;
  11175. }
  11176. returnErrorMsg("下载订单更新失败");
  11177. }
  11178. }
  11179. public void uploaderFileSuccess()
  11180. {
  11181. if (UrlPostParmsCheck("fileName"))
  11182. {
  11183. string fileName = GetPostString("fileName");
  11184. ApiVo apiVo = new ApiVo();
  11185. apiVo.orderNumber = fileName;
  11186. apiVo.actionName = "finishDesign";
  11187. designHelper.API_WorkCore(apiVo);//finishDesign
  11188. returnSuccessMsg("");
  11189. }
  11190. }
  11191. public void get_sample2_order()
  11192. {
  11193. if (UrlPostParmsCheck("ctid"))
  11194. {
  11195. string ctid = GetPostString("ctid");
  11196. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11197. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11198. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11199. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11200. double total = 0.0;
  11201. double order_price = 0.0;
  11202. if (dt_bu.Rows.Count > 0)
  11203. {
  11204. foreach (DataRow dr in dt_bu.Rows)
  11205. {
  11206. total += Convert.ToDouble(dr["payment"]);
  11207. }
  11208. }
  11209. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11210. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11211. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11212. string tid = ctid.Replace("S_", "");
  11213. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11214. double paymant = 0.0;
  11215. if (entity != null)
  11216. {
  11217. paymant = entity.payment;
  11218. }
  11219. string return_reason = "";
  11220. if (dt_after != null && dt_after.Rows.Count > 0)
  11221. {
  11222. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11223. }
  11224. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11225. }
  11226. }
  11227. public void get_erp_design_status()
  11228. {
  11229. string designName = GetPostString("designName");
  11230. DataStruct dStruct = GetPostStruct();
  11231. if (designName.Length > 0)
  11232. {
  11233. 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";
  11234. sql_user += " and Name like '%" + designName + "%'";
  11235. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11236. List<string> ids_list = new List<string>();
  11237. if (user_table.Rows.Count > 0)
  11238. {
  11239. foreach (DataRow item in user_table.Rows)
  11240. {
  11241. ids_list.Add(item["id"].ToString());
  11242. string ids_s = item["TeamIds"].ToString();
  11243. if (ids_s.Length > 0)
  11244. {
  11245. ids_list.AddRange(ids_s.Split(','));
  11246. }
  11247. }
  11248. }
  11249. HashSet<string> set = new HashSet<string>(ids_list);
  11250. ids_list = set.ToList();
  11251. if (ids_list.Count > 0)
  11252. {
  11253. 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));
  11254. dStruct.MainWhere = sql;
  11255. DataTable dt = null;
  11256. dt = WebCache.GetData("view_ErpUser", dStruct);
  11257. writeGridDataTableJson(dStruct.TotalCount, dt);
  11258. }
  11259. }
  11260. }
  11261. public void change_erp_order_price()
  11262. {
  11263. string ctid = GetPostString("ctid");
  11264. double price = GetPostDouble("price");
  11265. if (ctid.Length > 0)
  11266. {
  11267. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11268. if (ceErpTradeCellExtend == null)
  11269. {
  11270. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11271. ceErpTradeCellExtend.ctid = ctid;
  11272. ceErpTradeCellExtend.payment_cyt = price;
  11273. ceErpTradeCellExtend.Create();
  11274. }
  11275. else
  11276. {
  11277. ceErpTradeCellExtend.payment_cyt = price;
  11278. ceErpTradeCellExtend.Update();
  11279. }
  11280. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11281. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11282. {
  11283. ceErpDataSendOrderInfo.isSync = false;
  11284. ceErpDataSendOrderInfo.Update();
  11285. }
  11286. if (ceErpDataSendOrderInfo == null)
  11287. {
  11288. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11289. ceErpDataSendOrderInfo.isSync = false;
  11290. ceErpDataSendOrderInfo.ctid = ctid;
  11291. ceErpDataSendOrderInfo.Create();
  11292. }
  11293. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11294. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11295. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11296. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11297. {
  11298. dataSendOrderBean dataSendOrderBean = null;
  11299. foreach (DataRow item in dth.Rows)
  11300. {
  11301. try
  11302. {
  11303. dataSendOrderBean = new dataSendOrderBean();
  11304. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11305. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11306. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11307. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11308. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11309. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11310. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11311. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11312. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11313. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11314. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11315. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11316. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11317. if (result != null)
  11318. {
  11319. if ("0".Equals(result.errcode))
  11320. {
  11321. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11322. }
  11323. else
  11324. {
  11325. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11326. }
  11327. }
  11328. }
  11329. catch (Exception ex)
  11330. {
  11331. }
  11332. }
  11333. }
  11334. returnSuccessMsg("修改成功!");
  11335. return;
  11336. }
  11337. returnErrorMsg("找不到订单");
  11338. }
  11339. public void find_he_together()
  11340. {
  11341. string ctid = GetPostString("ctid");
  11342. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11343. List<string> list = new List<string>();
  11344. if (ceErpTradeCell != null)
  11345. {
  11346. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11347. {
  11348. 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);
  11349. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11350. if (table != null && table.Rows.Count > 0)
  11351. {
  11352. foreach (TableRow row in table.Rows)
  11353. {
  11354. }
  11355. }
  11356. }
  11357. }
  11358. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11359. }
  11360. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11361. {
  11362. //chy----19
  11363. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11364. //GD-CYT-----64
  11365. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11366. //ZHX----3
  11367. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11368. //JK----97
  11369. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11370. //ZT----70
  11371. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11372. //LHCY-----98
  11373. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11374. //XD-----90
  11375. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11376. //CYCY-----14
  11377. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11378. };
  11379. //其他改名
  11380. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11381. {
  11382. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11383. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11384. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11385. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11386. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11387. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11388. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11389. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11390. };
  11391. //不统计
  11392. List<int> no_suppliers = new List<int>()
  11393. {
  11394. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11395. };
  11396. //配件单
  11397. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11398. {
  11399. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11400. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11401. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11402. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11403. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11404. {"旗杆",new List<string>(){ "班旗" } },
  11405. {"牙签",new List<string>(){ "不干胶" } }
  11406. };
  11407. public void get_place_order_data()
  11408. {
  11409. string date1 = GetPostString("date1");
  11410. string date2 = GetPostString("date2");
  11411. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11412. DateTime start = DateTime.Parse(starttime);
  11413. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11414. DateTime end = DateTime.Parse(endtime);
  11415. if (date1 != null && date1.Length > 0)
  11416. {
  11417. DateTime dateTime = DateTime.Parse(date1);
  11418. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11419. start = DateTime.Parse(starttime);
  11420. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11421. end = DateTime.Parse(endtime);
  11422. }
  11423. if (date2 != null && date2.Length > 0)
  11424. {
  11425. DateTime dateTime = DateTime.Parse(date2);
  11426. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11427. end = DateTime.Parse(endtime);
  11428. }
  11429. 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);
  11430. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11431. //不干胶-----1,卡片-----29
  11432. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11433. foreach (DataRow row in data.Rows)
  11434. {
  11435. int productId = Convert.ToInt32(row["ProductId"]);
  11436. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11437. if (no_suppliers.Contains(supplierId))
  11438. {
  11439. continue;
  11440. }
  11441. string seller_memo = row["seller_memo"].ToString();
  11442. bool ispj = false;//是否配件单
  11443. bool isfirst = true;//第一个配
  11444. maps.Keys.ForEach(key =>
  11445. {
  11446. //备注包含配件
  11447. if (seller_memo.Contains(key) && isfirst)
  11448. {
  11449. List<string> list = maps[key];
  11450. ispj = true;
  11451. isfirst = false;
  11452. for (int i = 0; i < list.Count; i++)
  11453. {
  11454. if (seller_memo.Contains(list[i]))
  11455. {
  11456. ispj = false;
  11457. break;
  11458. }
  11459. }
  11460. }
  11461. });
  11462. if (ispj)
  11463. {
  11464. continue;
  11465. }
  11466. seller_memo = seller_memo.Replace("UV", "uv");
  11467. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11468. //吊牌归到卡片
  11469. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11470. seller_memo = seller_memo.Replace("卡套", "卡片");
  11471. seller_memo = seller_memo.Replace("封套", "卡片");
  11472. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11473. seller_memo = seller_memo.Replace("腰封", "卡片");
  11474. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11475. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11476. seller_memo = seller_memo.Replace("横幅", "条幅");
  11477. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11478. string map_key = "";
  11479. string type = "";
  11480. if (supplierMap.ContainsKey(supplierId))
  11481. {
  11482. foreach (var kvp in supplierMap[supplierId])
  11483. {
  11484. if (seller_memo.Contains(kvp.Key))
  11485. {
  11486. map_key = kvp.Value;
  11487. type = kvp.Value;
  11488. break;
  11489. }
  11490. }
  11491. }
  11492. if (map_key == "")
  11493. {
  11494. type = "其他";
  11495. map_key = "其他";
  11496. }
  11497. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11498. {
  11499. map_key = suppliers[supplierId];
  11500. }
  11501. if (supplierId == 70)
  11502. {
  11503. supplierId = 70;
  11504. }
  11505. map_key += "_" + row["SupplierName"].ToString();
  11506. Dictionary<string, int> map = null;
  11507. if (other_map.ContainsKey(map_key))
  11508. {
  11509. other_map.TryGetValue(map_key, out map);
  11510. }
  11511. else
  11512. {
  11513. map = new Dictionary<string, int>();
  11514. map.Add("dayDev", 0);//当天出货
  11515. map.Add("dayTotal", 0);//下单总数
  11516. map.Add("payTotal", 0);//500以上
  11517. map.Add("today", 0);//当天出货数量
  11518. map.Add("unusua", 0);//异常数
  11519. other_map.Add(map_key, map);
  11520. other_map.TryGetValue(map_key, out map);
  11521. }
  11522. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11523. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11524. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11525. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11526. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11527. {
  11528. map["dayTotal"]++;
  11529. if (supplierId == 97)
  11530. {
  11531. supplierId = 97;
  11532. }
  11533. }
  11534. if (Convert.ToDecimal(row["payment"]) >= 500)
  11535. {
  11536. map["payTotal"]++;
  11537. }
  11538. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11539. {
  11540. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11541. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11542. {
  11543. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11544. {
  11545. map["today"]++;
  11546. }
  11547. }
  11548. else
  11549. {
  11550. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11551. {
  11552. map["today"]++;
  11553. }
  11554. else
  11555. {
  11556. }
  11557. }
  11558. }
  11559. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11560. {
  11561. map["unusua"]++;
  11562. }
  11563. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11564. //GD-CYT-----64
  11565. DateTime two = palceTimeStart.AddHours(14);
  11566. DateTime three = palceTimeStart.AddHours(15);
  11567. DateTime four = palceTimeStart.AddHours(16);
  11568. DateTime six = palceTimeStart.AddHours(18);
  11569. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11570. {
  11571. //下午四点前 500-1000
  11572. string count = row["ProductCount"].ToString();
  11573. if (count != null && count.Length > 0)
  11574. {
  11575. int productCount = commonHelper.getPlaceProductCount(count);
  11576. if (productCount >= 500 && productCount <= 1000)
  11577. {
  11578. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11579. {
  11580. map["dayDev"]++;
  11581. }
  11582. }
  11583. }
  11584. }
  11585. //UV
  11586. else if ("uv".Equals(type))
  11587. {
  11588. //ZT----70
  11589. //ZHX----3
  11590. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11591. {
  11592. map["dayDev"]++;
  11593. }
  11594. //JK----97
  11595. //HZX----105
  11596. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11597. {
  11598. map["dayDev"]++;
  11599. }
  11600. }
  11601. //帆布---52|条幅---27
  11602. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11603. {
  11604. //LHCY-----98
  11605. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11606. {
  11607. map["dayDev"]++;
  11608. }
  11609. }
  11610. //条幅
  11611. else if ("条幅".Equals(type))
  11612. {
  11613. //XD-----90
  11614. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11615. {
  11616. map["dayDev"]++;
  11617. }
  11618. }
  11619. //桌布
  11620. else if ("桌布".Equals(type))
  11621. {
  11622. //XD-----90
  11623. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11624. {
  11625. map["dayDev"]++;
  11626. }
  11627. }
  11628. //DL---10
  11629. //AYTW---119
  11630. //FS-CYT-DY ----80
  11631. //JK----97
  11632. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11633. {
  11634. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11635. {
  11636. map["dayDev"]++;
  11637. }
  11638. }
  11639. // QC---121
  11640. else if (supplierId == 121)
  11641. {
  11642. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11643. {
  11644. map["dayDev"]++;
  11645. }
  11646. }
  11647. }
  11648. DataTable dt = new DataTable();
  11649. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11650. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11651. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11652. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11653. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11654. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11655. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11656. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11657. other_map.Keys.ForEach(key =>
  11658. {
  11659. DataRow dr = dt.NewRow();
  11660. Dictionary<string, int> map = other_map[key];
  11661. string[] key_list = key.Split('_');
  11662. dr[0] = key_list[0];
  11663. dr[1] = key_list[1];
  11664. if (key_list.Length > 2)
  11665. {
  11666. dr[1] += "(" + key_list[2] + ")";
  11667. }
  11668. dr[2] = map["dayTotal"];
  11669. dr[3] = map["payTotal"];
  11670. dr[4] = map["today"];
  11671. dr[5] = map["unusua"];
  11672. dr[6] = map["dayDev"];
  11673. double rate = 0.00;
  11674. if (map["dayDev"] > 0)
  11675. {
  11676. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11677. }
  11678. dr[7] = rate.ToString();
  11679. dt.Rows.Add(dr);
  11680. });
  11681. DataView dv = new DataView(dt);
  11682. dv.Sort = "SupplierName";
  11683. //dv.Sort = "AllOrder desc";
  11684. DataTable dtNew = dv.ToTable();
  11685. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11686. }
  11687. public void check_order_desing_info()
  11688. {
  11689. string ctid = GetPostString("ctid");
  11690. if (!string.IsNullOrEmpty(ctid))
  11691. {
  11692. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11693. if (ceErpTradeCell != null)
  11694. {
  11695. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11696. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11697. return;
  11698. }
  11699. returnErrorMsg("找不到订单");
  11700. return;
  11701. }
  11702. returnErrorMsg("找不到订单");
  11703. }
  11704. public void get_timeout_detail()
  11705. {
  11706. string poscode = CurrentUser.UserPost.Post.Code;
  11707. DataStruct dStruct = GetPostStruct();
  11708. List<string> lw = new List<string>();
  11709. string id = GetPostString("id");
  11710. string pay_date1 = GetPostString("pay_date1");
  11711. string pay_date2 = GetPostString("pay_date2");
  11712. int type = GetPostInt("type");
  11713. if (type == 0)
  11714. {
  11715. if (pay_date1.Length > 0)
  11716. {
  11717. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11718. }
  11719. if (pay_date2.Length > 0)
  11720. {
  11721. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11722. }
  11723. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11724. }
  11725. if (type == 1)
  11726. {
  11727. if (pay_date1.Length > 0)
  11728. {
  11729. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11730. }
  11731. if (pay_date2.Length > 0)
  11732. {
  11733. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11734. }
  11735. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11736. }
  11737. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11738. DataTable dt = null;
  11739. dt = WebCache.GetData("view_orderlist", dStruct);
  11740. writeGridDataTableJson(dStruct.TotalCount, dt);
  11741. }
  11742. public void saveUrgentChargePrice()
  11743. {
  11744. string ctid = GetPostString("ctid");
  11745. if (!string.IsNullOrEmpty(ctid))
  11746. {
  11747. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11748. if (ceErpTradeCell != null)
  11749. {
  11750. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11751. if (prices <= 100)
  11752. {
  11753. returnErrorMsg("此订单金额不足100元,无法加急。");
  11754. return;
  11755. }
  11756. double price = GetPostDouble("price");
  11757. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11758. if (ceErpTradeCellExtend == null)
  11759. {
  11760. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11761. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11762. }
  11763. ceErpTradeCellExtend.urgentCharge = price;
  11764. if (ceErpTradeCellExtend.ID > 0)
  11765. {
  11766. ceErpTradeCellExtend.Update();
  11767. }
  11768. else
  11769. {
  11770. ceErpTradeCellExtend.Save();
  11771. }
  11772. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11773. returnSuccessMsg("修改成功!");
  11774. return;
  11775. }
  11776. returnErrorMsg("找不到订单");
  11777. return;
  11778. }
  11779. returnErrorMsg("找不到订单");
  11780. }
  11781. public void finish_erp_order()
  11782. {
  11783. string ctid = GetPostString("ctid");
  11784. if (!string.IsNullOrEmpty(ctid))
  11785. {
  11786. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11787. {
  11788. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11789. if (ceErpTradeCell != null)
  11790. {
  11791. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11792. ceErpTradeCell.Update();
  11793. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11794. returnSuccessMsg("修改成功!");
  11795. return;
  11796. }
  11797. }
  11798. }
  11799. returnErrorMsg("找不到订单");
  11800. }
  11801. public void get_trade_order_list()
  11802. {
  11803. string tid = GetPostString("tid");
  11804. if (!string.IsNullOrEmpty(tid))
  11805. {
  11806. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11807. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11808. writeGridDataTableJson(data.Rows.Count, data);
  11809. return;
  11810. }
  11811. returnErrorMsg("找不到订单");
  11812. }
  11813. public void save_cell_spu()
  11814. {
  11815. string ctid = GetPostString("ctid");
  11816. string spu_id = GetPostString("spu_id");
  11817. if (!string.IsNullOrEmpty(ctid))
  11818. {
  11819. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11820. if (ceErpTradeCellExtend == null)
  11821. {
  11822. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11823. ceErpTradeCellExtend.ctid = ctid;
  11824. }
  11825. ceErpTradeCellExtend.spu_id = spu_id;
  11826. if (!string.IsNullOrEmpty(spu_id))
  11827. {
  11828. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11829. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11830. }
  11831. if (ceErpTradeCellExtend.ID == 0)
  11832. {
  11833. ceErpTradeCellExtend.Create();
  11834. }
  11835. else
  11836. {
  11837. ceErpTradeCellExtend.Update();
  11838. }
  11839. returnSuccessMsg("修改成功!");
  11840. return;
  11841. }
  11842. returnErrorMsg("找不到订单");
  11843. }
  11844. public void change_express_info()
  11845. {
  11846. string ctid = GetPostString("ctid");
  11847. string transNo = GetPostString("transNo");
  11848. string transCom = GetPostString("transCom");
  11849. if (!string.IsNullOrEmpty(ctid))
  11850. {
  11851. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11852. if (ceErpTradeCellExtend == null)
  11853. {
  11854. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11855. ceErpTradeCellExtend.ctid = ctid;
  11856. }
  11857. ceErpTradeCellExtend.modExpressNo = transNo;
  11858. ceErpTradeCellExtend.modExpressCom = transCom;
  11859. ceErpTradeCellExtend.readMod = 2;
  11860. if (ceErpTradeCellExtend.ID == 0)
  11861. {
  11862. ceErpTradeCellExtend.Create();
  11863. }
  11864. else
  11865. {
  11866. ceErpTradeCellExtend.Update();
  11867. }
  11868. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11869. returnSuccessMsg("修改成功!");
  11870. return;
  11871. }
  11872. returnErrorMsg("找不到订单");
  11873. }
  11874. public void get_change_express_list()
  11875. {
  11876. DataStruct dStruct = GetPostStruct();
  11877. List<string> lw = new List<string>();
  11878. int st = 2;
  11879. string tid = GetPostString("ctid");
  11880. if (tid.Length > 0)
  11881. {
  11882. string select_tid = getTidByCtid(tid);
  11883. lw.Add(string.Format("tid='{0}'", select_tid));
  11884. }
  11885. string shopname = GetPostString("shopname");
  11886. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11887. string buyernick = GetPostString("buyer_nick");
  11888. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11889. string sellermemo = GetPostString("seller_memo");
  11890. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11891. string supplier = GetPostString("supplier");
  11892. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11893. string customer = GetPostString("customer");
  11894. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11895. string design = GetPostString("design");
  11896. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11897. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11898. string poscode = CurrentUser.UserPost.Post.Code;
  11899. if (poscode != "SysAdmin")
  11900. {
  11901. string shopid = CurrentUser.User.pemShop;
  11902. lw.Add(string.Format("shopId in ({0})", shopid));
  11903. }
  11904. lw.Add("readMod = 2");
  11905. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11906. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11907. writeGridDataTableJson(dStruct.TotalCount, dt);
  11908. }
  11909. public void deal_express_complete()
  11910. {
  11911. string ctid = GetPostString("ctid");
  11912. if (!string.IsNullOrEmpty(ctid))
  11913. {
  11914. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11915. if (ceErpTradeCellExtend == null)
  11916. {
  11917. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11918. ceErpTradeCellExtend.ctid = ctid;
  11919. }
  11920. ceErpTradeCellExtend.readMod = 1;
  11921. if (ceErpTradeCellExtend.ID == 0)
  11922. {
  11923. ceErpTradeCellExtend.Create();
  11924. }
  11925. else
  11926. {
  11927. ceErpTradeCellExtend.Update();
  11928. }
  11929. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11930. returnSuccessMsg("修改成功!");
  11931. return;
  11932. }
  11933. returnErrorMsg("找不到订单");
  11934. }
  11935. public void aftersale_return_visit()
  11936. {
  11937. string ctid = GetPostString("ctid");
  11938. if (!string.IsNullOrEmpty(ctid))
  11939. {
  11940. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11941. if (ceErpTradeCellExtend == null)
  11942. {
  11943. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11944. ceErpTradeCellExtend.ctid = ctid;
  11945. }
  11946. ceErpTradeCellExtend.returnVisit = 1;
  11947. if (ceErpTradeCellExtend.ID == 0)
  11948. {
  11949. ceErpTradeCellExtend.Create();
  11950. }
  11951. else
  11952. {
  11953. ceErpTradeCellExtend.Update();
  11954. }
  11955. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11956. if (ceErpTradeAfterSaleExtend != null)
  11957. {
  11958. ceErpTradeAfterSaleExtend.TextResult = "";
  11959. ceErpTradeAfterSaleExtend.Update();
  11960. }
  11961. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11962. returnSuccessMsg("修改成功!");
  11963. return;
  11964. }
  11965. returnErrorMsg("找不到订单");
  11966. }
  11967. public void orderPlaceInfo()
  11968. {
  11969. string ctids = GetPostString("ctids");
  11970. string[] list = ctids.Split(',');
  11971. foreach (string ctid in list)
  11972. {
  11973. CeErpSukuraData.createInfo(ctid, 3);
  11974. }
  11975. StringBuilder sql = new StringBuilder();
  11976. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11977. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11978. designHelper.api_approveDesign(ctids); //approveDesign
  11979. returnSuccessMsg("");
  11980. }
  11981. public void get_issue_list()
  11982. {
  11983. DataStruct dStruct = GetPostStruct();
  11984. List<string> lw = new List<string>();
  11985. int st = 2;
  11986. string tid = GetPostString("ctid");
  11987. if (tid.Length > 0)
  11988. {
  11989. string select_tid = getTidByCtid(tid);
  11990. lw.Add(string.Format("tid='{0}'", select_tid));
  11991. }
  11992. string shopname = GetPostString("shopname");
  11993. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11994. string buyernick = GetPostString("buyer_nick");
  11995. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11996. string sellermemo = GetPostString("seller_memo");
  11997. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11998. string supplier = GetPostString("supplier");
  11999. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12000. string customer = GetPostString("customer");
  12001. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12002. string design = GetPostString("design");
  12003. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12004. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12005. string poscode = CurrentUser.UserPost.Post.Code;
  12006. if (poscode != "SysAdmin")
  12007. {
  12008. string shopid = CurrentUser.User.pemShop;
  12009. lw.Add(string.Format("shopId in ({0})", shopid));
  12010. }
  12011. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12012. {
  12013. lw.Add("IssueState = 1");
  12014. }
  12015. else
  12016. {
  12017. string iisstate = GetPostString("iisstate");
  12018. if ("1".Equals(iisstate))
  12019. {
  12020. lw.Add("IssueState =1");
  12021. }
  12022. else if ("2".Equals(iisstate))
  12023. {
  12024. lw.Add("IssueState = 2");
  12025. }
  12026. else
  12027. {
  12028. lw.Add("IssueState > 0");
  12029. }
  12030. }
  12031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12032. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12033. writeGridDataTableJson(dStruct.TotalCount, dt);
  12034. }
  12035. public void saveIssueContent()
  12036. {
  12037. string ctid = GetPostString("ctid");
  12038. if (!string.IsNullOrEmpty(ctid))
  12039. {
  12040. string content = GetPostString("content");
  12041. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12042. if (ceErpTradeAfterSaleExtend == null)
  12043. {
  12044. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12045. ceErpTradeAfterSaleExtend.tid = ctid;
  12046. }
  12047. ceErpTradeAfterSaleExtend.IssueContent = content;
  12048. ceErpTradeAfterSaleExtend.IssueState = 1;
  12049. if (ceErpTradeAfterSaleExtend.ID > 0)
  12050. {
  12051. ceErpTradeAfterSaleExtend.Update();
  12052. }
  12053. else
  12054. {
  12055. ceErpTradeAfterSaleExtend.Create();
  12056. }
  12057. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12058. returnSuccessMsg("添加成功!");
  12059. return;
  12060. }
  12061. returnErrorMsg("找不到订单");
  12062. }
  12063. public void dealIssueContent()
  12064. {
  12065. string ctid = GetPostString("ctid");
  12066. if (!string.IsNullOrEmpty(ctid))
  12067. {
  12068. string content = GetPostString("content");
  12069. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12070. if (ceErpTradeAfterSaleExtend != null)
  12071. {
  12072. ceErpTradeAfterSaleExtend.IssueState = 2;
  12073. ceErpTradeAfterSaleExtend.Update();
  12074. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12075. returnSuccessMsg("修改完成!");
  12076. return;
  12077. }
  12078. }
  12079. returnErrorMsg("找不到订单");
  12080. }
  12081. public void set_tid_attachments()
  12082. {
  12083. string tid = GetPostString("tid");
  12084. string atta = GetPostString("atta");
  12085. if (!string.IsNullOrEmpty(tid))
  12086. {
  12087. if (string.IsNullOrEmpty(atta))
  12088. {
  12089. returnErrorMsg("文件地址为空");
  12090. return;
  12091. }
  12092. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12093. if (ceErpTradeCell != null)
  12094. {
  12095. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12096. if (ceErpTrade == null)
  12097. {
  12098. returnErrorMsg("找不到订单");
  12099. return;
  12100. }
  12101. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12102. bool isSend = false;
  12103. if (dt != null && dt.Rows.Count > 0)
  12104. {
  12105. foreach (DataRow row in dt.Rows)
  12106. {
  12107. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12108. {
  12109. isSend = true;
  12110. }
  12111. }
  12112. if (isSend)
  12113. {
  12114. returnErrorMsg("已发货无法修改");
  12115. return;
  12116. }
  12117. ceErpTrade.Attachments = atta;
  12118. ceErpTrade.Update();
  12119. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12120. returnSuccessMsg("上传成功!");
  12121. return;
  12122. }
  12123. }
  12124. }
  12125. returnErrorMsg("找不到订单");
  12126. }
  12127. public void get_tid_attachments()
  12128. {
  12129. string tid = GetPostString("tid");
  12130. if (!string.IsNullOrEmpty(tid))
  12131. {
  12132. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12133. if (ceErpTradeCell != null)
  12134. {
  12135. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12136. if (ceErpTrade == null)
  12137. {
  12138. returnErrorMsg("找不到订单");
  12139. return;
  12140. }
  12141. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12142. return;
  12143. }
  12144. }
  12145. returnErrorMsg("找不到订单");
  12146. }
  12147. public void check_erp_sameorders()
  12148. {
  12149. if (UrlPostParmsCheck("ctid"))
  12150. {
  12151. string eid = GetPostString("ctid");
  12152. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12153. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12154. if (entity != null && ceErpTrade != null)
  12155. {
  12156. if (entity.OrderState > 6)
  12157. {
  12158. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12159. return;
  12160. }
  12161. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12162. List<string> ids = new List<string>();
  12163. if (dt != null && dt.Rows.Count > 1)
  12164. {
  12165. bool needhe = true;
  12166. foreach (DataRow dr in dt.Rows)
  12167. {
  12168. ids.Add("'" + dr["ctid"] + "'");
  12169. /* //备注有合包
  12170. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12171. {
  12172. needhe = true;
  12173. }
  12174. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12175. {
  12176. needhe = true;
  12177. }
  12178. //顺丰快递
  12179. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12180. {
  12181. needhe = true;
  12182. }*/
  12183. }
  12184. if (!needhe)
  12185. {
  12186. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12187. return;
  12188. }
  12189. StringBuilder sql = new StringBuilder();
  12190. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12191. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12192. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12193. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12194. foreach (DataRow dr in dt.Rows)
  12195. {
  12196. dr["dstate"] = 0;
  12197. dr["dnumber"] = 0;
  12198. foreach (DataRow row in dt1.Rows)
  12199. {
  12200. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12201. {
  12202. dr["dstate"] = 2;
  12203. dr["default"] = 1;
  12204. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12205. }
  12206. }
  12207. if (eid.Equals(dr["ctid"].ToString()))
  12208. {
  12209. dr["dstate"] = 1;
  12210. dr["default"] = 1;
  12211. }
  12212. }
  12213. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12214. return;
  12215. }
  12216. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12217. return;
  12218. }
  12219. returnErrorMsg("未找到订单");
  12220. return;
  12221. }
  12222. returnErrorMsg("缺少必要的参数");
  12223. }
  12224. public void get_mark_number()
  12225. {
  12226. string eid = GetPostString("ctid");
  12227. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12228. if (entity != null)
  12229. {
  12230. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12231. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12232. int current = 1;
  12233. if (ceErpDeliverMark == null)
  12234. {
  12235. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12236. List<string> ids = new List<string>();
  12237. if (dt != null && dt.Rows.Count > 1)
  12238. {
  12239. foreach (DataRow dr in dt.Rows)
  12240. {
  12241. ids.Add("'" + dr["ctid"] + "'");
  12242. }
  12243. //查询已有的编号
  12244. StringBuilder sql = new StringBuilder();
  12245. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12246. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12247. if (dt1 == null || dt1.Rows.Count == 0)
  12248. {
  12249. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12250. List<int> list_number = new List<int>();
  12251. foreach (DataRow row in numbers.Rows)
  12252. {
  12253. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12254. }
  12255. //查询空余编号
  12256. for (int i = 0; i < list_number.Count + 2; i++)
  12257. {
  12258. if (!list_number.Contains(current))
  12259. {
  12260. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12261. //防止查询过程中有新数据生成
  12262. if (ceErpDeliverMark1 == null)
  12263. {
  12264. break;
  12265. }
  12266. }
  12267. current++;
  12268. }
  12269. }
  12270. else
  12271. {
  12272. foreach (DataRow row in dt1.Rows)
  12273. {
  12274. current = Convert.ToInt32(row["markNumber"]);
  12275. }
  12276. }
  12277. ceErpDeliverMark = new CeErpDeliverMark();
  12278. ceErpDeliverMark.ctid = eid;
  12279. ceErpDeliverMark.createtime = DateTime.Now;
  12280. if (ceErpTrade != null)
  12281. {
  12282. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12283. }
  12284. ceErpDeliverMark.markNumber = current;
  12285. ceErpDeliverMark.Create();
  12286. }
  12287. }
  12288. else
  12289. {
  12290. current = ceErpDeliverMark.markNumber;
  12291. }
  12292. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12293. return;
  12294. }
  12295. }
  12296. public void aftersaleCytSend()
  12297. {
  12298. string ctid = GetPostString("ctid");
  12299. if (!string.IsNullOrEmpty(ctid))
  12300. {
  12301. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12302. if (ceErpTradeCell != null)
  12303. {
  12304. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12305. }
  12306. returnSuccessMsg("推送成功");
  12307. return;
  12308. }
  12309. returnErrorMsg("缺少必要的参数");
  12310. }
  12311. public void packOrderInfo()
  12312. {
  12313. string ctids = GetPostString("ctids");
  12314. if (!string.IsNullOrEmpty(ctids))
  12315. {
  12316. string[] ctid_list = ctids.Split(',');
  12317. if (ctid_list.Length > 20)
  12318. {
  12319. returnErrorMsg("单次下载次数不能超过20个");
  12320. return;
  12321. }
  12322. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12323. StringBuilder sql = new StringBuilder();
  12324. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12325. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12326. int supplierId = 0;
  12327. StringBuilder insterSql = new StringBuilder();
  12328. for (int i = 0; i < dt.Rows.Count; i++)
  12329. {
  12330. DataRow row = dt.Rows[i];
  12331. if (i == 0)
  12332. {
  12333. supplierId = Convert.ToInt32(row["SupplierId"]);
  12334. }
  12335. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12336. {
  12337. returnErrorMsg("同车间的订单才能一起打包");
  12338. return;
  12339. }
  12340. int orderState = Convert.ToInt32(row["OrderState"]);
  12341. if (orderState != 5)
  12342. {
  12343. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12344. return;
  12345. }
  12346. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12347. }
  12348. CeErpPackData ceErpPackData = new CeErpPackData();
  12349. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12350. ceErpPackData.supplierId = supplierId;
  12351. ceErpPackData.createtime = DateTime.Now;
  12352. ceErpPackData.createBy = CurrentUser.UserID;
  12353. ceErpPackData.createName = CurrentUser.UserName;
  12354. ceErpPackData.Create();
  12355. if (ceErpPackData.ID > 0)
  12356. {
  12357. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12358. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12359. }
  12360. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12361. returnSuccessMsg("打包成功");
  12362. return;
  12363. }
  12364. returnErrorMsg("缺少必要的参数");
  12365. }
  12366. public void rePackOrderInfo()
  12367. {
  12368. string id = GetPostString("id");
  12369. if (!string.IsNullOrEmpty(id))
  12370. {
  12371. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12372. if (ceErpPackData == null)
  12373. {
  12374. returnSuccessMsg("查无数据");
  12375. return;
  12376. }
  12377. ceErpPackData.upStatus = 0;
  12378. ceErpPackData.message = "";
  12379. ceErpPackData.Update();
  12380. returnSuccessMsg("打包成功");
  12381. return;
  12382. }
  12383. returnErrorMsg("缺少必要的参数");
  12384. }
  12385. public void backPackOrderInfo()
  12386. {
  12387. string id = GetPostString("id");
  12388. if (!string.IsNullOrEmpty(id))
  12389. {
  12390. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12391. if (ceErpPackData == null)
  12392. {
  12393. returnSuccessMsg("查无数据");
  12394. return;
  12395. }
  12396. ceErpPackData.upStatus = 4;
  12397. ceErpPackData.Update();
  12398. List<string> list = new List<string>();
  12399. StringBuilder sql = new StringBuilder();
  12400. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12402. for (int i = 0; i < dt.Rows.Count; i++)
  12403. {
  12404. DataRow row = dt.Rows[i];
  12405. list.Add("'" + row["ctid"].ToString() + "'");
  12406. }
  12407. string textCtids = string.Join(",", list);
  12408. 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));
  12409. 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, "无法打包退回"));
  12410. returnSuccessMsg("退回成功");
  12411. return;
  12412. }
  12413. returnErrorMsg("缺少必要的参数");
  12414. }
  12415. public void addPackDownNum()
  12416. {
  12417. string id = GetPostString("id");
  12418. if (!string.IsNullOrEmpty(id))
  12419. {
  12420. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12421. returnSuccessMsg("下载成功");
  12422. return;
  12423. }
  12424. returnErrorMsg("缺少必要的参数");
  12425. }
  12426. public void get_pack_list()
  12427. {
  12428. DataStruct dStruct = GetPostStruct();
  12429. List<string> lw = new List<string>();
  12430. string supplier = GetPostString("supplier");
  12431. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12432. string posTag = CurrentUser.UserPost.Post.Code;
  12433. if (posTag == "Supplier")
  12434. {
  12435. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12436. }
  12437. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12438. dStruct.Order = "createtime desc";
  12439. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12440. writeGridDataTableJson(dStruct.TotalCount, dt);
  12441. }
  12442. public void get_pack_order_list()
  12443. {
  12444. string packId = GetPostString("packId");
  12445. if (string.IsNullOrEmpty(packId))
  12446. {
  12447. returnErrorMsg("缺少必要的参数");
  12448. return;
  12449. }
  12450. StringBuilder sql = new StringBuilder();
  12451. 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);
  12452. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12453. if (dt == null || dt.Rows.Count == 0)
  12454. {
  12455. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12456. return;
  12457. }
  12458. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12459. return;
  12460. }
  12461. public void get_supplier_product_time_list()
  12462. {
  12463. DataStruct dStruct = GetPostStruct();
  12464. List<string> lw = new List<string>();
  12465. string supplier = GetPostString("supplier");
  12466. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12467. string posTag = CurrentUser.UserPost.Post.Code;
  12468. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12469. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12470. writeGridDataTableJson(dStruct.TotalCount, dt);
  12471. }
  12472. public void saveSupplierProductTime()
  12473. {
  12474. string productId = GetPostString("productId");
  12475. if (string.IsNullOrEmpty(productId))
  12476. {
  12477. returnErrorMsg("缺少必要的参数");
  12478. return;
  12479. }
  12480. string productName = GetPostString("productName");
  12481. int supplierId = GetPostInt("supplierId");
  12482. if (supplierId == 0)
  12483. {
  12484. returnErrorMsg("缺少必要的参数");
  12485. return;
  12486. }
  12487. int quantity = GetPostInt("quantity");
  12488. int sendDay = GetPostInt("sendTime");
  12489. string supplierName = GetPostString("supplierName");
  12490. string craft = GetPostString("craft");
  12491. string deadLine = GetPostString("deadLine");
  12492. string dayDeadLine = GetPostString("dayDeadLine");
  12493. try
  12494. {
  12495. int eid = GetPostInt("eid");
  12496. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12497. if (ceErpSupplierProductTime == null)
  12498. {
  12499. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12500. }
  12501. ceErpSupplierProductTime.productId = productId;
  12502. ceErpSupplierProductTime.productName = productName;
  12503. ceErpSupplierProductTime.supplierId = supplierId;
  12504. ceErpSupplierProductTime.supplierName = supplierName;
  12505. ceErpSupplierProductTime.craft = craft;
  12506. ceErpSupplierProductTime.sendDay = sendDay;
  12507. ceErpSupplierProductTime.quantity = quantity;
  12508. if (!string.IsNullOrEmpty(deadLine))
  12509. {
  12510. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12511. }
  12512. if (!string.IsNullOrEmpty(dayDeadLine))
  12513. {
  12514. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12515. }
  12516. if (ceErpSupplierProductTime.ID == 0)
  12517. {
  12518. ceErpSupplierProductTime.Save();
  12519. }
  12520. else
  12521. {
  12522. ceErpSupplierProductTime.Update();
  12523. }
  12524. }
  12525. catch (Exception e)
  12526. {
  12527. }
  12528. returnSuccessMsg("保存成功");
  12529. return;
  12530. }
  12531. public void delSupplierProductTime()
  12532. {
  12533. int eid = GetPostInt("eid");
  12534. if (eid > 0)
  12535. {
  12536. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12537. if (ceErpSupplierProductTime == null)
  12538. {
  12539. returnErrorMsg("查无数据");
  12540. return;
  12541. }
  12542. ceErpSupplierProductTime.Delete();
  12543. returnSuccessMsg("保存成功");
  12544. return;
  12545. }
  12546. returnErrorMsg("缺少必要的参数");
  12547. }
  12548. public void getExpressInfo()
  12549. {
  12550. string ctid = GetPostString("ctid");
  12551. if (!string.IsNullOrEmpty(ctid))
  12552. {
  12553. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12554. if (ceErpTradeCell != null)
  12555. {
  12556. string outSid = ceErpTradeCell.OutSid;
  12557. if (outSid.Length > 0)
  12558. {
  12559. 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);
  12560. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12561. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12562. return;
  12563. }
  12564. }
  12565. returnErrorMsg("查无记录");
  12566. return;
  12567. }
  12568. returnErrorMsg("缺少必要的参数");
  12569. }
  12570. public void getExpressPostData()
  12571. {
  12572. string express = GetPostString("express");
  12573. if (!string.IsNullOrEmpty(express))
  12574. {
  12575. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12576. if (ceErpExpressInfo != null)
  12577. {
  12578. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12579. return;
  12580. }
  12581. }
  12582. returnErrorMsg("缺少必要的参数");
  12583. }
  12584. public void checkSupplierOrder()
  12585. {
  12586. string ctids = GetPostString("ctids");
  12587. if (ctids != null)
  12588. {
  12589. List<string> list = new List<string>();
  12590. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12591. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12592. for (int i = 0; i < dt.Rows.Count; i++)
  12593. {
  12594. DataRow row = dt.Rows[i];
  12595. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12596. {
  12597. continue;
  12598. }
  12599. list.Add(row["seller_memo"].ToString());
  12600. }
  12601. if (list.Count > 0)
  12602. {
  12603. 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, "点击下载按钮"));
  12604. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12605. return;
  12606. }
  12607. }
  12608. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12609. return;
  12610. }
  12611. public void addPersonId()
  12612. {
  12613. string tid = GetPostString("tid");
  12614. string personId = GetPostString("personId");
  12615. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12616. if (ceErpTrade != null)
  12617. {
  12618. ceErpTrade.receiver_zip = personId;
  12619. ceErpTrade.Update();
  12620. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12621. returnSuccessMsg("保存成功");
  12622. return;
  12623. }
  12624. returnErrorMsg("缺少必要的参数");
  12625. }
  12626. public void addDeliveryPaymant()
  12627. {
  12628. string tid = GetPostString("tid");
  12629. string paymant = GetPostString("paymant");
  12630. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12631. if (ceErpTrade != null)
  12632. {
  12633. if (!string.IsNullOrEmpty(paymant))
  12634. {
  12635. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12636. }
  12637. ceErpTrade.Update();
  12638. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12639. returnSuccessMsg("保存成功");
  12640. return;
  12641. }
  12642. returnErrorMsg("缺少必要的参数");
  12643. }
  12644. public void saveCellFile()
  12645. {
  12646. string tid = GetPostString("tid");
  12647. string ctid = GetPostString("ctid");
  12648. string urls = GetPostString("urls");
  12649. string type = GetPostString("type");
  12650. string del = GetPostString("del");
  12651. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12652. {
  12653. if ("1".Equals(del))
  12654. {
  12655. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12656. }
  12657. string[] list = urls.Split(',');
  12658. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12659. {
  12660. foreach (string item in list)
  12661. {
  12662. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12663. ceErpTradeCellFile.Create();
  12664. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12665. }
  12666. }
  12667. returnSuccessMsg("保存成功");
  12668. return;
  12669. }
  12670. returnErrorMsg("缺少必要的参数");
  12671. }
  12672. public void getCellFile()
  12673. {
  12674. string tid = GetPostString("tid");
  12675. string ctid = GetPostString("ctid");
  12676. string type = GetPostString("type");
  12677. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12678. {
  12679. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12680. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12681. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12682. return;
  12683. }
  12684. returnErrorMsg("缺少必要的参数");
  12685. }
  12686. public void delCellFile()
  12687. {
  12688. string id = GetPostString("id");
  12689. if (string.IsNullOrEmpty(id))
  12690. {
  12691. returnErrorMsg("缺少必要的参数");
  12692. return;
  12693. }
  12694. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12695. CeErpTradeCellFile.delByID(id);
  12696. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12697. returnSuccessMsg("保存成功");
  12698. }
  12699. }
  12700. }