sync.order.cs 665 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214
  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("BnK3+504SQ8=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\香薰卡售价.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\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1756945416000,\"deliveryType\":\"OFFLINE\",\"discountFee\":20.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1757118213000,\"lines\":[{\"latestDeliveryTime\":1757118213000,\"mark2\":[\"DELIVERED\"],\"num\":1,\"outerId\":\"JSBHUVZYT\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/490100363/O1CN01pEaojF1EYIjYhp76h_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4718408366815008220\",\"refSkuId\":\"5139754537453\",\"refSpuId\":\"641811002682\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"【撕膜留字 | 易撕无残留】\",\"status\":\"SHIPPED\",\"title\":\"水晶标贴UV转印贴logo定制透明标识贴纸设计金属商标烫金标签定做\",\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"YT7568465598389\",\"mark2\":[],\"modifyTime\":1756946987000,\"openBuyerId\":\"AAEVRHraABkUZRPgSx3gFRIR\",\"openBuyerNick\":\"a**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1756945412000,\"payTime\":1756945413000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{\"logisticNo\":\"YT7568465598389\",\"logisticName\":\"圆通速递\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"苏州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴江区\",\"receiverId\":\"871dbaa880a955e031c5061436d7a5c1$\",\"receiverState\":\"江苏省\",\"receiverTown\":\"江陵街道\",\"refOid\":\"4718408366815008220\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-不干胶-uv转印贴小尺寸字母银色黑色-aa_小f-龙井-5,寄样-不干胶-金属标字母银色黑色-aa_小f-龙井-5\",\"serviceFee\":0.0,\"shippingTime\":1756946983000,\"status\":\"SHIPPED\",\"sysTags\":[],\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.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. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  125. List<string> lw = new List<string>();
  126. string tid = GetPostString("ctid");
  127. string date1 = GetPostString("date1");
  128. //12-1 修改
  129. string urgent = GetPostString("urgent");
  130. string back = GetPostString("back");
  131. string offlineSearch = GetPostString("offlineSearch");
  132. int paramsCount = 0;
  133. if (!string.IsNullOrWhiteSpace(urgent))
  134. {
  135. if (urgent.Equals("true"))
  136. {
  137. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  138. }
  139. }
  140. if (!string.IsNullOrWhiteSpace(back))
  141. {
  142. if (back.Equals("true"))
  143. {
  144. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  145. }
  146. }
  147. if (!string.IsNullOrWhiteSpace(offlineSearch))
  148. {
  149. if (offlineSearch.Equals("true"))
  150. {
  151. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  152. }
  153. }
  154. //end
  155. string date2 = GetPostString("date2");
  156. string buyernick = GetPostString("buyer_nick");
  157. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  158. {
  159. if (tid.Length <= 0 && buyernick.Length <= 0)
  160. {
  161. return;
  162. }
  163. }
  164. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  165. {
  166. if (tid.Length > 0)
  167. {
  168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  169. if (ceErpTradeCell != null)
  170. {
  171. tid = ceErpTradeCell.tid;
  172. }
  173. List<string> select_tid = getTidByCtidMore(tid);
  174. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  175. }
  176. if (buyernick.Length > 0)
  177. {
  178. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  179. }
  180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  181. if (dw.Length > 0)
  182. {
  183. lw.Add(dw);
  184. }
  185. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  186. {
  187. string usershop = CurrentUser.User.pemShop;
  188. lw.Add(string.Format("ShopId in ({0})", usershop));
  189. }
  190. }
  191. else
  192. {
  193. if (ex_psize == 0)
  194. {
  195. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  196. }
  197. if (PKey != "admin" && poscode != "SysAdmin")
  198. {
  199. string usershop = CurrentUser.User.pemShop;
  200. lw.Add(string.Format("ShopId in ({0})", usershop));
  201. paramsCount++;
  202. }
  203. }
  204. string uploaddate1 = GetPostString("uploaddate1");
  205. string uploaddate2 = GetPostString("uploaddate2");
  206. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  207. if (update.Length > 0) lw.Add(update);
  208. string deliverydate1 = GetPostString("deliverydate1");
  209. string deliverydate2 = GetPostString("deliverydate2");
  210. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  211. if (deliverydate.Length > 0)
  212. {
  213. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  214. };
  215. string shopname = GetPostString("shopname");
  216. if (shopname.Length > 0)
  217. {
  218. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  219. if (ceErpShop != null)
  220. {
  221. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  222. }
  223. }
  224. string addwechat = GetPostString("addwechat");
  225. if (addwechat.Length > 0)
  226. {
  227. int addWt = Convert.ToInt32(addwechat);
  228. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  229. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  230. }
  231. string customer = GetPostString("customer");
  232. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  233. string design = GetPostString("design");
  234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  235. string orderState = GetPostString("orderState");
  236. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  237. string address = GetPostString("address");
  238. 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));
  239. string sellermemo = GetPostString("seller_memo");
  240. if (sellermemo.Length > 0)
  241. {
  242. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  243. }
  244. string otherMemo = GetPostString("otherMemo");
  245. if (otherMemo.Length > 0)
  246. {
  247. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  248. }
  249. string backReason = GetPostString("backReason");
  250. if (backReason.Length > 0)
  251. {
  252. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  253. }
  254. string apdate1 = GetPostString("apdate1");
  255. string apdate2 = GetPostString("apdate2");
  256. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  257. if (dwap.Length > 0) lw.Add(dwap);
  258. string price1 = GetPostString("price1");
  259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  260. string price2 = GetPostString("price2");
  261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  262. string isoldcustomer = GetPostString("isoldcus");
  263. string spudata = GetPostString("spudata");
  264. if ("0".Equals(spudata))
  265. {
  266. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  267. }
  268. if ("1".Equals(spudata))
  269. {
  270. lw.Add(string.Format("spu_id <> ''"));
  271. }
  272. string finishdate1 = GetPostString("finishdate1");
  273. string finishdate2 = GetPostString("finishdate2");
  274. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  275. bool isFinish = false;
  276. if (finishdate.Length > 0)
  277. {
  278. lw.Add(finishdate);
  279. isFinish = true;
  280. paramsCount++;
  281. }
  282. if (isoldcustomer.Length > 0)
  283. {
  284. if ("2".Equals(isoldcustomer))
  285. {
  286. lw.Add(string.Format("VipCustomer=1"));
  287. }
  288. else
  289. {
  290. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  291. }
  292. }
  293. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  294. if (ex_psize > 0)
  295. {
  296. int UserID = CurrentUser.UserID;
  297. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  298. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  299. {
  300. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  301. }
  302. dStruct.Order = "pay_time desc";
  303. }
  304. string isNew = GetPostString("isNew");
  305. if (isNew == "true")
  306. {
  307. lw.Add(string.Format("IsNew = {0}", 1));
  308. }
  309. string overtime = GetPostString("overtime");
  310. if (overtime == "1")
  311. {
  312. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  313. }
  314. String usePost = CurrentUser.UserPost.Post.Code;
  315. if (usePost.Equals("Operation") == true)
  316. {
  317. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  318. }
  319. else
  320. {
  321. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  322. }
  323. //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";
  324. if (dStruct.PageSize == 100000)
  325. {
  326. dStruct.Order = "";
  327. }
  328. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  329. DataTable dt = null;
  330. string tablename = "view_orderlist";
  331. if (isFinish)
  332. {
  333. tablename = "view_orderlist_end";
  334. }
  335. dt = WebCache.GetData(tablename, dStruct);
  336. if (dt != null && dt.Rows.Count > 0)
  337. {
  338. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  339. foreach (DataRow dr in dt.Rows)
  340. {
  341. try
  342. {
  343. if (dr["refund_fees"] != null)
  344. {
  345. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  346. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  347. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  348. if (payment == refund_fees)
  349. {
  350. dr["refund_fees"] = Math.Round(refund_fees, 2);
  351. }
  352. else if (refund_fees == total_fee)
  353. {
  354. dr["refund_fees"] = payment;
  355. }
  356. else
  357. {
  358. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  359. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  360. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  361. }
  362. }
  363. // 对象操作
  364. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  365. ceErpTradeCell.ctid = dr["ctid"].ToString();
  366. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  367. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  368. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  369. if (dStruct.PageSize != 100000)
  370. {
  371. if (dr["DispatchSort"].ToString() == "2")
  372. {
  373. dr["gongchuang"] = 200;
  374. }
  375. else if ("外协".Equals(dr["ToType"].ToString()))
  376. {
  377. dr["gongchuang"] = 200;
  378. }
  379. else if ("内部".Equals(dr["ToType"].ToString()))
  380. {
  381. dr["gongchuang"] = -1;
  382. }
  383. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  384. {
  385. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  386. dr["gongchuang"] = response.code;
  387. }
  388. }
  389. }
  390. catch (NullReferenceException ex)
  391. {
  392. // 处理空引用异常
  393. dr["refund_fees"] = "0.00";
  394. }
  395. }
  396. }
  397. writeGridDataTableJson(dStruct.TotalCount, dt);
  398. }
  399. public void get_erp_orderlist_sumprice()
  400. {
  401. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  402. return;
  403. List<string> lw = new List<string>();
  404. string tid = GetPostString("ctid");
  405. string date1 = GetPostString("date1");
  406. string date2 = GetPostString("date2");
  407. if (tid.Length > 0 || date1.Length > 0)
  408. {
  409. lw.Add(string.Format("ctid like '%{0}%'", tid));
  410. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  411. if (dw.Length > 0) lw.Add(dw);
  412. }
  413. else
  414. {
  415. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  416. }
  417. string shopname = GetPostString("shopname");
  418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  419. string buyernick = GetPostString("buyer_nick");
  420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  421. string customer = GetPostString("customer");
  422. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  423. string design = GetPostString("design");
  424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  425. string orderState = GetPostString("orderState");
  426. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  427. string address = GetPostString("address");
  428. 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));
  429. string sellermemo = GetPostString("seller_memo");
  430. if (sellermemo.Length > 0)
  431. {
  432. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  433. }
  434. string apdate1 = GetPostString("apdate1");
  435. string apdate2 = GetPostString("apdate2");
  436. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  437. if (dwap.Length > 0) lw.Add(dwap);
  438. string price1 = GetPostString("price1");
  439. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  440. string price2 = GetPostString("price2");
  441. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  442. string isoldcustomer = GetPostString("isoldcus");
  443. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  444. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  445. if (PKey != "admin")
  446. {
  447. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  448. lw.Add(string.Format("shopId in ({0})", usershop));
  449. }
  450. //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";
  451. string mainWhere = string.Join(" and ", lw.ToArray());
  452. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  453. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  454. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  455. decimal total = 0;
  456. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  457. {
  458. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  459. }
  460. var res = new
  461. {
  462. data = total
  463. };
  464. string ro_jsond = JsonConvert.SerializeObject(res);
  465. returnSuccess(ro_jsond);
  466. return;
  467. }
  468. public void get_erp_CustomerServiceGather()
  469. {
  470. string userWhere = "", orderWhere = "";
  471. List<string> lw = new List<string>();
  472. string customer = GetPostString("customer");
  473. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  474. string shopname = GetPostString("shopname");
  475. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  476. string date1 = GetPostString("date1");
  477. string date2 = GetPostString("date2");
  478. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  479. if (dw.Length > 0) lw.Add(dw);
  480. orderWhere = string.Join(" and ", lw.ToArray());
  481. 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 " +
  482. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  483. "left join " +
  484. "( " +
  485. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  486. ") as b on a.ID = b.CustomerUserId " +
  487. "left join " +
  488. "( " +
  489. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  490. ") as d on a.ID = d.CustomerUserId " +
  491. "left join " +
  492. "( " +
  493. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  494. ") as e on a.ID = e.CustomerUserId " +
  495. "left join " +
  496. "( " +
  497. " select CustomerUserId, RefundCount, RefundSum from " +
  498. " ( " +
  499. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  500. " from CE_ErpTradeRefund a " +
  501. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  502. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  503. " group by CustomerUserId " +
  504. " ) as a " +
  505. ") as f on a.ID = f.CustomerUserId " +
  506. "where a.PostCode = 'CustomerService'",
  507. userWhere, orderWhere);
  508. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  509. writeGridDataTableJson(dt.Rows.Count, dt);
  510. //writeGridDataTableJson(dt.Rows.Count, dt);
  511. }
  512. //设计汇总
  513. public void get_erp_DesignerGather()
  514. {
  515. string userWhere = "", orderWhere = "";
  516. List<string> lw = new List<string>();
  517. string Designer = GetPostString("designer");
  518. int org = GetPostInt("org");
  519. if (Designer.Length > 0)
  520. {
  521. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  522. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  523. }
  524. else if (org > 0)
  525. {
  526. userWhere = string.Format(" where OrgID ={0}", org);
  527. }
  528. string shopname = GetPostString("shopname");
  529. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  530. string state = GetPostString("state");
  531. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  532. string OrderArea = GetPostString("order_area");
  533. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  534. string date1 = GetPostString("date1");
  535. string date2 = GetPostString("date2");
  536. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  537. if (dw.Length > 0) lw.Add(dw);
  538. string UpDate1 = GetPostString("UpDate1");
  539. string UpDate2 = GetPostString("UpDate2");
  540. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  541. if (dw.Length > 0) lw.Add(dw);
  542. orderWhere = string.Join(" and ", lw.ToArray());
  543. 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 (" +
  544. "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 " +
  545. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  546. "left join " +
  547. "( " +
  548. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  549. ") as b on a.ID = b.DesignUserId " +
  550. "left join " +
  551. "( " +
  552. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  553. ") as d on a.ID = d.DesignUserId " +
  554. "left join " +
  555. "( " +
  556. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  557. ") as e on a.ID = e.DesignUserId " +
  558. "left join " +
  559. "( " +
  560. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  561. ") as g on a.ID = g.DesignUserId " +
  562. "left join " +
  563. "( " +
  564. " select CustomerUserId, RefundCount, RefundSum from " +
  565. " ( " +
  566. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  567. " from CE_ErpTradeRefund a " +
  568. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  569. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  570. " group by CustomerUserId " +
  571. " ) as a " +
  572. ") as f on a.ID = f.CustomerUserId " +
  573. "where a.PostCode = 'Designer') as z",
  574. userWhere, orderWhere);
  575. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  576. writeGridDataTableJson(dt.Rows.Count, dt);
  577. }
  578. //删除tradecell的订单
  579. public void del_erp_cellorder()
  580. {
  581. if (UrlPostParmsCheck("ctid"))
  582. {
  583. string eid = GetPostString("ctid");
  584. CeErpTradeCell.DelByCtid(eid);
  585. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  586. returnSuccessMsg("删除成功");
  587. }
  588. }
  589. public void clear_erp_refundstate()
  590. {
  591. if (UrlPostParmsCheck("ids"))
  592. {
  593. string eids = GetPostString("ids");
  594. string[] ctidList = eids.Split(',');
  595. foreach (string ctid in ctidList)
  596. {
  597. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  598. if (entity != null)
  599. {
  600. entity.IsRefund = 0;
  601. entity.Update();
  602. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  603. }
  604. else
  605. continue;
  606. }
  607. returnSuccessMsg("操作成功");
  608. return;
  609. }
  610. returnErrorMsg("缺少必要参数");
  611. }
  612. public void set_erp_urgency()
  613. {
  614. if (UrlPostParmsCheck("ctid"))
  615. {
  616. string eid = GetPostString("ctid");
  617. CeErpTradeCell entity = null;
  618. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  619. if (entity != null)
  620. {
  621. double prices = commonHelper.calculationPrice(entity);
  622. if (prices <= 100)
  623. {
  624. returnErrorMsg("此订单金额不足100元,无法加急。");
  625. return;
  626. }
  627. string utime = GetPostString("urgencytime");
  628. if (utime.Length > 0)
  629. {
  630. entity.UrgencyTime = Convert.ToDateTime(utime);
  631. }
  632. else
  633. {
  634. returnErrorMsg("请选择加急时间");
  635. return;
  636. }
  637. if (entity.OrderState <= 4)
  638. {
  639. //entity.seller_memo = entity.seller_memo + "-加急";
  640. string smemo = entity.seller_memo;
  641. int kindex = smemo.IndexOf(")");
  642. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  643. if (lastoneStr != "-")
  644. {
  645. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  646. }
  647. string prememo = smemo.Substring(0, kindex + 2);
  648. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  649. int lastkindex = lastmemo.IndexOf("(");
  650. DateTime urgtime = Convert.ToDateTime(utime);
  651. string newlastmemo = "";
  652. if (lastkindex == 0)
  653. {
  654. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  655. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  656. }
  657. else
  658. {
  659. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  660. }
  661. entity.seller_memo = prememo + newlastmemo;
  662. }
  663. entity.IsUrgency = true;
  664. entity.UpdateTime = DateTime.Now;
  665. entity.Update();
  666. ApiVo apiVo = new ApiVo();
  667. apiVo.orderNumber = entity.ctid;
  668. apiVo.actionName = "changeDesign";
  669. apiVo.orderRemarks = entity.seller_memo;
  670. apiVo.remarkSign = 3;
  671. designHelper.API_WorkCore(apiVo); //changeDesign
  672. CeErpSukuraData.createInfo(entity.ctid, 7);
  673. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  674. returnSuccessMsg("设置成功!");
  675. return;
  676. }
  677. returnErrorMsg("找不到记录");
  678. }
  679. }
  680. public void set_erp_reset()
  681. {
  682. if (UrlPostParmsCheck("ctid"))
  683. {
  684. string eid = GetPostString("ctid");
  685. CeErpTradeCell entity = null;
  686. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  687. if (entity != null)
  688. {
  689. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  690. {
  691. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  692. {
  693. returnErrorMsg("财务要求已下单已发货无法重置");
  694. return;
  695. }
  696. }
  697. entity.IsUrgency = false;
  698. entity.seller_memo = "";
  699. entity.OtherMemo = "";
  700. entity.OrderState = 0;
  701. entity.IsReturn = 0;
  702. //entity.IsRefund = 0;
  703. entity.MemoOpt = 0;
  704. entity.AfterSaleState = 0;
  705. entity.AfterSaleResponsible = "";
  706. entity.AfterSaleUserId = 0;
  707. entity.IsNeedBill = 0;
  708. entity.CustomerUserId = 0;
  709. entity.DesignUserId = 0;
  710. entity.SupplierId = 0;
  711. entity.PlaceUserId = 0;
  712. entity.ptid = "";
  713. entity.IsSample = 0;
  714. entity.IsXianHuo = 0;
  715. entity.isDianziOrder = 0;
  716. entity.DispatchSort = 0;
  717. entity.IsVerifyToSupplier = false;
  718. entity.FinishPlaceTime = null;
  719. entity.Update();
  720. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  721. if (trade != null)
  722. {
  723. trade.seller_memo = "";
  724. trade.Update();
  725. }
  726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  727. returnSuccessMsg("重置成功!");
  728. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  729. if (desginBill != null)
  730. {
  731. desginBill.isDel = 1;
  732. desginBill.Update();
  733. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  734. }
  735. ApiVo apiVo = new ApiVo();
  736. apiVo.orderNumber = entity.ctid;
  737. apiVo.actionName = "resetDesign";
  738. designHelper.API_WorkCore(apiVo);//resetDesign
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_sellermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. string memo = GetPostString("seller_memo");
  754. string qn_memo = GetPostString("qn_memo");
  755. memo = memo.Replace(" ", "");
  756. if (memo.Contains("补差"))
  757. {
  758. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  759. return;
  760. }
  761. List<string> bitList = new List<string>
  762. {
  763. "\\","/",":","*","?", "\"","<" ,">","|"
  764. };
  765. bool isIn = false;
  766. foreach (string bit in bitList)
  767. {
  768. if (memo.Contains(bit))
  769. {
  770. isIn = true;
  771. }
  772. }
  773. if (isIn)
  774. {
  775. returnErrorMsg("不能使用 一些符合作为文件名");
  776. return;
  777. }
  778. if (entity.seller_memo != memo)
  779. {
  780. if (entity.IsSample == 2)
  781. {
  782. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  783. return;
  784. }
  785. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  786. {
  787. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  788. {
  789. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  790. return;
  791. }
  792. /*if (CurrentUser.UserPost.Post.Code != "Place")
  793. {
  794. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  795. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  796. {
  797. returnErrorMsg("售前系统订单无法再此修改!");
  798. return;
  799. }
  800. }*/
  801. }
  802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  803. }
  804. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  805. {
  806. if (entity.OrderState >= 5)
  807. {
  808. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  809. return;
  810. }
  811. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  812. if (string.IsNullOrEmpty(delMemo))
  813. {
  814. returnErrorMsg("备注不规范,无法识别");
  815. return;
  816. }
  817. memo = delMemo;
  818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  819. }
  820. commonHelper.getCytPrice(entity);
  821. int memoopt = GetPostInt("MemoOpt");
  822. Boolean ismemoopt = false;
  823. if (memoopt > 0)
  824. {
  825. string stropt = "";
  826. if (memoopt == 1)
  827. {
  828. stropt = "“改稿”";
  829. ismemoopt = true;
  830. }
  831. else if (memoopt == 2)
  832. {
  833. stropt = "“定稿”";
  834. }
  835. else if (memoopt == 3)
  836. {
  837. stropt = "“查货”";
  838. CeErpSukuraData.createInfo(entity.ctid, 6);
  839. }
  840. entity.MemoOpt = Convert.ToInt32(memoopt);
  841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  842. }
  843. if (entity.OrderState < 5)
  844. {
  845. memo = memo.Replace("(", "(");
  846. memo = memo.Replace(")", ")");
  847. }
  848. /* if (entity.OrderState < 3)
  849. {
  850. entity.DispatchSort = 0;
  851. }*/
  852. entity.seller_memo = memo;
  853. entity.UpdateTime = DateTime.Now;
  854. entity.Update();
  855. ApiVo apiVo = new ApiVo();
  856. apiVo.orderNumber = entity.ctid;
  857. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  858. apiVo.orderRemarks = memo;
  859. apiVo.remarkSign = memoopt;
  860. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  861. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  862. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  863. {
  864. dataHelper.api_orderBack(entity.ctid, "0", "");
  865. }
  866. if (entity.seller_memo.Contains("改稿"))
  867. {
  868. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  869. }
  870. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  871. returnSuccessMsg("保存成功!");
  872. return;
  873. }
  874. returnErrorMsg("找不到记录");
  875. }
  876. }
  877. public void ins_erp_checkorder()
  878. {
  879. if (UrlPostParmsCheck("ctid"))
  880. {
  881. string ctid = GetPostString("ctid");
  882. CeErpTradeCell entity = null;
  883. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  884. if (entity != null)
  885. {
  886. if (entity.OrderState < 6)
  887. {
  888. returnErrorMsg("下单完成后才可查货");
  889. return;
  890. }
  891. /*if (entity.OrderState > 6)
  892. {
  893. returnErrorMsg("订单已发货");
  894. return;
  895. }*/
  896. if (entity.FinishPlaceTime != null)
  897. {
  898. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  899. {
  900. returnErrorMsg("下单时间不足,无法查货");
  901. return;
  902. }
  903. }
  904. entity.MemoOpt = 3;
  905. entity.CheckOrderTime = DateTime.Now;
  906. entity.UpdateTime = DateTime.Now;
  907. entity.Update();
  908. CeErpSukuraData.createInfo(entity.ctid, 6);
  909. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  910. returnSuccessMsg("操作成功!");
  911. return;
  912. }
  913. returnErrorMsg("找不到记录");
  914. }
  915. }
  916. public void save_erp_othermemo()
  917. {
  918. if (UrlPostParmsCheck("ctid"))
  919. {
  920. string ctid = GetPostString("ctid");
  921. CeErpTradeCell entity = null;
  922. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  923. if (entity != null)
  924. {
  925. entity.OtherMemo = GetPostString("otherMemo");
  926. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  927. {
  928. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  929. StringBuilder sql = new StringBuilder();
  930. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  931. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  932. if (dt != null && dt.Rows.Count > 0)
  933. {
  934. foreach (DataRow dr in dt.Rows)
  935. {
  936. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  937. {
  938. //品类一直
  939. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  940. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  941. if (ceErpSampleCustomer == null)
  942. {
  943. ceErpSampleCustomer = new CeErpSampleCustomer();
  944. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  945. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  946. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  947. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  948. ceErpSampleCustomer.shopId = entity.ShopId;
  949. }
  950. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  951. ceErpSampleCustomer.lastTid = entity.tid;
  952. if (ceErpSampleCustomer.ID > 0)
  953. {
  954. ceErpSampleCustomer.Update();
  955. }
  956. else
  957. {
  958. ceErpSampleCustomer.Create();
  959. }
  960. }
  961. }
  962. }
  963. }
  964. //if (entity.IsOldCustomer == 1)
  965. //{
  966. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  967. //{
  968. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  969. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  970. //}
  971. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  972. //{
  973. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  974. // {
  975. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  976. // {
  977. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  978. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  979. // }
  980. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  981. // {
  982. // entity.OrderState = 2;
  983. // entity.DesignUserId = 0;
  984. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  985. // }
  986. // else
  987. // {
  988. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  989. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  990. // }
  991. // }
  992. //}
  993. //}
  994. entity.UpdateTime = DateTime.Now;
  995. entity.Update();
  996. returnSuccessMsg("保存成功!");
  997. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  998. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  999. if (entity.OtherMemo.Contains("改稿"))
  1000. {
  1001. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1002. }
  1003. return;
  1004. }
  1005. returnErrorMsg("找不到记录");
  1006. }
  1007. }
  1008. public void save_erp_customermemo()
  1009. {
  1010. if (UrlPostParmsCheck("ctid"))
  1011. {
  1012. string ctid = GetPostString("ctid");
  1013. CeErpTradeCell entity = null;
  1014. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1015. if (entity != null)
  1016. {
  1017. entity.UpdateTime = DateTime.Now;
  1018. entity.CustomerMemo = GetPostString("CustomerMemo");
  1019. entity.Update();
  1020. ApiVo apiVo = new ApiVo();
  1021. apiVo.orderNumber = entity.ctid;
  1022. apiVo.actionName = "followRemarks";
  1023. apiVo.orderRemarks = entity.CustomerMemo;
  1024. designHelper.API_WorkCore(apiVo);//followRemarks
  1025. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1026. returnSuccessMsg("保存成功!");
  1027. return;
  1028. }
  1029. returnErrorMsg("找不到记录");
  1030. }
  1031. }
  1032. public void upd_erp_addmemotag()
  1033. {
  1034. if (UrlPostParmsCheck("ctid"))
  1035. {
  1036. ;
  1037. string eid = GetPostString("ctid");
  1038. string sfTagstr = GetPostString("memotag");
  1039. CeErpTradeCell entity = null;
  1040. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1041. if (entity != null)
  1042. {
  1043. ApiVo apiVo = new ApiVo();
  1044. if (entity.OrderState == 0)
  1045. {
  1046. returnErrorMsg("请先领单");
  1047. return;
  1048. }
  1049. //撤销顺丰
  1050. if (sfTagstr == "撤销顺丰")
  1051. {
  1052. entity.IsSF = 0;
  1053. string reMsg = "";
  1054. string oldmemo = entity.seller_memo;
  1055. if (entity.OrderState < 5)
  1056. {
  1057. oldmemo = oldmemo.Replace("顺丰到付", "");
  1058. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1059. entity.seller_memo = oldmemo;
  1060. }
  1061. else
  1062. {
  1063. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1064. {
  1065. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1066. }
  1067. }
  1068. entity.Update();
  1069. apiVo.orderNumber = entity.ctid;
  1070. apiVo.actionName = "orderRemarks";
  1071. apiVo.orderRemarks = entity.seller_memo;
  1072. apiVo.isSf = entity.IsSF.ToString();
  1073. designHelper.API_WorkCore(apiVo);//orderRemarks
  1074. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1075. returnSuccessMsg("撤销成功!" + reMsg);
  1076. return;
  1077. }
  1078. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1079. {
  1080. //string oldmemo = entity.seller_memo;
  1081. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1082. string sfStr = GetPostString("memotag");
  1083. string smemo = entity.seller_memo;
  1084. int kindex = smemo.IndexOf(")");
  1085. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1086. if (lastoneStr != "-")
  1087. {
  1088. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1089. }
  1090. string prememo = smemo.Substring(0, kindex + 2);
  1091. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1092. int lastkindex = lastmemo.IndexOf("(");
  1093. string newlastmemo = "";
  1094. if (lastkindex == 0)
  1095. {
  1096. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1097. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1098. }
  1099. else
  1100. {
  1101. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1102. }
  1103. entity.seller_memo = prememo + newlastmemo;
  1104. }
  1105. string sfTagMSg = "";
  1106. if (sfTagstr == "顺丰寄付")
  1107. {
  1108. entity.IsSF = 1;
  1109. sfTagMSg = "顺丰寄付";
  1110. }
  1111. else if (sfTagstr == "顺丰到付")
  1112. {
  1113. entity.IsSF = 2;
  1114. sfTagMSg = "顺丰到付";
  1115. }
  1116. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1117. {
  1118. string deliveryWayName = "";
  1119. if (sfTagstr == "撤销顺丰")
  1120. {
  1121. sfTagstr = "普通快递";
  1122. }
  1123. if (sfTagstr == "顺丰寄付")
  1124. {
  1125. sfTagstr = "顺丰特快寄付";
  1126. }
  1127. if (sfTagstr == "顺丰到付")
  1128. {
  1129. sfTagstr = "顺丰特快到付";
  1130. }
  1131. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1132. if ("修改失败".Equals(result))
  1133. {
  1134. returnErrorMsg("修改失败");
  1135. return;
  1136. }
  1137. }
  1138. entity.Update();
  1139. apiVo = new ApiVo();
  1140. apiVo.orderNumber = entity.ctid;
  1141. apiVo.actionName = "orderRemarks";
  1142. apiVo.orderRemarks = entity.seller_memo;
  1143. apiVo.isSf = entity.IsSF.ToString();
  1144. designHelper.API_WorkCore(apiVo);//orderRemarks
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_ordertag()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. string eid = GetPostString("ctid");
  1157. CeErpTradeCell entity = null;
  1158. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1159. if (entity != null)
  1160. {
  1161. int tag = GetPostInt("wechattag");
  1162. //if(tag==4 && entity.IsSample == 2)
  1163. //{
  1164. // returnErrorMsg("补差价单不能标记微信单");
  1165. // return;
  1166. //}
  1167. entity.wechatTag = tag;
  1168. entity.Update();
  1169. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1170. if (tag == 1)
  1171. {
  1172. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1173. if (cash == null)
  1174. {
  1175. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1176. cash = new CeErpReturnCash();
  1177. cash.tid = entity.tid;
  1178. cash.seller_nick = main.seller_nick;
  1179. cash.payment = trade.payment;
  1180. cash.buyer_nick = main.buyer_nick;
  1181. cash.cashstate = 0;
  1182. cash.rtype = "微信返现";
  1183. cash.returnprice = 0;
  1184. cash.created = DateTime.Now;
  1185. cash.con = "订单标记微信单";
  1186. cash.img = "";
  1187. cash.applyuserid = CurrentUser.UserID;
  1188. cash.Create();
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1190. }
  1191. else
  1192. {
  1193. cash.cashstate = 0;
  1194. cash.Update();
  1195. }
  1196. CeErpSukuraData.createInfo(entity.ctid, 9);
  1197. }
  1198. else if (tag == 2)
  1199. {
  1200. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1201. if (cash == null)
  1202. {
  1203. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1204. cash = new CeErpReturnCash();
  1205. cash.tid = entity.tid;
  1206. cash.seller_nick = main.seller_nick;
  1207. cash.payment = trade.payment;
  1208. cash.buyer_nick = main.buyer_nick;
  1209. cash.cashstate = 0;
  1210. cash.rtype = "推购返现";
  1211. cash.returnprice = 5;
  1212. cash.created = DateTime.Now;
  1213. cash.con = "订单标记推购单";
  1214. cash.img = "";
  1215. cash.applyuserid = CurrentUser.UserID;
  1216. cash.Create();
  1217. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1218. }
  1219. else
  1220. {
  1221. cash.cashstate = 0;
  1222. cash.Update();
  1223. }
  1224. CeErpSukuraData.createInfo(entity.ctid, 9);
  1225. }
  1226. else if (tag == 3)
  1227. {
  1228. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1229. if (pers == null)
  1230. {
  1231. pers = new CeErpPersuade();
  1232. pers.ctid = entity.ctid;
  1233. pers.pstate = 0;
  1234. pers.created = DateTime.Now;
  1235. pers.applyuserid = CurrentUser.UserID;
  1236. pers.Create();
  1237. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1238. }
  1239. else
  1240. {
  1241. pers.pstate = 0;
  1242. pers.Update();
  1243. }
  1244. }
  1245. else if (tag == 4 || tag == 5)
  1246. {
  1247. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1248. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1249. if (pers == null)
  1250. {
  1251. pers = CeErpStayGoods.GetByTid(entity.tid);
  1252. }
  1253. if (pers == null)
  1254. {
  1255. pers = new CeErpStayGoods();
  1256. pers.t_id = entity.tid;
  1257. pers.ctid = entity.ctid;
  1258. pers.status = "待审核";
  1259. pers.audit_type = 0;
  1260. if (tag == 4)
  1261. {
  1262. pers.stay_type = "微信推购";
  1263. }
  1264. else
  1265. {
  1266. pers.stay_type = "旺旺推购";
  1267. }
  1268. if (entity.IsXianHuo == 0)
  1269. {
  1270. pers.product_id = entity.ProductId;
  1271. }
  1272. pers.wangwang = main.buyer_nick;
  1273. pers.shop_name = main.seller_nick;
  1274. pers.creata_time = DateTime.Now;
  1275. pers.create_u_id = CurrentUser.UserID;
  1276. pers.create_u_name = CurrentUser.UserName;
  1277. pers.Create();
  1278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1279. }
  1280. else
  1281. {
  1282. pers.ctid = entity.ctid;
  1283. pers.audit_type = 0;
  1284. pers.Update();
  1285. }
  1286. CeErpSukuraData.createInfo(entity.ctid, 10);
  1287. }
  1288. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1289. returnSuccessMsg("标记成功!");
  1290. return;
  1291. }
  1292. returnErrorMsg("找不到记录");
  1293. }
  1294. }
  1295. public void upd_erp_ordertag_cancel()
  1296. {
  1297. if (UrlPostParmsCheck("ctid"))
  1298. {
  1299. string eid = GetPostString("ctid");
  1300. CeErpTradeCell entity = null;
  1301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1302. if (entity != null)
  1303. {
  1304. entity.wechatTag = 0;
  1305. entity.Update();
  1306. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1307. if (pers != null)
  1308. {
  1309. pers.status = "取消推购";
  1310. pers.audit_type = 3;
  1311. pers.Update();
  1312. }
  1313. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1314. returnSuccessMsg("标记成功!");
  1315. return;
  1316. }
  1317. returnErrorMsg("找不到记录");
  1318. }
  1319. }
  1320. public void upd_erp_addweichattag()
  1321. {
  1322. if (UrlPostParmsCheck("ctid"))
  1323. {
  1324. ;
  1325. string eid = GetPostString("ctid");
  1326. CeErpTradeCell entity = null;
  1327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1328. if (entity != null)
  1329. {
  1330. if (entity.IsAddWechat > 0)
  1331. {
  1332. returnErrorMsg("此单已经标记过了");
  1333. return;
  1334. }
  1335. 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);
  1336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1337. if (dt.Rows.Count > 0)
  1338. {
  1339. entity.IsAddWechat = 2;
  1340. }
  1341. else
  1342. {
  1343. entity.IsAddWechat = 1;
  1344. }
  1345. entity.Update();
  1346. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1347. returnSuccessMsg("标记成功!");
  1348. return;
  1349. }
  1350. returnErrorMsg("找不到记录");
  1351. }
  1352. }
  1353. public void upd_erp_getmyorder()
  1354. {
  1355. if (UrlPostParmsCheck("ctid"))
  1356. {
  1357. string eid = GetPostString("ctid");
  1358. CeErpTradeCell entity = null;
  1359. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1360. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1361. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1362. {
  1363. returnErrorMsg("台湾客户需填写身份证号!");
  1364. return;
  1365. }
  1366. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1367. {
  1368. returnErrorMsg("偏远地区需要填写物流费!");
  1369. return;
  1370. }
  1371. if (entity != null)
  1372. {
  1373. if (entity.ctid.IndexOf("C") != -1)
  1374. {
  1375. StringBuilder sql = new StringBuilder();
  1376. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1378. if (dt.Rows.Count > 0)
  1379. {
  1380. decimal total = 0;
  1381. foreach (DataRow dr in dt.Rows)
  1382. {
  1383. total += Convert.ToDecimal(dr["payment"]);
  1384. }
  1385. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1386. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1387. {
  1388. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1389. return;
  1390. }
  1391. }
  1392. }
  1393. if (entity.OrderState == -1)
  1394. {
  1395. returnErrorMsg("待审核订单无法领取!");
  1396. return;
  1397. }
  1398. entity.CustomerUserId = CurrentUser.UserID;
  1399. if (entity.OrderState < 2)
  1400. {
  1401. entity.OrderState = 2;
  1402. if (entity.ShopId != 0)
  1403. {
  1404. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1405. }
  1406. }
  1407. entity.UpdateTime = DateTime.Now;
  1408. entity.Update();
  1409. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1410. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1411. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1412. {
  1413. dataHelper.api_orderBack(entity.ctid, "0", "");
  1414. }
  1415. returnSuccessMsg("领单成功!");
  1416. return;
  1417. }
  1418. returnErrorMsg("找不到记录");
  1419. }
  1420. }
  1421. public void getmyorder_from_init()
  1422. {
  1423. if (UrlPostParmsCheck("ctid"))
  1424. {
  1425. string eid = GetPostString("ctid");
  1426. CeErpTradeCell entity = null;
  1427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1428. if (entity != null)
  1429. {
  1430. string sellerMemo = GetPostString("sellerMemo");
  1431. if (sellerMemo.Length > 0)
  1432. {
  1433. entity.seller_memo = sellerMemo;
  1434. }
  1435. string oterhMemo = GetPostString("otherMemo");
  1436. if (oterhMemo.Length > 0)
  1437. {
  1438. entity.OtherMemo = oterhMemo;
  1439. }
  1440. int urg = GetPostInt("urgency");
  1441. entity.IsUrgency = (urg == 1 ? true : false);
  1442. int wechat = GetPostInt("wechat");
  1443. int command = GetPostInt("command");
  1444. if (wechat == 1)
  1445. {
  1446. entity.wechatTag = 1;
  1447. }
  1448. if (command == 1)
  1449. {
  1450. entity.wechatTag = 2;
  1451. }
  1452. string pPro = GetPostString("pprofession");
  1453. if (pPro.Length > 0)
  1454. {
  1455. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1456. string spro = GetPostString("profession");
  1457. if (spro.Length > 0)
  1458. {
  1459. entity.ProfessionId = Convert.ToInt32(spro);
  1460. }
  1461. }
  1462. string proId = GetPostString("productId");
  1463. if (proId.Length > 0)
  1464. {
  1465. entity.ProductId = Convert.ToInt32(proId);
  1466. }
  1467. entity.Material = GetPostString("material");
  1468. entity.Craft = GetPostString("craft");
  1469. entity.CustomerUserId = CurrentUser.UserID;
  1470. if (entity.OrderState < 2)
  1471. {
  1472. entity.OrderState = 2;
  1473. if (entity.ShopId != 0)
  1474. {
  1475. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1476. }
  1477. }
  1478. entity.Update();
  1479. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1480. returnSuccessMsg("领单成功!");
  1481. return;
  1482. }
  1483. returnErrorMsg("找不到记录");
  1484. }
  1485. }
  1486. public void upd_erp_setrelationorder()
  1487. {
  1488. if (UrlPostParmsCheck("ctid"))
  1489. {
  1490. ;
  1491. string eid = GetPostString("ctid");
  1492. string ftid = GetPostString("ftid");
  1493. CeErpTradeCell entity = null;
  1494. CeErpTradeCell fentity = null;
  1495. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1496. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1497. if (fentity == null)
  1498. {
  1499. returnErrorMsg("找不到关联的主订单");
  1500. return;
  1501. }
  1502. if (entity != null)
  1503. {
  1504. if (entity.OrderState >= 5)
  1505. {
  1506. returnErrorMsg("本单已经设计完成无法关联");
  1507. return;
  1508. }
  1509. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1510. {
  1511. returnErrorMsg("线下单续审核后才能关联!");
  1512. return;
  1513. }
  1514. entity.ptid = ftid;
  1515. entity.OrderState = fentity.OrderState;
  1516. //entity.status = fentity.status;
  1517. entity.CustomerUserId = fentity.CustomerUserId;
  1518. entity.DesignUserId = fentity.DesignUserId;
  1519. entity.seller_memo = "补差价单:" + ftid;
  1520. entity.IsSample = 2;
  1521. entity.Update();
  1522. ApiVo apiVo = new ApiVo();
  1523. apiVo.orderNumber = ftid;
  1524. apiVo.payment = entity.payment;
  1525. apiVo.actionName = "repairDesign";
  1526. designHelper.API_WorkCore(apiVo);//repairDesign
  1527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1528. returnSuccessMsg("关联成功!");
  1529. return;
  1530. }
  1531. else
  1532. returnErrorMsg("找不到记录");
  1533. }
  1534. }
  1535. public void download_erp_neworder()
  1536. {
  1537. string seller = GetPostString("seller_nick");
  1538. string tid = GetPostString("tid");
  1539. if (seller.Length <= 0 || tid.Length <= 0)
  1540. {
  1541. returnErrorMsg("数据错误");
  1542. }
  1543. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1544. //{
  1545. // returnErrorMsg("找不到店铺Sessionkey");
  1546. //}
  1547. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1548. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1549. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1550. if (res.IndexOf("refOid") == -1)
  1551. {
  1552. returnErrorMsg("下载订单数据失败");
  1553. return;
  1554. }
  1555. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1556. returnSuccessMsg("下载完成");
  1557. //tmcHelper.createNewOrder(res);
  1558. //CeErpTrade entr = null;
  1559. //entr = CeErpTrade.Get(tid);
  1560. //if (entr != null)
  1561. //{
  1562. // returnSuccess("下载成功");
  1563. // //下载成功之后,Cell表生成对应的订单;
  1564. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1565. //}
  1566. //else
  1567. //{
  1568. // returnErrorMsg("下载失败或者创建订单失败");
  1569. //}
  1570. }
  1571. public void set_erp_atersale()
  1572. {
  1573. if (UrlPostParmsCheck("ctid"))
  1574. {
  1575. string eid = GetPostString("ctid");
  1576. string reason = GetPostString("AfterSaleReason");
  1577. CeErpTradeCell entity = null;
  1578. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1579. if (entity != null)
  1580. {
  1581. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1582. {
  1583. returnErrorMsg("此订单已经在售后");
  1584. return;
  1585. }*/
  1586. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1587. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1588. entity.AfterSaleTime = DateTime.Now;
  1589. entity.HandleTime = null;
  1590. entity.Update();
  1591. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1592. returnSuccessMsg("转售后成功!");
  1593. return;
  1594. }
  1595. returnErrorMsg("找不到记录");
  1596. }
  1597. }
  1598. public void set_erp_withdraw()
  1599. {
  1600. if (UrlPostParmsCheck("ctid"))
  1601. {
  1602. try
  1603. {
  1604. string eid = GetPostString("ctid");//商品id
  1605. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1606. CeWithdraw ceWithdrawSelect = null;
  1607. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1608. if (ceWithdrawSelect != null)
  1609. {
  1610. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1611. {
  1612. ceWithdrawSelect.status = -1;
  1613. ceWithdrawSelect.Update();
  1614. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1615. returnSuccessMsg("重新发起审核成功");
  1616. return;
  1617. }
  1618. else
  1619. {
  1620. returnSuccessMsg("请勿重复申请!");
  1621. return;
  1622. }
  1623. }
  1624. else
  1625. {
  1626. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1627. if (string.IsNullOrEmpty(CustomerUserId))
  1628. {
  1629. CustomerUserId = "-1";
  1630. }
  1631. int Userid = CurrentUser.UserID;//用户id
  1632. CeWithdraw ceWithdraw = new CeWithdraw();
  1633. ceWithdraw.tid = eid;
  1634. ceWithdraw.userid = Userid;
  1635. ceWithdraw.providerid = CustomerUserId;
  1636. ceWithdraw.status = 3;
  1637. ceWithdraw.creationtime = DateTime.Now;
  1638. ceWithdraw.Create();
  1639. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1640. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1641. return;
  1642. }
  1643. }
  1644. catch
  1645. {
  1646. returnErrorMsg("申请撤回订单失败");
  1647. return;
  1648. }
  1649. }
  1650. }
  1651. public void ins_erp_billinfo()
  1652. {
  1653. if (UrlPostParmsCheck("ctid"))
  1654. {
  1655. string eid = GetPostString("ctid");
  1656. CeErpTradeCell entity = null;
  1657. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1658. if (entity != null)
  1659. {
  1660. CeErpBill bill = CeErpBill.GetByTid(eid);
  1661. bool isHave = false;
  1662. if (bill != null)
  1663. {
  1664. isHave = true;
  1665. if (bill.state != 4)
  1666. {
  1667. returnErrorMsg("此单已经申请过发票了");
  1668. return;
  1669. }
  1670. }
  1671. if (entity.IsNeedBill == 0)
  1672. {
  1673. entity.IsNeedBill = 1;
  1674. }
  1675. entity.Update();
  1676. string errjson = "";
  1677. try
  1678. {
  1679. CeErpBill bill_entity = new CeErpBill();
  1680. bill_entity.tid = entity.tid;
  1681. bill_entity.title = GetPostString("title");
  1682. string taxstr = GetPostString("tax");
  1683. taxstr = taxstr.Replace(" ", "");
  1684. bill_entity.tax = taxstr;
  1685. bill_entity.bank = GetPostString("bank");
  1686. string bankacstr = GetPostString("bankac");
  1687. bankacstr = bankacstr.Replace(" ", "");
  1688. bill_entity.bankac = bankacstr;
  1689. bill_entity.address = GetPostString("address");
  1690. bill_entity.phone = GetPostString("phone");
  1691. bill_entity.price = GetPostString("price");
  1692. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1693. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1694. {
  1695. billCount += 1;
  1696. }
  1697. string prebill = "ltb";
  1698. for (int idx = 1; idx <= 1; idx++)
  1699. {
  1700. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1701. string billoid = prebill + idx + dtstr;
  1702. bill_entity.billOrderId += billoid;
  1703. if (idx < billCount)
  1704. {
  1705. bill_entity.billOrderId += ",";
  1706. }
  1707. }
  1708. bill_entity.productId = GetPostInt("ProductName");
  1709. bill_entity.num = GetPostInt("num");
  1710. bill_entity.unit = GetPostString("unit");
  1711. bill_entity.type = GetPostString("type");
  1712. bill_entity.sendType = GetPostString("SendType");
  1713. bill_entity.email = GetPostString("email");
  1714. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1715. bill_entity.shopName = GetPostString("ShopName");
  1716. bill_entity.applymemo = GetPostString("applyMemo");
  1717. bill_entity.createTime = DateTime.Now;
  1718. bill_entity.state = 0;
  1719. bill_entity.userId = CurrentUser.UserID;
  1720. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1721. bill_entity.Create();
  1722. }
  1723. catch (Exception ex)
  1724. {
  1725. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1726. returnErrorMsg("创建发票出错!");
  1727. return;
  1728. }
  1729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1730. returnSuccessMsg("发票申请成功!");
  1731. return;
  1732. }
  1733. returnErrorMsg("找不到记录");
  1734. }
  1735. }
  1736. public void ins_erp_neworder()
  1737. {
  1738. if (UrlPostParmsCheck("receiver_name"))
  1739. {
  1740. CeErpTrade entity = new CeErpTrade();
  1741. string plat_form = GetPostString("platform");
  1742. string preStr = "N_";
  1743. if (plat_form == "拼多多")
  1744. {
  1745. preStr = "P_";
  1746. }
  1747. else if (plat_form == "阿里巴巴")
  1748. {
  1749. preStr = "A_";
  1750. }
  1751. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1752. entity.seller_nick = GetPostString("seller_nick");
  1753. entity.buyer_nick = GetPostString("buyer_nick");
  1754. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1755. entity.total_fee = entity.payment;
  1756. entity.pay_time = DateTime.Now;
  1757. entity.status = "NOT_SHIPPED";
  1758. entity.receiver_name = GetPostString("receiver_name");
  1759. entity.receiver_mobile = GetPostString("receiver_mobile");
  1760. entity.receiver_state = GetPostString("receiver_state");
  1761. entity.receiver_city = GetPostString("receiver_city");
  1762. entity.receiver_district = GetPostString("receiver_district");
  1763. entity.receiver_address = GetPostString("receiver_address");
  1764. if (entity.receiver_state == "" || entity.receiver_city == "")
  1765. {
  1766. returnErrorMsg("收件地址不能为空");
  1767. return;
  1768. }
  1769. int shopId = 0;
  1770. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1771. if (nShop != null)
  1772. {
  1773. shopId = nShop.ID;
  1774. }
  1775. if (shopId != 34 && entity.payment == 0)
  1776. {
  1777. returnErrorMsg("公司自用的单金额才能为0");
  1778. return;
  1779. }
  1780. entity.Create();
  1781. CeErpTradeCell entitycell = new CeErpTradeCell();
  1782. entitycell.ctid = entity.tid;
  1783. entitycell.tid = entity.tid;
  1784. entitycell.ShopId = shopId;
  1785. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1786. entitycell.OrderState = 0;
  1787. entitycell.pay_time = entity.pay_time;
  1788. entitycell.IsOffLineOrder = 1;
  1789. entitycell.Create();
  1790. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1791. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1792. return;
  1793. }
  1794. }
  1795. public void ins_erp_neworder2()
  1796. {
  1797. if (UrlPostParmsCheck("receiver_name"))
  1798. {
  1799. //string plat_form = GetPostString("platform");
  1800. string preStr = "X_";
  1801. string memo = GetPostString("memo");
  1802. string productId = GetPostString("productId");
  1803. string primg = GetPostString("proofimg");
  1804. string sellerNick = GetPostString("seller_nick");
  1805. string addFrom = GetPostString("addfrom");
  1806. if (addFrom == "1")
  1807. {
  1808. preStr = "N_";
  1809. }
  1810. int shopId = 0;
  1811. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1812. if (nShop != null)
  1813. {
  1814. shopId = nShop.ID;
  1815. }
  1816. else
  1817. {
  1818. returnErrorMsg("找不到对应店铺");
  1819. return;
  1820. }
  1821. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1822. {
  1823. returnErrorMsg("必须上传付款凭证");
  1824. return;
  1825. }
  1826. CeErpTrade entity = new CeErpTrade();
  1827. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1828. entity.seller_nick = sellerNick;
  1829. entity.buyer_nick = GetPostString("buyer_nick");
  1830. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1831. entity.total_fee = entity.payment;
  1832. entity.pay_time = DateTime.Now;
  1833. entity.status = "NOT_SHIPPED";
  1834. entity.receiver_name = GetPostString("receiver_name");
  1835. entity.receiver_mobile = GetPostString("receiver_mobile");
  1836. entity.receiver_state = GetPostString("receiver_state");
  1837. entity.receiver_city = GetPostString("receiver_city");
  1838. entity.receiver_district = GetPostString("receiver_district");
  1839. entity.receiver_address = GetPostString("receiver_address");
  1840. entity.seller_memo = memo;
  1841. entity.orderFrom = 20;
  1842. entity.orderType = 15;
  1843. if (entity.receiver_state == "" || entity.receiver_city == "")
  1844. {
  1845. returnErrorMsg("收件地址不能为空");
  1846. return;
  1847. }
  1848. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1849. {
  1850. returnErrorMsg("公司自用的单金额才能为0");
  1851. return;
  1852. }
  1853. entity.Create();
  1854. string toWhere = GetPostString("towhere");
  1855. string oldOrder = GetPostString("oldOrder");
  1856. CeErpTradeCell entitycell = new CeErpTradeCell();
  1857. entitycell.ctid = entity.tid;
  1858. //唯一标识
  1859. entitycell.OrderSn = entity.tid;
  1860. string orderSn = dataHelper.getSaleOrderSn();
  1861. if (orderSn != "")
  1862. {
  1863. entitycell.OrderSn = orderSn;
  1864. }
  1865. entitycell.tid = entity.tid;
  1866. //if (preStr == "X_")
  1867. //{
  1868. entitycell.IsOffLineOrder = 1;
  1869. if ("1".Equals(oldOrder))
  1870. {
  1871. entitycell.IsOldCustomer = 1;
  1872. }
  1873. //}
  1874. entitycell.CustomerUserId = CurrentUser.UserID;
  1875. entitycell.PayProofImg = primg;
  1876. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1877. entitycell.ProductId = Convert.ToInt32(productId);
  1878. entitycell.ShopId = shopId;
  1879. entitycell.UpdateTime = DateTime.Now;
  1880. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1881. if (entitycell.ProductId > 0)
  1882. {
  1883. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1884. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1885. {
  1886. entitycell.NewProduct = 1;
  1887. }
  1888. }
  1889. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1890. {
  1891. entitycell.IsXianHuo = 1;
  1892. }
  1893. entitycell.pay_time = entity.pay_time;
  1894. if (toWhere == "1")
  1895. {
  1896. entitycell.OrderState = 2;
  1897. }
  1898. else
  1899. {
  1900. entitycell.OrderState = 6;
  1901. entitycell.FinishPlaceTime = entitycell.pay_time;
  1902. }
  1903. if (shopId == 94)
  1904. {
  1905. entitycell.OrderState = 4;
  1906. entitycell.WaitDesignTime = entitycell.pay_time;
  1907. entitycell.StartDesignTime = entitycell.pay_time;
  1908. entitycell.DesignUserId = 218;
  1909. }
  1910. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1911. {
  1912. entitycell.OrderState = -1;//修改12-5
  1913. CeWithdraw ceWithdraw = new CeWithdraw();
  1914. ceWithdraw.tid = entity.tid;
  1915. ceWithdraw.providerid = "-1";
  1916. ceWithdraw.status = -1;
  1917. ceWithdraw.creationtime = DateTime.Now;
  1918. ceWithdraw.userid = 4634;
  1919. ceWithdraw.Create();
  1920. }
  1921. entitycell.Create();
  1922. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1923. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1924. {
  1925. addPlaceRegist(entitycell, CurrentUser.UserID);
  1926. }
  1927. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1928. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1929. return;
  1930. }
  1931. }
  1932. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1933. {
  1934. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1935. entity.PlactTime = tradecell.pay_time;
  1936. entity.AddUserId = userid;
  1937. entity.FileName = tradecell.seller_memo;
  1938. entity.Supplier = 24;
  1939. entity.CreateTime = DateTime.Now;
  1940. entity.Did = tradecell.ctid;
  1941. entity.tid = tradecell.tid;
  1942. entity.splitTag = tradecell.SplitTag;
  1943. entity.CurState = "未完成";
  1944. entity.Create();
  1945. }
  1946. public void get_erp_offlinelist()
  1947. {
  1948. DataStruct dStruct = GetPostStruct();
  1949. List<string> lw = new List<string>();
  1950. string tid = GetPostString("ctid");
  1951. string date1 = GetPostString("date1");
  1952. string date2 = GetPostString("date2");
  1953. if (tid.Length > 0 || date1.Length > 0)
  1954. {
  1955. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1956. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1957. if (dw.Length > 0) lw.Add(dw);
  1958. }
  1959. else
  1960. {
  1961. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1962. }
  1963. string shopname = GetPostString("shopname");
  1964. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1965. string buyernick = GetPostString("buyer_nick");
  1966. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1967. string customer = GetPostString("customer");
  1968. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1969. string design = GetPostString("design");
  1970. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1971. string orderState = GetPostString("orderState");
  1972. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1973. string address = GetPostString("address");
  1974. 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));
  1975. string sellermemo = GetPostString("seller_memo");
  1976. if (sellermemo.Length > 0)
  1977. {
  1978. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1979. }
  1980. string price1 = GetPostString("price1");
  1981. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1982. string price2 = GetPostString("price2");
  1983. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1984. //if (PKey != "admin")
  1985. //{
  1986. // string usershop = CurrentUser.User.pemShop;
  1987. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1988. //}
  1989. //if (ex_psize > 0)
  1990. //{
  1991. dStruct.Order = "pay_time desc";
  1992. //}
  1993. //else
  1994. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1995. lw.Add(string.Format("IsOffLineOrder=1"));
  1996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1997. DataTable dt = null;
  1998. dt = WebCache.GetData("view_erptradecell", dStruct);
  1999. writeGridDataTableJson(dStruct.TotalCount, dt);
  2000. }
  2001. public void get_erp_returncashrecord()
  2002. {
  2003. DataStruct dStruct = GetPostStruct();
  2004. List<string> lw = new List<string>();
  2005. string tid = GetPostString("ctid");
  2006. if (tid.Length > 0)
  2007. {
  2008. lw.Add(string.Format("tid like '%{0}%'", tid));
  2009. dStruct.Order = "id desc";
  2010. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2011. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2012. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2013. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2014. return;
  2015. }
  2016. returnErrorMsg("id数据错误!");
  2017. }
  2018. public void ins_erp_returncashrecord()
  2019. {
  2020. if (UrlPostParmsCheck("tid"))
  2021. {
  2022. string tid = GetPostString("tid");
  2023. string retype = GetPostString("type");
  2024. StringBuilder sql = new StringBuilder();
  2025. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2027. if (dt.Rows.Count > 0)
  2028. {
  2029. returnErrorMsg("相同返现类型记录已存在");
  2030. return;
  2031. }
  2032. CeErpReturnCash entity = new CeErpReturnCash();
  2033. entity.tid = tid;
  2034. entity.seller_nick = GetPostString("seller_nick");
  2035. string pment = GetPostString("payment");
  2036. if (pment.Length > 0)
  2037. {
  2038. entity.payment = Convert.ToDouble(pment);
  2039. }
  2040. entity.buyer_nick = GetPostString("buyer_nick");
  2041. entity.cashstate = 0;
  2042. entity.rtype = retype;
  2043. string rPrice = GetPostString("returnprice");
  2044. if (rPrice.Length > 0)
  2045. {
  2046. entity.returnprice = Convert.ToDouble(rPrice);
  2047. }
  2048. entity.created = DateTime.Now;
  2049. entity.con = GetPostString("con");
  2050. entity.img = GetPostString("img");
  2051. entity.applyuserid = CurrentUser.UserID;
  2052. entity.Create();
  2053. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2054. returnSuccessMsg("操作成功!");
  2055. return;
  2056. }
  2057. }
  2058. public void set_erp_predelivery()
  2059. {
  2060. if (UrlPostParmsCheck("ctid"))
  2061. {
  2062. string eid = GetPostString("ctid");
  2063. CeErpTradeCell entity = null;
  2064. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2065. if (entity != null)
  2066. {
  2067. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2068. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2069. //{
  2070. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2071. // return;
  2072. //}
  2073. entity.IsPreDelivery = 1;
  2074. entity.Update();
  2075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2076. returnSuccessMsg("预发货成功!");
  2077. return;
  2078. //string shop = GetPostString("seller_nick");
  2079. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2080. //string comName = GetPostString("comName");
  2081. //string comCode = GetPostString("comCode");
  2082. //string outSid = GetPostString("outSid");//运单号
  2083. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2084. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2085. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2086. //string apires = "";
  2087. //if (deliveryType == "虚拟发货")
  2088. //{
  2089. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2090. //}
  2091. //else
  2092. //{
  2093. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2094. //}
  2095. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2096. ////{
  2097. //if (apires.IndexOf("发货成功") != -1)
  2098. //{
  2099. // if (deliveryType != "虚拟发货")
  2100. // {
  2101. // //还要插入快递信息到 快递信息表
  2102. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2103. // exinfo.tid = eid;
  2104. // exinfo.out_sid = outSid;
  2105. // exinfo.company_code = comCode;
  2106. // exinfo.company_name = comName;
  2107. // exinfo.delivery_memo = deliveryMemo;
  2108. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2109. // exinfo.deliveryType = deliveryType;
  2110. // exinfo.Create();
  2111. // }
  2112. // returnSuccessMsg("发货成功!");
  2113. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2114. //}
  2115. //else
  2116. //{
  2117. // returnErrorMsg("淘宝发货失败!!");
  2118. //}
  2119. //return;
  2120. }
  2121. returnErrorMsg("找不到订单记录");
  2122. }
  2123. }
  2124. public void get_erp_unusuallist()
  2125. {
  2126. DataStruct dStruct = GetPostStruct();
  2127. List<string> lw = new List<string>();
  2128. string tid = GetPostString("ctid");
  2129. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2130. string shopname = GetPostString("shopname");
  2131. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2132. string buyernick = GetPostString("buyer_nick");
  2133. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2134. string ResponsibleMan = GetPostString("responsible");
  2135. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2136. string date1 = GetPostString("date1");
  2137. string date2 = GetPostString("date2");
  2138. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2139. if (dw.Length > 0) lw.Add(dw);
  2140. string price1 = GetPostString("price1");
  2141. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2142. string price2 = GetPostString("price2");
  2143. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2144. string orderState = GetPostString("orderState");
  2145. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2146. string sellermemo = GetPostString("seller_memo");
  2147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2148. lw.Add(string.Format("UnusualTag > 0"));
  2149. lw.Add(string.Format("IsRefund<={0}", 1));
  2150. dStruct.Order = "pay_time desc";
  2151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2152. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2153. writeGridDataTableJson(dStruct.TotalCount, dt);
  2154. }
  2155. public void set_erp_unusualtonomal()
  2156. {
  2157. if (UrlPostParmsCheck("ctid"))
  2158. {
  2159. string eid = GetPostString("ctid");
  2160. CeErpTradeCell entity = null;
  2161. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2162. if (entity != null)
  2163. {
  2164. entity.UnusualTag = -1;
  2165. entity.Update();
  2166. returnSuccessMsg("忽略成功!");
  2167. return;
  2168. }
  2169. returnErrorMsg("找不到记录");
  2170. }
  2171. }
  2172. public void ins_erp_unusualreason()
  2173. {
  2174. if (UrlPostParmsCheck("ctid"))
  2175. {
  2176. string eid = GetPostString("ctid");
  2177. CeErpTradeCell entity = null;
  2178. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2179. if (entity != null)
  2180. {
  2181. entity.MemoOpt = 4;
  2182. entity.UnusualCon = GetPostString("con");
  2183. entity.Update();
  2184. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2185. if (trade != null)
  2186. {
  2187. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2188. }
  2189. //查货是否超时
  2190. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2191. if (ceErpTradeCellExtend == null)
  2192. {
  2193. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2194. ceErpTradeCellExtend.ctid = entity.ctid;
  2195. }
  2196. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2197. {
  2198. ceErpTradeCellExtend.CheckOut += 1;
  2199. }
  2200. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2201. if (ceErpTradeCellExtend.ID > 0)
  2202. {
  2203. ceErpTradeCellExtend.Update();
  2204. }
  2205. else
  2206. {
  2207. ceErpTradeCellExtend.Create();
  2208. }
  2209. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2210. returnSuccessMsg("操作成功!");
  2211. return;
  2212. }
  2213. returnErrorMsg("找不到记录");
  2214. }
  2215. }
  2216. public void upd_erp_sampleorder()
  2217. {
  2218. if (UrlPostParmsCheck("ctid"))
  2219. {
  2220. string eid = GetPostString("ctid");
  2221. string[] eArr = eid.Split(',');
  2222. if (eArr.Length > 1)
  2223. {
  2224. List<string> eLst = new List<string>();
  2225. for (int i = 0; i < eArr.Length; i++)
  2226. {
  2227. eLst.Add("'" + eArr[i] + "'");
  2228. }
  2229. eid = string.Join(",", eLst.ToArray());
  2230. }
  2231. else
  2232. {
  2233. eid = "'" + eid + "'";
  2234. }
  2235. StringBuilder sql = new StringBuilder();
  2236. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2237. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2238. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2239. if (dt.Rows.Count > 0)
  2240. {
  2241. string errmsg = "";
  2242. foreach (DataRow dr in dt.Rows)
  2243. {
  2244. StringBuilder sqlsb = new StringBuilder();
  2245. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2246. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2247. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2248. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2249. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2250. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2251. {
  2252. continue;
  2253. }
  2254. else
  2255. {
  2256. string emsg = commonHelper.KeepChinese(apires);
  2257. errmsg += emsg;
  2258. }*/
  2259. }
  2260. if (errmsg.Length > 0)
  2261. {
  2262. returnErrorMsg(errmsg);
  2263. return;
  2264. }
  2265. returnSuccessMsg("操作成功");
  2266. return;
  2267. }
  2268. returnErrorMsg("找不到记录");
  2269. }
  2270. }
  2271. public void upd_erp_transcustomer()
  2272. {
  2273. if (UrlPostParmsCheck("ctid"))
  2274. {
  2275. string eid = GetPostString("ctid");
  2276. int userid = GetPostInt("CustomerUserId");
  2277. CeErpTradeCell entity = null;
  2278. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2279. if (entity != null)
  2280. {
  2281. //string[] mlist = entity.seller_memo.Split('-');
  2282. //string sql = "select * from view_erpuser where id=" + userid;
  2283. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2284. //if (dt != null && dt.Rows.Count > 0)
  2285. //{
  2286. // string nmemo = "";
  2287. // for(int i = 0; i < mlist.Length - 1; i++)
  2288. // {
  2289. // nmemo += mlist[i];
  2290. // nmemo += "-";
  2291. // }
  2292. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2293. // entity.seller_memo = nmemo;
  2294. //}
  2295. entity.CustomerUserId = userid;
  2296. entity.Update();
  2297. returnSuccessMsg("操作成功!");
  2298. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2299. return;
  2300. }
  2301. returnErrorMsg("找不到记录");
  2302. }
  2303. }
  2304. public void upd_erp_transdesigner()
  2305. {
  2306. if (UrlPostParmsCheck("ctid"))
  2307. {
  2308. string eids = GetPostString("ctid");
  2309. string[] ctidList = eids.Split(',');
  2310. int userid = GetPostInt("DesignUserId");
  2311. foreach (string ctid in ctidList)
  2312. {
  2313. CeErpTradeCell entity = null;
  2314. CeErpDesignerBill entitys = null;
  2315. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2316. entitys = CeErpDesignerBill.GetByTid(ctid);
  2317. if (entity != null)
  2318. {
  2319. if (entity.OrderState > 4)
  2320. {
  2321. continue;
  2322. }
  2323. //存在退款不能流转
  2324. if (entity.IsRefund > 0)
  2325. {
  2326. continue;
  2327. }
  2328. entity.DesignUserId = userid;
  2329. entity.WaitDesignTime = DateTime.Now;
  2330. entity.Update();
  2331. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2332. }
  2333. }
  2334. returnSuccessMsg("操作成功!");
  2335. }
  2336. }
  2337. public void upd_erp_distributedesigner()
  2338. {
  2339. if (UrlPostParmsCheck("ctid"))
  2340. {
  2341. string eid = GetPostString("ctid");
  2342. int userid = GetPostInt("DesignUserId");
  2343. string[] idlist = eid.Split(',');
  2344. if (idlist.Length <= 0)
  2345. {
  2346. returnErrorMsg("订单不能为空");
  2347. return;
  2348. }
  2349. foreach (string ctid in idlist)
  2350. {
  2351. CeErpTradeCell entity = null;
  2352. CeErpDesignerBill entitys = null;
  2353. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2354. else continue;
  2355. if (entity != null)
  2356. {
  2357. if (userid == 2125 || userid == 3542)
  2358. { }
  2359. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2360. {
  2361. returnErrorMsg("金额错误的订单无法指派");
  2362. return;
  2363. }
  2364. if (entity.OrderState >= 5)
  2365. {
  2366. returnErrorMsg("已经设计完成无法指派");
  2367. return;
  2368. }
  2369. if (entity.OrderState == -1)
  2370. {
  2371. returnErrorMsg("审核中的订单无法指派");
  2372. return;
  2373. }
  2374. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2375. {
  2376. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2377. return;
  2378. }
  2379. //157赖橙帆 159林晨 73 静之颖
  2380. 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)
  2381. {
  2382. returnErrorMsg("指派设计共创无法再次指派!");
  2383. return;
  2384. }
  2385. entity.OrderState = 3;
  2386. if (entity.SupplierId == 0)
  2387. {
  2388. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2389. entity.SupplierId = suid;
  2390. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2391. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2392. }
  2393. if (userid == 2125 && entity.seller_memo != "")
  2394. {
  2395. //apiDesign.API_GetPrintData_CreateOrder(entity);
  2396. }
  2397. if (userid == 3542 && entity.seller_memo != "")
  2398. {
  2399. string userPost = CurrentUser.UserPost.Post.Code;
  2400. if (CurrentUser.UserID == 73)
  2401. {
  2402. userPost = "SysAdmin";
  2403. }
  2404. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2405. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2406. if (response.msg != "设计共创:成功")
  2407. {
  2408. returnErrorMsg(response.msg);
  2409. return;
  2410. }
  2411. entity.DispatchSort = 2;
  2412. }
  2413. else
  2414. {
  2415. if (entity.DispatchSort == 2)
  2416. {
  2417. ApiVo apiVo = new ApiVo();
  2418. apiVo.actionName = "closeDesign";
  2419. apiVo.orderNumber = entity.ctid;
  2420. designHelper.API_WorkCore(apiVo);//closeDesign
  2421. }
  2422. entity.DispatchSort = 0;
  2423. }
  2424. entity.DesignUserId = userid;
  2425. entity.WaitDesignTime = DateTime.Now;
  2426. entity.UpdateTime = DateTime.Now;
  2427. entity.Update();
  2428. string name = commonHelper.getUserNameById(userid);
  2429. commonHelper.UpdateRelationOrder(entity.ctid);
  2430. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2431. }
  2432. }
  2433. returnSuccessMsg("操作成功!");
  2434. return;
  2435. }
  2436. }
  2437. public string getTidByCtid(string ctid)
  2438. {
  2439. string tid = "";
  2440. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2441. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2442. if (dataTable != null && dataTable.Rows.Count > 0)
  2443. {
  2444. tid = dataTable.Rows[0]["tid"].ToString();
  2445. }
  2446. return tid;
  2447. }
  2448. public List<string> getTidByCtidMore(string ctid)
  2449. {
  2450. 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);
  2451. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2452. List<string> list = new List<string>();
  2453. if (dataTable != null && dataTable.Rows.Count > 0)
  2454. {
  2455. foreach (DataRow item in dataTable.Rows)
  2456. {
  2457. list.Add("'" + item["tid"].ToString() + "'");
  2458. }
  2459. }
  2460. return list;
  2461. }
  2462. public List<string> getTidByCtidLike(string ctid)
  2463. {
  2464. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2465. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2466. List<string> list = new List<string>();
  2467. if (dataTable != null && dataTable.Rows.Count > 0)
  2468. {
  2469. foreach (DataRow item in dataTable.Rows)
  2470. {
  2471. list.Add("'" + item["tid"].ToString() + "'");
  2472. }
  2473. }
  2474. return list;
  2475. }
  2476. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2477. {
  2478. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2479. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2480. List<string> list = new List<string>();
  2481. if (dataTable != null && dataTable.Rows.Count > 0)
  2482. {
  2483. foreach (DataRow item in dataTable.Rows)
  2484. {
  2485. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2486. {
  2487. continue;
  2488. }
  2489. list.Add("'" + item["receiverId"].ToString() + "'");
  2490. }
  2491. }
  2492. return list;
  2493. }
  2494. public void get_erp_myorderlist()
  2495. {
  2496. DataStruct dStruct = GetPostStruct();
  2497. List<string> lw = new List<string>();
  2498. string tid = GetPostString("ctid");
  2499. if (tid.Length > 0)
  2500. {
  2501. string select_tid = getTidByCtid(tid);
  2502. lw.Add(string.Format("tid='{0}'", select_tid));
  2503. }
  2504. else
  2505. {
  2506. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2507. }
  2508. //12-1 修改
  2509. string urgent = GetPostString("urgent");
  2510. string back = GetPostString("back");
  2511. string offlineSearch = GetPostString("offlineSearch");
  2512. if (!string.IsNullOrWhiteSpace(urgent))
  2513. {
  2514. if (urgent.Equals("true"))
  2515. {
  2516. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2517. }
  2518. }
  2519. if (!string.IsNullOrWhiteSpace(back))
  2520. {
  2521. if (back.Equals("true"))
  2522. {
  2523. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2524. }
  2525. }
  2526. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2527. {
  2528. if (offlineSearch.Equals("true"))
  2529. {
  2530. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2531. }
  2532. }
  2533. //end
  2534. string shopname = GetPostString("shopname");
  2535. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2536. string buyernick = GetPostString("buyer_nick");
  2537. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2538. string design = GetPostString("design");
  2539. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2540. string orderState = GetPostString("orderState");
  2541. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2542. string sellermemo = GetPostString("seller_memo");
  2543. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2544. string date1 = GetPostString("date1");
  2545. string date2 = GetPostString("date2");
  2546. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2547. if (dw.Length > 0) lw.Add(dw);
  2548. string price1 = GetPostString("price1");
  2549. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2550. string price2 = GetPostString("price2");
  2551. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2552. string urgency = GetPostString("urgency");
  2553. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2554. string after = GetPostString("after");
  2555. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2556. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2557. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2558. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2559. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2560. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2561. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2562. if (dt != null && dt.Rows.Count > 0)
  2563. {
  2564. foreach (DataRow dr in dt.Rows)
  2565. {
  2566. try
  2567. {
  2568. // 对象操作
  2569. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2570. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2571. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2572. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2573. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2574. if (dStruct.PageSize != 100000)
  2575. {
  2576. if (dr["DispatchSort"].ToString() == "2")
  2577. {
  2578. dr["gongchuang"] = 200;
  2579. }
  2580. else if ("外协".Equals(dr["ToType"].ToString()))
  2581. {
  2582. dr["gongchuang"] = 200;
  2583. }
  2584. else if ("内部".Equals(dr["ToType"].ToString()))
  2585. {
  2586. dr["gongchuang"] = -1;
  2587. }
  2588. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2589. {
  2590. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2591. dr["gongchuang"] = response.code;
  2592. }
  2593. }
  2594. }
  2595. catch (NullReferenceException ex)
  2596. {
  2597. }
  2598. }
  2599. }
  2600. writeGridDataTableJson(dStruct.TotalCount, dt);
  2601. }
  2602. public void get_erp_myreturnorderlist()
  2603. {
  2604. DataStruct dStruct = GetPostStruct();
  2605. List<string> lw = new List<string>();
  2606. string tid = GetPostString("ctid");
  2607. if (tid.Length > 0)
  2608. {
  2609. string select_tid = getTidByCtid(tid);
  2610. lw.Add(string.Format("tid='{0}'", select_tid));
  2611. }
  2612. else
  2613. {
  2614. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2615. }
  2616. string shopname = GetPostString("shopname");
  2617. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2618. string buyernick = GetPostString("buyer_nick");
  2619. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2620. string design = GetPostString("design");
  2621. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2622. string orderState = GetPostString("orderState");
  2623. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2624. string sellermemo = GetPostString("seller_memo");
  2625. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2626. string date1 = GetPostString("date1");
  2627. string date2 = GetPostString("date2");
  2628. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2629. if (dw.Length > 0) lw.Add(dw);
  2630. string price1 = GetPostString("price1");
  2631. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2632. string price2 = GetPostString("price2");
  2633. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2634. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2635. {
  2636. lw.Add(string.Format("CusOrgID = 94"));
  2637. }
  2638. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2639. {
  2640. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2641. }
  2642. else
  2643. {
  2644. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2645. }
  2646. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2647. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2648. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2649. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2650. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2651. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2652. if (dt != null && dt.Rows.Count > 0)
  2653. {
  2654. foreach (DataRow dr in dt.Rows)
  2655. {
  2656. try
  2657. {
  2658. // 对象操作
  2659. if (dStruct.PageSize != 100000)
  2660. {
  2661. if (dr["DispatchSort"].ToString() == "2")
  2662. {
  2663. dr["gongchuang"] = 200;
  2664. }
  2665. else if ("外协".Equals(dr["ToType"].ToString()))
  2666. {
  2667. dr["gongchuang"] = 200;
  2668. }
  2669. else if ("内部".Equals(dr["ToType"].ToString()))
  2670. {
  2671. dr["gongchuang"] = -1;
  2672. }
  2673. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2674. {
  2675. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2676. dr["gongchuang"] = response.code;
  2677. }
  2678. }
  2679. }
  2680. catch (NullReferenceException ex)
  2681. {
  2682. // 处理空引用异常
  2683. }
  2684. }
  2685. }
  2686. writeGridDataTableJson(dStruct.TotalCount, dt);
  2687. }
  2688. public void get_erp_myorderlist_pregather()
  2689. {
  2690. string date1 = GetPostString("date1");
  2691. string date2 = GetPostString("date2");
  2692. int userId = CurrentUser.UserID; //客服id
  2693. string orderWhere = "";
  2694. List<string> lw = new List<string>();
  2695. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2696. if (dw.Length > 0) lw.Add(dw);
  2697. lw.Add(string.Format("CustomerUserId={0}", userId));
  2698. lw.Add(string.Format("OrderState<9"));
  2699. orderWhere = string.Join(" and ", lw.ToArray());
  2700. string orderWhere2 = "";
  2701. List<string> lw2 = new List<string>();
  2702. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2703. if (dw2.Length > 0) lw2.Add(dw2);
  2704. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2705. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2706. string sql = string.Format("select *" +
  2707. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2708. "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 " +
  2709. "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 " +
  2710. "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");
  2711. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2712. //writeGridDataTableJson(dt.Rows.Count, dt);
  2713. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2714. }
  2715. public void upd_erp_publishorder()
  2716. {
  2717. if (UrlPostParmsCheck("ctid"))
  2718. {
  2719. string eid = GetPostString("ctid");
  2720. CeErpTradeCell entity = null;
  2721. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2722. if (entity != null)
  2723. {
  2724. entity.OrderState = 0; //发布后,变为待抢单
  2725. entity.Update();
  2726. commonHelper.UpdateRelationOrder(entity.ctid);
  2727. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2728. returnSuccessMsg("发布成功!");
  2729. return;
  2730. }
  2731. returnErrorMsg("找不到记录");
  2732. }
  2733. }
  2734. public void get_erp_my_tiporder()
  2735. {
  2736. StringBuilder sql = new StringBuilder();
  2737. int userId = 0;
  2738. if (CurrentUser != null) userId = CurrentUser.UserID;
  2739. string posCode = CurrentUser.UserPost.Post.Code;
  2740. string isTipedAfterSaleVerify = GetPostString("af");
  2741. DataTable dt = new DataTable();
  2742. if (posCode != "Supplier")
  2743. {
  2744. if (posCode == "CustomerService" || posCode == "Director")
  2745. {
  2746. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2747. }
  2748. else if (posCode == "Place" || posCode == "PlaceMr")
  2749. {
  2750. }
  2751. else
  2752. {
  2753. string teamIds = CurrentUser.User.TeamIds;
  2754. if (teamIds == "")
  2755. {
  2756. teamIds = "0";
  2757. }
  2758. 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);
  2759. }
  2760. if (sql.Length > 0)
  2761. {
  2762. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2763. }
  2764. }
  2765. if (dt.Rows.Count <= 0)
  2766. {
  2767. string key = "aftersale_order_" + userId;
  2768. if (RedisHelper.HasKey(key))
  2769. {
  2770. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2771. dt.Columns.Add("ctid", typeof(string));
  2772. dt.Columns.Add("IsReadTag", typeof(int));
  2773. foreach (var i in list)
  2774. {
  2775. DataRow data = dt.NewRow();
  2776. data["ctid"] = i;
  2777. data["IsReadTag"] = 4;
  2778. dt.Rows.Add(data);
  2779. }
  2780. RedisHelper.StringDelete(key);
  2781. }
  2782. }
  2783. if (dt.Rows.Count <= 0)
  2784. {
  2785. sql = new StringBuilder();
  2786. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2787. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2788. }
  2789. if (posCode == "Supplier")
  2790. {
  2791. string ids = CurrentUser.User.pemVend;
  2792. if (ids != null && ids.Length > 0)
  2793. {
  2794. string[] ids_list = ids.Split(',');
  2795. foreach (var item in ids_list)
  2796. {
  2797. string key = "return_order_" + item;
  2798. if (RedisHelper.HasKey(key))
  2799. {
  2800. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2801. dt.Columns.Add("ctid", typeof(string));
  2802. dt.Columns.Add("IsReadTag", typeof(int));
  2803. foreach (var i in list)
  2804. {
  2805. DataRow data = dt.NewRow();
  2806. data["ctid"] = i;
  2807. data["IsReadTag"] = 1;
  2808. dt.Rows.Add(data);
  2809. }
  2810. RedisHelper.StringDelete(key);
  2811. }
  2812. }
  2813. }
  2814. if (dt.Rows.Count <= 0)
  2815. {
  2816. sql = new StringBuilder();
  2817. 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);
  2818. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2819. }
  2820. }
  2821. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2822. }
  2823. public void reset_erp_tiporder()
  2824. {
  2825. string ids = GetPostString("ids");
  2826. string[] ctidList = ids.Split(',');
  2827. foreach (string ctid in ctidList)
  2828. {
  2829. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2830. if (enty != null)
  2831. {
  2832. enty.IsReadTag = 0;
  2833. enty.Update();
  2834. }
  2835. }
  2836. returnSuccessMsg("成功!");
  2837. return;
  2838. }
  2839. public void get_erp_designlist()
  2840. {
  2841. DataStruct dStruct = GetPostStruct();
  2842. List<string> lw = new List<string>();
  2843. string tid = GetPostString("ctid");
  2844. if (tid.Length > 0)
  2845. {
  2846. string select_tid = getTidByCtid(tid);
  2847. lw.Add(string.Format("tid='{0}'", select_tid));
  2848. }
  2849. string shopname = GetPostString("shopname");
  2850. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2851. string buyernick = GetPostString("buyer_nick");
  2852. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2853. string customer = GetPostString("customer");
  2854. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2855. string design = GetPostString("design");
  2856. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2857. string orderState = GetPostString("orderState");
  2858. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2859. lw.Add(string.Format("OrderState<6"));
  2860. string address = GetPostString("address");
  2861. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2862. string sellermemo = GetPostString("seller_memo");
  2863. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2864. string date1 = GetPostString("date1");
  2865. string date2 = GetPostString("date2");
  2866. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2867. if (dw.Length > 0) lw.Add(dw);
  2868. string apdate1 = GetPostString("apdate1");
  2869. string apdate2 = GetPostString("apdate2");
  2870. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2871. if (dwap.Length > 0) lw.Add(dwap);
  2872. string price1 = GetPostString("price1");
  2873. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2874. string price2 = GetPostString("price2");
  2875. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2876. string designTime = GetPostString("designtime");
  2877. if (designTime.Length > 0)
  2878. {
  2879. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2880. }
  2881. string usershop = CurrentUser.User.pemShop;
  2882. if (usershop.Length > 0)
  2883. {
  2884. lw.Add(string.Format("shopId in ({0})", usershop));
  2885. }
  2886. int myOrgid = CurrentUser.UserPost.OrgID;
  2887. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2888. if (myOrgCode.IndexOf("Designer") != -1)
  2889. {
  2890. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2891. {
  2892. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2893. }
  2894. else
  2895. {
  2896. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2897. }
  2898. }
  2899. else
  2900. {
  2901. string orgId = GetPostString("designerhd");
  2902. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2903. }
  2904. if (tid.Length > 0 || buyernick.Length > 0)
  2905. {
  2906. lw.Add(string.Format("OrderState >= 3"));
  2907. }
  2908. else
  2909. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2910. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2911. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2912. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2913. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2914. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2915. if (dt != null && dt.Rows.Count > 0)
  2916. {
  2917. foreach (DataRow dr in dt.Rows)
  2918. {
  2919. try
  2920. {
  2921. // 对象操作
  2922. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2923. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2924. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2925. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2926. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2927. if (dStruct.PageSize != 100000)
  2928. {
  2929. if (dr["DispatchSort"].ToString() == "2")
  2930. {
  2931. dr["gongchuang"] = 200;
  2932. }
  2933. else if ("外协".Equals(dr["ToType"].ToString()))
  2934. {
  2935. dr["gongchuang"] = 200;
  2936. }
  2937. else if ("内部".Equals(dr["ToType"].ToString()))
  2938. {
  2939. dr["gongchuang"] = -1;
  2940. }
  2941. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2942. {
  2943. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2944. dr["gongchuang"] = response.code;
  2945. }
  2946. }
  2947. }
  2948. catch (NullReferenceException ex)
  2949. {
  2950. }
  2951. }
  2952. }
  2953. writeGridDataTableJson(dStruct.TotalCount, dt);
  2954. }
  2955. public void get_erp_mydesignlist()
  2956. {
  2957. DataStruct dStruct = GetPostStruct();
  2958. List<string> lw = new List<string>();
  2959. string tid = GetPostString("ctid");
  2960. if (tid.Length > 0)
  2961. {
  2962. string select_tid = getTidByCtid(tid);
  2963. lw.Add(string.Format("tid='{0}'", select_tid));
  2964. }
  2965. string shopname = GetPostString("shopname");
  2966. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2967. string buyernick = GetPostString("buyer_nick");
  2968. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2969. string customer = GetPostString("customer");
  2970. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2971. string orderState = GetPostString("orderState");
  2972. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2973. //lw.Add(string.Format("OrderState<6"));
  2974. string date1 = GetPostString("date1");
  2975. string date2 = GetPostString("date2");
  2976. string dw = GetDateWhere("pay_time", date1, date2);
  2977. if (dw.Length > 0) lw.Add(dw);
  2978. string apdate1 = GetPostString("apdate1");
  2979. string apdate2 = GetPostString("apdate2");
  2980. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2981. if (dwap.Length > 0) lw.Add(dwap);
  2982. string price1 = GetPostString("price1");
  2983. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2984. string price2 = GetPostString("price2");
  2985. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2986. string olddownload = GetPostString("olddown");
  2987. if (olddownload == "1")
  2988. {
  2989. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2990. }
  2991. else if (olddownload == "2")
  2992. {
  2993. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2994. }
  2995. string sellermemo = GetPostString("seller_memo");
  2996. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2997. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2998. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2999. {
  3000. if (CurrentUser.User.TeamIds.Length > 0)
  3001. {
  3002. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  3003. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3004. else
  3005. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3006. }
  3007. else
  3008. {
  3009. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3010. }
  3011. }
  3012. if (tid.Length <= 0)
  3013. {
  3014. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3015. }
  3016. lw.Add(string.Format("IsReturn!=3"));
  3017. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3018. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3019. string teamids = CurrentUser.User.TeamIds.ToString();
  3020. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3021. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3022. if (dt != null && dt.Rows.Count > 0)
  3023. {
  3024. foreach (DataRow dr in dt.Rows)
  3025. {
  3026. try
  3027. {
  3028. // 对象操作
  3029. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3030. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3031. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3032. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3033. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3034. if (dStruct.PageSize != 100000)
  3035. {
  3036. if (dr["DispatchSort"].ToString() == "2")
  3037. {
  3038. dr["gongchuang"] = 200;
  3039. }
  3040. else if ("外协".Equals(dr["ToType"].ToString()))
  3041. {
  3042. dr["gongchuang"] = 200;
  3043. }
  3044. else if ("内部".Equals(dr["ToType"].ToString()))
  3045. {
  3046. dr["gongchuang"] = -1;
  3047. }
  3048. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3049. {
  3050. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3051. dr["gongchuang"] = response.code;
  3052. }
  3053. }
  3054. }
  3055. catch (NullReferenceException ex)
  3056. {
  3057. }
  3058. }
  3059. }
  3060. writeGridDataTableJson(dStruct.TotalCount, dt);
  3061. }
  3062. public void set_erp_startdesign()
  3063. {
  3064. if (UrlPostParmsCheck("ctid"))
  3065. {
  3066. string eid = GetPostString("ctid");
  3067. CeErpTradeCell entity = null;
  3068. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3069. if (entity != null)
  3070. {
  3071. if (entity.OrderState != 3)
  3072. {
  3073. returnErrorMsg("请刷新,订单已经设计了");
  3074. return;
  3075. }
  3076. entity.StartDesignTime = DateTime.Now;
  3077. entity.OrderState = 4;
  3078. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3079. {
  3080. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3081. entity.SupplierId = suid;
  3082. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3083. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3084. }
  3085. entity.UpdateTime = DateTime.Now;
  3086. //entity.MakeSupplier = suname;
  3087. entity.Update();
  3088. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3090. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3091. commonHelper.getCytPrice(entity);
  3092. returnSuccessMsg("操作成功!");
  3093. return;
  3094. }
  3095. returnErrorMsg("找不到记录");
  3096. }
  3097. }
  3098. public void ins_erp_designselfmemo()
  3099. {
  3100. if (UrlPostParmsCheck("ctid"))
  3101. {
  3102. string eid = GetPostString("ctid");
  3103. string con = GetPostString("con");
  3104. CeErpTradeCell entity = null;
  3105. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3106. if (entity != null)
  3107. {
  3108. entity.DesignSelfMemo = con;
  3109. entity.Update();
  3110. returnSuccessMsg("操作成功!");
  3111. return;
  3112. }
  3113. returnErrorMsg("找不到记录");
  3114. }
  3115. }
  3116. public void ins_erp_designprice()
  3117. {
  3118. if (UrlPostParmsCheck("ctid"))
  3119. {
  3120. string eid = GetPostString("ctid");
  3121. int uid = CurrentUser.UserID;
  3122. string userName = CurrentUser.UserName;
  3123. CeErpTradeCell entity = null;
  3124. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3125. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3126. if (entitys == null)
  3127. {
  3128. entitys = new CeErpDesignerBill();
  3129. }
  3130. if (entity != null)
  3131. {
  3132. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3133. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3134. entity.StartDesignTime = DateTime.Now;
  3135. entity.OrderState = 4;
  3136. string suname = "";
  3137. if (entity.SupplierId == 0)
  3138. {
  3139. int sid = commonHelper.autoDistributeToSupplier(entity);
  3140. entity.SupplierId = sid;
  3141. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3142. }
  3143. entity.Update();
  3144. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3145. if (ceErpUserPost != null)
  3146. {
  3147. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3148. if (ceErpPost != null)
  3149. {
  3150. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3151. {
  3152. entitys.tid = entity.ctid;
  3153. entitys.oid = entity.tid;
  3154. entitys.uid = uid;
  3155. entitys.userName = userName;
  3156. entitys.designerType = 1;
  3157. entitys.designerTypeText = "内部设计师";
  3158. entitys.price = Convert.ToDouble(GetPostString("price"));
  3159. entitys.designNum = GetPostInt("designNum");
  3160. entitys.modifyNum = GetPostInt("modifyNum");
  3161. entitys.designSize = GetPostString("designSize");
  3162. entitys.modifySize = GetPostString("modifySize");
  3163. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3164. {
  3165. entitys.create_time = DateTime.Now;
  3166. entitys.create_u_id = uid;
  3167. entitys.create_u_name = userName;
  3168. entitys.Save();
  3169. }
  3170. else
  3171. {
  3172. entitys.update_time = DateTime.Now;
  3173. entitys.update_u_id = uid;
  3174. entitys.update_u_name = userName;
  3175. entitys.Update();
  3176. }
  3177. }
  3178. }
  3179. }
  3180. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3181. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3182. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3183. if (suname != "")
  3184. {
  3185. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3186. }
  3187. commonHelper.getCytPrice(entity);
  3188. returnSuccessMsg("操作成功!");
  3189. return;
  3190. }
  3191. returnErrorMsg("找不到记录");
  3192. }
  3193. }
  3194. public void upload_erp_filecomplete()
  3195. {
  3196. if (UrlPostParmsCheck("ctid"))
  3197. {
  3198. string eid = GetPostString("ctid");
  3199. CeErpTradeCell entity = null;
  3200. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3201. if (entity != null)
  3202. {
  3203. entity.OrderState = 5; //设计完成
  3204. entity.Update();
  3205. returnSuccessMsg(eid + "上传成功,设计完成!");
  3206. return;
  3207. }
  3208. returnErrorMsg("找不到订单记录");
  3209. }
  3210. }
  3211. public void get_erp_designovertimelist()
  3212. {
  3213. DataStruct dStruct = GetPostStruct();
  3214. List<string> lw = new List<string>();
  3215. string tid = GetPostString("ctid");
  3216. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3217. string shopname = GetPostString("shopname");
  3218. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3219. string buyernick = GetPostString("buyer_nick");
  3220. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3221. string ResponsibleMan = GetPostString("responsible");
  3222. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3223. string date1 = GetPostString("date1");
  3224. string date2 = GetPostString("date2");
  3225. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3226. if (dw.Length > 0) lw.Add(dw);
  3227. string price1 = GetPostString("price1");
  3228. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3229. string price2 = GetPostString("price2");
  3230. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3231. string orderState = GetPostString("orderState");
  3232. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3233. string sellermemo = GetPostString("seller_memo");
  3234. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3235. lw.Add(string.Format("UnusualTag=3"));
  3236. lw.Add(string.Format("IsRefund<={0}", 1));
  3237. dStruct.Order = "WaitDesignTime desc";
  3238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3239. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3240. writeGridDataTableJson(dStruct.TotalCount, dt);
  3241. }
  3242. //设计管理 获取抢单大厅列表
  3243. public void get_erp_grabinglist()
  3244. {
  3245. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3246. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3247. bool oldOrder = false;
  3248. if (org != null)
  3249. {
  3250. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3251. }
  3252. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3253. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3254. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3255. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3256. //先处理订单数据
  3257. if (dt.Rows.Count > 0)
  3258. {
  3259. Dictionary<string, int> design = null;
  3260. int count = 0;
  3261. foreach (DataRow row in dt.Rows)
  3262. {
  3263. if (map.ContainsKey(row["ShopId"].ToString()))
  3264. {
  3265. map.TryGetValue(row["ShopId"].ToString(), out design);
  3266. }
  3267. else
  3268. {
  3269. design = new Dictionary<string, int>();
  3270. }
  3271. if (design.ContainsKey(row["ProductId"].ToString()))
  3272. {
  3273. design.TryGetValue(row["ProductId"].ToString(), out count);
  3274. }
  3275. count++;
  3276. design[row["ProductId"].ToString()] = count;
  3277. map[row["ShopId"].ToString()] = design;
  3278. }
  3279. }
  3280. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3281. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3282. //把店铺排序和技能排序分类
  3283. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3284. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3285. if (design_dt.Rows.Count > 0)
  3286. {
  3287. Dictionary<string, string> design = null;
  3288. List<string> shopIds = null;
  3289. foreach (DataRow row in design_dt.Rows)
  3290. {
  3291. if ("0".Equals(row["designId"].ToString()))
  3292. {
  3293. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3294. {
  3295. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3296. }
  3297. else
  3298. {
  3299. shopIds = new List<string>();
  3300. }
  3301. shopIds.Add(row["shopId"].ToString());
  3302. shop_orders[row["orders"].ToString()] = shopIds;
  3303. }
  3304. else
  3305. {
  3306. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3307. {
  3308. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3309. }
  3310. else
  3311. {
  3312. design = new Dictionary<string, string>();
  3313. }
  3314. design[row["orders"].ToString()] = row["designId"].ToString();
  3315. design_orders[row["shopId"].ToString()] = design;
  3316. }
  3317. }
  3318. //处理成key value后根据key排序
  3319. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3320. foreach (List<string> val in shop_orders.Values)
  3321. {
  3322. if (val != null)
  3323. {
  3324. foreach (string key in val)
  3325. {
  3326. if (design_orders.ContainsKey(key.ToString()))
  3327. {
  3328. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3329. }
  3330. }
  3331. }
  3332. }
  3333. }
  3334. //校验哪个优先级有订单
  3335. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3336. foreach (string key in shop_orders.Keys)
  3337. {
  3338. List<string> ids = null;
  3339. shop_orders.TryGetValue(key, out ids);
  3340. //id为shopid
  3341. foreach (string id in ids)
  3342. {
  3343. Dictionary<string, int> list = null;
  3344. Dictionary<string, string> desing = null;
  3345. map.TryGetValue(id, out list);
  3346. design_orders.TryGetValue(id, out desing);
  3347. if (list != null && desing != null)
  3348. {
  3349. foreach (var item in desing)
  3350. {
  3351. int count = 0;
  3352. if (list.ContainsKey(item.Value))
  3353. {
  3354. list.TryGetValue(item.Value, out count);
  3355. if (count > 0)
  3356. {
  3357. designIds[id] = item.Value;
  3358. break;
  3359. }
  3360. }
  3361. }
  3362. }
  3363. }
  3364. if (designIds.Count > 0)
  3365. {
  3366. break;
  3367. }
  3368. }
  3369. DataTable table = new DataTable();
  3370. table.Columns.Add("tid", typeof(string));
  3371. table.Columns.Add("ctid", typeof(string));
  3372. table.Columns.Add("seller_nick", typeof(string));
  3373. table.Columns.Add("productName", typeof(string));
  3374. table.Columns.Add("pay_time", typeof(string));
  3375. table.Columns.Add("seller_memo", typeof(string));
  3376. if (designIds.Count > 0)
  3377. {
  3378. string shopId = "";
  3379. string productId = "";
  3380. foreach (var designInfo in designIds)
  3381. {
  3382. shopId = designInfo.Key;
  3383. productId = designInfo.Value;
  3384. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3385. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3386. if (dt.Rows.Count > 0)
  3387. {
  3388. foreach (DataRow row in dt.Rows)
  3389. {
  3390. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3391. {
  3392. DataRow data = table.NewRow();
  3393. data["ctid"] = row["ctid"].ToString();
  3394. data["tid"] = row["tid"].ToString();
  3395. data["seller_nick"] = ceErpShop.ShopName;
  3396. data["pay_time"] = row["pay_time"].ToString();
  3397. data["seller_memo"] = row["seller_memo"].ToString();
  3398. data["productName"] = ceErpProduct.PType;
  3399. table.Rows.Add(data);
  3400. }
  3401. }
  3402. }
  3403. }
  3404. }
  3405. writeGridDataTableJson(table.Rows.Count, table);
  3406. }
  3407. private object rushLockObject = new object();
  3408. public void set_erp_grabingorder()
  3409. {
  3410. if (UrlPostParmsCheck("ctid"))
  3411. {
  3412. int total = CurrentUser.User.Person.Total;
  3413. int userId = CurrentUser.User.ID;
  3414. int noFinish = CurrentUser.User.Person.NoFinish;
  3415. int finalization = CurrentUser.User.Person.Finalization;
  3416. string eids = GetPostString("ctid");
  3417. string key = "RushKey_" + userId;
  3418. int count = 0;
  3419. if (erpRedis.RedisHelper.KeyExists(key))
  3420. {
  3421. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3422. if (redisCount != null)
  3423. {
  3424. count = Convert.ToInt32(redisCount);
  3425. }
  3426. }
  3427. if (count >= total)
  3428. {
  3429. returnErrorMsg("半小时内已经抢" + total + "单");
  3430. return;
  3431. }
  3432. string[] ctidlist = eids.Split(',');
  3433. if (count + ctidlist.Length > total)
  3434. {
  3435. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3436. return;
  3437. }
  3438. int itag = 0;
  3439. lock (rushLockObject)
  3440. {
  3441. if (ctidlist.Length > 0)
  3442. {
  3443. string[] dtList = new string[ctidlist.Length];
  3444. for (int i = 0; i < ctidlist.Length; i++)
  3445. {
  3446. dtList[i] = "'" + ctidlist[i] + "'";
  3447. }
  3448. 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"));
  3449. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3450. if (dt_user.Rows.Count > 0)
  3451. {
  3452. int doing = 0;//未定稿
  3453. int finish = 0;//已完成
  3454. foreach (DataRow dr in dt_user.Rows)
  3455. {
  3456. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3457. {
  3458. doing++;
  3459. }
  3460. else
  3461. {
  3462. finish++;
  3463. }
  3464. }
  3465. if (doing >= noFinish)
  3466. {
  3467. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3468. return;
  3469. }
  3470. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3471. {
  3472. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3473. return;
  3474. }
  3475. }
  3476. //校验选择单子状态
  3477. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3478. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3479. if (dt.Rows.Count > 0)
  3480. {
  3481. List<string> list = new List<string>();
  3482. foreach (DataRow dr in dt.Rows)
  3483. {
  3484. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3485. {
  3486. list.Add(dr["ctid"].ToString());
  3487. }
  3488. }
  3489. if (list.Count > 0)
  3490. {
  3491. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3492. return;
  3493. }
  3494. }
  3495. foreach (string ctid in ctidlist)
  3496. {
  3497. CeErpTradeCell entity = null;
  3498. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3499. if (entity != null)
  3500. {
  3501. entity.OrderState = 3;
  3502. entity.DesignUserId = CurrentUser.UserID;
  3503. entity.WaitDesignTime = DateTime.Now;
  3504. entity.StartDesignTime = DateTime.Now;
  3505. entity.Update();
  3506. commonHelper.UpdateRelationOrder(entity.ctid);
  3507. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3508. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3509. itag++;
  3510. }
  3511. }
  3512. }
  3513. }
  3514. count += ctidlist.Length;
  3515. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3516. if (itag == 0)
  3517. returnErrorMsg("没有找到相关订单");
  3518. else
  3519. returnSuccessMsg("抢单成功!");
  3520. return;
  3521. }
  3522. }
  3523. public void get_erp_waitorderlist()
  3524. {
  3525. DataStruct dStruct = GetPostStruct();
  3526. List<string> lw = new List<string>();
  3527. string tid = GetPostString("ctid");
  3528. if (tid.Length > 0)
  3529. {
  3530. string select_tid = getTidByCtid(tid);
  3531. lw.Add(string.Format("tid='{0}'", select_tid));
  3532. }
  3533. string shopname = GetPostString("shopname");
  3534. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3535. string buyernick = GetPostString("buyer_nick");
  3536. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3537. string customer = GetPostString("customer");
  3538. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3539. string design = GetPostString("design");
  3540. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3541. string orderState = GetPostString("orderState");
  3542. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3543. string supplier = GetPostString("supplier");
  3544. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3545. string sellermemo = GetPostString("seller_memo");
  3546. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3547. string otherMemo = GetPostString("otherMemo");
  3548. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3549. string address = GetPostString("address");
  3550. 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));
  3551. string date1 = GetPostString("date1");
  3552. string date2 = GetPostString("date2");
  3553. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3554. if (dw.Length > 0) lw.Add(dw);
  3555. string price1 = GetPostString("price1");
  3556. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3557. string price2 = GetPostString("price2");
  3558. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3559. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3560. lw.Add(string.Format("IsSample != 2 "));
  3561. lw.Add(string.Format("OrderState = 5 "));
  3562. lw.Add(string.Format("IsRefund<={0}", 1));
  3563. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3564. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3565. string pagesize = GetPostString("pagesize");
  3566. if (pagesize != null)
  3567. {
  3568. dStruct.PageSize = 200;
  3569. }
  3570. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3571. List<string> tids = new List<string>();
  3572. if (dt != null)
  3573. {
  3574. dt.Columns.Add("compenPrice", typeof(double));
  3575. foreach (DataRow dr in dt.Rows)
  3576. {
  3577. if (Convert.IsDBNull(dr["compenPrice"]))
  3578. {
  3579. dr["compenPrice"] = 0;
  3580. }
  3581. tids.Add("'" + dr["tid"].ToString() + "'");
  3582. 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();
  3583. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3584. {
  3585. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3586. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3587. entity.SupplierId = suid;
  3588. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3589. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3590. entity.Update();
  3591. }
  3592. }
  3593. }
  3594. if (tids.Count > 0)
  3595. {
  3596. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3597. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3598. if (dt_price != null && dt_price.Rows.Count > 0)
  3599. {
  3600. foreach (DataRow dr in dt_price.Rows)
  3601. {
  3602. foreach (DataRow row in dt.Rows)
  3603. {
  3604. if (row["tid"].Equals(dr["ptid"]))
  3605. {
  3606. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3607. break;
  3608. }
  3609. }
  3610. }
  3611. }
  3612. }
  3613. writeGridDataTableJson(dStruct.TotalCount, dt);
  3614. }
  3615. public void get_erp_supplierwaitorderlist()
  3616. {
  3617. DataStruct dStruct = GetPostStruct();
  3618. List<string> lw = new List<string>();
  3619. string tid = GetPostString("ctid");
  3620. if (tid.Length > 0)
  3621. {
  3622. string select_tid = getTidByCtid(tid);
  3623. lw.Add(string.Format("tid='{0}'", select_tid));
  3624. }
  3625. string shopname = GetPostString("shopname");
  3626. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3627. string sellermemo = GetPostString("seller_memo");
  3628. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3629. string date1 = GetPostString("date1");
  3630. string date2 = GetPostString("date2");
  3631. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3632. if (dw.Length > 0) lw.Add(dw);
  3633. lw.Add(string.Format("OrderState = 5 "));
  3634. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3635. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3636. {
  3637. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3638. }
  3639. string supplier = GetPostString("supplier");
  3640. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3641. {
  3642. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3643. }
  3644. lw.Add(string.Format("IsRefund<={0}", 1));
  3645. dStruct.Order = "FinishDesignTime desc";
  3646. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3647. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3648. if (dt != null)
  3649. {
  3650. foreach (DataRow dr in dt.Rows)
  3651. {
  3652. 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();
  3653. }
  3654. }
  3655. writeGridDataTableJson(dStruct.TotalCount, dt);
  3656. }
  3657. public void upd_erp_verifytosupplier()
  3658. {
  3659. if (UrlPostParmsCheck("ctid"))
  3660. {
  3661. string eids = GetPostString("ctid");
  3662. CeErpTradeCell entity = null;
  3663. string[] eidsList = eids.Split(',');
  3664. if (eidsList.Length <= 0)
  3665. {
  3666. returnErrorMsg("订单号不能空");
  3667. return;
  3668. }
  3669. List<string> tLst = new List<string>();
  3670. foreach (string ctidstr in eidsList)
  3671. {
  3672. tLst.Add("'" + ctidstr + "'");
  3673. CeErpDataSendOrderInfo.createObject(ctidstr);
  3674. }
  3675. string needtids = string.Join(",", tLst.ToArray());
  3676. StringBuilder sql = new StringBuilder();
  3677. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3678. 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);
  3679. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3680. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3681. returnSuccessMsg("操作成功!");
  3682. return;
  3683. /**foreach (string ctidstr in eidsList)
  3684. {
  3685. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3686. if (entity != null)
  3687. {
  3688. if (entity.SupplierId == 0)
  3689. {
  3690. continue;
  3691. }
  3692. entity.IsVerifyToSupplier = true;
  3693. if (entity.IsReturn == 1) //1是供应商打回
  3694. {
  3695. entity.IsReturn = 0;
  3696. }
  3697. entity.FinishPlaceTime = DateTime.Now;
  3698. entity.PlaceUserId = CurrentUser.UserID;
  3699. entity.Update();
  3700. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3701. }
  3702. }
  3703. returnSuccessMsg("操作成功!");
  3704. return;**/
  3705. }
  3706. }
  3707. public void upd_erp_supplierback()
  3708. {
  3709. if (UrlPostParmsCheck("ctid"))
  3710. {
  3711. string eid = GetPostString("ctid");
  3712. string reason = GetPostString("returnreason");
  3713. CeErpTradeCell entity = null;
  3714. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3715. if (entity != null)
  3716. {
  3717. string message = "操作成功!";
  3718. string isDown = "";
  3719. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3720. {
  3721. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3722. isDown = "被点击下载";
  3723. }
  3724. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3725. {
  3726. string key = "return_order_" + entity.SupplierId;
  3727. List<string> list = new List<string>();
  3728. if (RedisHelper.HasKey(key))
  3729. {
  3730. object data = RedisHelper.StringGet(key);
  3731. list = Convert.ToString(data).Split(',').ToList();
  3732. }
  3733. list.Add(eid);
  3734. RedisHelper.StringSet(key, string.Join(",", list));
  3735. }
  3736. entity.IsVerifyToSupplier = false;
  3737. entity.IsReturn = 1;
  3738. entity.IsHaveNewOrder = 0;
  3739. entity.ReturnTime = DateTime.Now;
  3740. entity.ReturnReason = reason;
  3741. if (entity.OrderState == 6)
  3742. {
  3743. entity.OrderState = 5;
  3744. }
  3745. entity.Update();
  3746. CeErpSukuraData.createInfo(entity.ctid, 5);
  3747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3748. returnSuccessMsg(message);
  3749. return;
  3750. }
  3751. returnErrorMsg("找不到订单记录");
  3752. }
  3753. }
  3754. public void upd_erp_toaftersaleorder()
  3755. {
  3756. if (UrlPostParmsCheck("ctid"))
  3757. {
  3758. string eid = GetPostString("ctid");
  3759. string reason = GetPostString("returnreason");
  3760. CeErpTradeCell entity = null;
  3761. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3762. if (entity != null)
  3763. {
  3764. if (entity.isAfterSaleOrder != 1)
  3765. {
  3766. returnErrorMsg("带S的售后单才能打回给售后");
  3767. return;
  3768. }
  3769. if (entity.OrderState >= 5)
  3770. {
  3771. returnErrorMsg("已经设计完成了不能打回给售后");
  3772. return;
  3773. }
  3774. entity.OrderState = 0;
  3775. entity.IsReturn = 3;
  3776. entity.ReturnTime = DateTime.Now;
  3777. entity.UpdateTime = DateTime.Now;
  3778. entity.ReturnReason = reason;
  3779. entity.Update();
  3780. CeErpSukuraData.createInfo(entity.ctid, 5);
  3781. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3782. returnSuccessMsg("操作成功!");
  3783. return;
  3784. }
  3785. returnErrorMsg("找不到订单记录");
  3786. }
  3787. }
  3788. public void upd_erp_aftersaletodesign()
  3789. {
  3790. if (UrlPostParmsCheck("ctid"))
  3791. {
  3792. string eid = GetPostString("ctid");
  3793. CeErpTradeCell entity = null;
  3794. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3795. if (entity != null)
  3796. {
  3797. entity.OrderState = 3;
  3798. entity.IsReturn = 0;
  3799. entity.UpdateTime = DateTime.Now;
  3800. entity.Update();
  3801. CeErpSukuraData.createInfo(entity.ctid, 5);
  3802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3803. returnSuccessMsg("操作成功!");
  3804. return;
  3805. }
  3806. returnErrorMsg("找不到订单记录");
  3807. }
  3808. }
  3809. public void assign_erp_supplier()
  3810. {
  3811. if (UrlPostParmsCheck("ctid"))
  3812. {
  3813. string eids = GetPostString("ctid");
  3814. int sid = GetPostInt("SupplierName");
  3815. string fromTag = GetPostString("tag");
  3816. string[] eidList = eids.Split(',');
  3817. if (eidList.Length <= 0)
  3818. {
  3819. returnErrorMsg("指派不能为空");
  3820. return;
  3821. }
  3822. string errMsg = "";
  3823. string suname = commonHelper.getSupplierNameById(sid);
  3824. foreach (string ctid in eidList)
  3825. {
  3826. CeErpTradeCell entity = null;
  3827. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3828. if (entity != null)
  3829. {
  3830. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3831. {
  3832. errMsg += (ctid + "指派失败!!!");
  3833. continue;
  3834. }
  3835. entity.SupplierId = sid;
  3836. entity.Update();
  3837. commonHelper.UpdateRelationOrder(entity.ctid);
  3838. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3839. if (entity.OrderState >= 6)
  3840. {
  3841. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3842. //{
  3843. // string msl = entity.MakeSupplier;
  3844. // string[] mslist = msl.Split(',');
  3845. // 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);
  3846. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3847. //}
  3848. //else
  3849. //{
  3850. StringBuilder sql = new StringBuilder();
  3851. 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);
  3852. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3853. //}
  3854. }
  3855. }
  3856. else
  3857. {
  3858. continue;
  3859. }
  3860. }
  3861. if (errMsg.Length > 0)
  3862. {
  3863. returnErrorMsg(errMsg);
  3864. return;
  3865. }
  3866. returnSuccessMsg("操作成功!");
  3867. return;
  3868. }
  3869. }
  3870. public void assign_erp_makesupplier()
  3871. {
  3872. if (UrlPostParmsCheck("ctid"))
  3873. {
  3874. string eids = GetPostString("ctid");
  3875. string sname = GetPostString("SupplierName");
  3876. string[] eidList = eids.Split(',');
  3877. if (eidList.Length <= 0)
  3878. {
  3879. returnErrorMsg("指派不能为空");
  3880. return;
  3881. }
  3882. List<string> tLst = new List<string>();
  3883. foreach (string ctid in eidList)
  3884. {
  3885. CeErpTradeCell entity = null;
  3886. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3887. if (entity != null)
  3888. {
  3889. entity.MakeSupplier = sname;
  3890. entity.Update();
  3891. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3892. tLst.Add("'" + ctid + "'");
  3893. }
  3894. else
  3895. {
  3896. continue;
  3897. }
  3898. }
  3899. string ctids = string.Join(",", tLst.ToArray());
  3900. StringBuilder sql2 = new StringBuilder();
  3901. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3902. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3903. returnSuccessMsg("操作成功!");
  3904. return;
  3905. }
  3906. }
  3907. public void ins_erp_returnreason()
  3908. {
  3909. if (UrlPostParmsCheck("ctid"))
  3910. {
  3911. string eid = GetPostString("ctid");
  3912. CeErpTradeCell entity = null;
  3913. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3914. string userpost = CurrentUser.UserPost.Post.Code;
  3915. if (entity != null)
  3916. {
  3917. bool isPlace = false;
  3918. if (entity.OrderState > 6)
  3919. {
  3920. returnErrorMsg("已发货无法打回!");
  3921. return;
  3922. }
  3923. if (entity.OrderState == 6)
  3924. {
  3925. isPlace = true;
  3926. }
  3927. bool isNeedUpdateCell2 = false;
  3928. if (entity.OrderState >= 6)
  3929. {
  3930. isNeedUpdateCell2 = true;
  3931. }
  3932. int returnTag = 2;
  3933. if (userpost == "Supplier")
  3934. {
  3935. returnTag = 1;
  3936. }
  3937. int toType = GetPostInt("totype");
  3938. string fromType = "3";
  3939. if (entity.OrderState < 5)
  3940. {
  3941. fromType = "3";
  3942. }
  3943. else
  3944. {
  3945. fromType = "4";
  3946. }
  3947. if (entity.IsXianHuo == 0)
  3948. {
  3949. if (returnTag == 2)
  3950. {
  3951. if (toType == 1)
  3952. {
  3953. entity.OrderState = 0;
  3954. entity.ReturnUserType = 1;
  3955. string clearman = GetPostString("clearman");
  3956. if (!string.IsNullOrEmpty(clearman))
  3957. {
  3958. entity.DesignUserId = 0;
  3959. }
  3960. }
  3961. else
  3962. {
  3963. entity.OrderState = 3;
  3964. entity.ReturnUserType = 2;
  3965. }
  3966. entity.IsReadTag = 1;
  3967. }
  3968. else if (returnTag == 1)
  3969. {
  3970. entity.OrderState = 5;
  3971. }
  3972. entity.IsVerifyToSupplier = false;
  3973. }
  3974. if (entity.IsXianHuo == 1)
  3975. {
  3976. entity.OrderState = 5;
  3977. }
  3978. entity.UnusualTag = 0;
  3979. entity.UnusualTime = null;
  3980. entity.UnusualCon = "";
  3981. entity.IsReturn = returnTag;
  3982. entity.ReturnTime = DateTime.Now;
  3983. entity.UpdateTime = DateTime.Now;
  3984. entity.ReturnReason = GetPostString("returnreason");
  3985. entity.Update();
  3986. if (entity.OrderState == 3)
  3987. {
  3988. ApiVo apiVo = new ApiVo();
  3989. apiVo.orderNumber = entity.ctid;
  3990. apiVo.actionName = "rebutDesign";
  3991. apiVo.orderRemarks = entity.ReturnReason;
  3992. designHelper.API_WorkCore(apiVo);//rebutDesign
  3993. }
  3994. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3995. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3996. {
  3997. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3998. }
  3999. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4000. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4001. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4002. if (isPlace)
  4003. {
  4004. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4005. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4006. if (dth != null && dth.Rows.Count > 0)
  4007. {
  4008. dataSendOrderBean dataSendOrderBean = null;
  4009. foreach (DataRow item in dth.Rows)
  4010. {
  4011. try
  4012. {
  4013. dataSendOrderBean = new dataSendOrderBean();
  4014. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4015. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4016. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4017. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4018. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4019. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4020. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4021. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4022. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4023. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4024. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4025. dataSendOrderBean.Radio1723534706288 = "打回";
  4026. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4027. if (result != null)
  4028. {
  4029. if ("0".Equals(result.errcode))
  4030. {
  4031. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4032. }
  4033. else
  4034. {
  4035. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4036. }
  4037. }
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. }
  4042. }
  4043. }
  4044. }
  4045. /*if (isNeedUpdateCell2)
  4046. {
  4047. if (entity.MakeSupplier.IndexOf(",") != -1)
  4048. {
  4049. StringBuilder sql2 = new StringBuilder();
  4050. 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);
  4051. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4052. }
  4053. else
  4054. {
  4055. StringBuilder sql2 = new StringBuilder();
  4056. 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);
  4057. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4058. }
  4059. }*/
  4060. returnSuccessMsg("操作成功!");
  4061. return;
  4062. }
  4063. returnErrorMsg("找不到订单记录");
  4064. }
  4065. }
  4066. public void cyt_erp_returnreason()
  4067. {
  4068. if (UrlPostParmsCheck("ctid"))
  4069. {
  4070. string eid = GetPostString("ctid");
  4071. CeErpTradeCell entity = null;
  4072. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4073. string userpost = CurrentUser.UserPost.Post.Code;
  4074. if (entity != null)
  4075. {
  4076. if (entity.OrderState > 6)
  4077. {
  4078. returnErrorMsg("已发货无法打回!");
  4079. return;
  4080. }
  4081. JObject jsonObject = new JObject
  4082. {
  4083. { "Userid", "77886" },
  4084. { "Pwd", "lt666888" },
  4085. { "LTOrderId",eid }
  4086. };
  4087. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4088. JObject jsonObjects = JObject.Parse(response);
  4089. string msg = (string)jsonObjects["msg"];
  4090. if (msg != "取消成功")
  4091. {
  4092. returnErrorMsg(msg);
  4093. return;
  4094. }
  4095. bool isNeedUpdateCell2 = false;
  4096. if (entity.OrderState >= 6)
  4097. {
  4098. isNeedUpdateCell2 = true;
  4099. }
  4100. int returnTag = 2;
  4101. if (userpost == "Supplier")
  4102. {
  4103. returnTag = 1;
  4104. }
  4105. if (entity.IsXianHuo == 0)
  4106. {
  4107. if (returnTag == 2)
  4108. {
  4109. int toType = GetPostInt("totype");
  4110. if (toType == 1)
  4111. {
  4112. entity.OrderState = 0;
  4113. entity.ReturnUserType = 1;
  4114. }
  4115. else
  4116. {
  4117. entity.OrderState = 4;
  4118. entity.ReturnUserType = 2;
  4119. }
  4120. entity.IsReadTag = 1;
  4121. }
  4122. else if (returnTag == 1)
  4123. {
  4124. entity.OrderState = 5;
  4125. }
  4126. entity.IsVerifyToSupplier = false;
  4127. }
  4128. entity.UnusualTag = 0;
  4129. entity.UnusualTime = null;
  4130. entity.UnusualCon = "";
  4131. entity.IsReturn = returnTag;
  4132. entity.ReturnTime = DateTime.Now;
  4133. entity.ReturnReason = GetPostString("returnreason");
  4134. entity.Update();
  4135. if (entity.OrderState == 4)
  4136. {
  4137. ApiVo apiVo = new ApiVo();
  4138. apiVo.orderNumber = entity.ctid;
  4139. apiVo.actionName = "rebutDesign";
  4140. apiVo.orderRemarks = entity.ReturnReason;
  4141. designHelper.API_WorkCore(apiVo);//rebutDesign
  4142. }
  4143. CeErpSukuraData.createInfo(entity.ctid, 5);
  4144. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4146. if (isNeedUpdateCell2)
  4147. {
  4148. if (entity.MakeSupplier.IndexOf(",") != -1)
  4149. {
  4150. StringBuilder sql2 = new StringBuilder();
  4151. 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);
  4152. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4153. }
  4154. else
  4155. {
  4156. StringBuilder sql2 = new StringBuilder();
  4157. 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);
  4158. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4159. }
  4160. }
  4161. returnSuccessMsg("操作成功!");
  4162. return;
  4163. }
  4164. returnErrorMsg("找不到订单记录");
  4165. }
  4166. }
  4167. public void upd_erp_xianhuoreturntag()
  4168. {
  4169. if (UrlPostParmsCheck("ctid"))
  4170. {
  4171. string eids = GetPostString("ctid");
  4172. string[] ctids = eids.Split(',');
  4173. foreach (string ctid in ctids)
  4174. {
  4175. CeErpTradeCell entity = null;
  4176. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4177. if (entity != null)
  4178. {
  4179. entity.IsReturn = 0;
  4180. entity.Update();
  4181. CeErpSukuraData.createInfo(entity.ctid, 5);
  4182. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4183. }
  4184. }
  4185. returnSuccessMsg("操作成功!");
  4186. return;
  4187. }
  4188. }
  4189. public void get_erp_waitdeliverylist()
  4190. {
  4191. DataStruct dStruct = GetPostStruct();
  4192. List<string> lw = new List<string>();
  4193. string tid = GetPostString("ctid");
  4194. if (tid.Length > 0)
  4195. {
  4196. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4197. if (tid.Length > 5)
  4198. {
  4199. List<string> tids = getTidByCtidLike(tid);
  4200. if (tids.Count > 0 && tids.Count < 10)
  4201. {
  4202. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4203. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4204. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4205. {
  4206. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4207. }*/
  4208. }
  4209. }
  4210. lw.Add(tid_sql);
  4211. }
  4212. string shopname = GetPostString("shopname");
  4213. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4214. string buyernick = GetPostString("buyer_nick");
  4215. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4216. //if (tid.Length == 0 && buyernick.Length == 0)
  4217. //{
  4218. // lw.Add(string.Format("IsRefund<={0}", 1));
  4219. //}
  4220. string customer = GetPostString("customer");
  4221. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4222. string design = GetPostString("design");
  4223. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4224. string orderState = GetPostString("orderState");
  4225. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4226. string address = GetPostString("address");
  4227. 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));
  4228. string sellermemo = GetPostString("seller_memo");
  4229. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4230. string supplier = GetPostString("supplier");
  4231. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4232. string OrderArea = GetPostString("order_area");
  4233. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4234. string placedate1 = GetPostString("placedate1");
  4235. string placedate2 = GetPostString("placedate2");
  4236. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4237. if (fdw.Length > 0) lw.Add(fdw);
  4238. string price1 = GetPostString("price1");
  4239. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4240. string price2 = GetPostString("price2");
  4241. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4242. string unusualCon = GetPostString("unusualcon");
  4243. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4244. string otherMemo = GetPostString("otherMemo");
  4245. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4246. string posTag = CurrentUser.UserPost.Post.Code;
  4247. if (posTag == "Supplier")
  4248. {
  4249. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4250. }
  4251. else
  4252. {
  4253. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4254. {
  4255. string usershop = CurrentUser.User.pemShop;
  4256. lw.Add(string.Format("ShopId in ({0})", usershop));
  4257. }
  4258. }
  4259. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4260. lw.Add(string.Format("type != 'PDD' "));
  4261. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4262. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4263. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4264. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4265. writeGridDataTableJson(dStruct.TotalCount, dt);
  4266. }
  4267. public void get_erp_changedeliverylist()
  4268. {
  4269. DataStruct dStruct = GetPostStruct();
  4270. List<string> lw = new List<string>();
  4271. string tid = GetPostString("ctid");
  4272. if (tid.Length > 0)
  4273. {
  4274. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4275. if (tid.Length > 5)
  4276. {
  4277. List<string> tids = getTidByCtidLike(tid);
  4278. if (tids.Count > 0 && tids.Count < 10)
  4279. {
  4280. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4281. }
  4282. }
  4283. lw.Add(tid_sql);
  4284. }
  4285. string shopname = GetPostString("shopname");
  4286. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4287. string buyernick = GetPostString("buyer_nick");
  4288. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4289. //if (tid.Length == 0 && buyernick.Length == 0)
  4290. //{
  4291. // lw.Add(string.Format("IsRefund<={0}", 1));
  4292. //}
  4293. string customer = GetPostString("customer");
  4294. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4295. string design = GetPostString("design");
  4296. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4297. string orderState = GetPostString("orderState");
  4298. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4299. string address = GetPostString("address");
  4300. 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));
  4301. string sellermemo = GetPostString("seller_memo");
  4302. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4303. string supplier = GetPostString("supplier");
  4304. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4305. string OrderArea = GetPostString("order_area");
  4306. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4307. string placedate1 = GetPostString("placedate1");
  4308. string placedate2 = GetPostString("placedate2");
  4309. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4310. if (fdw.Length > 0) lw.Add(fdw);
  4311. string price1 = GetPostString("price1");
  4312. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4313. string price2 = GetPostString("price2");
  4314. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4315. string unusualCon = GetPostString("unusualcon");
  4316. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4317. string otherMemo = GetPostString("otherMemo");
  4318. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4319. string posTag = CurrentUser.UserPost.Post.Code;
  4320. if (posTag == "Supplier")
  4321. {
  4322. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4323. }
  4324. else
  4325. {
  4326. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4327. {
  4328. string usershop = CurrentUser.User.pemShop;
  4329. lw.Add(string.Format("ShopId in ({0})", usershop));
  4330. }
  4331. }
  4332. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4333. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4334. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4335. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4336. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4337. /*if (tid.Length > 0)
  4338. {
  4339. List<string> tids = new List<string>();
  4340. if (dt != null && dt.Rows.Count > 0)
  4341. {
  4342. foreach (DataRow item in dt.Rows)
  4343. {
  4344. tids.Add("'" + item["tid"] + "'");
  4345. }
  4346. }
  4347. if (tids.Count > 0)
  4348. {
  4349. lw.RemoveAt(0);
  4350. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4351. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4352. dt = WebCache.GetData("view_erptradecell", dStruct);
  4353. }
  4354. }*/
  4355. writeGridDataTableJson(dStruct.TotalCount, dt);
  4356. }
  4357. public void get_erp_pddderiving()
  4358. {
  4359. DataStruct dStruct = GetPostStruct();
  4360. List<string> lw = new List<string>();
  4361. string tid = GetPostString("ctid");
  4362. if (tid.Length > 0)
  4363. {
  4364. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4365. if (tid.Length > 5)
  4366. {
  4367. List<string> tids = getTidByCtidLike(tid);
  4368. if (tids.Count > 0 && tids.Count < 10)
  4369. {
  4370. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4371. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4372. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4373. {
  4374. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4375. }*/
  4376. }
  4377. }
  4378. lw.Add(tid_sql);
  4379. }
  4380. string shopname = GetPostString("shopname");
  4381. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4382. string buyernick = GetPostString("buyer_nick");
  4383. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4384. //if (tid.Length == 0 && buyernick.Length == 0)
  4385. //{
  4386. // lw.Add(string.Format("IsRefund<={0}", 1));
  4387. //}
  4388. string customer = GetPostString("customer");
  4389. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4390. string design = GetPostString("design");
  4391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4392. string orderState = GetPostString("orderState");
  4393. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4394. string address = GetPostString("address");
  4395. 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));
  4396. string sellermemo = GetPostString("seller_memo");
  4397. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4398. string supplier = GetPostString("supplier");
  4399. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4400. string OrderArea = GetPostString("order_area");
  4401. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4402. string placedate1 = GetPostString("placedate1");
  4403. string placedate2 = GetPostString("placedate2");
  4404. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4405. if (fdw.Length > 0) lw.Add(fdw);
  4406. string price1 = GetPostString("price1");
  4407. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4408. string price2 = GetPostString("price2");
  4409. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4410. string unusualCon = GetPostString("unusualcon");
  4411. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4412. string posTag = CurrentUser.UserPost.Post.Code;
  4413. if (posTag == "Supplier")
  4414. {
  4415. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4416. }
  4417. else
  4418. {
  4419. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4420. {
  4421. string usershop = CurrentUser.User.pemShop;
  4422. lw.Add(string.Format("ShopId in ({0})", usershop));
  4423. }
  4424. }
  4425. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4426. lw.Add(string.Format("type = 'PDD' "));
  4427. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4428. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4429. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4430. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4431. /*if (tid.Length > 0)
  4432. {
  4433. List<string> tids = new List<string>();
  4434. if (dt != null && dt.Rows.Count > 0)
  4435. {
  4436. foreach (DataRow item in dt.Rows)
  4437. {
  4438. tids.Add("'" + item["tid"] + "'");
  4439. }
  4440. }
  4441. if (tids.Count > 0)
  4442. {
  4443. lw.RemoveAt(0);
  4444. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4445. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4446. dt = WebCache.GetData("view_erptradecell", dStruct);
  4447. }
  4448. }*/
  4449. writeGridDataTableJson(dStruct.TotalCount, dt);
  4450. }
  4451. public void get_erp_jdderiving()
  4452. {
  4453. DataStruct dStruct = GetPostStruct();
  4454. List<string> lw = new List<string>();
  4455. string tid = GetPostString("ctid");
  4456. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4457. string shopname = GetPostString("shopname");
  4458. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4459. string buyernick = GetPostString("buyer_nick");
  4460. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4461. //if (tid.Length == 0 && buyernick.Length == 0)
  4462. //{
  4463. // lw.Add(string.Format("IsRefund<={0}", 1));
  4464. //}
  4465. string customer = GetPostString("customer");
  4466. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4467. string design = GetPostString("design");
  4468. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4469. string orderState = GetPostString("orderState");
  4470. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4471. string address = GetPostString("address");
  4472. 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));
  4473. string sellermemo = GetPostString("seller_memo");
  4474. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4475. string supplier = GetPostString("supplier");
  4476. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4477. string OrderArea = GetPostString("order_area");
  4478. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4479. string placedate1 = GetPostString("placedate1");
  4480. string placedate2 = GetPostString("placedate2");
  4481. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4482. if (fdw.Length > 0) lw.Add(fdw);
  4483. string price1 = GetPostString("price1");
  4484. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4485. string price2 = GetPostString("price2");
  4486. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4487. string unusualCon = GetPostString("unusualcon");
  4488. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4489. string posTag = CurrentUser.UserPost.Post.Code;
  4490. if (posTag == "Supplier")
  4491. {
  4492. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4493. }
  4494. lw.Add(string.Format("OrderState = 6 "));
  4495. lw.Add(string.Format("type = 'JD' "));
  4496. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4497. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4498. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4499. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4500. writeGridDataTableJson(dStruct.TotalCount, dt);
  4501. }
  4502. public void get_erp_demoorderlist()
  4503. {
  4504. DataStruct dStruct = GetPostStruct();
  4505. List<string> lw = new List<string>();
  4506. string tid = GetPostString("ctid");
  4507. if (tid.Length > 0)
  4508. {
  4509. string select_tid = getTidByCtid(tid);
  4510. lw.Add(string.Format("tid='{0}'", select_tid));
  4511. }
  4512. string shopname = GetPostString("shopname");
  4513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4514. string buyernick = GetPostString("buyer_nick");
  4515. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4516. string customer = GetPostString("customer");
  4517. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4518. string design = GetPostString("design");
  4519. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4520. string orderState = GetPostString("orderState");
  4521. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4522. string address = GetPostString("address");
  4523. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4524. string sellermemo = GetPostString("seller_memo");
  4525. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4526. string supplier = GetPostString("supplier");
  4527. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4528. string OrderArea = GetPostString("order_area");
  4529. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4530. string date1 = GetPostString("date1");
  4531. string date2 = GetPostString("date2");
  4532. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4533. if (dw.Length > 0) lw.Add(dw);
  4534. string price1 = GetPostString("price1");
  4535. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4536. string price2 = GetPostString("price2");
  4537. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4538. string posTag = CurrentUser.UserPost.Post.Code;
  4539. if (posTag == "Supplier")
  4540. {
  4541. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4542. }
  4543. //lw.Add(string.Format("OrderState = 6 "));
  4544. lw.Add(string.Format("IsSample={0}", 3));
  4545. lw.Add(string.Format("IsRefund<={0}", 1));
  4546. dStruct.Order = "pay_time desc";
  4547. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4548. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4549. writeGridDataTableJson(dStruct.TotalCount, dt);
  4550. }
  4551. public void save_erp_checkmemo()
  4552. {
  4553. if (UrlPostParmsCheck("ctid"))
  4554. {
  4555. string ctid = GetPostString("ctid");
  4556. CeErpTradeCell entity = null;
  4557. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4558. if (entity != null)
  4559. {
  4560. entity.CheckMemo = GetPostString("CheckMemo");
  4561. entity.Update();
  4562. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4563. if (trade != null)
  4564. {
  4565. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4566. }
  4567. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4568. returnSuccessMsg("保存成功!");
  4569. return;
  4570. }
  4571. returnErrorMsg("找不到记录");
  4572. }
  4573. }
  4574. public void get_erp_returnlist()
  4575. {
  4576. DataStruct dStruct = GetPostStruct();
  4577. List<string> lw = new List<string>();
  4578. string tid = GetPostString("ctid");
  4579. if (tid.Length > 0)
  4580. {
  4581. string select_tid = getTidByCtid(tid);
  4582. lw.Add(string.Format("tid='{0}'", select_tid));
  4583. }
  4584. string shopname = GetPostString("shopname");
  4585. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4586. string buyernick = GetPostString("buyer_nick");
  4587. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4588. string customer = GetPostString("customer");
  4589. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4590. string design = GetPostString("design");
  4591. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4592. string orderState = GetPostString("orderState");
  4593. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4594. string address = GetPostString("address");
  4595. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4596. string sellermemo = GetPostString("seller_memo");
  4597. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4598. string supplier = GetPostString("supplier");
  4599. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4600. string date1 = GetPostString("date1");
  4601. string date2 = GetPostString("date2");
  4602. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4603. if (dw.Length > 0) lw.Add(dw);
  4604. string bdate1 = GetPostString("backdate1");
  4605. string bdate2 = GetPostString("backdate2");
  4606. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4607. if (dw_back.Length > 0) lw.Add(dw_back);
  4608. string price1 = GetPostString("price1");
  4609. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4610. string price2 = GetPostString("price2");
  4611. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4612. lw.Add(string.Format("IsReturn>0"));
  4613. lw.Add(string.Format("IsXianHuo=0"));
  4614. lw.Add(string.Format("IsReturn!=3"));
  4615. string backtype = GetPostString("backtype");
  4616. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4617. dStruct.Order = "FinishDesignTime desc";
  4618. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4619. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4620. writeGridDataTableJson(dStruct.TotalCount, dt);
  4621. }
  4622. public void get_erp_today_sumreturn()
  4623. {
  4624. DataStruct dStruct = GetPostStruct();
  4625. List<string> lw = new List<string>();
  4626. string bdate1 = GetPostString("returnTimeS");
  4627. string bdate2 = GetPostString("returnTimeE");
  4628. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4629. if (dw_back.Length > 0) lw.Add(dw_back);
  4630. lw.Add(string.Format("IsReturn=0"));
  4631. lw.Add(string.Format("IsXianHuo=0"));
  4632. string mainWhere = string.Join(" and ", lw.ToArray());
  4633. string sql = "";
  4634. if (dw_back.Length > 0)
  4635. {
  4636. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4637. }
  4638. else
  4639. {
  4640. 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 + "'";
  4641. }
  4642. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4643. decimal total = 0, today_finish = 0;
  4644. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4645. {
  4646. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4647. }
  4648. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4649. {
  4650. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4651. }
  4652. var res = new
  4653. {
  4654. data = total,
  4655. data1 = today_finish,
  4656. };
  4657. string ro_jsond = JsonConvert.SerializeObject(res);
  4658. returnSuccess(ro_jsond);
  4659. return;
  4660. }
  4661. public void get_erp_allreturnlist()
  4662. {
  4663. DataStruct dStruct = GetPostStruct();
  4664. List<string> lw = new List<string>();
  4665. string tid = GetPostString("ctid");
  4666. if (tid.Length > 0)
  4667. {
  4668. string select_tid = getTidByCtid(tid);
  4669. lw.Add(string.Format("tid='{0}'", select_tid));
  4670. }
  4671. string shopname = GetPostString("shopname");
  4672. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4673. string buyernick = GetPostString("buyer_nick");
  4674. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4675. string customer = GetPostString("customer");
  4676. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4677. string design = GetPostString("design");
  4678. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4679. string orderState = GetPostString("orderState");
  4680. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4681. string address = GetPostString("address");
  4682. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4683. string sellermemo = GetPostString("seller_memo");
  4684. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4685. string supplier = GetPostString("supplier");
  4686. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4687. string date1 = GetPostString("date1");
  4688. string date2 = GetPostString("date2");
  4689. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4690. if (dw.Length > 0) lw.Add(dw);
  4691. string bdate1 = GetPostString("backdate1");
  4692. string bdate2 = GetPostString("backdate2");
  4693. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4694. if (dw_back.Length > 0) lw.Add(dw_back);
  4695. string price1 = GetPostString("price1");
  4696. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4697. string price2 = GetPostString("price2");
  4698. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4699. string backreason = GetPostString("backreason");
  4700. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4701. lw.Add(string.Format("IsXianHuo=0"));
  4702. lw.Add(string.Format("ReturnTime != ''"));
  4703. string backtype = GetPostString("backtype");
  4704. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4705. string posTag = CurrentUser.UserPost.Post.Code;
  4706. if (posTag == "Supplier")
  4707. {
  4708. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4709. }
  4710. else
  4711. {
  4712. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4713. {
  4714. string usershop = CurrentUser.User.pemShop;
  4715. lw.Add(string.Format("ShopId in ({0})", usershop));
  4716. }
  4717. }
  4718. dStruct.Order = "FinishDesignTime desc";
  4719. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4720. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4721. writeGridDataTableJson(dStruct.TotalCount, dt);
  4722. }
  4723. public void get_erp_aftersalereturnlist()
  4724. {
  4725. DataStruct dStruct = GetPostStruct();
  4726. List<string> lw = new List<string>();
  4727. string tid = GetPostString("ctid");
  4728. if (tid.Length > 0)
  4729. {
  4730. string select_tid = getTidByCtid(tid);
  4731. lw.Add(string.Format("tid='{0}'", select_tid));
  4732. }
  4733. string shopname = GetPostString("shopname");
  4734. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4735. string buyernick = GetPostString("buyer_nick");
  4736. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4737. string customer = GetPostString("customer");
  4738. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4739. string design = GetPostString("design");
  4740. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4741. string orderState = GetPostString("orderState");
  4742. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4743. string address = GetPostString("address");
  4744. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4745. string sellermemo = GetPostString("seller_memo");
  4746. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4747. string supplier = GetPostString("supplier");
  4748. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4749. string date1 = GetPostString("date1");
  4750. string date2 = GetPostString("date2");
  4751. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4752. if (dw.Length > 0) lw.Add(dw);
  4753. string bdate1 = GetPostString("backdate1");
  4754. string bdate2 = GetPostString("backdate2");
  4755. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4756. if (dw_back.Length > 0) lw.Add(dw_back);
  4757. string price1 = GetPostString("price1");
  4758. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4759. string price2 = GetPostString("price2");
  4760. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4761. lw.Add(string.Format("IsReturn=3"));
  4762. string backtype = GetPostString("backtype");
  4763. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4764. string backreason = GetPostString("backreason");
  4765. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4766. dStruct.Order = "ReturnTime desc";
  4767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4768. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4769. writeGridDataTableJson(dStruct.TotalCount, dt);
  4770. }
  4771. public void get_erp_xianhuoreturnlist()
  4772. {
  4773. DataStruct dStruct = GetPostStruct();
  4774. List<string> lw = new List<string>();
  4775. string tid = GetPostString("ctid");
  4776. if (tid.Length > 0)
  4777. {
  4778. string select_tid = getTidByCtid(tid);
  4779. lw.Add(string.Format("tid='{0}'", select_tid));
  4780. }
  4781. string shopname = GetPostString("shopname");
  4782. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4783. string buyernick = GetPostString("buyer_nick");
  4784. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4785. string customer = GetPostString("customer");
  4786. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4787. string design = GetPostString("design");
  4788. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4789. string orderState = GetPostString("orderState");
  4790. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4791. string address = GetPostString("address");
  4792. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4793. string sellermemo = GetPostString("seller_memo");
  4794. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4795. string supplier = GetPostString("supplier");
  4796. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4797. string OrderArea = GetPostString("order_area");
  4798. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4799. string date1 = GetPostString("date1");
  4800. string date2 = GetPostString("date2");
  4801. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4802. if (dw.Length > 0) lw.Add(dw);
  4803. string price1 = GetPostString("price1");
  4804. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4805. string price2 = GetPostString("price2");
  4806. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4807. string posTag = CurrentUser.UserPost.Post.Code;
  4808. if (posTag == "Supplier")
  4809. {
  4810. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4811. }
  4812. lw.Add(string.Format("OrderState=6 "));
  4813. lw.Add(string.Format("IsXianHuo=1 "));
  4814. lw.Add(string.Format("IsReturn>0 "));
  4815. lw.Add(string.Format("IsReturn!=3"));
  4816. lw.Add(string.Format("IsRefund<={0}", 1));
  4817. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4819. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4820. writeGridDataTableJson(dStruct.TotalCount, dt);
  4821. }
  4822. public void set_erp_orderdelivery()
  4823. {
  4824. if (UrlPostParmsCheck("ctid"))
  4825. {
  4826. string eid = GetPostString("ctid");
  4827. CeErpTradeCell entity = null;
  4828. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4829. if (entity != null)
  4830. {
  4831. if (entity.OrderState >= 7)
  4832. {
  4833. returnErrorMsg("此单已发货,无需重复发货");
  4834. return;
  4835. }
  4836. if (entity.OrderState != 6)
  4837. {
  4838. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4839. return;
  4840. }
  4841. string shop = GetPostString("seller_nick");
  4842. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4843. string comName = GetPostString("comName");
  4844. string comCode = GetPostString("comCode");
  4845. string outSid = GetPostString("outSid");
  4846. string deliveryType = GetPostString("deliveryType");
  4847. string deliveryMemo = GetPostString("deliveryMemo");
  4848. outSid = outSid.Trim();
  4849. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4850. if (mainEn == null)
  4851. {
  4852. returnErrorMsg("找不到原始订单记录");
  4853. return;
  4854. }
  4855. bool isInitOrderDeliv = false;
  4856. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4857. {
  4858. isInitOrderDeliv = true;
  4859. }
  4860. string apires = "";
  4861. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4862. 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)
  4863. {
  4864. apires = "发货成功true";
  4865. }
  4866. else
  4867. {
  4868. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4869. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid, entity.ctid);
  4870. }
  4871. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4872. {
  4873. entity.OrderState = 7;//发货后订单已发货
  4874. entity.OutSid = outSid;
  4875. entity.MemoOpt = 0;
  4876. entity.UpdateTime = DateTime.Now;
  4877. entity.FinishDeliveryTime = DateTime.Now;
  4878. entity.Update();
  4879. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4880. commonHelper.UpdateRelationOrder(entity.ctid);
  4881. //还要插入快递信息到 快递信息表
  4882. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4883. exinfo.tid = eid;
  4884. exinfo.out_sid = outSid;
  4885. exinfo.company_code = comCode;
  4886. exinfo.company_name = comName;
  4887. exinfo.delivery_memo = deliveryMemo;
  4888. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4889. exinfo.deliveryType = deliveryType;
  4890. exinfo.printUser = CurrentUser.UserName;
  4891. exinfo.print_time = DateTime.Now;
  4892. exinfo.Create();
  4893. returnSuccessMsg("发货操作成功!");
  4894. commonHelper.UpdateRelationOrder(entity.ctid);
  4895. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4896. CeErpSukuraData.createInfo(entity.ctid, 4);
  4897. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4898. {
  4899. commonHelper.sendCytExpress(exinfo);
  4900. }
  4901. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4902. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4903. }
  4904. else
  4905. {
  4906. string errmsg = commonHelper.KeepChinese(apires);
  4907. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4908. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4909. }
  4910. return;
  4911. }
  4912. returnErrorMsg("找不到订单记录");
  4913. }
  4914. }
  4915. public void set_erp_multidelivery()
  4916. {
  4917. string eids = GetPostString("tids");
  4918. string[] eidList = eids.Split(',');
  4919. if (eidList.Length <= 0)
  4920. {
  4921. returnErrorMsg("发货不能为空");
  4922. return;
  4923. }
  4924. foreach (string ctid in eidList)
  4925. {
  4926. if (ctid.Length <= 0) continue;
  4927. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4928. if (expInfo != null)
  4929. {
  4930. StringBuilder sql = new StringBuilder();
  4931. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4932. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4933. if (dt.Rows.Count > 0)
  4934. {
  4935. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4936. {
  4937. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4938. expInfo.state = "异常";
  4939. expInfo.isMultiDelivery = 1;
  4940. expInfo.Update();
  4941. continue;
  4942. }
  4943. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4944. {
  4945. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4946. expInfo.state = "异常";
  4947. expInfo.Update();
  4948. continue;
  4949. }
  4950. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4951. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4952. bool isInitOrderDeliv = false;
  4953. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4954. {
  4955. isInitOrderDeliv = true;
  4956. expInfo.isMultiDelivery = 1;
  4957. }
  4958. if (ctid.IndexOf("N") != -1)
  4959. {
  4960. StringBuilder sqlbucha = new StringBuilder();
  4961. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4962. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4963. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4964. commonHelper.UpdateRelationOrder(ctid);
  4965. expInfo.delivery_memo = "发货成功";
  4966. expInfo.state = "发货成功";
  4967. expInfo.isMultiDelivery = 1;
  4968. expInfo.Update();
  4969. }
  4970. else
  4971. {
  4972. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4973. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid, ctid);
  4974. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4975. {
  4976. expInfo.delivery_memo = "发货成功";
  4977. expInfo.state = "发货成功";
  4978. expInfo.isMultiDelivery = 1;
  4979. expInfo.Update();
  4980. commonHelper.UpdateRelationOrder(ctid);
  4981. CeErpSukuraData.createInfo(ctid, 4);
  4982. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4983. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4984. }
  4985. else
  4986. {
  4987. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4988. expInfo.state = "异常";
  4989. expInfo.Update();
  4990. }
  4991. }
  4992. }
  4993. }
  4994. }
  4995. returnSuccessMsg("操作完成");
  4996. }
  4997. public void reset_erp_memoopt()
  4998. {
  4999. if (UrlPostParmsCheck("ctid"))
  5000. {
  5001. string eid = GetPostString("ctid");
  5002. CeErpTradeCell entity = null;
  5003. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5004. if (entity != null)
  5005. {
  5006. string stropt = "";
  5007. if (entity.MemoOpt == 1)
  5008. {
  5009. stropt = "“改稿”";
  5010. }
  5011. else if (entity.MemoOpt == 2)
  5012. {
  5013. stropt = "“定稿”";
  5014. }
  5015. else if (entity.MemoOpt == 3)
  5016. {
  5017. stropt = "“完成查货”";
  5018. CeErpSukuraData.createInfo(entity.ctid, 6);
  5019. }
  5020. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5021. entity.UpdateTime = DateTime.Now;
  5022. entity.MemoOpt = 0;
  5023. entity.Update();
  5024. returnSuccessMsg("操作成功!");
  5025. return;
  5026. }
  5027. returnErrorMsg("找不到记录");
  5028. }
  5029. }
  5030. public void get_erp_deliveryunusual()
  5031. {
  5032. DataStruct dStruct = GetPostStruct();
  5033. List<string> lw = new List<string>();
  5034. string tid = GetPostString("ctid");
  5035. if (tid.Length > 0)
  5036. {
  5037. string select_tid = getTidByCtid(tid);
  5038. lw.Add(string.Format("tid='{0}'", select_tid));
  5039. }
  5040. string shopname = GetPostString("shopname");
  5041. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5042. string buyernick = GetPostString("buyer_nick");
  5043. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5044. string customer = GetPostString("customer");
  5045. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5046. string design = GetPostString("design");
  5047. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5048. string sellermemo = GetPostString("seller_memo");
  5049. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5050. string supplier = GetPostString("supplier");
  5051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5052. string date1 = GetPostString("date1");
  5053. string date2 = GetPostString("date2");
  5054. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5055. if (dw.Length > 0) lw.Add(dw);
  5056. string placedate1 = GetPostString("placedate1");
  5057. string placedate2 = GetPostString("placedate2");
  5058. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5059. if (dw_place.Length > 0) lw.Add(dw_place);
  5060. string price1 = GetPostString("price1");
  5061. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5062. string price2 = GetPostString("price2");
  5063. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5064. string unusualCon = GetPostString("unusualcon");
  5065. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5066. string posTag = CurrentUser.UserPost.Post.Code;
  5067. if (posTag == "Supplier")
  5068. {
  5069. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5070. }
  5071. lw.Add(string.Format("OrderState = 6"));
  5072. lw.Add(string.Format("UnusualTag = 5"));
  5073. lw.Add(string.Format("IsRefund<={0}", 1));
  5074. dStruct.Order = "FinishPlaceTime desc";
  5075. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5076. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5077. writeGridDataTableJson(dStruct.TotalCount, dt);
  5078. }
  5079. public void get_erp_deliveryedlist()
  5080. {
  5081. DataStruct dStruct = GetPostStruct();
  5082. List<string> lw = new List<string>();
  5083. string tid = GetPostString("ctid");
  5084. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5085. string shopname = GetPostString("shopname");
  5086. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5087. string buyernick = GetPostString("buyer_nick");
  5088. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5089. string customer = GetPostString("customer");
  5090. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5091. string design = GetPostString("design");
  5092. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5093. string sellermemo = GetPostString("seller_memo");
  5094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5095. string logistics = GetPostString("logistics");
  5096. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5097. string date1 = GetPostString("date1");
  5098. string date2 = GetPostString("date2");
  5099. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5100. //if (dw.Length > 0) lw.Add(dw);
  5101. string placedate1 = GetPostString("placedate1");
  5102. string placedate2 = GetPostString("placedate2");
  5103. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5104. if (fdw.Length > 0) lw.Add(fdw);
  5105. string devdate1 = GetPostString("deliverydate1");
  5106. string devdate2 = GetPostString("deliverydate2");
  5107. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5108. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5109. string price1 = GetPostString("price1");
  5110. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5111. string price2 = GetPostString("price2");
  5112. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5113. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5114. {
  5115. if (tid.Length > 0)
  5116. {
  5117. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5118. if (tid.Length > 5)
  5119. {
  5120. List<string> tids = getTidByCtidLike(tid);
  5121. if (tids.Count > 0 && tids.Count < 10)
  5122. {
  5123. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5124. }
  5125. }
  5126. lw.Add(tid_sql);
  5127. }
  5128. if (buyernick.Length > 0)
  5129. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5130. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5131. if (dw.Length > 0) lw.Add(dw);
  5132. }
  5133. else
  5134. {
  5135. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5136. }
  5137. string posTag = CurrentUser.UserPost.Post.Code;
  5138. if (posTag == "Supplier")
  5139. {
  5140. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5141. }
  5142. else
  5143. {
  5144. string supplier = GetPostString("supplier");
  5145. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5146. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5147. {
  5148. string usershop = CurrentUser.User.pemShop;
  5149. lw.Add(string.Format("ShopId in ({0})", usershop));
  5150. }
  5151. }
  5152. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5153. lw.Add(string.Format("type != 'PDD' "));
  5154. lw.Add(string.Format("IsRefund!={0}", 2));
  5155. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5156. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5157. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5158. /*if (tid.Length > 0)
  5159. {
  5160. List<string> tids = new List<string>();
  5161. if (dt != null && dt.Rows.Count > 0)
  5162. {
  5163. foreach (DataRow item in dt.Rows)
  5164. {
  5165. tids.Add("'" + item["tid"] + "'");
  5166. }
  5167. }
  5168. if (tids.Count > 0)
  5169. {
  5170. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5171. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5172. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5173. dt = WebCache.GetData("view_erptradecell", dStruct);
  5174. }
  5175. }*/
  5176. if (dt != null)
  5177. {
  5178. foreach (DataRow dr in dt.Rows)
  5179. {
  5180. 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();
  5181. }
  5182. }
  5183. writeGridDataTableJson(dStruct.TotalCount, dt);
  5184. }
  5185. public void get_erp_pdddeliveryed()
  5186. {
  5187. DataStruct dStruct = GetPostStruct();
  5188. List<string> lw = new List<string>();
  5189. string tid = GetPostString("ctid");
  5190. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5191. string shopname = GetPostString("shopname");
  5192. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5193. string buyernick = GetPostString("buyer_nick");
  5194. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5195. string customer = GetPostString("customer");
  5196. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5197. string design = GetPostString("design");
  5198. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5199. string sellermemo = GetPostString("seller_memo");
  5200. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5201. string logistics = GetPostString("logistics");
  5202. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5203. string date1 = GetPostString("date1");
  5204. string date2 = GetPostString("date2");
  5205. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5206. //if (dw.Length > 0) lw.Add(dw);
  5207. string placedate1 = GetPostString("placedate1");
  5208. string placedate2 = GetPostString("placedate2");
  5209. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5210. if (fdw.Length > 0) lw.Add(fdw);
  5211. string devdate1 = GetPostString("deliverydate1");
  5212. string devdate2 = GetPostString("deliverydate2");
  5213. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5214. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5215. string price1 = GetPostString("price1");
  5216. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5217. string price2 = GetPostString("price2");
  5218. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5219. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5220. {
  5221. if (tid.Length > 0)
  5222. {
  5223. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5224. if (tid.Length > 5)
  5225. {
  5226. List<string> tids = getTidByCtidLike(tid);
  5227. if (tids.Count > 0 && tids.Count < 10)
  5228. {
  5229. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5230. }
  5231. }
  5232. lw.Add(tid_sql);
  5233. }
  5234. if (buyernick.Length > 0)
  5235. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5236. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5237. if (dw.Length > 0) lw.Add(dw);
  5238. }
  5239. else
  5240. {
  5241. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5242. }
  5243. string posTag = CurrentUser.UserPost.Post.Code;
  5244. if (posTag == "Supplier")
  5245. {
  5246. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5247. }
  5248. else
  5249. {
  5250. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5251. {
  5252. string usershop = CurrentUser.User.pemShop;
  5253. lw.Add(string.Format("ShopId in ({0})", usershop));
  5254. }
  5255. string supplier = GetPostString("supplier");
  5256. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5257. }
  5258. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5259. lw.Add(string.Format("type = 'PDD' "));
  5260. lw.Add(string.Format("IsRefund!={0}", 2));
  5261. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5262. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5263. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5264. /* if (tid.Length > 0)
  5265. {
  5266. List<string> tids = new List<string>();
  5267. if (dt != null && dt.Rows.Count > 0)
  5268. {
  5269. foreach (DataRow item in dt.Rows)
  5270. {
  5271. tids.Add("'" + item["tid"] + "'");
  5272. }
  5273. }
  5274. if (tids.Count > 0)
  5275. {
  5276. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5277. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5278. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5279. dt = WebCache.GetData("view_erptradecell", dStruct);
  5280. }
  5281. }*/
  5282. foreach (DataRow dr in dt.Rows)
  5283. {
  5284. 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();
  5285. }
  5286. writeGridDataTableJson(dStruct.TotalCount, dt);
  5287. }
  5288. public void get_erp_jddeliveryed()
  5289. {
  5290. DataStruct dStruct = GetPostStruct();
  5291. List<string> lw = new List<string>();
  5292. string tid = GetPostString("ctid");
  5293. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5294. string shopname = GetPostString("shopname");
  5295. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5296. string buyernick = GetPostString("buyer_nick");
  5297. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5298. string customer = GetPostString("customer");
  5299. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5300. string design = GetPostString("design");
  5301. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5302. string sellermemo = GetPostString("seller_memo");
  5303. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5304. string date1 = GetPostString("date1");
  5305. string date2 = GetPostString("date2");
  5306. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5307. //if (dw.Length > 0) lw.Add(dw);
  5308. string placedate1 = GetPostString("placedate1");
  5309. string placedate2 = GetPostString("placedate2");
  5310. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5311. if (fdw.Length > 0) lw.Add(fdw);
  5312. string devdate1 = GetPostString("deliverydate1");
  5313. string devdate2 = GetPostString("deliverydate2");
  5314. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5315. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5316. string price1 = GetPostString("price1");
  5317. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5318. string price2 = GetPostString("price2");
  5319. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5320. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5321. {
  5322. if (tid.Length > 0)
  5323. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5324. if (buyernick.Length > 0)
  5325. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5326. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5327. if (dw.Length > 0) lw.Add(dw);
  5328. }
  5329. else
  5330. {
  5331. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5332. }
  5333. string posTag = CurrentUser.UserPost.Post.Code;
  5334. if (posTag == "Supplier")
  5335. {
  5336. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5337. }
  5338. else
  5339. {
  5340. string supplier = GetPostString("supplier");
  5341. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5342. }
  5343. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5344. lw.Add(string.Format("type = 'JD' "));
  5345. lw.Add(string.Format("IsRefund!={0}", 2));
  5346. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5347. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5348. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5349. foreach (DataRow dr in dt.Rows)
  5350. {
  5351. 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();
  5352. }
  5353. writeGridDataTableJson(dStruct.TotalCount, dt);
  5354. }
  5355. public void get_erp_allplacelist()
  5356. {
  5357. DataStruct dStruct = GetPostStruct();
  5358. List<string> lw = new List<string>();
  5359. string tid = GetPostString("ctid");
  5360. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5361. string shopname = GetPostString("shopname");
  5362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5363. string buyernick = GetPostString("buyer_nick");
  5364. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5365. string customer = GetPostString("customer");
  5366. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5367. string design = GetPostString("design");
  5368. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5369. string sellermemo = GetPostString("seller_memo");
  5370. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5371. string supplier = GetPostString("supplier");
  5372. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5373. string date1 = GetPostString("date1");
  5374. string date2 = GetPostString("date2");
  5375. string pldate1 = GetPostString("placedate1");
  5376. string pldate2 = GetPostString("placedate2");
  5377. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5378. //if (dw.Length > 0) lw.Add(dw);
  5379. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5380. {
  5381. if (tid.Length > 0)
  5382. {
  5383. string select_tid = getTidByCtid(tid);
  5384. lw.Add(string.Format("tid='{0}'", select_tid));
  5385. }
  5386. if (buyernick.Length > 0)
  5387. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5388. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5389. if (dw.Length > 0) lw.Add(dw);
  5390. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5391. if (dw_place.Length > 0) lw.Add(dw_place);
  5392. }
  5393. else
  5394. {
  5395. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5396. {
  5397. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5398. }
  5399. }
  5400. string price1 = GetPostString("price1");
  5401. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5402. string price2 = GetPostString("price2");
  5403. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5404. string posTag = CurrentUser.UserPost.Post.Code;
  5405. if (posTag == "Supplier")
  5406. {
  5407. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5408. }
  5409. lw.Add(string.Format("OrderState >= 6"));
  5410. lw.Add(string.Format("IsSample != 2 "));
  5411. //lw.Add(string.Format("isDianziOrder = 0 "));
  5412. lw.Add(string.Format("SupplierId > 0 "));
  5413. //lw.Add(string.Format("IsRefund<={0}", 1));
  5414. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5415. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5416. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5417. foreach (DataRow dr in dt.Rows)
  5418. {
  5419. 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();
  5420. }
  5421. writeGridDataTableJson(dStruct.TotalCount, dt);
  5422. }
  5423. public void get_erp_financeallplacelist()
  5424. {
  5425. DataStruct dStruct = GetPostStruct();
  5426. List<string> lw = new List<string>();
  5427. string tid = GetPostString("ctid");
  5428. string shopname = GetPostString("shopname");
  5429. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5430. string buyernick = GetPostString("buyer_nick");
  5431. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5432. string customer = GetPostString("customer");
  5433. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5434. string design = GetPostString("design");
  5435. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5436. string sellermemo = GetPostString("seller_memo");
  5437. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5438. string supplier = GetPostString("supplier");
  5439. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5440. string date1 = GetPostString("date1");
  5441. string date2 = GetPostString("date2");
  5442. string pldate1 = GetPostString("placedate1");
  5443. string pldate2 = GetPostString("placedate2");
  5444. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5445. {
  5446. if (tid.Length > 0)
  5447. {
  5448. string select_tid = getTidByCtid(tid);
  5449. lw.Add(string.Format("tid='{0}'", select_tid));
  5450. }
  5451. if (buyernick.Length > 0)
  5452. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5453. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5454. if (dw.Length > 0) lw.Add(dw);
  5455. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5456. if (dw_place.Length > 0) lw.Add(dw_place);
  5457. }
  5458. else
  5459. {
  5460. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5461. {
  5462. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5463. }
  5464. }
  5465. string price1 = GetPostString("price1");
  5466. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5467. string price2 = GetPostString("price2");
  5468. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5469. string posTag = CurrentUser.UserPost.Post.Code;
  5470. if (posTag == "Supplier")
  5471. {
  5472. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5473. }
  5474. //lw.Add(string.Format("OrderState >= 6"));
  5475. lw.Add(string.Format("IsSample != 2 "));
  5476. lw.Add(string.Format("isDianziOrder = 0 "));
  5477. //lw.Add(string.Format("IsRefund<={0}", 1));
  5478. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5479. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5480. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5481. foreach (DataRow dr in dt.Rows)
  5482. {
  5483. 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();
  5484. }
  5485. writeGridDataTableJson(dStruct.TotalCount, dt);
  5486. }
  5487. public void get_erp_expresslist()
  5488. {
  5489. int listtype = GetInt("ltype");
  5490. DataStruct dStruct = GetPostStruct();
  5491. List<string> lw = new List<string>();
  5492. string tid = GetPostString("tid");
  5493. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5494. string outsid = GetPostString("out_sid");
  5495. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5496. string importer = GetPostString("ImportUserName");
  5497. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5498. string file = GetPostString("import_file");
  5499. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5500. string printman = GetPostString("printman");
  5501. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5502. string date1 = GetPostString("date1");
  5503. string date2 = GetPostString("date2");
  5504. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5505. if (dw.Length > 0) lw.Add(dw);
  5506. string fdate1 = GetPostString("finishdate1");
  5507. string fdate2 = GetPostString("finishdate2");
  5508. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5509. if (fdw.Length > 0) lw.Add(fdw);
  5510. string supplierId = GetPostString("supplierId");
  5511. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5512. if (listtype == 1)
  5513. {
  5514. lw.Add(string.Format("importUserId !=0"));
  5515. }
  5516. string posTag = CurrentUser.UserPost.Post.Code;
  5517. if (posTag == "Supplier")
  5518. {
  5519. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5520. }
  5521. if (dStruct.PageSize != 100000)
  5522. {
  5523. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5524. }
  5525. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5526. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5527. writeGridDataTableJson(dStruct.TotalCount, dt);
  5528. }
  5529. public void set_erp_buchaorderdelivery()
  5530. {
  5531. if (UrlPostParmsCheck("ctid"))
  5532. {
  5533. string eid = GetPostString("ctid");
  5534. CeErpTradeCell entity = null;
  5535. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5536. if (entity != null)
  5537. {
  5538. if (entity.IsSample != 2)
  5539. {
  5540. returnErrorMsg("补差价单才能标记为已发货");
  5541. return;
  5542. }
  5543. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5544. entity.OrderState = 7;
  5545. entity.Update();
  5546. returnSuccessMsg("操作成功!");
  5547. return;
  5548. }
  5549. returnErrorMsg("找不到记录");
  5550. }
  5551. }
  5552. public void get_stdtemplates()
  5553. {
  5554. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5555. //string res = taobaoHelper.test();
  5556. string res = apiHelper.API_PrintTemplate();
  5557. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5558. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5559. {
  5560. int sidx = res.IndexOf("error_code");
  5561. int eidx = res.IndexOf("success");
  5562. string msg = res.Substring(sidx, eidx - sidx);
  5563. returnErrorMsg(msg);
  5564. return;
  5565. }
  5566. if (res.Length <= 0)
  5567. {
  5568. returnErrorMsg("模板数据为空!");
  5569. return;
  5570. }
  5571. ReturnSuccess(res);
  5572. }
  5573. public void cancel_print_order()
  5574. {
  5575. if (UrlPostParmsCheck("ctid"))
  5576. {
  5577. string ctid = GetPostString("ctid");
  5578. CeErpTradeCell entity = null;
  5579. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5580. if (entity != null)
  5581. {
  5582. string res = "";
  5583. string code = entity.LastBillWaybillCode;
  5584. if (code == "")
  5585. {
  5586. code = entity.OutSid;
  5587. }
  5588. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5589. XLog.SaveLog(0, "取消面单" + res);
  5590. }
  5591. }
  5592. }
  5593. public void set_erp_printwaybill()
  5594. {
  5595. if (UrlPostParmsCheck("ctid"))
  5596. {
  5597. string ctid = GetPostString("ctid");
  5598. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5599. string cpName = GetPostString("cpname");
  5600. string isTogether = GetPostString("together");
  5601. string printType = GetPostString("printType");
  5602. //var res_obj = new
  5603. //{
  5604. // restype = 1,
  5605. // 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\"}"
  5606. //};
  5607. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5608. //ReturnSuccess(ro_json);
  5609. //return;
  5610. bool isUseLastWayBillCode = false;
  5611. CeErpTradeCell entity = null;
  5612. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5613. if (entity != null)
  5614. {
  5615. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5616. {
  5617. isUseLastWayBillCode = true;
  5618. }
  5619. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5620. {
  5621. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5622. return;
  5623. }
  5624. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5625. {
  5626. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5627. return;
  5628. }
  5629. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5630. {
  5631. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5632. return;
  5633. }
  5634. }
  5635. string res = "";
  5636. Api_waybill_code_response_Obj fullObj = null;
  5637. string pData_str = "";
  5638. string curUseWayBillCode = "";
  5639. if (isUseLastWayBillCode == false)
  5640. {
  5641. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5642. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5643. if (res.IndexOf("failure") != -1)
  5644. {
  5645. //int idx = res.IndexOf("sub_message");
  5646. //int idx2 = res.IndexOf("flag");
  5647. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5648. string errMsgNeed = commonHelper.KeepChinese(res);
  5649. var res_objd = new
  5650. {
  5651. restype = 0,
  5652. data = "获取面单失败" + errMsgNeed
  5653. };
  5654. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5655. returnSuccess(ro_jsond);
  5656. if (res.IndexOf("停发") != -1)
  5657. {
  5658. entity.UnusualCon = "物流停发";
  5659. entity.Update();
  5660. }
  5661. //returnErrorMsg("获取面单失败,"+emsg);
  5662. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5663. return;
  5664. }
  5665. else if (res.IndexOf("errorMsg") != -1)
  5666. {
  5667. //int idx = res.IndexOf("errorMsg");
  5668. //int idx2 = res.IndexOf("}]}");
  5669. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5670. string errMsgNeed = commonHelper.KeepChinese(res);
  5671. var res_objf = new
  5672. {
  5673. restype = 0,
  5674. data = "获取面单失败2" + errMsgNeed
  5675. };
  5676. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5677. if (res.IndexOf("停发") != -1)
  5678. {
  5679. entity.UnusualCon = "物流停发";
  5680. entity.Update();
  5681. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5682. if (trade != null)
  5683. {
  5684. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5685. }
  5686. }
  5687. returnSuccess(ro_jsonf);
  5688. //returnErrorMsg("获取面单失败," + emsg);
  5689. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5690. return;
  5691. }
  5692. try
  5693. {
  5694. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5695. //res = res.Replace(" ", "");
  5696. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5697. }
  5698. catch (Exception ex)
  5699. {
  5700. XLog.SaveLog(0, "生成fullObj" + res);
  5701. var res_objf = new
  5702. {
  5703. restype = 0,
  5704. data = "生成fullObj发生错误" + ex.Message
  5705. };
  5706. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5707. returnSuccess(ro_jsonf);
  5708. return;
  5709. }
  5710. if (fullObj.response.data.content.Count > 0)
  5711. {
  5712. ContentItem codeObj = fullObj.response.data.content[0];
  5713. if (cpCode.IndexOf("SFFQ-") != -1)
  5714. {
  5715. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5716. }
  5717. else
  5718. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5719. curUseWayBillCode = codeObj.waybillCode;
  5720. }
  5721. else
  5722. {
  5723. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5724. var res_objf = new
  5725. {
  5726. restype = 0,
  5727. data = "生成fullObj找不到快递单号waybillCode"
  5728. };
  5729. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5730. returnSuccess(ro_jsonf);
  5731. return;
  5732. }
  5733. }
  5734. else
  5735. {
  5736. //使用上次打印的快递单号
  5737. if (cpCode == "SFFQ-LY")
  5738. {
  5739. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5740. }
  5741. else
  5742. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5743. curUseWayBillCode = entity.LastBillWaybillCode;
  5744. }
  5745. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5746. {
  5747. var res_obje = new
  5748. {
  5749. restype = 0,
  5750. data = "获取加密打印数据失败"
  5751. };
  5752. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5753. returnSuccess(ro_jsone);
  5754. entity.LastBillCpCode = cpCode;
  5755. entity.LastBillWaybillCode = curUseWayBillCode;
  5756. entity.Update();
  5757. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5758. //returnErrorMsg("获取加密打印数据失败");
  5759. return;
  5760. }
  5761. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5762. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5763. string btnType = "";
  5764. string errorMsg = "";
  5765. if (entity != null)
  5766. {
  5767. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5768. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5769. //cpcode是 YTO-CAINIAO
  5770. //string comCode = cpCode.Split('-')[0].ToString();
  5771. string apires = "";
  5772. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5773. //isTogether=2是新的合包弹窗
  5774. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5775. {
  5776. if (ctid.IndexOf("N") != -1)
  5777. {
  5778. apires = "发货成功";
  5779. }
  5780. else
  5781. {
  5782. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode, entity.ctid);
  5783. }
  5784. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5785. //打单后发货
  5786. StringBuilder sql = new StringBuilder();
  5787. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5788. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5789. {
  5790. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5791. }
  5792. else
  5793. {
  5794. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5795. }
  5796. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5797. foreach (DataRow row in dt.Rows)
  5798. {
  5799. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5800. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5801. {
  5802. try
  5803. {
  5804. btnType = "待发货";
  5805. entity.OutSid = curUseWayBillCode;
  5806. entity.OrderState = 7;
  5807. entity.IsUrgency = false;
  5808. entity.LastBillCpCode = "";
  5809. entity.LastBillWaybillCode = "";
  5810. entity.FinishDeliveryTime = DateTime.Now;
  5811. entity.IsReturn = 0;
  5812. entity.MemoOpt = 0;
  5813. entity.UpdateTime = DateTime.Now;
  5814. entity.Update();
  5815. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5816. //还要插入快递信息到 快递信息表
  5817. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5818. exinfo.tid = entity.ctid;
  5819. exinfo.out_sid = curUseWayBillCode;
  5820. exinfo.company_code = cpCode;
  5821. exinfo.company_name = cpName;
  5822. exinfo.supplierUserName = supplierName;
  5823. exinfo.deliveryType = "发货成功";
  5824. exinfo.print_time = DateTime.Now;
  5825. exinfo.printUser = CurrentUser.UserName;
  5826. exinfo.postData = pData_str;
  5827. exinfo.Create();
  5828. commonHelper.UpdateRelationOrder(entity.ctid);
  5829. CeErpSukuraData.createInfo(ctid, 4);
  5830. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5831. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5832. {
  5833. commonHelper.sendCytExpress(exinfo);
  5834. }
  5835. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5836. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5837. }
  5838. catch (Exception ex)
  5839. {
  5840. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5841. }
  5842. }
  5843. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5844. {
  5845. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5846. if (entity.OrderState == 6)
  5847. {
  5848. entity.OrderState = 7;
  5849. }
  5850. entity.UpdateTime = DateTime.Now;
  5851. entity.FinishDeliveryTime = DateTime.Now;
  5852. btnType = "已发货";
  5853. entity.Update();
  5854. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5855. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5856. exinfo.tid = entity.ctid;
  5857. exinfo.out_sid = curUseWayBillCode;
  5858. exinfo.company_code = cpCode;
  5859. exinfo.company_name = cpName;
  5860. exinfo.supplierUserName = supplierName;
  5861. exinfo.deliveryType = "发货成功";
  5862. exinfo.print_time = DateTime.Now;
  5863. exinfo.printUser = CurrentUser.UserName;
  5864. exinfo.postData = pData_str;
  5865. exinfo.Create();
  5866. commonHelper.UpdateRelationOrder(entity.ctid);
  5867. CeErpSukuraData.createInfo(entity.ctid, 4);
  5868. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5869. {
  5870. commonHelper.sendCytExpress(exinfo);
  5871. }
  5872. //不处理
  5873. }
  5874. else
  5875. {
  5876. entity.UpdateTime = DateTime.Now;
  5877. entity.LastBillCpCode = cpCode;
  5878. entity.LastBillWaybillCode = curUseWayBillCode;
  5879. entity.Update();
  5880. string errmsg = commonHelper.KeepChinese(apires);
  5881. var res_objz = new
  5882. {
  5883. restype = 0,
  5884. data = "打单后发货失败"
  5885. };
  5886. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5887. returnSuccess(ro_jsonz);
  5888. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5889. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5890. return;
  5891. }
  5892. }
  5893. }
  5894. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5895. {
  5896. string ctids = GetPostString("ctids");
  5897. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5898. List<string> list = new List<string>();
  5899. List<string> send_list = new List<string>();
  5900. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5901. CeErpTrade ceErpTrade = new CeErpTrade();
  5902. //可合包的合并一起发货
  5903. if (dt == null && string.IsNullOrEmpty(ctids))
  5904. {
  5905. var res_objz = new
  5906. {
  5907. restype = 0,
  5908. data = "打单后发货失败"
  5909. };
  5910. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5911. returnSuccess(ro_jsonz);
  5912. return;
  5913. }
  5914. if (!string.IsNullOrEmpty(ctids))
  5915. {
  5916. StringBuilder sql = new StringBuilder();
  5917. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5918. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5919. }
  5920. foreach (DataRow row in dt.Rows)
  5921. {
  5922. list.Add("'" + row["ctid"] + "'");
  5923. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5924. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5925. if (ctid.IndexOf("N") != -1)
  5926. {
  5927. apires = "发货成功";
  5928. }
  5929. else
  5930. {
  5931. if (!send_list.Contains(ceErpTrade.tid))
  5932. {
  5933. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode, ctid);
  5934. }
  5935. else
  5936. {
  5937. apires = "发货成功";
  5938. }
  5939. }
  5940. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5941. {
  5942. send_list.Add(ceErpTrade.tid);
  5943. try
  5944. {
  5945. btnType = "待发货";
  5946. ceErpTradeCell.OutSid = curUseWayBillCode;
  5947. ceErpTradeCell.OrderState = 7;
  5948. ceErpTradeCell.IsUrgency = false;
  5949. ceErpTradeCell.LastBillCpCode = "";
  5950. ceErpTradeCell.LastBillWaybillCode = "";
  5951. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5952. ceErpTradeCell.IsReturn = 0;
  5953. ceErpTradeCell.MemoOpt = 0;
  5954. ceErpTradeCell.UpdateTime = DateTime.Now;
  5955. ceErpTradeCell.Update();
  5956. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5957. //还要插入快递信息到 快递信息表
  5958. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5959. exinfo.tid = ceErpTradeCell.ctid;
  5960. exinfo.out_sid = curUseWayBillCode;
  5961. exinfo.company_code = cpCode;
  5962. exinfo.company_name = cpName;
  5963. exinfo.supplierUserName = supplierName;
  5964. exinfo.deliveryType = "发货成功";
  5965. exinfo.print_time = DateTime.Now;
  5966. exinfo.printUser = CurrentUser.UserName;
  5967. exinfo.postData = pData_str;
  5968. exinfo.Create();
  5969. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5970. CeErpSukuraData.createInfo(ctid, 4);
  5971. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5972. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5973. {
  5974. commonHelper.sendCytExpress(exinfo);
  5975. }
  5976. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5977. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5978. }
  5979. catch (Exception ex)
  5980. {
  5981. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5982. }
  5983. }
  5984. else
  5985. {
  5986. ceErpTradeCell.UpdateTime = DateTime.Now;
  5987. ceErpTradeCell.LastBillCpCode = cpCode;
  5988. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5989. ceErpTradeCell.Update();
  5990. string errmsg = commonHelper.KeepChinese(apires);
  5991. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5992. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5993. }
  5994. }
  5995. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5996. }
  5997. }
  5998. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5999. var res_obj = new
  6000. {
  6001. restype = 1,
  6002. data = pData_str,
  6003. errorMsg
  6004. };
  6005. string ro_json = JsonConvert.SerializeObject(res_obj);
  6006. ReturnSuccess(ro_json);
  6007. return;
  6008. }
  6009. }
  6010. private string GetUTF8String(byte[] vs)
  6011. {
  6012. throw new NotImplementedException();
  6013. }
  6014. public void set_erp_printwaybill_cn()
  6015. {
  6016. if (UrlPostParmsCheck("ctid"))
  6017. {
  6018. string ctid = GetPostString("ctid");
  6019. string cpCode = GetPostString("cpcode");
  6020. string cpName = GetPostString("cpname");
  6021. string tempUrl = GetPostString("tempurl");
  6022. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6023. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6024. //string res = taobaoHelper.test();
  6025. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6026. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6027. {
  6028. int sidx = res.IndexOf("errorMsg");
  6029. int eidx = res.IndexOf("}");
  6030. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6031. var res_objzxx = new
  6032. {
  6033. restype = 0,
  6034. data = msg
  6035. };
  6036. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6037. returnSuccess(ro_jsonzxx);
  6038. //returnErrorMsg(msg);
  6039. return;
  6040. }
  6041. int idx = res.IndexOf("waybillCode");
  6042. int idx2 = res.IndexOf("printData");
  6043. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6044. string eid = GetPostString("ctid");
  6045. CeErpTradeCell entity = null;
  6046. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6047. if (entity != null)
  6048. {
  6049. string osid = entity.OutSid;
  6050. entity.OutSid = osid + "," + outsid;
  6051. entity.FinishDeliveryTime = DateTime.Now;
  6052. entity.OrderState = 7;
  6053. entity.UpdateTime = DateTime.Now;
  6054. entity.IsReturn = 0;
  6055. entity.Update();
  6056. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6057. exinfo.tid = entity.ctid;
  6058. exinfo.out_sid = outsid;
  6059. exinfo.company_code = cpCode;
  6060. exinfo.company_name = cpName;
  6061. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6062. exinfo.deliveryType = "发货成功";
  6063. exinfo.print_time = DateTime.Now;
  6064. exinfo.printUser = CurrentUser.UserName;
  6065. exinfo.Create();
  6066. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6067. {
  6068. commonHelper.sendCytExpress(exinfo);
  6069. }
  6070. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6071. }
  6072. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6073. var res_objz = new
  6074. {
  6075. restype = 1,
  6076. data = res
  6077. };
  6078. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6079. returnSuccess(ro_jsonz);
  6080. //ReturnSuccess(res);
  6081. }
  6082. }
  6083. ////打单,打印面单 获取面单号
  6084. //public void set_erp_printwaybill()
  6085. //{
  6086. // if (UrlPostParmsCheck("ctid"))
  6087. // {
  6088. // string ctid = GetPostString("ctid");
  6089. // string cpCode = GetPostString("cpcode");
  6090. // string tempUrl = GetPostString("tempurl");
  6091. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6092. // //string res = taobaoHelper.test();
  6093. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6094. // if (res.IndexOf("error_response") != -1)
  6095. // {
  6096. // int sidx = res.IndexOf("sub_msg");
  6097. // int eidx = res.IndexOf("request_id");
  6098. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6099. // returnErrorMsg(msg);
  6100. // return;
  6101. // }
  6102. // int idx = res.IndexOf("waybill_code");
  6103. // int idx2 = res.IndexOf("}]}");
  6104. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6105. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6106. // ReturnSuccess(res);
  6107. // }
  6108. //}
  6109. public void cancel_erp_aftersale()
  6110. {
  6111. if (UrlPostParmsCheck("ctid"))
  6112. {
  6113. string eid = GetPostString("ctid");
  6114. CeErpTradeCell entity = null;
  6115. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6116. if (entity != null)
  6117. {
  6118. //有过处理的售后,取消也不能删除 售 字,保留
  6119. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6120. {
  6121. entity.AfterSaleState = 4;
  6122. }
  6123. else
  6124. entity.AfterSaleState = 0;
  6125. entity.UpdateTime = DateTime.Now;
  6126. entity.Update();
  6127. returnSuccessMsg("操作成功!");
  6128. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6129. return;
  6130. }
  6131. returnErrorMsg("找不到订单记录");
  6132. }
  6133. }
  6134. public void get_erp_aftersalelist()
  6135. {
  6136. DataStruct dStruct = GetPostStruct();
  6137. List<string> lw = new List<string>();
  6138. int st = GetInt("st");
  6139. string tid = GetPostString("ctid");
  6140. if (st == 3)
  6141. {
  6142. if (tid.Length > 0)
  6143. {
  6144. string select_tid = getTidByCtid(tid);
  6145. lw.Add(string.Format("tid='{0}'", select_tid));
  6146. }
  6147. }
  6148. else
  6149. {
  6150. if (tid.Length > 0)
  6151. {
  6152. string select_tid = getTidByCtid(tid);
  6153. lw.Add(string.Format("tid='{0}'", select_tid));
  6154. }
  6155. }
  6156. string shopname = GetPostString("shopname");
  6157. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6158. string buyernick = GetPostString("buyer_nick");
  6159. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6160. string sellermemo = GetPostString("seller_memo");
  6161. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6162. string orderState = GetPostString("orderState");
  6163. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6164. string afterState = GetPostString("afterstate");
  6165. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6166. string date1 = GetPostString("date1");
  6167. string date2 = GetPostString("date2");
  6168. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6169. if (dw.Length > 0) lw.Add(dw);
  6170. string price1 = GetPostString("price1");
  6171. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6172. string price2 = GetPostString("price2");
  6173. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6174. //lw.Add(string.Format("IsRefund!={0}", 1));
  6175. string reason = GetPostString("reason");
  6176. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6177. string method = GetPostString("method");
  6178. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6179. string handler = GetPostString("handler");
  6180. if (handler.Length > 0)
  6181. {
  6182. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6183. }
  6184. string handledate1 = GetPostString("handledate1");
  6185. string handledate2 = GetPostString("handledate2");
  6186. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6187. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6188. string finish1 = GetPostString("finishdate1");
  6189. string finish2 = GetPostString("finishdate2");
  6190. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6191. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6192. string afterdate1 = GetPostString("afterdate1");
  6193. string afterdate2 = GetPostString("afterdate2");
  6194. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6195. if (afterDate.Length > 0) lw.Add(afterDate);
  6196. string supplier = GetPostString("supplier");
  6197. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6198. string responsible = GetPostString("responsibleman");
  6199. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6200. string customer = GetPostString("customer");
  6201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6202. string design = GetPostString("design");
  6203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6204. string afterMemoType = GetPostString("aftermemotype");
  6205. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6206. string posCode = CurrentUser.UserPost.Post.Code;
  6207. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6208. //{
  6209. // string vstate = GetPostString("vstate");
  6210. // if (vstate.Length > 0)
  6211. // {
  6212. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6213. // }
  6214. // if (posCode == "Supplier")
  6215. // {
  6216. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6217. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6218. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6219. // }
  6220. // else
  6221. // {
  6222. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6223. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6224. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6225. // {
  6226. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6227. // }
  6228. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6229. // {
  6230. // int orgid = CurrentUser.UserPost.OrgID;
  6231. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6232. // }
  6233. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6234. // {
  6235. // string shopid = CurrentUser.User.pemShop;
  6236. // lw.Add(string.Format("shopId in ({0})", shopid));
  6237. // }
  6238. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6239. // //{
  6240. // // int org_id = CurrentUser.UserPost.OrgID;
  6241. // // lw.Add(string.Format("OrgID={0}", org_id));
  6242. // //}
  6243. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6244. // }
  6245. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6246. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6247. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6248. //}
  6249. if (st == 5)
  6250. {
  6251. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6252. {
  6253. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6254. {
  6255. string shopid = CurrentUser.User.pemShop;
  6256. lw.Add(string.Format("shopId in ({0})", shopid));
  6257. }
  6258. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6259. {
  6260. int mrOrgid = CurrentUser.UserPost.OrgID;
  6261. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6262. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6263. }
  6264. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6265. //{
  6266. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6267. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6268. //}
  6269. else
  6270. {
  6271. string userIdStr = "";
  6272. if (posCode == "CustomerService")
  6273. {
  6274. userIdStr = CurrentUser.UserID + "_k";
  6275. }
  6276. else if (posCode == "Designer" || posCode == "wxDesigner")
  6277. {
  6278. userIdStr = CurrentUser.UserID + "_s";
  6279. }
  6280. else if (posCode == "Place")
  6281. {
  6282. userIdStr = CurrentUser.UserID + "_x";
  6283. }
  6284. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6285. }
  6286. }
  6287. string placedate1 = GetPostString("placedate1");
  6288. string placedate2 = GetPostString("placedate2");
  6289. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6290. if (dwplace.Length > 0) lw.Add(dwplace);
  6291. string supState = GetPostString("supState");
  6292. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6293. string searchType = GetPostString("searchType");
  6294. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6295. {
  6296. lw.Add(string.Format("BackNum>1"));
  6297. }
  6298. lw.Add(string.Format("AfterSaleState>0"));
  6299. if (ex_psize > 0)
  6300. {
  6301. if (CurrentUser.UserPost.Post.Code == "Finance")
  6302. dStruct.Order = "pay_time desc";
  6303. else
  6304. dStruct.Order = "HandleTime desc";
  6305. }
  6306. else
  6307. dStruct.Order = "HandleTime desc";
  6308. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6309. DataTable dt = WebCache.GetData("view_test", dStruct);
  6310. writeGridDataTableJson(dStruct.TotalCount, dt);
  6311. }
  6312. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6313. //{
  6314. // lw.Add(string.Format("AfterSaleState=4"));
  6315. // string code = CurrentUser.UserPost.Post.Code;
  6316. // if (code == "CustomerService")
  6317. // {
  6318. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6319. // }
  6320. // else if (code == "Designer" || code == "DesignerMr")
  6321. // {
  6322. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6323. // }
  6324. // else if (code == "Place" || code == "PlaceMr")
  6325. // {
  6326. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6327. // }
  6328. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6329. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6330. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6331. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6332. //}
  6333. //else //处理中的售后,待处理和处理中合并
  6334. //{
  6335. // if (afterState.Length <= 0)
  6336. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6337. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6338. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6339. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6340. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6341. //}
  6342. }
  6343. public void get_erp_disagreeftersalelist()
  6344. {
  6345. DataStruct dStruct = GetPostStruct();
  6346. List<string> lw = new List<string>();
  6347. int st = 2;
  6348. string tid = GetPostString("ctid");
  6349. if (tid.Length > 0)
  6350. {
  6351. string select_tid = getTidByCtid(tid);
  6352. lw.Add(string.Format("tid='{0}'", select_tid));
  6353. }
  6354. string shopname = GetPostString("shopname");
  6355. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6356. string buyernick = GetPostString("buyer_nick");
  6357. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6358. string sellermemo = GetPostString("seller_memo");
  6359. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6360. string orderState = GetPostString("orderState");
  6361. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6362. string afterState = GetPostString("afterstate");
  6363. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6364. string date1 = GetPostString("date1");
  6365. string date2 = GetPostString("date2");
  6366. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6367. if (dw.Length > 0) lw.Add(dw);
  6368. string price1 = GetPostString("price1");
  6369. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6370. string price2 = GetPostString("price2");
  6371. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6372. //lw.Add(string.Format("IsRefund!={0}", 1));
  6373. string reason = GetPostString("reason");
  6374. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6375. string method = GetPostString("method");
  6376. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6377. string handler = GetPostString("handler");
  6378. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6379. string handledate1 = GetPostString("handledate1");
  6380. string handledate2 = GetPostString("handledate2");
  6381. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6382. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6383. string afterdate1 = GetPostString("afterdate1");
  6384. string afterdate2 = GetPostString("afterdate2");
  6385. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6386. if (afterDate.Length > 0) lw.Add(afterDate);
  6387. string backdate1 = GetPostString("backdate1");
  6388. string backdate2 = GetPostString("backdate2");
  6389. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6390. if (backDate.Length > 0) lw.Add(backDate);
  6391. string supplier = GetPostString("supplier");
  6392. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6393. string responsible = GetPostString("responsibleman");
  6394. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6395. string customer = GetPostString("customer");
  6396. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6397. string design = GetPostString("design");
  6398. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6399. string afterSaleMemo = GetPostString("afterSaleMemo");
  6400. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6401. string afterMemoType = GetPostString("aftermemotype");
  6402. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6403. string aftersakereason = GetPostString("aftersakereason");
  6404. if (aftersakereason.Length > 0)
  6405. {
  6406. if (aftersakereason == "1")
  6407. {
  6408. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6409. }
  6410. if (aftersakereason == "2")
  6411. {
  6412. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6413. }
  6414. }
  6415. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6416. string poscode = CurrentUser.UserPost.Post.Code;
  6417. if (poscode != "SysAdmin")
  6418. {
  6419. string shopid = CurrentUser.User.pemShop;
  6420. lw.Add(string.Format("shopId in ({0})", shopid));
  6421. }
  6422. string searchType = GetPostString("searchType");
  6423. if (searchType == "wait")
  6424. {
  6425. lw.Add(string.Format("HandleTime is null"));
  6426. }
  6427. if (searchType == "handling")
  6428. {
  6429. lw.Add(string.Format("HandleTime is not null "));
  6430. }
  6431. if (searchType == "back" || searchType == "puBack")
  6432. {
  6433. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6434. }
  6435. if (searchType == "reBack")
  6436. {
  6437. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6438. }
  6439. if (searchType == "moreBack")
  6440. {
  6441. lw.Add(string.Format("backNum > 1"));
  6442. }
  6443. lw.Add(string.Format("(AfterSaleState=5)"));
  6444. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6445. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6446. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6447. writeGridDataTableJson(dStruct.TotalCount, dt);
  6448. }
  6449. public void get_erp_handlingaftersalelist()
  6450. {
  6451. DataStruct dStruct = GetPostStruct();
  6452. List<string> lw = new List<string>();
  6453. int st = 2;
  6454. string tid = GetPostString("ctid");
  6455. if (tid.Length > 0)
  6456. {
  6457. string select_tid = getTidByCtid(tid);
  6458. lw.Add(string.Format("tid='{0}'", select_tid));
  6459. }
  6460. string shopname = GetPostString("shopname");
  6461. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6462. string buyernick = GetPostString("buyer_nick");
  6463. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6464. string sellermemo = GetPostString("seller_memo");
  6465. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6466. string orderState = GetPostString("orderState");
  6467. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6468. string afterState = GetPostString("afterstate");
  6469. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6470. string date1 = GetPostString("date1");
  6471. string date2 = GetPostString("date2");
  6472. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6473. if (dw.Length > 0) lw.Add(dw);
  6474. string price1 = GetPostString("price1");
  6475. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6476. string price2 = GetPostString("price2");
  6477. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6478. //lw.Add(string.Format("IsRefund!={0}", 1));
  6479. string reason = GetPostString("reason");
  6480. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6481. string method = GetPostString("method");
  6482. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6483. string handler = GetPostString("handler");
  6484. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6485. string handledate1 = GetPostString("handledate1");
  6486. string handledate2 = GetPostString("handledate2");
  6487. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6488. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6489. string afterdate1 = GetPostString("afterdate1");
  6490. string afterdate2 = GetPostString("afterdate2");
  6491. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6492. if (afterDate.Length > 0) lw.Add(afterDate);
  6493. string supplier = GetPostString("supplier");
  6494. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6495. string responsible = GetPostString("responsibleman");
  6496. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6497. string customer = GetPostString("customer");
  6498. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6499. string design = GetPostString("design");
  6500. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6501. string afterSaleMemo = GetPostString("afterSaleMemo");
  6502. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6503. string afterMemoType = GetPostString("aftermemotype");
  6504. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6505. string afterresult = GetPostString("afterresult");
  6506. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6507. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6508. string poscode = CurrentUser.UserPost.Post.Code;
  6509. if (poscode != "SysAdmin")
  6510. {
  6511. string shopid = CurrentUser.User.pemShop;
  6512. lw.Add(string.Format("shopId in ({0})", shopid));
  6513. }
  6514. string searchType = GetPostString("searchType");
  6515. if (searchType == "wait")
  6516. {
  6517. lw.Add(string.Format("HandleTime is null"));
  6518. }
  6519. if (searchType == "documentary")
  6520. {
  6521. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6522. }
  6523. if (searchType == "handling")
  6524. {
  6525. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6526. }
  6527. if (searchType == "back" || searchType == "puBack")
  6528. {
  6529. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6530. }
  6531. if (searchType == "reBack")
  6532. {
  6533. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6534. }
  6535. if (afterState.Length <= 0)
  6536. {
  6537. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6538. }
  6539. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6541. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6542. writeGridDataTableJson(dStruct.TotalCount, dt);
  6543. }
  6544. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6545. //public void get_erp_back_handlingaftersalelist()
  6546. //{
  6547. // DataStruct dStruct = GetPostStruct();
  6548. // List<string> lw = new List<string>();
  6549. // string tid = GetPostString("ctid");
  6550. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6551. // string shopname = GetPostString("shopname");
  6552. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6553. // string buyernick = GetPostString("buyer_nick");
  6554. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6555. // string sellermemo = GetPostString("seller_memo");
  6556. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6557. // string orderState = GetPostString("orderState");
  6558. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6559. // string afterState = GetPostString("afterstate");
  6560. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6561. // string date1 = GetPostString("date1");
  6562. // string date2 = GetPostString("date2");
  6563. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6564. // if (dw.Length > 0) lw.Add(dw);
  6565. // string price1 = GetPostString("price1");
  6566. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6567. // string price2 = GetPostString("price2");
  6568. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6569. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6570. // string reason = GetPostString("reason");
  6571. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6572. // string method = GetPostString("method");
  6573. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6574. // string handler = GetPostString("handler");
  6575. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6576. // string handledate1 = GetPostString("handledate1");
  6577. // string handledate2 = GetPostString("handledate2");
  6578. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6579. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6580. // string afterdate1 = GetPostString("afterdate1");
  6581. // string afterdate2 = GetPostString("afterdate2");
  6582. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6583. // if (afterDate.Length > 0) lw.Add(afterDate);
  6584. // string supplier = GetPostString("supplier");
  6585. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6586. // string responsible = GetPostString("responsibleman");
  6587. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6588. // string customer = GetPostString("customer");
  6589. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6590. // string design = GetPostString("design");
  6591. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6592. // string afterMemoType = GetPostString("aftermemotype");
  6593. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6594. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6595. // if (afterState.Length <= 0)
  6596. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6597. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6598. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6599. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6600. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6601. //}
  6602. public void get_erp_aftersaleverifylist()
  6603. {
  6604. DataStruct dStruct = GetPostStruct();
  6605. List<string> lw = new List<string>();
  6606. string tid = GetPostString("ctid");
  6607. if (tid.Length > 0)
  6608. {
  6609. string select_tid = getTidByCtid(tid);
  6610. lw.Add(string.Format("otid='{0}'", select_tid));
  6611. }
  6612. string shopname = GetPostString("shopname");
  6613. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6614. string buyernick = GetPostString("buyer_nick");
  6615. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6616. string sellermemo = GetPostString("seller_memo");
  6617. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6618. string orderState = GetPostString("orderState");
  6619. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6620. //lw.Add(string.Format("IsRefund!={0}", 1));
  6621. string reason = GetPostString("reason");
  6622. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6623. string method = GetPostString("method");
  6624. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6625. string handler = GetPostString("handler");
  6626. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6627. string handledate1 = GetPostString("handledate1");
  6628. string handledate2 = GetPostString("handledate2");
  6629. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6630. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6631. string finish1 = GetPostString("finishdate1");
  6632. string finish2 = GetPostString("finishdate2");
  6633. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6634. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6635. string supplier = GetPostString("supplier");
  6636. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6637. string responsible = GetPostString("responsibleman");
  6638. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6639. string posCode = CurrentUser.UserPost.Post.Code;
  6640. string vstate = GetPostString("vstate");
  6641. if (vstate.Length > 0)
  6642. {
  6643. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6644. }
  6645. if (posCode == "Supplier")
  6646. {
  6647. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6648. lw.Add(string.Format("VerifyState = 0"));
  6649. lw.Add("type = 1");
  6650. lw.Add(string.Format("AfterSaleState={0}", 3));
  6651. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6652. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6653. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6654. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6655. writeGridDataTableJson(dStruct.TotalCount, dt);
  6656. }
  6657. else if (posCode == "logistics")
  6658. {
  6659. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6660. lw.Add(string.Format("VerifyState = 0"));
  6661. lw.Add("type = 2");
  6662. lw.Add(string.Format("AfterSaleState={0}", 3));
  6663. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6664. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6665. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6666. writeGridDataTableJson(dStruct.TotalCount, dt);
  6667. }
  6668. else
  6669. {
  6670. lw.Add(string.Format("(AfterSaleState = 3)"));
  6671. lw.Add("type = 0");
  6672. string reasonState = GetPostString("reasonState");
  6673. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6674. {
  6675. if (reasonState == "2")
  6676. {
  6677. lw.Add("VerifyState = 3");
  6678. }
  6679. else if (reasonState == "1")
  6680. {
  6681. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6682. }
  6683. else
  6684. {
  6685. lw.Add("VerifyState in (0,3)");
  6686. }
  6687. //不加条件,可以看全部
  6688. }
  6689. 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")
  6690. {
  6691. int orgid = CurrentUser.UserPost.OrgID;
  6692. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6693. if (string.IsNullOrEmpty(manageOrgId))
  6694. {
  6695. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6696. }
  6697. else
  6698. {
  6699. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6700. }
  6701. if (reasonState == "1")
  6702. {
  6703. lw.Add("VerifyState = 3");
  6704. }
  6705. else if (reasonState == "2")
  6706. {
  6707. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6708. }
  6709. else
  6710. {
  6711. }
  6712. }
  6713. else
  6714. {
  6715. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6716. }
  6717. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6718. //{
  6719. // int org_id = CurrentUser.UserPost.OrgID;
  6720. // lw.Add(string.Format("OrgID={0}", org_id));
  6721. //}
  6722. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6723. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6724. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6725. writeGridDataTableJson(dStruct.TotalCount, dt);
  6726. }
  6727. }
  6728. public void get_erp_finishaftersalelist()
  6729. {
  6730. DataStruct dStruct = GetPostStruct();
  6731. List<string> lw = new List<string>();
  6732. int st = 4;
  6733. string tid = GetPostString("ctid");
  6734. if (tid.Length > 0)
  6735. {
  6736. string select_tid = getTidByCtid(tid);
  6737. lw.Add(string.Format("otid='{0}'", select_tid));
  6738. }
  6739. string shopname = GetPostString("shopname");
  6740. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6741. //lw.Add(string.Format("IsRefund!={0}", 1));
  6742. string reason = GetPostString("reason");
  6743. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6744. string method = GetPostString("method");
  6745. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6746. string buyernick = GetPostString("buyer_nick");
  6747. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6748. string handler = GetPostString("handler");
  6749. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6750. string handledate1 = GetPostString("handledate1");
  6751. string handledate2 = GetPostString("handledate2");
  6752. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6753. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6754. string finish1 = GetPostString("finishdate1");
  6755. string finish2 = GetPostString("finishdate2");
  6756. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6757. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6758. string supplier = GetPostString("supplier");
  6759. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6760. string responsible = GetPostString("responsibleman");
  6761. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6762. string vstate = GetPostString("vstate");
  6763. if (vstate.Length > 0)
  6764. {
  6765. if ("3".Equals(vstate))
  6766. {
  6767. lw.Add(string.Format("IsTem=1"));
  6768. }
  6769. else
  6770. {
  6771. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6772. }
  6773. }
  6774. lw.Add(string.Format("AfterSaleState=4"));
  6775. string code = CurrentUser.UserPost.Post.Code;
  6776. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6777. {
  6778. //不加条件,可以看全部
  6779. }
  6780. else if (code == "Supplier")
  6781. {
  6782. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6783. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6784. lw.Add("type = 1");
  6785. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6786. }
  6787. else if (code == "logistics")
  6788. {
  6789. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6790. lw.Add("type = 2");
  6791. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6792. }
  6793. 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")
  6794. {
  6795. lw.Add("type = 0");
  6796. int orgid = CurrentUser.UserPost.OrgID;
  6797. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6798. if (string.IsNullOrEmpty(manageOrgIds))
  6799. {
  6800. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6801. }
  6802. else
  6803. {
  6804. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6805. }
  6806. }
  6807. else
  6808. {
  6809. lw.Add("type = 0");
  6810. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6811. }
  6812. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6813. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6814. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6815. writeGridDataTableJson(dStruct.TotalCount, dt);
  6816. }
  6817. public void handle_erp_aftersale()
  6818. {
  6819. if (UrlPostParmsCheck("ctid"))
  6820. {
  6821. string eid = GetPostString("ctid");
  6822. string responStr = GetPostString("AfterSaleResponsible");
  6823. if (responStr.Length <= 0)
  6824. {
  6825. returnErrorMsg("售后责任人不能为空");
  6826. return;
  6827. }
  6828. bool isDesign = false;
  6829. double designFree = 0.00;
  6830. int responsibleId = 0;
  6831. CeErpTradeCell entity = null;
  6832. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6833. if (entity != null)
  6834. {
  6835. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6836. string afterMethod = GetPostString("AfterSaleMethod");
  6837. if (isNeedNewOrder == 1)
  6838. {
  6839. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6840. bool ishav = true;
  6841. if (newentity == null)
  6842. {
  6843. newentity = entity.Clone() as CeErpTradeCell;
  6844. ishav = false;
  6845. newentity.ctid = "S_" + entity.ctid;
  6846. newentity.OrderState = 0;
  6847. //唯一标识
  6848. newentity.OrderSn = newentity.ctid;
  6849. string orderSn = dataHelper.getSaleOrderSn();
  6850. if (orderSn != "")
  6851. {
  6852. newentity.OrderSn = orderSn;
  6853. }
  6854. }
  6855. newentity.UpdateTime = DateTime.Now;
  6856. newentity.AfterSaleState = 0;
  6857. newentity.AfterSaleMethod = afterMethod;
  6858. if (!ishav)
  6859. {
  6860. string memo_str = newentity.seller_memo;
  6861. memo_str = memo_str.Replace("(", "(");
  6862. memo_str = memo_str.Replace(")", ")");
  6863. int sIndex = memo_str.IndexOf("(");
  6864. int eIndex = memo_str.IndexOf(")");
  6865. if (sIndex == -1 || eIndex == -1)
  6866. {
  6867. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6868. return;
  6869. }
  6870. string first = memo_str.Substring(0, sIndex + 1);
  6871. string memoCtid = newentity.OrderSn;
  6872. //if (memoCtid.IndexOf("C") != -1)
  6873. //{
  6874. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6875. //if (CIdx.IndexOf("+") != -1)
  6876. //{
  6877. //CIdx = "C" + CIdx.Split('+')[1];
  6878. //}
  6879. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6880. //}
  6881. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6882. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6883. string newMemo = first + memoCtid + last;
  6884. newentity.seller_memo = newMemo;
  6885. newentity.FinishPlaceTime = null;
  6886. newentity.UnusualTag = 0;
  6887. newentity.UnusualCon = "";
  6888. newentity.UnusualTime = null;
  6889. newentity.AfterSaleMemo = "";
  6890. newentity.AfterSaleMethod = afterMethod;
  6891. newentity.AfterSalePreTime = null;
  6892. newentity.AfterSaleReason = "";
  6893. newentity.AfterSaleResponsible = "";
  6894. newentity.AfterSaleState = 0;
  6895. newentity.AfterSaleTime = null;
  6896. newentity.AfterSaleUserId = 0;
  6897. newentity.AfterSaleSupplierState = 0;
  6898. newentity.LastBillWaybillCode = "";
  6899. newentity.LastBillCpCode = "";
  6900. newentity.FinishAfterSaleTime = null;
  6901. newentity.HandleTime = null;
  6902. newentity.IsSF = 0;
  6903. newentity.IsOldCustomer = 0;
  6904. newentity.UrgencyTime = null;
  6905. newentity.ResponsibleUserId = "";
  6906. newentity.IsVerifyToSupplier = false;
  6907. newentity.payment = 0;
  6908. newentity.CheckMemo = "";
  6909. newentity.OutSid = "";
  6910. newentity.CheckOrderTime = null;
  6911. newentity.MemoOpt = 0;
  6912. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6913. }
  6914. newentity.isAfterSaleOrder = 1;
  6915. newentity.IsRefund = 0;
  6916. string receiveMobile = GetPostString("receiver_mobile");
  6917. if (receiveMobile.Length > 0)
  6918. {
  6919. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6920. if (trade != null)
  6921. {
  6922. trade.receiver_name = GetPostString("receiver_name");
  6923. trade.receiver_mobile = receiveMobile;
  6924. trade.receiver_state = GetPostString("receiver_state");
  6925. trade.receiver_city = GetPostString("receiver_city");
  6926. trade.receiver_district = GetPostString("receiver_district");
  6927. trade.receiver_address = GetPostString("receiver_address");
  6928. newentity.IsOffLineOrder = 1;
  6929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6930. }
  6931. }
  6932. string st = GetPostString("ToState");
  6933. if (st.Length > 0)
  6934. {
  6935. if (newentity.OrderState <= 3)
  6936. {
  6937. newentity.WaitDesignTime = DateTime.Now;
  6938. newentity.StartDesignTime = null;
  6939. newentity.FinishDesignTime = null;
  6940. newentity.OrderState = 3;
  6941. if (st == "下单员")
  6942. {
  6943. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6944. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6945. {
  6946. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6947. }
  6948. }
  6949. else
  6950. {
  6951. newentity.WaitDesignTime = DateTime.Now;
  6952. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6953. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6954. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6955. {
  6956. DataRow user = dt1.Rows[0];
  6957. //找主管
  6958. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6959. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6960. if (dt != null && dt.Rows.Count > 0)
  6961. {
  6962. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6963. newentity.DesignUserId = designMr;
  6964. string key = "aftersale_order_" + designMr;
  6965. if (RedisHelper.HasKey(key))
  6966. {
  6967. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6968. list.Add(newentity.ctid);
  6969. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6970. }
  6971. }
  6972. //账号正常
  6973. if (user["State"].ToString() == "0")
  6974. {
  6975. newentity.DesignUserId = entity.DesignUserId;
  6976. string key = "aftersale_order_" + entity.DesignUserId;
  6977. if (RedisHelper.HasKey(key))
  6978. {
  6979. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6980. list.Add(newentity.ctid);
  6981. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6982. }
  6983. }
  6984. }
  6985. }
  6986. }
  6987. if (entity.IsXianHuo == 1)
  6988. {
  6989. newentity.OrderState = 6;
  6990. entity.FinishPlaceTime = DateTime.Now;
  6991. }
  6992. }
  6993. if (ishav)
  6994. {
  6995. newentity.Update();
  6996. }
  6997. else
  6998. {
  6999. newentity.Create();
  7000. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  7001. newCellExtend.ctid = newentity.ctid;
  7002. newCellExtend.orderFrom = 20;
  7003. newCellExtend.orderType = 30;
  7004. if (st == "下单员")
  7005. {
  7006. }
  7007. else
  7008. {
  7009. newCellExtend.ReprintTime = DateTime.Now;
  7010. }
  7011. newCellExtend.Create();
  7012. }
  7013. if (st != "下单员")
  7014. {
  7015. if (entity.DispatchSort == 2)
  7016. {
  7017. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7018. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7019. }
  7020. }
  7021. }
  7022. //处理售后扩展
  7023. string resIdStr = GetPostString("ResponsibleUserId");
  7024. string refundFees = GetPostString("refundFrees");
  7025. int IsComplain = GetPostInt("isComplain");
  7026. int IsBad = GetPostInt("isBad");
  7027. string IsOriginal = GetPostString("isOriginal");
  7028. double diffResultPrice = GetPostDouble("diffResultPrice");
  7029. string textResult = GetPostString("textResult");
  7030. string supplierResponsible = GetPostString("supplierResponsible");
  7031. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7032. if (ceErpTradeAfterSaleExtend == null)
  7033. {
  7034. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7035. ceErpTradeAfterSaleExtend.tid = eid;
  7036. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7037. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7038. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7039. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7040. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7041. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7042. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7043. ceErpTradeAfterSaleExtend.Create();
  7044. }
  7045. else
  7046. {
  7047. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7048. {
  7049. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7050. }
  7051. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7052. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7053. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7054. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7055. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7056. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7057. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7058. ceErpTradeAfterSaleExtend.Update();
  7059. }
  7060. int gysid = GetPostInt("ResponsibleSupId");
  7061. if (entity.AfterSaleUserId == 0)
  7062. {
  7063. entity.AfterSaleUserId = CurrentUser.UserID;
  7064. }
  7065. entity.ResponsibleUserId = resIdStr;
  7066. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7067. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7068. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7069. {
  7070. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7071. int backNum = 0;
  7072. if (number != null)
  7073. {
  7074. backNum = number.BackNum;
  7075. }
  7076. char[] separator = { ',' };
  7077. string[] sArray = resIdStr.Split(separator);
  7078. string[] refundFreeList = { };
  7079. if (refundFees.Length > 0)
  7080. {
  7081. refundFreeList = refundFees.Split(separator);
  7082. }
  7083. int index = -1;
  7084. List<int> responsibleIds = new List<int>();
  7085. foreach (string i in sArray)
  7086. {
  7087. index++;
  7088. if (i.Length <= 0) continue;
  7089. char[] separator2 = { '_' };
  7090. string idstr = i.Split(separator2)[0];
  7091. string idtype = i.Split(separator2)[1];
  7092. double refudFree = 0;
  7093. if (refundFreeList.Length > 0)
  7094. {
  7095. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7096. }
  7097. if (idtype == "s")
  7098. {
  7099. isDesign = true;
  7100. designFree = refudFree;
  7101. }
  7102. int userId = Convert.ToInt32(idstr);
  7103. int type = 0;
  7104. if (idtype == "g")
  7105. {
  7106. type = 1;
  7107. }
  7108. if (idtype == "w")
  7109. {
  7110. type = 2;
  7111. }
  7112. if (idtype == "t")
  7113. {
  7114. type = 3;
  7115. }
  7116. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7117. if (ceErpTradeResponsible == null)
  7118. {
  7119. ceErpTradeResponsible = new CeErpTradeResponsible();
  7120. ceErpTradeResponsible.tid = eid;
  7121. ceErpTradeResponsible.UserId = userId;
  7122. ceErpTradeResponsible.createdTime = DateTime.Now;
  7123. ceErpTradeResponsible.type = type;
  7124. if (type == 1)
  7125. {
  7126. ceErpTradeResponsible.IsSup = 1;
  7127. }
  7128. if (type == 2)
  7129. {
  7130. ceErpTradeResponsible.IsFlow = 1;
  7131. }
  7132. }
  7133. int state = 0;
  7134. //已认可的不需要再次认可
  7135. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7136. {
  7137. state = 1;
  7138. }
  7139. ceErpTradeResponsible.RefundFee = refudFree;
  7140. ceErpTradeResponsible.VerifyState = state;
  7141. if (userId == 2125 || idtype == "w")
  7142. {
  7143. ceErpTradeResponsible.VerifyState = 1;
  7144. }
  7145. if (idtype == "w" && userId == 101)
  7146. {
  7147. ceErpTradeResponsible.VerifyState = state;
  7148. }
  7149. if (ceErpTradeResponsible.ID > 0)
  7150. {
  7151. ceErpTradeResponsible.Update();
  7152. }
  7153. else
  7154. {
  7155. ceErpTradeResponsible.Create();
  7156. }
  7157. if (isDesign)
  7158. {
  7159. responsibleId = ceErpTradeResponsible.ID;
  7160. }
  7161. responsibleIds.Add(ceErpTradeResponsible.ID);
  7162. }
  7163. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7164. CeErpTradeResponsible.NumByTid(backNum, eid);
  7165. }
  7166. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7167. if (ceErpTradeCellExtend != null)
  7168. {
  7169. ceErpTradeCellExtend.returnVisit = 0;
  7170. ceErpTradeCellExtend.Update();
  7171. }
  7172. if (entity.HandleTime != null)
  7173. {
  7174. if (entity.AfterSaleState == 1)
  7175. {
  7176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7177. }
  7178. else
  7179. {
  7180. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7181. }
  7182. }
  7183. else
  7184. {
  7185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7186. entity.HandleTime = DateTime.Now;
  7187. }
  7188. bool isCompale = false;
  7189. if (entity.AfterSaleState == 5)
  7190. {
  7191. isCompale = true;
  7192. entity.AfterSaleState = 3;
  7193. }
  7194. entity.AfterSaleSupplierState = 0;
  7195. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7196. {
  7197. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7198. }
  7199. string sImgs = GetPostString("img");
  7200. entity.AfterSaleSupplierImg = sImgs;
  7201. entity.supRefundType = GetPostString("supRefundType");
  7202. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7203. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7204. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7205. entity.AfterSaleMemoType = GetPostString("MemoType");
  7206. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7207. {
  7208. //entity.AfterSaleSupplierState = 2;
  7209. }
  7210. string df = GetPostString("DeductFee");
  7211. if (df == "")
  7212. {
  7213. df = "0";
  7214. }
  7215. string rf = GetPostString("RefundFee");
  7216. if (rf == "")
  7217. {
  7218. rf = "0";
  7219. }
  7220. string pm = GetPostString("AfterSalePayment");
  7221. if (pm == "")
  7222. {
  7223. pm = "0";
  7224. }
  7225. entity.AfterSalePayment = Convert.ToDouble(pm);
  7226. entity.DeductFee = Convert.ToDouble(df);
  7227. entity.RefundFee = Convert.ToDouble(rf);
  7228. entity.UpdateTime = DateTime.Now;
  7229. entity.Update();
  7230. string toState = GetPostString("ToState");
  7231. string original = GetPostString("isOriginal");
  7232. ApiVo apiVo = new ApiVo();
  7233. apiVo.orderNumber = entity.ctid;
  7234. apiVo.actionName = "afterDesign";
  7235. apiVo.orderRemarks = entity.AfterSaleMethod;
  7236. apiVo.reasonRemarks = entity.AfterSaleReason;
  7237. apiVo.isDesign = isDesign;
  7238. apiVo.designFree = designFree;
  7239. apiVo.responsibleId = responsibleId;
  7240. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7241. if (toState == "设计师")
  7242. {
  7243. apiVo.isOriginal = Convert.ToBoolean(original);
  7244. }
  7245. designHelper.API_WorkCore(apiVo);//afterDesign
  7246. CeErpMethod methodSql = new CeErpMethod();
  7247. methodSql.con = entity.AfterSaleMethod;
  7248. methodSql.addTime = DateTime.Now;
  7249. methodSql.Create();
  7250. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7251. CeErpMethod.ExecuteNonQuery(delsql);
  7252. if (isCompale)
  7253. {
  7254. aftersale_data_change(entity.ctid);
  7255. }
  7256. returnSuccessMsg("操作成功!");
  7257. return;
  7258. }
  7259. returnErrorMsg("找不到订单记录");
  7260. }
  7261. }
  7262. public void ins_erp_toresponsible()
  7263. {
  7264. if (UrlPostParmsCheck("ctid"))
  7265. {
  7266. string eid = GetPostString("ctid");
  7267. CeErpTradeCell entity = null;
  7268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7269. if (entity != null)
  7270. {
  7271. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7272. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7273. {
  7274. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7275. return;
  7276. }
  7277. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7278. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7279. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7280. if (entity.AfterSalePreTime == null)
  7281. {
  7282. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7283. {
  7284. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7285. }
  7286. }
  7287. entity.AfterSalePreTime = DateTime.Now;
  7288. //预完成给售后主管审核客户问题直接完成
  7289. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7290. {
  7291. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7292. {
  7293. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7294. }
  7295. }
  7296. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7297. ceErpTradeAfterSaleExtend.Update();
  7298. entity.AfterSaleState = 2;
  7299. entity.UpdateTime = DateTime.Now;
  7300. entity.Update();
  7301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7302. aftersale_data_change(entity.ctid);
  7303. returnSuccessMsg("操作成功!");
  7304. return;
  7305. }
  7306. returnErrorMsg("找不到订单记录");
  7307. }
  7308. }
  7309. public void cancel_erp_aftersaleanddelnew()
  7310. {
  7311. if (UrlPostParmsCheck("ctid"))
  7312. {
  7313. string eid = GetPostString("ctid");
  7314. CeErpTradeCell entity = null;
  7315. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7316. if (entity != null)
  7317. {
  7318. entity.AfterSaleState = 0;
  7319. entity.AfterSaleReason = "";
  7320. entity.AfterSaleMethod = "";
  7321. entity.AfterSaleMemo = "";
  7322. entity.AfterSaleResponsible = "";
  7323. entity.ResponsibleUserId = "";
  7324. entity.DeductFee = 0;
  7325. entity.RefundFee = 0;
  7326. entity.IsArbitrate = 0;
  7327. CeErpTradeResponsible.DelByTid(eid, -1);
  7328. entity.Update();
  7329. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7330. if (after != null)
  7331. {
  7332. if (after.OrderState < 5)
  7333. CeErpTradeCell.DelByCtid("S_" + eid);
  7334. }
  7335. returnSuccessMsg("操作成功!");
  7336. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7337. return;
  7338. }
  7339. returnErrorMsg("找不到订单记录");
  7340. }
  7341. }
  7342. public void get_erp_aftersale_pregather()
  7343. {
  7344. List<string> lw = new List<string>();
  7345. int st = GetInt("st");
  7346. string tid = GetPostString("ctid");
  7347. if (tid.Length > 0)
  7348. {
  7349. string select_tid = getTidByCtid(tid);
  7350. lw.Add(string.Format("tid='{0}'", select_tid));
  7351. }
  7352. string shopname = GetPostString("shopname");
  7353. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7354. string buyernick = GetPostString("buyer_nick");
  7355. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7356. string sellermemo = GetPostString("seller_memo");
  7357. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7358. string orderState = GetPostString("orderState");
  7359. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7360. string reason = GetPostString("reason");
  7361. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7362. string method = GetPostString("method");
  7363. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7364. string handler = GetPostString("handler");
  7365. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7366. string handledate1 = GetPostString("handledate1");
  7367. string handledate2 = GetPostString("handledate2");
  7368. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7369. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7370. string supplier = GetPostString("supplier");
  7371. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7372. string responsible = GetPostString("responsibleman");
  7373. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7374. string customer = GetPostString("customer");
  7375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7376. string design = GetPostString("design");
  7377. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7378. string afterMemoType = GetPostString("aftermemotype");
  7379. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7380. string afterSaleMemo = GetPostString("afterSaleMemo");
  7381. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7382. string afterresult = GetPostString("afterresult");
  7383. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7384. string poscode = CurrentUser.UserPost.Post.Code;
  7385. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7386. {
  7387. string shopid = CurrentUser.User.pemShop;
  7388. lw.Add(string.Format("shopId in ({0})", shopid));
  7389. }
  7390. var mainwhere = string.Join(" and ", lw.ToArray());
  7391. string ro_json = "";
  7392. string type = GetPostString("gather_type");
  7393. int number = 0;
  7394. if (poscode == "AfterSale")
  7395. {
  7396. //处理中
  7397. if (type == "Handling")
  7398. {
  7399. 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) : ""));
  7400. DataTable dt = null;
  7401. try
  7402. {
  7403. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7404. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7405. }
  7406. catch (Exception e)
  7407. {
  7408. dt = new DataTable();
  7409. }
  7410. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7411. return;
  7412. }
  7413. if (type == "Wait")
  7414. {
  7415. //待处理
  7416. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7417. DataTable dt1 = null;
  7418. try
  7419. {
  7420. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7421. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7422. }
  7423. catch (Exception e)
  7424. {
  7425. dt1 = new DataTable();
  7426. }
  7427. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7428. return;
  7429. }
  7430. if (type == "back")
  7431. {
  7432. //打回
  7433. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7434. DataTable dt2 = null;
  7435. try
  7436. {
  7437. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7438. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7439. }
  7440. catch (Exception e)
  7441. {
  7442. dt2 = new DataTable();
  7443. }
  7444. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7445. return;
  7446. }
  7447. if (type == "preCompletion")
  7448. {
  7449. //预完成
  7450. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7451. DataTable dt3 = null;
  7452. try
  7453. {
  7454. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7455. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7456. }
  7457. catch (Exception e)
  7458. {
  7459. dt3 = new DataTable();
  7460. }
  7461. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7462. return;
  7463. }
  7464. if (type == "documentary")
  7465. {
  7466. //跟单中
  7467. 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) : ""));
  7468. DataTable dt4 = null;
  7469. try
  7470. {
  7471. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7472. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7473. }
  7474. catch (Exception e)
  7475. {
  7476. dt4 = new DataTable();
  7477. }
  7478. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7479. return;
  7480. }
  7481. if (type == "reBack")
  7482. {
  7483. //被打回
  7484. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7485. DataTable dt1 = null;
  7486. try
  7487. {
  7488. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7489. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7490. }
  7491. catch (Exception e)
  7492. {
  7493. dt1 = new DataTable();
  7494. }
  7495. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7496. return;
  7497. }
  7498. }
  7499. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7500. {
  7501. if (type == "puBack")
  7502. {
  7503. //退回
  7504. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7505. DataTable dt = null;
  7506. try
  7507. {
  7508. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7509. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7510. }
  7511. catch (Exception e)
  7512. {
  7513. dt = new DataTable();
  7514. }
  7515. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7516. return;
  7517. }
  7518. if (type == "reBack")
  7519. {
  7520. //打回
  7521. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7522. DataTable dt1 = null;
  7523. try
  7524. {
  7525. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7526. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7527. }
  7528. catch (Exception e)
  7529. {
  7530. dt1 = new DataTable();
  7531. }
  7532. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7533. return;
  7534. }
  7535. if (type == "examEd")
  7536. {
  7537. //已审核
  7538. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7539. DataTable dt2 = null;
  7540. try
  7541. {
  7542. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7543. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7544. }
  7545. catch (Exception e)
  7546. {
  7547. dt2 = new DataTable();
  7548. }
  7549. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7550. return;
  7551. }
  7552. if (type == "waitExam")
  7553. {
  7554. //待审核
  7555. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7556. DataTable dt3 = null;
  7557. try
  7558. {
  7559. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7560. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7561. }
  7562. catch (Exception e)
  7563. {
  7564. dt3 = new DataTable();
  7565. }
  7566. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7567. return;
  7568. }
  7569. if (type == "Handling")
  7570. {
  7571. //处理中
  7572. 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) : ""));
  7573. DataTable dt4 = null;
  7574. try
  7575. {
  7576. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7577. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7578. }
  7579. catch (Exception e)
  7580. {
  7581. dt4 = new DataTable();
  7582. }
  7583. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7584. return;
  7585. }
  7586. if (type == "Wait")
  7587. {
  7588. //待处理
  7589. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7590. DataTable dt5 = null;
  7591. try
  7592. {
  7593. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7594. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7595. }
  7596. catch (Exception e)
  7597. {
  7598. dt5 = new DataTable();
  7599. }
  7600. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7601. return;
  7602. }
  7603. if (type == "documentary")
  7604. {
  7605. //跟单中
  7606. 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) : ""));
  7607. DataTable dt6 = null;
  7608. try
  7609. {
  7610. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7611. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7612. }
  7613. catch (Exception e)
  7614. {
  7615. dt6 = new DataTable();
  7616. }
  7617. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7618. return;
  7619. }
  7620. }
  7621. returnSuccess(ro_json);
  7622. }
  7623. public void end_erp_aftersale()
  7624. {
  7625. if (UrlPostParmsCheck("ctid"))
  7626. {
  7627. string eid = GetPostString("ctid");
  7628. CeErpTradeCell entity = null;
  7629. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7630. if (entity != null)
  7631. {
  7632. string stype = GetPostString("stype");
  7633. string typeStr = stype;
  7634. entity.AfterSaleState = 4;
  7635. entity.FinishAfterSaleTime = DateTime.Now;
  7636. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7637. entity.Update();
  7638. ApiVo apiVo = new ApiVo();
  7639. apiVo.orderNumber = entity.ctid;
  7640. apiVo.actionName = "afterOver";
  7641. designHelper.API_WorkCore(apiVo); //afterOver
  7642. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7643. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7644. CeErpSukuraData.createInfo(entity.ctid, 8);
  7645. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7646. returnSuccessMsg("操作成功!");
  7647. return;
  7648. }
  7649. returnErrorMsg("找不到订单记录");
  7650. }
  7651. }
  7652. public void ins_erp_finishaftersale()
  7653. {
  7654. if (UrlPostParmsCheck("id"))
  7655. {
  7656. string eid = GetPostString("id");
  7657. CeErpTradeResponsible entity = null;
  7658. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7659. if (entity != null)
  7660. {
  7661. entity.VerifyState = 1;
  7662. entity.VerifyTime = DateTime.Now;
  7663. entity.Update();
  7664. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7665. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7666. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7667. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7668. if (dt.Rows.Count <= 0)
  7669. {
  7670. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7671. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7672. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7673. CeErpSukuraData.createInfo(entity.tid, 8);
  7674. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7675. {
  7676. CeErpDesignerBill.Del(entity.tid);
  7677. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7678. }
  7679. }
  7680. returnSuccessMsg("操作成功!");
  7681. return;
  7682. }
  7683. returnErrorMsg("找不到订单记录");
  7684. }
  7685. }
  7686. public void upd_erp_arbitrateaftersale()
  7687. {
  7688. if (UrlPostParmsCheck("id"))
  7689. {
  7690. string eid = GetPostString("id");
  7691. CeErpTradeResponsible entity = null;
  7692. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7693. if (entity != null)
  7694. {
  7695. entity.IsArbitrate = 1;
  7696. entity.ArbitradeMemo = GetPostString("reason");
  7697. entity.VerifyState = 2;
  7698. entity.Update();
  7699. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7700. if (tradecell != null)
  7701. {
  7702. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7703. tradecell.IsArbitrate = 1;
  7704. tradecell.Update();
  7705. }
  7706. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7707. returnSuccessMsg("操作成功!");
  7708. return;
  7709. }
  7710. returnErrorMsg("找不到订单记录");
  7711. }
  7712. }
  7713. public void upd_erp_backaftersale()
  7714. {
  7715. if (UrlPostParmsCheck("tid"))
  7716. {
  7717. string eid = GetPostString("tid");
  7718. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7719. int backNum = 0;
  7720. if (number != null)
  7721. {
  7722. backNum = number.BackNum;
  7723. }
  7724. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7725. CeErpTradeCell entity = null;
  7726. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7727. if (entity != null)
  7728. {
  7729. entity.AfterSaleBackReason = GetPostString("backreason");
  7730. entity.AfterSaleState = 1;
  7731. entity.AfterSaleSupplierState = 0;
  7732. entity.UpdateTime = DateTime.Now;
  7733. entity.Update();
  7734. returnSuccessMsg("操作成功!");
  7735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7736. return;
  7737. }
  7738. returnErrorMsg("找不到订单记录");
  7739. }
  7740. }
  7741. public void get_erp_supplieraftersalelist()
  7742. {
  7743. DataStruct dStruct = GetPostStruct();
  7744. List<string> lw = new List<string>();
  7745. string tid = GetPostString("ctid");
  7746. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7747. string shopname = GetPostString("shopname");
  7748. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7749. string buyernick = GetPostString("buyer_nick");
  7750. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7751. string sellermemo = GetPostString("seller_memo");
  7752. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7753. string orderState = GetPostString("orderState");
  7754. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7755. string afterState = GetPostString("afterstate");
  7756. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7757. string date1 = GetPostString("date1");
  7758. string date2 = GetPostString("date2");
  7759. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7760. if (dw.Length > 0) lw.Add(dw);
  7761. string price1 = GetPostString("price1");
  7762. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7763. string price2 = GetPostString("price2");
  7764. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7765. string reason = GetPostString("reason");
  7766. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7767. string method = GetPostString("method");
  7768. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7769. string handledate1 = GetPostString("handledate1");
  7770. string handledate2 = GetPostString("handledate2");
  7771. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7772. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7773. string handler = GetPostString("handler");
  7774. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7775. string afterdate1 = GetPostString("afterdate1");
  7776. string afterdate2 = GetPostString("afterdate2");
  7777. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7778. if (afterDate.Length > 0) lw.Add(afterDate);
  7779. string customer = GetPostString("customer");
  7780. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7781. string design = GetPostString("design");
  7782. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7783. string afterMemoType = GetPostString("aftermemotype");
  7784. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7785. string vstate = GetPostString("vstate");
  7786. if (vstate.Length > 0)
  7787. {
  7788. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7789. }
  7790. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7791. string supplier = GetPostString("supplier");
  7792. int supid = commonHelper.getSupplierIDByName(supplier);
  7793. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7794. string posCode = CurrentUser.UserPost.Post.Code;
  7795. if (posCode == "Supplier")
  7796. {
  7797. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7798. }
  7799. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7800. {
  7801. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7802. }
  7803. else
  7804. {
  7805. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7806. }
  7807. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7808. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7809. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7810. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7811. writeGridDataTableJson(dStruct.TotalCount, dt);
  7812. }
  7813. public void upd_erp_supverifyaftersale()
  7814. {
  7815. if (UrlPostParmsCheck("id"))
  7816. {
  7817. string id = GetPostString("id");
  7818. int st = GetPostInt("afterstate");
  7819. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7820. CeErpTradeCell entity = null;
  7821. if (ceErpTradeResponsible != null)
  7822. {
  7823. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7824. }
  7825. string afmemo = GetPostString("supmemo");
  7826. string image = GetPostString("image");
  7827. if (entity != null)
  7828. {
  7829. entity.AfterSaleSupplierState = st;
  7830. entity.AfterSaleSupplierMemo = afmemo;
  7831. if (st == 1)
  7832. {
  7833. ceErpTradeResponsible.VerifyState = 1;
  7834. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7835. ceErpTradeResponsible.Update();
  7836. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7837. if (isAll)
  7838. {
  7839. entity.AfterSaleState = 4;
  7840. entity.FinishAfterSaleTime = DateTime.Now;
  7841. }
  7842. }
  7843. else
  7844. {
  7845. CeErpTradeResponsible.dateByTid(entity.ctid);
  7846. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7847. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7848. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7849. if (num <= 1)
  7850. {
  7851. entity.AfterSaleState = 1;
  7852. }
  7853. else
  7854. {
  7855. entity.AfterSaleState = 5;
  7856. }
  7857. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7858. if (ceErpTradeAfterSaleExtend != null)
  7859. {
  7860. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7861. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7862. ceErpTradeAfterSaleExtend.Update();
  7863. }
  7864. else
  7865. {
  7866. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7867. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7868. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7869. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7870. ceErpTradeAfterSaleExtend.Create();
  7871. }
  7872. }
  7873. if (entity.AfterSaleState == 4)
  7874. {
  7875. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7876. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7877. {
  7878. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7879. }
  7880. ApiVo apiVo = new ApiVo();
  7881. apiVo.orderNumber = entity.ctid;
  7882. apiVo.actionName = "afterOver";
  7883. designHelper.API_WorkCore(apiVo); //afterOver
  7884. }
  7885. entity.UpdateTime = DateTime.Now;
  7886. entity.Update();
  7887. returnSuccessMsg("操作成功!");
  7888. CeErpSukuraData.createInfo(entity.ctid, 8);
  7889. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7890. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7891. return;
  7892. }
  7893. returnErrorMsg("找不到订单记录");
  7894. }
  7895. }
  7896. public void upd_erp_masteraftersale()
  7897. {
  7898. if (UrlPostParmsCheck("id"))
  7899. {
  7900. string id = GetPostString("id");
  7901. int st = GetPostInt("afterstate");
  7902. string afmemo = GetPostString("supmemo");
  7903. string image = GetPostString("image");
  7904. string textResult = GetPostString("textResult");
  7905. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7906. if (ceErpTradeResponsible != null)
  7907. {
  7908. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7909. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7910. ceErpTradeResponsible.Update();
  7911. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7912. if (entity != null)
  7913. {
  7914. entity.AfterSaleSupplierState = st;
  7915. entity.AfterSaleSupplierMemo = afmemo;
  7916. if (st == 1)
  7917. {
  7918. }
  7919. else
  7920. {
  7921. CeErpTradeResponsible.dateByTid(entity.ctid);
  7922. //退回到售后
  7923. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7924. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7925. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7926. if (num <= 1)
  7927. {
  7928. entity.AfterSaleState = 1;
  7929. }
  7930. else
  7931. {
  7932. entity.AfterSaleState = 5;
  7933. }
  7934. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7935. if (ceErpTradeAfterSaleExtend != null)
  7936. {
  7937. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7938. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7939. ceErpTradeAfterSaleExtend.Update();
  7940. }
  7941. else
  7942. {
  7943. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7944. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7945. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7946. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7947. ceErpTradeAfterSaleExtend.Create();
  7948. }
  7949. }
  7950. entity.UpdateTime = DateTime.Now;
  7951. entity.Update();
  7952. returnSuccessMsg("操作成功!");
  7953. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7954. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7955. return;
  7956. }
  7957. }
  7958. returnErrorMsg("找不到订单记录");
  7959. }
  7960. }
  7961. public void upd_erp_personaftersale()
  7962. {
  7963. if (UrlPostParmsCheck("id"))
  7964. {
  7965. //林小连
  7966. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7967. {
  7968. upd_erp_masteraftersale();
  7969. return;
  7970. }
  7971. string id = GetPostString("id");
  7972. int st = GetPostInt("afterstate");
  7973. string afmemo = GetPostString("supmemo");
  7974. string image = GetPostString("image");
  7975. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7976. if (ceErpTradeResponsible != null)
  7977. {
  7978. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7979. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7980. ceErpTradeResponsible.Update();
  7981. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7982. if (entity != null)
  7983. {
  7984. entity.AfterSaleSupplierMemo = afmemo;
  7985. entity.AfterSaleSupplierState = st;
  7986. if (st == 1)
  7987. {
  7988. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7989. if (isAll)
  7990. {
  7991. entity.AfterSaleState = 4;
  7992. entity.FinishAfterSaleTime = DateTime.Now;
  7993. }
  7994. }
  7995. else
  7996. {
  7997. CeErpTradeResponsible.dateByTid(entity.ctid);
  7998. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7999. if (ceErpTradeAfterSaleExtend != null)
  8000. {
  8001. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8002. ceErpTradeAfterSaleExtend.Update();
  8003. }
  8004. else
  8005. {
  8006. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8007. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8008. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8009. ceErpTradeAfterSaleExtend.Create();
  8010. }
  8011. //退回到主管
  8012. //entity.AfterSaleState = 2;
  8013. }
  8014. if (entity.AfterSaleState == 4)
  8015. {
  8016. ApiVo apiVo = new ApiVo();
  8017. apiVo.orderNumber = entity.ctid;
  8018. apiVo.actionName = "afterOver";
  8019. designHelper.API_WorkCore(apiVo); //afterOver
  8020. }
  8021. entity.UpdateTime = DateTime.Now;
  8022. entity.Update();
  8023. returnSuccessMsg("操作成功!");
  8024. CeErpSukuraData.createInfo(entity.ctid, 8);
  8025. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8026. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8027. return;
  8028. }
  8029. }
  8030. returnErrorMsg("找不到订单记录");
  8031. }
  8032. }
  8033. public void set_erp_supplierrefundtag()
  8034. {
  8035. if (UrlPostParmsCheck("ctid"))
  8036. {
  8037. string eid = GetPostString("ctid");
  8038. CeErpTradeCell entity = null;
  8039. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8040. if (entity != null)
  8041. {
  8042. entity.IsSupplierRefund = GetPostInt("tag");
  8043. entity.Update();
  8044. returnSuccessMsg("操作成功!");
  8045. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8046. return;
  8047. }
  8048. returnErrorMsg("找不到订单记录");
  8049. }
  8050. }
  8051. public void get_erp_refundlist()
  8052. {
  8053. DataStruct dStruct = GetPostStruct();
  8054. List<string> lw = new List<string>();
  8055. string tid = GetPostString("tid");
  8056. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8057. //string rid = GetPostString("refund_id");
  8058. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8059. string shopname = GetPostString("shopname");
  8060. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8061. string buyernick = GetPostString("buyer_nick");
  8062. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8063. string customer = GetPostString("customer");
  8064. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8065. string design = GetPostString("design");
  8066. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8067. string sellermemo = GetPostString("seller_memo");
  8068. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8069. //string date1 = GetPostString("date1");
  8070. //string date2 = GetPostString("date2");
  8071. //string dateType = GetPostString("dateType");
  8072. //if (dateType.Length > 0)
  8073. //{
  8074. // if (dateType == "1001") dateType = "0";
  8075. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8076. // if (searchDT.Count == 2)
  8077. // {
  8078. // date1 = searchDT[0].ToString();
  8079. // date2 = searchDT[1].ToString();
  8080. // }
  8081. //}
  8082. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8083. //if (dw.Length > 0) lw.Add(dw);
  8084. string redate1 = GetPostString("refunddate1");
  8085. string redate2 = GetPostString("refunddate2");
  8086. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8087. if (dwdate.Length > 0) lw.Add(dwdate);
  8088. string price1 = GetPostString("price1");
  8089. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8090. string price2 = GetPostString("price2");
  8091. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8092. string ispartrefund = GetPostString("ispartrefund");
  8093. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8094. string refundState = GetPostString("refundvstate");
  8095. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8096. int st = GetInt("st");
  8097. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8098. {
  8099. string responsible = GetPostString("responsibleman");
  8100. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8101. lw.Add(string.Format("RefundState>={0}", st));
  8102. string code = CurrentUser.UserPost.Post.Code;
  8103. if (code == "CustomerService")
  8104. {
  8105. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8106. }
  8107. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8108. {
  8109. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8110. }
  8111. else if (code == "Place" || code == "PlaceMr")
  8112. {
  8113. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8114. }
  8115. dStruct.Order = "RefundState asc,created desc";
  8116. }
  8117. else if (st == 10)
  8118. {
  8119. string responsible = GetPostString("responsibleman");
  8120. if (responsible == "空白")
  8121. {
  8122. lw.Add(string.Format("ResponsibleUserName = ''"));
  8123. }
  8124. else if (responsible.Length > 0)
  8125. {
  8126. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8127. }
  8128. lw.Add(string.Format("RefundState>=0"));
  8129. dStruct.Order = "created desc";
  8130. }
  8131. else
  8132. {
  8133. string responsible = GetPostString("responsibleman");
  8134. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8135. lw.Add(string.Format("RefundState={0}", st));
  8136. dStruct.Order = "created desc";
  8137. }
  8138. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8139. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8140. dt.Columns.Add("refund_fees");
  8141. foreach (DataRow dr in dt.Rows)
  8142. {
  8143. String status = dr["status"].ToString();
  8144. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8145. {
  8146. dr["refund_fees"] = dr["refund_fee"];
  8147. }
  8148. else
  8149. {
  8150. dr["refund_fees"] = "0.0";
  8151. }
  8152. }
  8153. writeGridDataTableJson(dStruct.TotalCount, dt);
  8154. }
  8155. public void get_erp_refunddesignlist()
  8156. {
  8157. DataStruct dStruct = GetPostStruct();
  8158. List<string> lw = new List<string>();
  8159. string tid = GetPostString("tid");
  8160. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8161. string shopname = GetPostString("shopname");
  8162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8163. string buyernick = GetPostString("buyer_nick");
  8164. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8165. string customer = GetPostString("customer");
  8166. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8167. string design = GetPostString("design");
  8168. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8169. string sellermemo = GetPostString("seller_memo");
  8170. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8171. string redate1 = GetPostString("refunddate1");
  8172. string redate2 = GetPostString("refunddate2");
  8173. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8174. if (dwdate.Length > 0) lw.Add(dwdate);
  8175. string price1 = GetPostString("price1");
  8176. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8177. string price2 = GetPostString("price2");
  8178. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8179. string ispartrefund = GetPostString("ispartrefund");
  8180. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8181. string designerorg = GetPostString("designerorg");
  8182. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8183. string refundState = GetPostString("refundState");
  8184. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8185. int myOrgid = CurrentUser.UserPost.OrgID;
  8186. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8187. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8188. {
  8189. if (CurrentUser.User.TeamIds.Length > 0)
  8190. {
  8191. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8192. }
  8193. else
  8194. {
  8195. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8196. }
  8197. }
  8198. else if ("SysAdmin".Equals(myOrgCode))
  8199. {
  8200. }
  8201. else
  8202. {
  8203. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8204. {
  8205. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8206. }
  8207. else
  8208. {
  8209. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8210. }
  8211. }
  8212. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8213. dStruct.Order = "created desc";
  8214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8215. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8216. dt.Columns.Add("refund_fees");
  8217. foreach (DataRow dr in dt.Rows)
  8218. {
  8219. String status = dr["status"].ToString();
  8220. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8221. {
  8222. dr["refund_fees"] = dr["refund_fee"];
  8223. }
  8224. else
  8225. {
  8226. dr["refund_fees"] = "0.0";
  8227. }
  8228. }
  8229. writeGridDataTableJson(dStruct.TotalCount, dt);
  8230. }
  8231. public void handle_erp_refundtag()
  8232. {
  8233. if (UrlPostParmsCheck("refund_id"))
  8234. {
  8235. string eid = GetPostString("refund_id");
  8236. string respMan = GetPostString("ResponsibleName");
  8237. if (respMan.Length <= 0)
  8238. {
  8239. returnErrorMsg("责任人不能为空");
  8240. return;
  8241. }
  8242. CeErpTradeRefund entity = null;
  8243. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8244. if (entity != null)
  8245. {
  8246. entity.ResponsibleUserName = respMan;
  8247. string userid = GetPostString("ResponsibleUserId");
  8248. if (userid.Length > 0)
  8249. {
  8250. entity.ResponsibleUserId = userid;
  8251. }
  8252. entity.Memo = GetPostString("Memo");
  8253. if (respMan.IndexOf("客服") != -1 ||
  8254. respMan.IndexOf("设计师") != -1 ||
  8255. respMan.IndexOf("下单员") != -1)
  8256. {
  8257. entity.RefundState = 2;
  8258. }
  8259. else
  8260. {
  8261. entity.RefundState = 3;
  8262. }
  8263. entity.modified = DateTime.Now;
  8264. entity.Update();
  8265. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8266. returnSuccessMsg("操作成功!");
  8267. return;
  8268. }
  8269. returnErrorMsg("找不到订单记录");
  8270. }
  8271. }
  8272. public void handle_erp_designrefundtag()
  8273. {
  8274. if (UrlPostParmsCheck("refund_id"))
  8275. {
  8276. string eid = GetPostString("refund_id");
  8277. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8278. if (ceErpTradeCellExtend == null)
  8279. {
  8280. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8281. ceErpTradeCellExtend.ctid = eid;
  8282. }
  8283. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8284. if (ceErpTradeCellExtend.ID > 0)
  8285. {
  8286. ceErpTradeCellExtend.Update();
  8287. }
  8288. else
  8289. {
  8290. ceErpTradeCellExtend.Create();
  8291. }
  8292. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8293. returnSuccessMsg("操作成功!");
  8294. return;
  8295. }
  8296. returnErrorMsg("找不到订单记录");
  8297. }
  8298. public void upd_erp_refundverify()
  8299. {
  8300. if (UrlPostParmsCheck("refund_id"))
  8301. {
  8302. string eid = GetPostString("refund_id");
  8303. CeErpTradeRefund entity = null;
  8304. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8305. if (entity != null)
  8306. {
  8307. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8308. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8309. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8310. {
  8311. entity.RefundState = 2;
  8312. }
  8313. else
  8314. {
  8315. entity.RefundState = 3;
  8316. }
  8317. entity.Update();
  8318. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8319. returnSuccessMsg("操作成功!");
  8320. return;
  8321. }
  8322. returnErrorMsg("找不到订单记录");
  8323. }
  8324. }
  8325. public void upd_erp_refundapprove()
  8326. {
  8327. if (UrlPostParmsCheck("refund_id"))
  8328. {
  8329. string eid = GetPostString("refund_id");
  8330. CeErpTradeRefund entity = null;
  8331. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8332. if (entity != null)
  8333. {
  8334. int apr = GetPostInt("approve");
  8335. if (apr == 0)
  8336. {
  8337. entity.RefundState = 1;
  8338. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8339. }
  8340. else if (apr == 1)
  8341. {
  8342. entity.RefundState = 3;
  8343. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8344. }
  8345. entity.modified = DateTime.Now;
  8346. entity.Update();
  8347. returnSuccessMsg("操作成功!");
  8348. return;
  8349. }
  8350. returnErrorMsg("找不到订单记录");
  8351. }
  8352. }
  8353. public void get_erp_billlist()
  8354. {
  8355. DataStruct dStruct = GetPostStruct();
  8356. List<string> lw = new List<string>();
  8357. string title = GetPostString("title");
  8358. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8359. string tid = GetPostString("tid");
  8360. string tids = GetPostString("tids");
  8361. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8362. if (tids.Length > 0)
  8363. {
  8364. tids = "'" + tids + "'";
  8365. tids = tids.Replace(",", "','");
  8366. lw.Add(string.Format("tid in ({0})", tids));
  8367. }
  8368. string shopname = GetPostString("shopname");
  8369. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8370. string buyernick = GetPostString("buyer_nick");
  8371. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8372. string customer = GetPostString("customer");
  8373. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8374. string date1 = GetPostString("date1");
  8375. string date2 = GetPostString("date2");
  8376. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8377. if (dw.Length > 0) lw.Add(dw);
  8378. string price1 = GetPostString("price1");
  8379. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8380. string price2 = GetPostString("price2");
  8381. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8382. string returndate1 = GetPostString("returndate1");
  8383. string returndate2 = GetPostString("returndate2");
  8384. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8385. if (dw1.Length > 0) lw.Add(dw1);
  8386. string billtype = GetPostString("billtype");
  8387. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8388. string billstate = GetPostString("billstate");
  8389. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8390. string usershop = CurrentUser.User.pemShop;
  8391. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8392. dStruct.Order = "createTime desc";
  8393. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8394. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8395. //foreach (DataRow dr in dt.Rows)
  8396. //{
  8397. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8398. //}
  8399. writeGridDataTableJson(dStruct.TotalCount, dt);
  8400. }
  8401. public void modify_erp_billinfo()
  8402. {
  8403. if (UrlPostParmsCheck("ID"))
  8404. {
  8405. string eid = GetPostString("ID");
  8406. CeErpBill bill_entity = null;
  8407. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8408. if (bill_entity != null)
  8409. {
  8410. bill_entity.tid = GetPostString("tid");
  8411. bill_entity.title = GetPostString("title");
  8412. bill_entity.tax = GetPostString("tax");
  8413. bill_entity.bank = GetPostString("bank");
  8414. bill_entity.bankac = GetPostString("bankac");
  8415. bill_entity.address = GetPostString("address");
  8416. bill_entity.phone = GetPostString("phone");
  8417. bill_entity.price = GetPostString("price");
  8418. bill_entity.productId = GetPostInt("ProductName");
  8419. bill_entity.num = GetPostInt("num");
  8420. bill_entity.unit = GetPostString("unit");
  8421. bill_entity.type = GetPostString("type");
  8422. bill_entity.sendType = GetPostString("SendType");
  8423. bill_entity.email = GetPostString("email");
  8424. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8425. bill_entity.shopName = GetPostString("ShopName");
  8426. bill_entity.applymemo = GetPostString("applymemo");
  8427. bill_entity.modifyTime = DateTime.Now;
  8428. bill_entity.createTime = DateTime.Now;
  8429. bill_entity.state = 0;
  8430. bill_entity.Update();
  8431. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8432. returnSuccessMsg("发票修改成功!");
  8433. return;
  8434. }
  8435. returnErrorMsg("找不到对应记录");
  8436. }
  8437. }
  8438. public void set_erp_invoicing()
  8439. {
  8440. if (UrlPostParmsCheck("id"))
  8441. {
  8442. try
  8443. {
  8444. string eid = GetPostString("id");
  8445. CeErpBill bill_entity = null;
  8446. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8447. if (bill_entity != null)
  8448. {
  8449. int ComId = GetPostInt("ComId");
  8450. //string memo = GetPostString("Memo");
  8451. int allInfo = GetPostInt("allinfo");
  8452. string clert = CurrentUser.User.Name;
  8453. //string detailValue = GetPostString("detailvalue");
  8454. string billId = bill_entity.billOrderId;
  8455. string[] billIdList = billId.Split(',');
  8456. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8457. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8458. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8459. {
  8460. billCount += 1;
  8461. }
  8462. if (billId.Length <= 0 || billIdList.Length != billCount)
  8463. {
  8464. bill_entity.billOrderId = "";
  8465. string prebill = "ltb";
  8466. for (int idx = 1; idx <= billCount; idx++)
  8467. {
  8468. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8469. string billoid = prebill + idx + dtstr;
  8470. bill_entity.billOrderId += billoid;
  8471. if (idx < billCount)
  8472. {
  8473. bill_entity.billOrderId += ",";
  8474. }
  8475. }
  8476. }
  8477. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8478. if (bill_entity.state == 5)
  8479. {
  8480. string errMsg = bill_entity.failerror;
  8481. string[] errlist = errMsg.Split('|');
  8482. string[] errTags = new string[errlist.Length];
  8483. for (int itag = 0; itag < errlist.Length; itag++)
  8484. {
  8485. if (errlist[itag].Length <= 0) continue;
  8486. errTags[itag] = errlist[itag].Split('&')[0];
  8487. }
  8488. for (int iii = 0; iii < errTags.Length; iii++)
  8489. {
  8490. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8491. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8492. if (billOrderList.Length >= erroBillOrderTag)
  8493. {
  8494. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8495. if (needModifyBillId.Length <= 19)
  8496. {
  8497. needModifyBillId = needModifyBillId + "1";
  8498. }
  8499. else
  8500. {
  8501. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8502. last = last + 1;
  8503. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8504. }
  8505. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8506. }
  8507. }
  8508. }
  8509. bool isHaveBillSucces = false;
  8510. string totalRes = "";
  8511. bill_entity.failerror = "";
  8512. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8513. {
  8514. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8515. totalRes += res;
  8516. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8517. {
  8518. isHaveBillSucces = true;
  8519. bill_entity.comId = ComId;
  8520. bill_entity.state = 1;
  8521. bill_entity.executeTime = DateTime.Now;
  8522. bill_entity.executeUser = clert;
  8523. }
  8524. else
  8525. {
  8526. bill_entity.state = 5;
  8527. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8528. }
  8529. }
  8530. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8531. bill_entity.Update();
  8532. if (isHaveBillSucces)
  8533. {
  8534. StringBuilder sql = new StringBuilder();
  8535. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8536. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8537. }
  8538. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8539. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8540. {
  8541. returnErrorMsg("开票失败");
  8542. }
  8543. else
  8544. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8545. return;
  8546. }
  8547. returnErrorMsg("找不到对应记录");
  8548. }
  8549. catch (Exception ex)
  8550. {
  8551. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8552. returnErrorMsg("操作失败");
  8553. }
  8554. }
  8555. }
  8556. public void get_erp_invoicing_back()
  8557. {
  8558. if (UrlPostParmsCheck("id"))
  8559. {
  8560. try
  8561. {
  8562. string id = GetPostString("id");
  8563. CeErpBill entiy = CeErpBill.Get(id);
  8564. if (entiy != null)
  8565. {
  8566. if (entiy.state == 0)
  8567. {
  8568. returnErrorMsg("发票还未开具");
  8569. return;
  8570. }
  8571. string[] billOrderList = entiy.billOrderId.Split(',');
  8572. int iTag = 0;
  8573. entiy.fplsh = "";
  8574. entiy.fpdm = "";
  8575. entiy.fphm = "";
  8576. foreach (string billOrderId in billOrderList)
  8577. {
  8578. iTag++;
  8579. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8580. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8581. {
  8582. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8583. try
  8584. {
  8585. Invoicing_get_response_Obj iObj = null;
  8586. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8587. if (iObj != null)
  8588. {
  8589. entiy.state = 2;
  8590. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8591. entiy.fpdm += iObj.list[0].c_fpdm;
  8592. entiy.fphm += iObj.list[0].c_fphm;
  8593. if (iTag < billOrderList.Length)
  8594. {
  8595. entiy.fplsh += ",";
  8596. entiy.fpdm += ",";
  8597. entiy.fphm += ",";
  8598. }
  8599. entiy.Update();
  8600. }
  8601. StringBuilder sql = new StringBuilder();
  8602. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8603. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8604. returnSuccessMsg("开票成功");
  8605. }
  8606. catch (Exception ex)
  8607. {
  8608. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8609. }
  8610. return;
  8611. }
  8612. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8613. {
  8614. var res_obj = new
  8615. {
  8616. data = "开票中"
  8617. };
  8618. string ro_json = JsonConvert.SerializeObject(res_obj);
  8619. returnSuccess(ro_json);
  8620. return;
  8621. }
  8622. else
  8623. {
  8624. int eidx = res.IndexOf("c_resultmsg");
  8625. int lidx = res.IndexOf("c_status");
  8626. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8627. entiy.state = 5;
  8628. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8629. entiy.Update();
  8630. returnErrorMsg("开票失败");
  8631. return;
  8632. }
  8633. }
  8634. }
  8635. }
  8636. catch (Exception ex)
  8637. {
  8638. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8639. }
  8640. return;
  8641. }
  8642. }
  8643. public void get_erp_invoicing()
  8644. {
  8645. if (UrlPostParmsCheck("id"))
  8646. {
  8647. try
  8648. {
  8649. string id = GetPostString("id");
  8650. CeErpBill entiy = CeErpBill.Get(id);
  8651. if (entiy != null)
  8652. {
  8653. if (entiy.state == 0)
  8654. {
  8655. returnErrorMsg("发票还未开具");
  8656. return;
  8657. }
  8658. if (entiy.sendType == "纸质发票")
  8659. {
  8660. if (entiy.img.Length <= 0)
  8661. {
  8662. returnErrorMsg("查无纸质发票");
  8663. return;
  8664. }
  8665. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8666. returnSuccess(returnres);
  8667. return;
  8668. }
  8669. string[] billOrderList = entiy.billOrderId.Split(',');
  8670. int iTag = 0;
  8671. string fpUrl = "";
  8672. entiy.fplsh = "";
  8673. entiy.fpdm = "";
  8674. entiy.fphm = "";
  8675. foreach (string billOrderId in billOrderList)
  8676. {
  8677. iTag++;
  8678. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8679. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8680. {
  8681. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8682. Invoicing_get_response_Obj iObj = null;
  8683. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8684. if (iObj != null)
  8685. {
  8686. //entiy.state = 2;
  8687. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8688. entiy.fpdm += iObj.list[0].c_fpdm;
  8689. entiy.fphm += iObj.list[0].c_fphm;
  8690. if (iTag < billOrderList.Length)
  8691. {
  8692. entiy.fplsh += ",";
  8693. entiy.fpdm += ",";
  8694. entiy.fphm += ",";
  8695. }
  8696. entiy.Update();
  8697. fpUrl += iObj.list[0].c_url + ",";
  8698. }
  8699. //returnSuccess(res);
  8700. StringBuilder sql = new StringBuilder();
  8701. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8702. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8703. }
  8704. else
  8705. {
  8706. int eidx = res.IndexOf("c_resultmsg");
  8707. //int lidx = res.IndexOf("c_status");
  8708. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8709. //开票失败
  8710. entiy.state = 5;
  8711. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8712. entiy.Update();
  8713. returnErrorMsg("开票失败");
  8714. return;
  8715. }
  8716. }
  8717. var returnObj = new
  8718. {
  8719. data = fpUrl
  8720. };
  8721. string ro_json = JsonConvert.SerializeObject(returnObj);
  8722. returnSuccess(ro_json);
  8723. }
  8724. }
  8725. catch (Exception ex)
  8726. {
  8727. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8728. }
  8729. return;
  8730. }
  8731. }
  8732. public void save_erp_billimg()
  8733. {
  8734. if (UrlPostParmsCheck("id"))
  8735. {
  8736. string eid = GetPostString("id");
  8737. CeErpBill bill_entity = null;
  8738. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8739. if (bill_entity != null)
  8740. {
  8741. bill_entity.img = GetPostString("img");
  8742. bill_entity.executeTime = DateTime.Now;
  8743. bill_entity.state = 2;
  8744. bill_entity.Update();
  8745. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8746. returnSuccessMsg("保存成功");
  8747. }
  8748. return;
  8749. }
  8750. }
  8751. public void upd_erp_billreturnback()
  8752. {
  8753. if (UrlPostParmsCheck("id"))
  8754. {
  8755. int eid = GetPostInt("id");
  8756. CeErpBill bill_entity = null;
  8757. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8758. if (bill_entity != null)
  8759. {
  8760. bill_entity.state = 3;
  8761. bill_entity.returnReason = GetPostString("reason");
  8762. bill_entity.Update();
  8763. returnSuccessMsg("驳回成功!");
  8764. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8765. }
  8766. return;
  8767. }
  8768. }
  8769. public void cancel_erp_bill()
  8770. {
  8771. if (UrlPostParmsCheck("id"))
  8772. {
  8773. int eid = GetPostInt("id");
  8774. int detailValue = GetPostInt("detailvalue");
  8775. CeErpBill bill_entity = null;
  8776. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8777. string cres = "";
  8778. string gres = "";
  8779. if (bill_entity != null)
  8780. {
  8781. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8782. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8783. {
  8784. int iTag = 0;
  8785. bill_entity.fplsh = "";
  8786. bill_entity.fpdm = "";
  8787. bill_entity.fphm = "";
  8788. foreach (string billOrderId in billOrderList)
  8789. {
  8790. iTag++;
  8791. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8792. if (gres.IndexOf("success") != -1)
  8793. {
  8794. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8795. Invoicing_get_response_Obj iObj = null;
  8796. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8797. if (iObj != null)
  8798. {
  8799. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8800. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8801. bill_entity.fphm += iObj.list[0].c_fphm;
  8802. if (iTag < billOrderList.Length)
  8803. {
  8804. bill_entity.fplsh += ",";
  8805. bill_entity.fpdm += ",";
  8806. bill_entity.fphm += ",";
  8807. }
  8808. bill_entity.Update();
  8809. }
  8810. }
  8811. else
  8812. {
  8813. returnErrorMsg(gres);
  8814. return;
  8815. }
  8816. }
  8817. }
  8818. if (bill_entity.sendType == "纸质发票")
  8819. {
  8820. //作废
  8821. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8822. //if (DateTime.Now.Month == extime.Month)
  8823. //{
  8824. //cres = taobaoHelper.cancel_invoicing(eid);
  8825. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8826. //{
  8827. bill_entity.state = 4;//已作废
  8828. bill_entity.Update();
  8829. returnSuccessMsg("发票已作废");
  8830. return;
  8831. //}
  8832. //else
  8833. //{
  8834. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8835. // bill_entity.Update();
  8836. // returnErrorMsg(cres);
  8837. // return;
  8838. //}
  8839. //}
  8840. //else
  8841. //{
  8842. // returnErrorMsg("纸质发票只能作废本月的发票");
  8843. // return;
  8844. //}
  8845. }
  8846. //红冲
  8847. int redTag = 0;
  8848. string[] fpdmList = bill_entity.fpdm.Split(',');
  8849. string[] fphmList = bill_entity.fphm.Split(',');
  8850. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8851. {
  8852. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8853. return;
  8854. }
  8855. foreach (string billOrderId in billOrderList)
  8856. {
  8857. redTag++;
  8858. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8859. cres += onecres;
  8860. cres += ",";
  8861. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8862. {
  8863. bill_entity.state = 4;//已作废
  8864. //bill_entity.Update();
  8865. //returnSuccessMsg("发票已红冲");
  8866. }
  8867. else if (onecres.IndexOf("重复冲红") != -1)
  8868. {
  8869. bill_entity.state = 4;//已作废
  8870. //bill_entity.Update();
  8871. //returnSuccessMsg("发票已红冲");
  8872. }
  8873. else
  8874. {
  8875. string errmsg = commonHelper.KeepChinese(onecres);
  8876. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8877. }
  8878. }
  8879. bill_entity.Update();
  8880. if (cres.IndexOf("失败") != -1)
  8881. returnErrorMsg("红冲失败");
  8882. else
  8883. returnSuccessMsg("发票已红冲");
  8884. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8885. return;
  8886. }
  8887. return;
  8888. }
  8889. }
  8890. public void del_erp_billorder()
  8891. {
  8892. if (UrlPostParmsCheck("id"))
  8893. {
  8894. string eid = GetPostString("id");
  8895. CeErpBill.Del(eid);
  8896. CeErpBill bill = CeErpBill.Get(eid);
  8897. if (bill != null)
  8898. {
  8899. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8900. }
  8901. returnSuccessMsg("删除成功");
  8902. }
  8903. }
  8904. public void finish_erp_bill()
  8905. {
  8906. if (UrlPostParmsCheck("ids"))
  8907. {
  8908. string eids = GetPostString("ids");
  8909. string[] list = eids.Split(',');
  8910. foreach (string eid in list)
  8911. {
  8912. CeErpBill bill = CeErpBill.Get(eid);
  8913. if (bill != null)
  8914. {
  8915. bill.state = 2;
  8916. bill.Update();
  8917. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8918. }
  8919. }
  8920. returnSuccessMsg("操作成功");
  8921. }
  8922. }
  8923. public void get_erp_returncash()
  8924. {
  8925. DataStruct dStruct = GetPostStruct();
  8926. List<string> lw = new List<string>();
  8927. string tid = GetPostString("tid");
  8928. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8929. string shopname = GetPostString("shopname");
  8930. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8931. string buyernick = GetPostString("buyer_nick");
  8932. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8933. string customer = GetPostString("customer");
  8934. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8935. string returndate1 = GetPostString("returndate1");
  8936. string returndate2 = GetPostString("returndate2");
  8937. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8938. if (dw.Length > 0) lw.Add(dw);
  8939. string finishDate1 = GetPostString("finishdate1");
  8940. string finishDate2 = GetPostString("finishdate2");
  8941. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8942. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8943. string returntype = GetPostString("returntype");
  8944. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8945. string returnvstate = GetPostString("returnvstate");
  8946. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8947. dStruct.Order = "created desc";
  8948. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8949. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8950. writeGridDataTableJson(dStruct.TotalCount, dt);
  8951. }
  8952. public void get_erp_staygoods()
  8953. {
  8954. DataStruct dStruct = GetPostStruct();
  8955. List<string> lw = new List<string>();
  8956. string tid = GetPostString("tid");
  8957. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8958. string shopname = GetPostString("shopname");
  8959. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8960. string wangwang = GetPostString("wangwang");
  8961. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8962. string customer = GetPostString("customer");
  8963. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8964. string returndate1 = GetPostString("returndate1");
  8965. string returndate2 = GetPostString("returndate2");
  8966. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8967. if (dw.Length > 0) lw.Add(dw);
  8968. string finishDate1 = GetPostString("finishdate1");
  8969. string finishDate2 = GetPostString("finishdate2");
  8970. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8971. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8972. string returnvstate = GetPostString("returnvstate");
  8973. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8974. string persuadetype = GetPostString("persuadetype");
  8975. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8976. string customerOrg = GetPostString("customerOrg");
  8977. if (customerOrg.Length > 0)
  8978. {
  8979. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8980. }
  8981. string designerorg = GetPostString("designerorg");
  8982. if (designerorg.Length > 0)
  8983. {
  8984. lw.Add(string.Format("OrgID = {0}", designerorg));
  8985. }
  8986. dStruct.Order = "creata_time desc";
  8987. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8988. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8989. writeGridDataTableJson(dStruct.TotalCount, dt);
  8990. }
  8991. public void upd_erp_staygoods()
  8992. {
  8993. if (UrlPostParmsCheck("id"))
  8994. {
  8995. int eid = GetPostInt("id");
  8996. CeErpStayGoods entity = null;
  8997. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8998. if (entity != null)
  8999. {
  9000. entity.audit_type = 1;
  9001. entity.audit_time = DateTime.Now;
  9002. entity.audit_u_id = CurrentUser.UserID;
  9003. entity.audit_u_name = CurrentUser.UserName;
  9004. entity.Update();
  9005. returnSuccessMsg("审核成功!");
  9006. return;
  9007. }
  9008. returnErrorMsg("找不到订单记录");
  9009. }
  9010. }
  9011. public void upd_erp_stayGoodsback()
  9012. {
  9013. if (UrlPostParmsCheck("id"))
  9014. {
  9015. int eid = GetPostInt("id");
  9016. CeErpStayGoods entity = null;
  9017. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9018. if (entity != null)
  9019. {
  9020. entity.audit_text = GetPostString("reason");
  9021. entity.audit_type = 2;
  9022. entity.audit_time = DateTime.Now;
  9023. entity.audit_u_id = CurrentUser.UserID;
  9024. entity.audit_u_name = CurrentUser.UserName;
  9025. entity.Update();
  9026. returnSuccessMsg("退回成功!");
  9027. return;
  9028. }
  9029. returnErrorMsg("找不到订单记录");
  9030. }
  9031. }
  9032. public void upd_erp_returncashverify()
  9033. {
  9034. if (UrlPostParmsCheck("ID"))
  9035. {
  9036. int eid = GetPostInt("ID");
  9037. CeErpReturnCash entity = null;
  9038. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9039. if (entity != null)
  9040. {
  9041. entity.cashstate = 1;
  9042. entity.verifytime = DateTime.Now;
  9043. entity.verifyuserid = CurrentUser.UserID;
  9044. entity.Update();
  9045. returnSuccessMsg("审核成功!");
  9046. return;
  9047. }
  9048. returnErrorMsg("找不到订单记录");
  9049. }
  9050. }
  9051. public void upd_all_erp_returncashverify()
  9052. {
  9053. if (UrlPostParmsCheck("ID"))
  9054. {
  9055. String[] list = GetPostString("ID").Split(',');
  9056. CeErpReturnCash entity = null;
  9057. for (int i = 0; i < list.Length; i++)
  9058. {
  9059. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9060. if (entity != null)
  9061. {
  9062. if (entity.cashstate == 1)
  9063. {
  9064. returnErrorMsg("已审核过的订单不需要在审核!");
  9065. return;
  9066. }
  9067. entity.cashstate = 1;
  9068. entity.verifytime = DateTime.Now;
  9069. entity.verifyuserid = CurrentUser.UserID;
  9070. entity.Update();
  9071. }
  9072. }
  9073. returnSuccessMsg("审核成功!");
  9074. return;
  9075. }
  9076. }
  9077. public void upd_erp_returncashback()
  9078. {
  9079. if (UrlPostParmsCheck("ID"))
  9080. {
  9081. int eid = GetPostInt("ID");
  9082. CeErpReturnCash entity = null;
  9083. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9084. if (entity != null)
  9085. {
  9086. entity.backreason = GetPostString("reason");
  9087. entity.cashstate = 2;
  9088. entity.verifytime = DateTime.Now;
  9089. entity.verifyuserid = CurrentUser.UserID;
  9090. entity.Update();
  9091. returnSuccessMsg("退回成功!");
  9092. return;
  9093. }
  9094. returnErrorMsg("找不到订单记录");
  9095. }
  9096. }
  9097. public void upd_erp_returnprice()
  9098. {
  9099. if (UrlPostParmsCheck("ID"))
  9100. {
  9101. int eid = GetPostInt("ID");
  9102. CeErpReturnCash entity = null;
  9103. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9104. if (entity != null)
  9105. {
  9106. if (entity.cashstate == 1)
  9107. {
  9108. returnErrorMsg("审核通过了不能改");
  9109. return;
  9110. }
  9111. entity.returnprice = GetPostDouble("returnprice");
  9112. entity.Update();
  9113. returnSuccessMsg("修改成功!");
  9114. return;
  9115. }
  9116. returnErrorMsg("找不到订单记录");
  9117. }
  9118. }
  9119. public void del_erp_returncash()
  9120. {
  9121. if (UrlPostParmsCheck("ID"))
  9122. {
  9123. int eid = GetPostInt("ID");
  9124. CeErpReturnCash.Del(eid);
  9125. returnSuccessMsg("操作成功");
  9126. return;
  9127. }
  9128. }
  9129. public void test_for_do_sql()
  9130. {
  9131. string sql = GetPostString("sqlstr");
  9132. if (sql.Length > 0)
  9133. {
  9134. try
  9135. {
  9136. DbHelper.DbConn.ExecuteNonQuery(sql);
  9137. var res_obj = new
  9138. {
  9139. data = "成功",
  9140. };
  9141. string ro_json = JsonConvert.SerializeObject(res_obj);
  9142. returnSuccess(ro_json);
  9143. }
  9144. catch (Exception ex)
  9145. {
  9146. var res_obj = new
  9147. {
  9148. data = ex.Message,
  9149. };
  9150. string ro_json = JsonConvert.SerializeObject(res_obj);
  9151. returnSuccess(ro_json);
  9152. }
  9153. }
  9154. }
  9155. public void get_user_info()
  9156. {
  9157. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9158. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9159. }
  9160. public void get_total_data()
  9161. {
  9162. int userId = CurrentUser.UserID;
  9163. string sql = "";
  9164. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9165. {
  9166. 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);
  9167. }
  9168. else
  9169. {
  9170. 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 " +
  9171. "(select ID from CE_ErpUser where ID = {0}) d " +
  9172. "left join " +
  9173. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9174. ") a on d.ID = a.id left join " +
  9175. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9176. ") b on a.id = b.id1 left join" +
  9177. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9178. ") c on a.id = c.id2;", userId);
  9179. }
  9180. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9181. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9182. }
  9183. public void get_date_area_total_data2()
  9184. {
  9185. int userId = CurrentUser.UserID;
  9186. string date_type = GetPostString("timetype");
  9187. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9188. string sql = "";
  9189. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9190. {
  9191. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9192. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9193. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9194. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9195. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9196. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9197. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9198. ") a on e.ID = a.id left join " +
  9199. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9200. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9201. ") b on a.id = b.id1 " +
  9202. "left join " +
  9203. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9204. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9205. ") c on a.id = c.id2 " +
  9206. "left join " +
  9207. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9208. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9209. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9210. }
  9211. else
  9212. {
  9213. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9214. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9215. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9216. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9217. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9218. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9219. ") a on e.ID = a.id left join " +
  9220. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9221. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9222. ") c on a.id = c.id2 " +
  9223. "left join " +
  9224. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9225. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9226. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9227. }
  9228. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9229. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9230. }
  9231. public void get_date_area_total_data()
  9232. {
  9233. int userId = CurrentUser.UserID;
  9234. string date_type = GetPostString("timetype");
  9235. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9236. string date1 = searchDT[0].ToString();
  9237. string date2 = searchDT[1].ToString();
  9238. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9239. {
  9240. SqlParameter[] sqlParameter ={
  9241. new SqlParameter("@userId", SqlDbType.Int,4),
  9242. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9243. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9244. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9245. };
  9246. sqlParameter[0].Value = userId;
  9247. sqlParameter[1].Value = date1;
  9248. sqlParameter[2].Value = date2;
  9249. sqlParameter[3].Direction = ParameterDirection.Output;
  9250. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9251. string res = sqlParameter[3].Value.ToString();
  9252. var res_obj = new
  9253. {
  9254. data = res
  9255. };
  9256. string ro_json = JsonConvert.SerializeObject(res_obj);
  9257. returnSuccess(ro_json);
  9258. }
  9259. else
  9260. {
  9261. SqlParameter[] sqlParameter ={
  9262. new SqlParameter("@userId", SqlDbType.Int,4),
  9263. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9264. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9265. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9266. };
  9267. sqlParameter[0].Value = userId;
  9268. sqlParameter[1].Value = date1;
  9269. sqlParameter[2].Value = date2;
  9270. sqlParameter[3].Direction = ParameterDirection.Output;
  9271. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9272. string res = sqlParameter[3].Value.ToString();
  9273. var res_obj = new
  9274. {
  9275. data = res
  9276. };
  9277. string ro_json = JsonConvert.SerializeObject(res_obj);
  9278. returnSuccess(ro_json);
  9279. }
  9280. //writeGridDataViewJson(dt.Rows.Count, dv);
  9281. }
  9282. public void get_order_list()
  9283. {
  9284. string strFields = GetPostString("paraFields");
  9285. string strOrder = GetPostString("paraOrder");
  9286. string strWhere = GetPostString("paraWhere");
  9287. string strPageSize = GetPostString("paraPageSize");
  9288. DataStruct dStruct = GetPostStruct();
  9289. dStruct.PageSize = int.Parse(strPageSize);
  9290. dStruct.Fileds = strFields;
  9291. dStruct.Order = strOrder;
  9292. dStruct.MainWhere = strWhere;
  9293. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9294. writeGridDataTableJson(dStruct.TotalCount, dt);
  9295. }
  9296. ////获取待开始订单列表
  9297. //public void get_wait_design_order_list()
  9298. //{
  9299. // string date_type = GetPostString("date_type");
  9300. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9301. // DataStruct dStruct = GetPostStruct();
  9302. // dStruct.PageSize = 1000;
  9303. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9304. // List<string> lw = new List<string>();
  9305. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9306. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9307. // dStruct.Order = "WaitDesignTime asc";
  9308. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9309. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9310. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9311. //}
  9312. //获取完成单量排名
  9313. public void get_finish_order_count_ranking()
  9314. {
  9315. /* string date_type = GetPostString("date_type");
  9316. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9317. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9318. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9319. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9320. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9321. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9322. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9323. writeGridDataTableJson(0, new DataTable());
  9324. }
  9325. public void get_finish_order_amount_ranking()
  9326. {
  9327. /*string date_type = GetPostString("date_type");
  9328. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9329. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9330. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9331. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9332. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9333. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9334. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9335. writeGridDataTableJson(0, new DataTable());
  9336. }
  9337. public void get_finish_refund_count_ranking()
  9338. {
  9339. string date_type = GetPostString("date_type");
  9340. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9341. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9342. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9343. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9344. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9345. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9346. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9347. writeGridDataTableJson(dt.Rows.Count, dt);
  9348. }
  9349. public void get_finish_refund_amount_ranking()
  9350. {
  9351. string date_type = GetPostString("date_type");
  9352. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9353. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9354. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9355. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9356. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9357. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9358. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9359. writeGridDataTableJson(dt.Rows.Count, dt);
  9360. }
  9361. public void set_erp_finishorder_director()
  9362. {
  9363. if (UrlPostParmsCheck("ctid"))
  9364. {
  9365. string eid = GetPostString("ctid");
  9366. CeErpTradeCell entity = null;
  9367. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9368. if (entity != null)
  9369. {
  9370. entity.OrderState = 8;
  9371. entity.Update();
  9372. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9373. returnSuccessMsg("操作成功!");
  9374. return;
  9375. }
  9376. returnErrorMsg("找不到记录");
  9377. }
  9378. }
  9379. public void get_erp_placeregistlist()
  9380. {
  9381. DataStruct dStruct = GetPostStruct();
  9382. List<string> lw = new List<string>();
  9383. string outsid = GetPostString("outsid");
  9384. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9385. string memo = GetPostString("memo");
  9386. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9387. string filename = GetPostString("filename");
  9388. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9389. string islate = GetPostString("islate");
  9390. if (islate.Length > 0)
  9391. {
  9392. if (islate == "1")
  9393. lw.Add(string.Format("OutLate>0"));
  9394. else
  9395. lw.Add(string.Format("OutLate=0"));
  9396. }
  9397. string placedate1 = GetPostString("placedate1");
  9398. string placedate2 = GetPostString("placedate2");
  9399. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9400. if (dw.Length > 0) lw.Add(dw);
  9401. string deliveryDate1 = GetPostString("deliverydate1");
  9402. string deliveryDate2 = GetPostString("deliverydate2");
  9403. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9404. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9405. dStruct.Order = "ID desc";
  9406. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9407. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9408. writeGridDataTableJson(dStruct.TotalCount, dt);
  9409. }
  9410. public void ins_erp_placeregist()
  9411. {
  9412. if (UrlPostParmsCheck("id"))
  9413. {
  9414. string eid = GetPostString("id");
  9415. CeErpPlaceRegister entity = null;
  9416. if (eid == "0")//新增
  9417. {
  9418. entity = new CeErpPlaceRegister();
  9419. string xdTime = GetPostString("placeTime");
  9420. if (xdTime.Length > 0)
  9421. {
  9422. entity.PlactTime = Convert.ToDateTime(xdTime);
  9423. }
  9424. string fhTime = GetPostString("deliveryTime");
  9425. if (fhTime.Length > 0)
  9426. {
  9427. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9428. }
  9429. string preTime = GetPostString("preOutTime");
  9430. if (preTime.Length > 0)
  9431. {
  9432. entity.PreOutTime = Convert.ToDateTime(preTime);
  9433. }
  9434. entity.DeliveryCount = GetPostInt("deliveryCount");
  9435. entity.ReceiveCount = GetPostInt("receiveCount");
  9436. entity.OutSid = GetPostString("outSid");
  9437. entity.FileName = GetPostString("fileName");
  9438. entity.Memo = GetPostString("memo");
  9439. entity.AddUserId = CurrentUser.UserID;
  9440. entity.CreateTime = DateTime.Now;
  9441. entity.Img = GetPostString("img");
  9442. entity.Supplier = GetPostInt("supplier");
  9443. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9444. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9445. {
  9446. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9447. DateTime dt2 = (DateTime)entity.PreOutTime;
  9448. TimeSpan span = dt1.Subtract(dt2);
  9449. if (span.Days > 0)
  9450. {
  9451. entity.OutLate = span.Days;
  9452. }
  9453. }
  9454. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9455. entity.Create();
  9456. returnSuccessMsg("添加成功!");
  9457. return;
  9458. }
  9459. else //修改
  9460. {
  9461. entity = CeErpPlaceRegister.Get(eid);
  9462. if (entity != null)
  9463. {
  9464. string xdTime = GetPostString("placeTime");
  9465. if (xdTime.Length > 0)
  9466. {
  9467. entity.PlactTime = Convert.ToDateTime(xdTime);
  9468. }
  9469. string fhTime = GetPostString("deliveryTime");
  9470. if (fhTime.Length > 0)
  9471. {
  9472. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9473. }
  9474. string preTime = GetPostString("preOutTime");
  9475. if (preTime.Length > 0)
  9476. {
  9477. entity.PreOutTime = Convert.ToDateTime(preTime);
  9478. }
  9479. entity.DeliveryCount = GetPostInt("deliveryCount");
  9480. entity.ReceiveCount = GetPostInt("receiveCount");
  9481. if (entity.DeliveryCount == entity.ReceiveCount)
  9482. {
  9483. entity.CurState = "已完成";
  9484. }
  9485. else
  9486. {
  9487. entity.CurState = "未完成";
  9488. }
  9489. entity.OutSid = GetPostString("outSid");
  9490. entity.FileName = GetPostString("fileName");
  9491. entity.Memo = GetPostString("memo");
  9492. entity.Img = GetPostString("img");
  9493. entity.Supplier = GetPostInt("supplier");
  9494. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9495. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9496. {
  9497. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9498. DateTime dt2 = (DateTime)entity.PreOutTime;
  9499. TimeSpan span = dt1.Subtract(dt2);
  9500. if (span.Days > 0)
  9501. {
  9502. entity.OutLate = span.Days;
  9503. }
  9504. }
  9505. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9506. entity.Update();
  9507. returnSuccessMsg("修改成功");
  9508. return;
  9509. }
  9510. returnErrorMsg("找不到对应的记录");
  9511. return;
  9512. }
  9513. }
  9514. returnErrorMsg("缺少必要参数");
  9515. }
  9516. public void del_erp_placeregist()
  9517. {
  9518. string eid = GetPostString("id");
  9519. CeErpPlaceRegister.Del(eid);
  9520. returnSuccessMsg("删除成功!");
  9521. return;
  9522. }
  9523. public void ins_erp_placeregistbyorder()
  9524. {
  9525. string ctid = GetPostString("ctid");
  9526. if (ctid.Length > 0)
  9527. {
  9528. StringBuilder sql = new StringBuilder();
  9529. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9530. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9531. if (dt.Rows.Count > 0)
  9532. {
  9533. foreach (DataRow dr in dt.Rows)
  9534. {
  9535. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9536. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9537. entity.AddUserId = CurrentUser.UserID;
  9538. entity.tid = dr["tid"].ToString();
  9539. entity.Did = Convert.ToString(dr["ctid"]);
  9540. entity.splitTag = dr["SplitTag"].ToString();
  9541. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9542. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9543. if (pre_ctid.Length > 0)
  9544. {
  9545. sellmemo = sellmemo.Replace(pre_ctid, "");
  9546. }
  9547. sellmemo = sellmemo.Replace("[", "");
  9548. sellmemo = sellmemo.Replace("]", "");
  9549. entity.FileName = sellmemo;
  9550. string count = dr["ProductCount"].ToString();
  9551. int usecount = commonHelper.getIntCountFromString(count);
  9552. entity.DeliveryCount = usecount;
  9553. entity.CurState = "未完成";
  9554. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9555. {
  9556. entity.Supplier = 24;//dl手提袋定制
  9557. }
  9558. else
  9559. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9560. entity.CreateTime = DateTime.Now;
  9561. entity.Create();
  9562. }
  9563. returnSuccessMsg("操作成功");
  9564. return;
  9565. }
  9566. returnErrorMsg("没有找到对应订单");
  9567. return;
  9568. }
  9569. returnErrorMsg("缺少订单编号");
  9570. return;
  9571. }
  9572. public void get_erp_persuadelist()
  9573. {
  9574. DataStruct dStruct = GetPostStruct();
  9575. List<string> lw = new List<string>();
  9576. string ctid = GetPostString("ctid");
  9577. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9578. string shopname = GetPostString("shopname");
  9579. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9580. string buyernick = GetPostString("buyer_nick");
  9581. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9582. string customer = GetPostString("customer");
  9583. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9584. string returndate1 = GetPostString("returndate1");
  9585. string returndate2 = GetPostString("returndate2");
  9586. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9587. if (dw.Length > 0) lw.Add(dw);
  9588. string finishDate1 = GetPostString("finishdate1");
  9589. string finishDate2 = GetPostString("finishdate2");
  9590. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9591. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9592. string persuadetype = GetPostString("persuadetype");
  9593. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9594. string returnvstate = GetPostString("returnvstate");
  9595. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9596. dStruct.Order = "created desc";
  9597. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9598. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9599. writeGridDataTableJson(dStruct.TotalCount, dt);
  9600. }
  9601. public void upd_erp_returnpersuadeback()
  9602. {
  9603. if (UrlPostParmsCheck("ID"))
  9604. {
  9605. int eid = GetPostInt("ID");
  9606. CeErpPersuade entity = null;
  9607. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9608. if (entity != null)
  9609. {
  9610. entity.backreason = GetPostString("reason");
  9611. entity.pstate = 2;
  9612. entity.verifytime = DateTime.Now;
  9613. entity.verifyuserid = CurrentUser.UserID;
  9614. entity.Update();
  9615. returnSuccessMsg("退回成功!");
  9616. return;
  9617. }
  9618. returnErrorMsg("找不到订单记录");
  9619. }
  9620. }
  9621. public void upd_erp_returnpersuadeverify()
  9622. {
  9623. if (UrlPostParmsCheck("ID"))
  9624. {
  9625. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9626. {
  9627. returnErrorMsg("暂无权限审核");
  9628. return;
  9629. }
  9630. int eid = GetPostInt("ID");
  9631. CeErpPersuade entity = null;
  9632. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9633. if (entity != null)
  9634. {
  9635. entity.pstate = 1;
  9636. entity.verifytime = DateTime.Now;
  9637. entity.verifyuserid = CurrentUser.UserID;
  9638. entity.Update();
  9639. returnSuccessMsg("审核成功!");
  9640. return;
  9641. }
  9642. returnErrorMsg("找不到订单记录");
  9643. }
  9644. }
  9645. public void del_erp_persuade()
  9646. {
  9647. if (UrlPostParmsCheck("ID"))
  9648. {
  9649. int eid = GetPostInt("ID");
  9650. CeErpPersuade.Del(eid);
  9651. returnSuccessMsg("操作成功");
  9652. return;
  9653. }
  9654. }
  9655. public void get_erp_oldcustoupload()
  9656. {
  9657. DataStruct dStruct = GetPostStruct();
  9658. List<string> lw = new List<string>();
  9659. string buyernick = GetPostString("buyer_nick");
  9660. if (buyernick.Length > 0)
  9661. {
  9662. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9663. }
  9664. else
  9665. return;
  9666. dStruct.Order = "pay_time desc";
  9667. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9668. DataTable dt = null;
  9669. dt = WebCache.GetData("view_erptradecell", dStruct);
  9670. writeGridDataTableJson(dStruct.TotalCount, dt);
  9671. }
  9672. public void get_erp_checkorderlist()
  9673. {
  9674. DataStruct dStruct = GetPostStruct();
  9675. List<string> lw = new List<string>();
  9676. string tid = GetPostString("ctid");
  9677. if (tid.Length > 0)
  9678. {
  9679. string select_tid = getTidByCtid(tid);
  9680. lw.Add(string.Format("tid='{0}'", select_tid));
  9681. }
  9682. string shopname = GetPostString("shopname");
  9683. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9684. string buyernick = GetPostString("buyer_nick");
  9685. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9686. string customer = GetPostString("customer");
  9687. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9688. string design = GetPostString("design");
  9689. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9690. string orderState = GetPostString("orderState");
  9691. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9692. string address = GetPostString("address");
  9693. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9694. string sellermemo = GetPostString("seller_memo");
  9695. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9696. string supplier = GetPostString("supplier");
  9697. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9698. {
  9699. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9700. }
  9701. else
  9702. {
  9703. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9704. }
  9705. string date1 = GetPostString("date1");
  9706. string date2 = GetPostString("date2");
  9707. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9708. if (dw.Length > 0) lw.Add(dw);
  9709. string placedate1 = GetPostString("placedate1");
  9710. string placedate2 = GetPostString("placedate2");
  9711. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9712. if (fdw.Length > 0) lw.Add(fdw);
  9713. string price1 = GetPostString("price1");
  9714. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9715. string price2 = GetPostString("price2");
  9716. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9717. string checkst = GetPostString("checkstate");
  9718. if (checkst.Length > 0 && "10".Equals(checkst))
  9719. {
  9720. lw.Add(string.Format("CheckOut>0"));
  9721. }
  9722. else
  9723. {
  9724. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9725. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9726. }
  9727. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9728. {
  9729. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9730. }
  9731. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9732. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9733. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9734. writeGridDataTableJson(dStruct.TotalCount, dt);
  9735. }
  9736. public void ins_erp_startCheck()
  9737. {
  9738. if (UrlPostParmsCheck("ctid"))
  9739. {
  9740. string eid = GetPostString("ctid");
  9741. CeErpTradeCell entity = null;
  9742. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9743. if (entity != null)
  9744. {
  9745. entity.MemoOpt = 4;
  9746. entity.UpdateTime = DateTime.Now;
  9747. entity.Update();
  9748. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9749. CeErpSukuraData.createInfo(entity.ctid, 6);
  9750. returnSuccessMsg("操作成功!");
  9751. return;
  9752. }
  9753. returnErrorMsg("找不到记录");
  9754. }
  9755. }
  9756. public void upd_erp_sendXlw()
  9757. {
  9758. if (UrlPostParmsCheck("ctid"))
  9759. {
  9760. string eid = GetPostString("ctid");
  9761. CeErpTradeCell entity = null;
  9762. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9763. if (entity != null)
  9764. {
  9765. if (entity.IsSendGift == 1)
  9766. {
  9767. returnErrorMsg("请勿重复标记");
  9768. return;
  9769. }
  9770. entity.IsSendGift = 1;
  9771. entity.Update();
  9772. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9773. returnSuccessMsg("操作成功!");
  9774. return;
  9775. }
  9776. returnErrorMsg("找不到记录");
  9777. }
  9778. }
  9779. public void cancel_sendXlw()
  9780. {
  9781. if (UrlPostParmsCheck("ctid"))
  9782. {
  9783. string eid = GetPostString("ctid");
  9784. CeErpTradeCell entity = null;
  9785. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9786. if (entity != null)
  9787. {
  9788. if (entity.IsSendGift == 0)
  9789. {
  9790. returnErrorMsg("未标记小礼物");
  9791. return;
  9792. }
  9793. entity.IsSendGift = 0;
  9794. entity.Update();
  9795. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9796. returnSuccessMsg("操作成功!");
  9797. return;
  9798. }
  9799. returnErrorMsg("找不到记录");
  9800. }
  9801. }
  9802. public void get_erp_designbill()
  9803. {
  9804. DataStruct dStruct = GetPostStruct();
  9805. List<string> lw = new List<string>();
  9806. int isMy = GetInt("my");
  9807. if (isMy == 1)
  9808. {
  9809. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9810. }
  9811. string tid = GetPostString("tid");
  9812. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9813. string userName = GetPostString("design");
  9814. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9815. string price1 = GetPostString("price1");
  9816. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9817. string price2 = GetPostString("price2");
  9818. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9819. string rePrice1 = GetPostString("rePrice1");
  9820. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9821. string rePrice2 = GetPostString("rePrice2");
  9822. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9823. string designerType = GetPostString("designerType");
  9824. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9825. string orderState = GetPostString("orderState");
  9826. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9827. string endTime1 = GetPostString("endTime1");
  9828. string endTime2 = GetPostString("endTime2");
  9829. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9830. if (dw.Length > 0) lw.Add(dw);
  9831. string isDk = GetPostString("isDk");
  9832. if (isDk == "1")
  9833. {
  9834. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9835. }
  9836. else if (isDk == "0")
  9837. {
  9838. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9839. }
  9840. dStruct.Order = "oid, create_time desc";
  9841. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9842. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9843. writeGridDataTableJson(dStruct.TotalCount, dt);
  9844. }
  9845. public void upd_erp_designerbill()
  9846. {
  9847. if (UrlPostParmsCheck("ID"))
  9848. {
  9849. string eid = GetPostString("ID");
  9850. CeErpDesignerBill entity = null;
  9851. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9852. if (entity != null)
  9853. {
  9854. if (GetPostDouble("designerpirce") > 0)
  9855. {
  9856. entity.realPrice = GetPostDouble("designerpirce");
  9857. entity.update_time = DateTime.Now;
  9858. entity.update_u_id = CurrentUser.UserID;
  9859. entity.update_u_name = CurrentUser.UserName;
  9860. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9861. entity.Update();
  9862. returnSuccessMsg("操作成功!");
  9863. return;
  9864. }
  9865. else
  9866. {
  9867. entity.price = GetPostDouble("price");
  9868. entity.update_time = DateTime.Now;
  9869. entity.update_u_id = CurrentUser.UserID;
  9870. entity.update_u_name = CurrentUser.UserName;
  9871. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9872. entity.Update();
  9873. returnSuccessMsg("操作成功!");
  9874. return;
  9875. }
  9876. }
  9877. returnErrorMsg("找不到记录");
  9878. }
  9879. }
  9880. public void audit_erp_designerbill()
  9881. {
  9882. if (UrlPostParmsCheck("ID"))
  9883. {
  9884. string eid = GetPostString("ID");
  9885. CeErpDesignerBill entity = null;
  9886. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9887. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9888. if (entity != null)
  9889. {
  9890. entity.realPrice = GetPostDouble("designerpirce");
  9891. entity.update_time = DateTime.Now;
  9892. entity.update_u_id = CurrentUser.UserID;
  9893. entity.update_u_name = CurrentUser.UserName;
  9894. entity.isAudit = 1;
  9895. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9896. entity.Update();
  9897. if (orderEntity != null)
  9898. {
  9899. orderEntity.IsReadTag = 3;
  9900. orderEntity.Update();
  9901. }
  9902. returnSuccessMsg("操作成功!");
  9903. return;
  9904. }
  9905. returnErrorMsg("找不到记录");
  9906. }
  9907. }
  9908. public void all_audit_erp_designerbill()
  9909. {
  9910. if (UrlPostParmsCheck("idList"))
  9911. {
  9912. string[] list = GetPostString("idList").Split(',');
  9913. CeErpDesignerBill entity = null;
  9914. for (int i = 0; i < list.Length; i++)
  9915. {
  9916. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9917. if (entity == null) return;
  9918. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9919. if (orderEntity == null) return;
  9920. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9921. entity.update_time = DateTime.Now;
  9922. entity.update_u_id = CurrentUser.UserID;
  9923. entity.update_u_name = CurrentUser.UserName;
  9924. entity.isAudit = 1;
  9925. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9926. entity.Update();
  9927. orderEntity.IsReadTag = 3;
  9928. orderEntity.Update();
  9929. }
  9930. returnSuccessMsg("操作成功!");
  9931. return;
  9932. }
  9933. }
  9934. public void get_erp_sameorders()
  9935. {
  9936. if (UrlPostParmsCheck("ctid"))
  9937. {
  9938. string eid = GetPostString("ctid");
  9939. CeErpTradeCell entity = null;
  9940. entity = CeErpTradeCell.GetByCtid(eid);
  9941. if (entity != null)
  9942. {
  9943. StringBuilder sql = new StringBuilder();
  9944. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9945. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9946. var res = new
  9947. {
  9948. data = dt.Rows.Count
  9949. };
  9950. string ro_jsond = JsonConvert.SerializeObject(res);
  9951. returnSuccess(ro_jsond);
  9952. return;
  9953. }
  9954. returnErrorMsg("未找到订单");
  9955. return;
  9956. }
  9957. returnErrorMsg("缺少必要的参数");
  9958. }
  9959. public void get_erp_islasthavesameorder()
  9960. {
  9961. if (UrlPostParmsCheck("ctid"))
  9962. {
  9963. string eid = GetPostString("ctid");
  9964. string[] ctidList = eid.Split(',');
  9965. StringBuilder sql = new StringBuilder();
  9966. string tisCtid = "";
  9967. foreach (string ctid in ctidList)
  9968. {
  9969. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9970. if (entity != null)
  9971. {
  9972. sql = new StringBuilder();
  9973. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9974. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9975. if (dth.Rows.Count > 0)
  9976. {
  9977. tisCtid += entity.ctid;
  9978. tisCtid += ",";
  9979. }
  9980. }
  9981. }
  9982. if (tisCtid.Length > 0)
  9983. {
  9984. var res = new
  9985. {
  9986. data = tisCtid
  9987. };
  9988. string ro_jsond = JsonConvert.SerializeObject(res);
  9989. returnSuccess(ro_jsond);
  9990. }
  9991. else
  9992. {
  9993. var res = new
  9994. {
  9995. data = ""
  9996. };
  9997. string ro_jsond = JsonConvert.SerializeObject(res);
  9998. returnSuccess(ro_jsond);
  9999. }
  10000. return;
  10001. }
  10002. returnErrorMsg("缺少必要的参数");
  10003. }
  10004. public void file_client_down_url()
  10005. {
  10006. if (!UrlPostParmsCheck("userId"))
  10007. {
  10008. returnErrorMsg("缺少必要的参数");
  10009. }
  10010. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10011. }
  10012. public void checkout_form_data()
  10013. {
  10014. if (!UrlPostParmsCheck("tid"))
  10015. {
  10016. returnErrorMsg("缺少必要的参数");
  10017. }
  10018. string tid = GetPostString("tid");
  10019. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10020. if (ceErpOrderFormData != null)
  10021. {
  10022. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10023. returnSuccess(ro_jsond);
  10024. return;
  10025. }
  10026. returnErrorMsg("尚未有文件!");
  10027. }
  10028. public void back_supplier_audit()
  10029. {
  10030. int userId = CurrentUser.UserID;
  10031. StringBuilder sql = new StringBuilder();
  10032. 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);
  10033. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10034. if (dt.Rows.Count > 0)
  10035. {
  10036. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10037. }
  10038. else
  10039. {
  10040. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10041. }
  10042. }
  10043. public void back_supplier_query()
  10044. {
  10045. string eid = GetPostString("ctid");
  10046. if (eid != "")
  10047. {
  10048. StringBuilder sql = new StringBuilder();
  10049. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10051. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10052. }
  10053. else
  10054. {
  10055. returnErrorMsg("找不到订单记录");
  10056. return;
  10057. }
  10058. }
  10059. public void verified_to_order()
  10060. {
  10061. int userId = CurrentUser.UserID;
  10062. StringBuilder sql = new StringBuilder();
  10063. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10064. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10065. if (dt.Rows.Count > 0)
  10066. {
  10067. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10068. }
  10069. else
  10070. {
  10071. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10072. }
  10073. }
  10074. public void upd_supplier_audit()
  10075. {
  10076. if (UrlPostParmsCheck("ctid"))
  10077. {
  10078. string eid = GetPostString("ctid");
  10079. string reason = GetPostString("returnreason");
  10080. CeErpTradeCell entity = null;
  10081. CeWithdraw withdraw = null;
  10082. withdraw = CeWithdraw.GetByTid(eid);
  10083. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10084. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10085. {
  10086. if (withdraw != null)
  10087. {
  10088. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10089. {
  10090. returnSuccessMsg("您没有权限操作!");
  10091. return;
  10092. }
  10093. else
  10094. {
  10095. if (reason.Equals("1"))
  10096. {
  10097. if (entity.OrderState == -1)
  10098. {
  10099. if (entity.FinishPlaceTime == null)
  10100. {
  10101. entity.OrderState = 2;
  10102. }
  10103. else
  10104. {
  10105. entity.OrderState = 6;
  10106. }
  10107. }
  10108. entity.Update();
  10109. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10110. if (withdraw != null)
  10111. {
  10112. withdraw.status = int.Parse(reason);
  10113. withdraw.Update();
  10114. }
  10115. returnSuccessMsg("操作成功!");
  10116. return;
  10117. }
  10118. else
  10119. {
  10120. withdraw.status = int.Parse(reason);
  10121. withdraw.acknowledgingtime = DateTime.Now;
  10122. withdraw.Update();
  10123. returnSuccessMsg("查看详细请点击线下订单查询");
  10124. return;
  10125. }
  10126. }
  10127. }
  10128. // 第一个字符是 'N'
  10129. }
  10130. if (eid[0] != 'N')
  10131. {
  10132. }
  10133. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10134. {
  10135. entity.IsVerifyToSupplier = false;
  10136. entity.IsReturn = 1;
  10137. entity.ReturnTime = DateTime.Now;
  10138. entity.ReturnReason = reason;
  10139. if (entity.OrderState == 6)
  10140. {
  10141. entity.OrderState = 5;
  10142. }
  10143. entity.Update();
  10144. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10145. if (withdraw != null)
  10146. {
  10147. withdraw.status = int.Parse(reason);
  10148. withdraw.Update();
  10149. }
  10150. returnSuccessMsg("操作成功!");
  10151. return;
  10152. }
  10153. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10154. {
  10155. ;
  10156. if (withdraw != null)
  10157. {
  10158. withdraw.status = int.Parse(reason);
  10159. withdraw.acknowledgingtime = DateTime.Now;
  10160. withdraw.Update();
  10161. returnSuccessMsg("供应商取消撤回!");
  10162. return;
  10163. }
  10164. }
  10165. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10166. {
  10167. if (entity.OrderState == -1)
  10168. {
  10169. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10170. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10171. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10172. {
  10173. returnErrorMsg("台湾客户需填写身份证!");
  10174. return;
  10175. }
  10176. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10177. {
  10178. returnErrorMsg("偏远地区需要填写物流费!");
  10179. return;
  10180. }
  10181. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10182. {
  10183. returnErrorMsg("订单spu没有确认无法通过审核!");
  10184. return;
  10185. }
  10186. if (entity.FinishPlaceTime == null)
  10187. {
  10188. entity.OrderState = 2;
  10189. }
  10190. else
  10191. {
  10192. entity.OrderState = 3;
  10193. }
  10194. commonHelper.getCytPrice(entity);
  10195. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10196. {
  10197. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10198. }
  10199. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10200. {
  10201. entity.OrderState = 6;
  10202. }
  10203. }
  10204. entity.Update();
  10205. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10206. if (withdraw != null)
  10207. {
  10208. withdraw.status = int.Parse(reason);
  10209. withdraw.Update();
  10210. }
  10211. returnSuccessMsg("操作成功!");
  10212. return;
  10213. }
  10214. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10215. {
  10216. if (withdraw == null)
  10217. {
  10218. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10219. return;
  10220. }
  10221. }
  10222. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10223. {
  10224. if (withdraw != null)
  10225. {
  10226. withdraw.status = int.Parse(reason);
  10227. withdraw.acknowledgingtime = DateTime.Now;
  10228. withdraw.Update();
  10229. returnSuccessMsg("查看详细请点击线下订单查询");
  10230. return;
  10231. }
  10232. }
  10233. return;
  10234. }
  10235. }
  10236. //校验报价
  10237. public void refund_order_tip()
  10238. {
  10239. int userid = CurrentUser.UserID;
  10240. int sectionId = CurrentUser.UserPost.OrgID;
  10241. StringBuilder sql = new StringBuilder();
  10242. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10243. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10244. List<string> ids = new List<string>();
  10245. if (dth.Rows.Count > 0)
  10246. {
  10247. foreach (DataRow dr in dth.Rows)
  10248. {
  10249. ids.Add(dr["ID"].ToString());
  10250. }
  10251. try
  10252. {
  10253. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10254. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10255. }
  10256. catch (Exception ex)
  10257. {
  10258. }
  10259. }
  10260. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10261. }
  10262. public void refund_order_Design()
  10263. {
  10264. int userid = CurrentUser.UserID;
  10265. int sectionId = CurrentUser.UserPost.OrgID;
  10266. StringBuilder sql = new StringBuilder();
  10267. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10268. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10269. List<string> ids = new List<string>();
  10270. if (dth.Rows.Count > 0)
  10271. {
  10272. foreach (DataRow dr in dth.Rows)
  10273. {
  10274. ids.Add(dr["ID"].ToString());
  10275. }
  10276. try
  10277. {
  10278. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10279. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10280. }
  10281. catch (Exception ex)
  10282. {
  10283. }
  10284. }
  10285. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10286. }
  10287. public void change_order_info()
  10288. {
  10289. int userid = CurrentUser.UserID;
  10290. StringBuilder sql = new StringBuilder();
  10291. 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);
  10292. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10293. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10294. }
  10295. public void change_win_mome()
  10296. {
  10297. if (UrlPostParmsCheck("id,ctid"))
  10298. {
  10299. string id = GetPostString("id");
  10300. string ctid = GetPostString("ctid");
  10301. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10302. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10303. if (ce == null || ceErpMessageTip == null)
  10304. {
  10305. returnSuccessMsg("未找到对应的订单!");
  10306. return;
  10307. }
  10308. if (ce.OrderState >= 5)
  10309. {
  10310. ceErpMessageTip.isVisit = true;
  10311. ceErpMessageTip.Update();
  10312. returnSuccessMsg("已上传文件无法修改!");
  10313. return;
  10314. }
  10315. int type = GetPostInt("type");
  10316. string content = GetPostString("content");
  10317. if (type == 0)
  10318. {
  10319. content = content.Replace("(", "(");
  10320. content = content.Replace(")", ")");
  10321. string check = MidStrEx(content, "(", ")").Trim();
  10322. if (string.IsNullOrEmpty(check))
  10323. {
  10324. returnSuccessMsg("文件名格式不正确");
  10325. return;
  10326. }
  10327. }
  10328. ce.seller_memo = content;
  10329. ce.Update();
  10330. ceErpMessageTip.isVisit = true;
  10331. ceErpMessageTip.Update();
  10332. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10333. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10334. ApiVo apiVo = new ApiVo();
  10335. apiVo.orderNumber = ce.ctid;
  10336. apiVo.actionName = "demandDesign";
  10337. apiVo.orderRemarks = content;
  10338. apiVo.demandExamine = type + 1;
  10339. designHelper.API_WorkCore(apiVo);//demandDesign
  10340. returnSuccessMsg("修改成功!");
  10341. }
  10342. }
  10343. public static string MidStrEx(string sourse, string startstr, string endstr)
  10344. {
  10345. string result = string.Empty;
  10346. int startindex, endindex;
  10347. try
  10348. {
  10349. startindex = sourse.IndexOf(startstr);
  10350. if (startindex == -1)
  10351. return result;
  10352. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10353. endindex = tmpstr.IndexOf(endstr);
  10354. if (endindex == -1)
  10355. return result;
  10356. result = tmpstr.Remove(endindex);
  10357. }
  10358. catch (Exception ex)
  10359. {
  10360. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10361. }
  10362. return result;
  10363. }
  10364. public void refund_order_list()
  10365. {
  10366. int userid = CurrentUser.UserID;
  10367. int sectionId = CurrentUser.UserPost.OrgID;
  10368. StringBuilder sql = new StringBuilder();
  10369. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10370. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10371. DataStruct dStruct = GetPostStruct();
  10372. DataTable dt = null;
  10373. List<string> ids = new List<string>();
  10374. List<string> tids = new List<string>();
  10375. if (dth.Rows.Count > 0)
  10376. {
  10377. foreach (DataRow dr in dth.Rows)
  10378. {
  10379. tids.Add("'" + dr["tid"].ToString() + "'");
  10380. ids.Add(dr["id"].ToString());
  10381. }
  10382. try
  10383. {
  10384. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10385. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10386. List<string> lw = new List<string>();
  10387. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10388. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10389. dt = WebCache.GetData("view_orderlist", dStruct);
  10390. }
  10391. catch (Exception ex)
  10392. {
  10393. }
  10394. }
  10395. writeGridDataTableJson(dStruct.TotalCount, dt);
  10396. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10397. }
  10398. //新增
  10399. public void order_batch_downloads()
  10400. {
  10401. string ceid = GetPostString("tid");
  10402. String[] tid = ceid.Split(',');
  10403. order_batch_caiyingtong(tid);
  10404. /* (string success, string errors) = UploadFiles(tid);
  10405. returnSuccessMsg(success + errors);*/
  10406. return;
  10407. }
  10408. //报价接口
  10409. public void Get_To_Quote()
  10410. {
  10411. string ceid = GetPostString("ctid");
  10412. if (ceid != null)
  10413. {
  10414. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10415. if (entity != null)
  10416. {
  10417. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10418. {
  10419. return;
  10420. }
  10421. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10422. double price = 0;
  10423. if (cp == null)
  10424. {
  10425. JObject jsonObject12 = new JObject
  10426. {
  10427. { "UserId", "77886" },
  10428. { "Pwd", "lt666888" },
  10429. { "Filename", entity.seller_memo }
  10430. };
  10431. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10432. JObject jsonObjects1 = JObject.Parse(response1);
  10433. string ms1g = (string)jsonObjects1["msg"];
  10434. if (ms1g == "报价成功")
  10435. {
  10436. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10437. string data = (string)jsonObject1["price"];
  10438. 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 + "');";
  10439. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10440. returnSuccessMsg("获取报价成功:" + data);
  10441. price = Convert.ToDouble(data);
  10442. }
  10443. else
  10444. {
  10445. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10446. return;
  10447. }
  10448. }
  10449. String[] beizhu = entity.seller_memo.Split('-');
  10450. String chanp = "";
  10451. if (beizhu.Length > 0)
  10452. {
  10453. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10454. }
  10455. else
  10456. {
  10457. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10458. }
  10459. JObject jsonObject = new JObject
  10460. {
  10461. { "UserId", "77886" },
  10462. { "Pwd", "lt666888" },
  10463. { "Filename", chanp }
  10464. };
  10465. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10466. JObject jsonObjects = JObject.Parse(response);
  10467. string msg = (string)jsonObjects["msg"];
  10468. if (msg == "报价成功")
  10469. {
  10470. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10471. string data = (string)jsonObject1["price"];
  10472. 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 + "');";
  10473. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10474. returnSuccessMsg("获取报价成功:" + data);
  10475. price = Convert.ToDouble(data);
  10476. }
  10477. else
  10478. {
  10479. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10480. return;
  10481. }
  10482. if (price > 0)
  10483. {
  10484. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10485. if (ceErpTradeCellExtend == null)
  10486. {
  10487. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10488. ceErpTradeCellExtend.ctid = entity.ctid;
  10489. ceErpTradeCellExtend.payment_cyt = price;
  10490. ceErpTradeCellExtend.Create();
  10491. }
  10492. else
  10493. {
  10494. ceErpTradeCellExtend.payment_cyt = price;
  10495. ceErpTradeCellExtend.Update();
  10496. }
  10497. }
  10498. return;
  10499. }
  10500. }
  10501. else
  10502. {
  10503. returnErrorMsg("请至少选择一条数据");
  10504. return;
  10505. }
  10506. }
  10507. //新增
  10508. public void order_To_Supplier()
  10509. {
  10510. string ceid = GetPostString("tid");
  10511. String[] tid = ceid.Split(',');
  10512. if (tid.Length > 0)
  10513. {
  10514. try
  10515. {
  10516. for (int i = 0; i < tid.Length; i++)
  10517. {
  10518. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10519. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10520. entity.SupplierId = suid;
  10521. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10522. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10523. entity.Update();
  10524. }
  10525. }
  10526. catch (Exception ex)
  10527. {
  10528. returnErrorMsg("自动匹配供应商失败");
  10529. return;
  10530. }
  10531. }
  10532. else
  10533. {
  10534. returnErrorMsg("请至少选择一条数据");
  10535. return;
  10536. }
  10537. returnSuccessMsg("自动匹配供应商成功");
  10538. return;
  10539. }
  10540. public (string, string) UploadFiles(string[] urls)
  10541. {
  10542. string success = "";
  10543. string errors = "";
  10544. int userid = CurrentUser.UserID;
  10545. foreach (string url in urls)
  10546. {
  10547. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10548. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10549. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10550. {
  10551. JObject jsonObject = new JObject
  10552. {
  10553. { "Userid", "77886" },
  10554. { "pwd", "cyt86435015" },
  10555. { "content", base64FileContent },
  10556. { "ext", Path.GetExtension(fileName) }
  10557. };
  10558. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10559. JObject jsonObjects = JObject.Parse(response);
  10560. string msg = (string)jsonObjects["msg"];
  10561. if (msg.Equals("上传成功"))
  10562. {
  10563. success += url + " 上传成功";
  10564. }
  10565. else
  10566. {
  10567. errors += url + " 上传失败";
  10568. }
  10569. }
  10570. else
  10571. {
  10572. errors += url + " 格式出现问题";
  10573. }
  10574. }
  10575. if (urls.Length == 0)
  10576. {
  10577. return (success, errors);
  10578. }
  10579. return (success, errors);
  10580. }
  10581. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10582. {
  10583. return true; //总是接受
  10584. }
  10585. public static string HttpPost(string url, string param = null)
  10586. {
  10587. HttpWebRequest request;
  10588. //如果是发送HTTPS请求
  10589. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10590. {
  10591. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10592. request = WebRequest.Create(url) as HttpWebRequest;
  10593. request.ProtocolVersion = HttpVersion.Version10;
  10594. }
  10595. else
  10596. {
  10597. request = WebRequest.Create(url) as HttpWebRequest;
  10598. }
  10599. request.Method = "POST";
  10600. request.ContentType = "application/json";
  10601. request.Accept = "*/*";
  10602. request.Timeout = 120000;
  10603. request.AllowAutoRedirect = false;
  10604. StreamWriter requestStream = null;
  10605. WebResponse response = null;
  10606. string responseStr = null;
  10607. try
  10608. {
  10609. requestStream = new StreamWriter(request.GetRequestStream());
  10610. requestStream.Write(param);
  10611. requestStream.Close();
  10612. response = request.GetResponse();
  10613. if (response != null)
  10614. {
  10615. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10616. responseStr = reader.ReadToEnd();
  10617. reader.Close();
  10618. }
  10619. }
  10620. catch (Exception ex)
  10621. {
  10622. return ex.Message;
  10623. }
  10624. finally
  10625. {
  10626. request = null;
  10627. requestStream = null;
  10628. response = null;
  10629. }
  10630. return responseStr;
  10631. }
  10632. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10633. {
  10634. string base64FileContent;
  10635. string fileName;
  10636. using (WebClient webClient = new WebClient())
  10637. {
  10638. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10639. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10640. {
  10641. using (Stream stream = response.GetResponseStream())
  10642. {
  10643. using (MemoryStream memoryStream = new MemoryStream())
  10644. {
  10645. stream.CopyTo(memoryStream);
  10646. byte[] fileBytes = memoryStream.ToArray();
  10647. base64FileContent = Convert.ToBase64String(fileBytes);
  10648. fileName = response.Headers["Content-Disposition"];
  10649. if (!string.IsNullOrEmpty(fileName))
  10650. {
  10651. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10652. if (index >= 0)
  10653. {
  10654. fileName = fileName.Substring(index + 9).Trim('\"');
  10655. }
  10656. }
  10657. else
  10658. {
  10659. fileName = Path.GetFileName(downloadUrl);
  10660. }
  10661. }
  10662. }
  10663. }
  10664. }
  10665. return (fileName, base64FileContent);
  10666. }
  10667. //新增
  10668. public void order_batch_caiyingtong(string[] downloadUrls)
  10669. {
  10670. try
  10671. {
  10672. //遍历文件
  10673. DataStruct dStruct = GetPostStruct();
  10674. DataTable dt = null;
  10675. int userid = CurrentUser.UserID;
  10676. List<string> ids = new List<string>();//失败组
  10677. List<string> tids = new List<string>();
  10678. using (WebClient webClient = new WebClient())
  10679. {
  10680. foreach (var url in downloadUrls)
  10681. {
  10682. try
  10683. {
  10684. tids.Add("'" + url + "'");
  10685. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10686. if (entity != null)
  10687. {
  10688. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10689. if (cp == null)
  10690. {
  10691. JObject jsonObject = new JObject
  10692. {
  10693. { "Userid", "77886" },
  10694. { "pwd", "lt666888" },
  10695. { "Filename",entity.seller_memo }
  10696. };
  10697. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10698. JObject jsonObjects = JObject.Parse(response);
  10699. string msg = (string)jsonObjects["msg"];
  10700. if (msg == "报价成功")
  10701. {
  10702. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10703. DownloadAndConvertToBase64(url1);
  10704. }
  10705. else
  10706. {
  10707. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10708. }
  10709. }
  10710. else
  10711. {
  10712. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10713. JObject jsonObject = new JObject
  10714. {
  10715. { "Userid", "77886" },
  10716. { "pwd", "lt666888" },
  10717. { "Filename",chanp }
  10718. };
  10719. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10720. JObject jsonObjects = JObject.Parse(response);
  10721. string msg = (string)jsonObjects["msg"];
  10722. if (msg == "报价成功")
  10723. {
  10724. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10725. DownloadAndConvertToBase64(url1);
  10726. }
  10727. else
  10728. {
  10729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10730. }
  10731. }
  10732. }
  10733. // 上传文件到FTP
  10734. }
  10735. catch (Exception ex)
  10736. {
  10737. Console.WriteLine($"An error occurred: {ex.Message}");
  10738. }
  10739. }
  10740. List<string> lw = new List<string>();
  10741. lw.Add(string.Format("( OrderState < 6 )"));
  10742. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10743. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10744. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10745. if (dt.Rows.Count > 0)
  10746. {
  10747. foreach (DataRow dr in dt.Rows)
  10748. {
  10749. ids.Add(dr["ctid"].ToString());
  10750. }
  10751. }
  10752. String ErrorMsgs = "";
  10753. foreach (String id in ids)
  10754. {
  10755. ErrorMsgs += id + ",";
  10756. }
  10757. if (ErrorMsgs.Length > 1)
  10758. {
  10759. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10760. }
  10761. if (ErrorMsgs.Length < 1)
  10762. {
  10763. ErrorMsgs = "上传成功";
  10764. returnSuccessMsg(ErrorMsgs);
  10765. }
  10766. else
  10767. {
  10768. returnErrorMsg("以下订单" + ErrorMsgs);
  10769. }
  10770. }
  10771. // 删除文件夹及其内容
  10772. /* Directory.Delete(localDirectory, true);*/
  10773. }
  10774. catch { }
  10775. }
  10776. public void get_center_data()
  10777. {
  10778. int userId = CurrentUser.UserID;
  10779. string postCode = CurrentUser.UserPost.Post.Code;
  10780. List<string> lw = new List<string>();
  10781. List<string> ww = new List<string>();
  10782. DateTime currentTime = DateTime.Now;
  10783. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10784. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10785. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10786. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10787. string sql = " SELECT ";
  10788. string startTime = "2023-10-01 11:22:31";
  10789. //设计
  10790. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10791. {
  10792. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10793. 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));
  10794. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10795. 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));
  10796. }
  10797. //客服
  10798. else if (postCode == "CustomerService" || postCode == "Director")
  10799. {
  10800. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10801. 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));
  10802. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10803. 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));
  10804. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10805. 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));
  10806. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10807. 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));
  10808. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10809. 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));
  10810. }
  10811. //售后
  10812. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10813. {
  10814. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10815. 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));
  10816. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10817. 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));
  10818. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10819. 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));
  10820. }
  10821. //下单部
  10822. else if (postCode == "Place" || postCode == "PlaceMr")
  10823. {
  10824. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10825. 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));
  10826. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10827. 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));
  10828. }
  10829. //车间
  10830. else if (postCode == "Supplier")
  10831. {
  10832. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10833. 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));
  10834. }
  10835. DataTable dt = new DataTable();
  10836. if (lw.Count > 0)
  10837. {
  10838. sql += string.Join(" , ", lw);
  10839. sql += " FROM ";
  10840. sql += string.Join(" , ", ww);
  10841. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10842. }
  10843. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10844. }
  10845. public void get_center_data_list()
  10846. {
  10847. int userId = CurrentUser.UserID;
  10848. string postCode = CurrentUser.UserPost.Post.Code;
  10849. string shopIds = CurrentUser.User.pemShop;
  10850. DataStruct dStruct = GetPostStruct();
  10851. List<string> lw = new List<string>();
  10852. DateTime currentTime = DateTime.Now;
  10853. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10854. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10855. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10856. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10857. string startTime = "2023-10-01 11:22:31";
  10858. int order_type = GetPostInt("order_type");
  10859. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10860. {
  10861. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10862. if (order_type == 0)
  10863. {
  10864. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10865. }
  10866. else if (order_type == 3)
  10867. {
  10868. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10869. }
  10870. else
  10871. {
  10872. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10873. }
  10874. }
  10875. //客服
  10876. if (postCode == "CustomerService" || postCode == "Director")
  10877. {
  10878. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10879. if (order_type == 0)
  10880. {
  10881. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10882. }
  10883. else if (order_type == 1)
  10884. {
  10885. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10886. }
  10887. else if (order_type == 2)
  10888. {
  10889. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10890. }
  10891. else if (order_type == 3)
  10892. {
  10893. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10894. }
  10895. else if (order_type == 4)
  10896. {
  10897. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10898. }
  10899. else
  10900. {
  10901. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10902. }
  10903. }
  10904. //售后
  10905. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10906. {
  10907. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10908. if (shopIds != "")
  10909. {
  10910. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10911. }
  10912. if (order_type == 2)
  10913. {
  10914. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10915. }
  10916. else if (order_type == 4)
  10917. {
  10918. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10919. }
  10920. else if (order_type == 5)
  10921. {
  10922. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10923. }
  10924. else
  10925. {
  10926. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10927. }
  10928. }
  10929. //下单部
  10930. if (postCode == "Place" || postCode == "PlaceMr")
  10931. {
  10932. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10933. if (shopIds != "")
  10934. {
  10935. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10936. }
  10937. else if (order_type == 1)
  10938. {
  10939. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10940. }
  10941. else if (order_type == 2)
  10942. {
  10943. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10944. }
  10945. else
  10946. {
  10947. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10948. }
  10949. }
  10950. //车间
  10951. if (postCode == "Supplier")
  10952. {
  10953. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10954. if (order_type == 5)
  10955. {
  10956. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10957. }
  10958. else
  10959. {
  10960. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10961. }
  10962. }
  10963. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10964. dStruct.Fileds = "tid,ctid";
  10965. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10966. writeGridDataTableJson(dStruct.TotalCount, dt);
  10967. }
  10968. public void aftersale_audit_master()
  10969. {
  10970. if (UrlPostParmsCheck("ctid"))
  10971. {
  10972. string ctid = GetPostString("ctid");
  10973. if (ctid.Length > 0)
  10974. {
  10975. bool result = aftersale_data_change(ctid);
  10976. if (result)
  10977. {
  10978. returnSuccessMsg("修改成功!");
  10979. return;
  10980. }
  10981. }
  10982. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10983. }
  10984. }
  10985. public void aftersale_batch_audit_master()
  10986. {
  10987. if (UrlPostParmsCheck("ctids"))
  10988. {
  10989. string ctids = GetPostString("ctids");
  10990. if (ctids.Length > 0)
  10991. {
  10992. List<string> list = new List<string>();
  10993. string[] ctid_list = ctids.Split(',');
  10994. foreach (var item in ctid_list)
  10995. {
  10996. bool result = aftersale_data_change(item);
  10997. if (!result)
  10998. {
  10999. list.Add(item);
  11000. }
  11001. }
  11002. if (list.Count > 0)
  11003. {
  11004. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11005. return;
  11006. }
  11007. returnSuccessMsg("修改成功!");
  11008. return;
  11009. }
  11010. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11011. }
  11012. }
  11013. public bool aftersale_data_change(string ctid)
  11014. {
  11015. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11016. if (ceErpTradeCell != null)
  11017. {
  11018. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11019. ceErpTradeCell.AfterSaleSupplierState = 0;
  11020. StringBuilder sql = new StringBuilder();
  11021. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11022. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11023. CeErpTradeResponsible.DelByTid(ctid, 0);
  11024. 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 == "不理赔")
  11025. {
  11026. CeErpTradeResponsible.DelByTid(ctid, 1);
  11027. ceErpTradeCell.AfterSaleSupplierState = 1;
  11028. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11029. ceErpTradeCell.AfterSaleState = 4;
  11030. }
  11031. else
  11032. {
  11033. ceErpTradeCell.AfterSaleState = 3;
  11034. }
  11035. bool needCyt = false;
  11036. if (dt != null)
  11037. {
  11038. if (dt.Rows.Count == 1)
  11039. {
  11040. bool isEnd = false;
  11041. foreach (DataRow dr in dt.Rows)
  11042. {
  11043. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11044. {
  11045. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11046. isEnd = true;
  11047. }
  11048. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11049. {
  11050. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11051. isEnd = true;
  11052. }
  11053. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11054. {
  11055. needCyt = true;
  11056. }
  11057. }
  11058. if (isEnd)
  11059. {
  11060. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11061. ceErpTradeCell.AfterSaleState = 4;
  11062. ceErpTradeCell.AfterSaleSupplierState = 1;
  11063. }
  11064. }
  11065. else
  11066. {
  11067. bool isAll = true;
  11068. foreach (DataRow dr in dt.Rows)
  11069. {
  11070. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11071. {
  11072. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11073. continue;
  11074. }
  11075. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11076. {
  11077. string path = "";
  11078. int OrgID = 0;
  11079. if (!Convert.IsDBNull(dr["OrgPath"]))
  11080. {
  11081. path = dr["OrgPath"].ToString();
  11082. }
  11083. if (!Convert.IsDBNull(dr["OrgID"]))
  11084. {
  11085. OrgID = Convert.ToInt32(dr["OrgID"]);
  11086. }
  11087. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11088. {
  11089. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11090. continue;
  11091. }
  11092. }
  11093. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11094. {
  11095. needCyt = true;
  11096. }
  11097. isAll = false;
  11098. }
  11099. if (isAll)
  11100. {
  11101. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11102. ceErpTradeCell.AfterSaleState = 4;
  11103. ceErpTradeCell.AfterSaleSupplierState = 1;
  11104. }
  11105. }
  11106. }
  11107. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11108. {
  11109. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11110. }
  11111. if (ceErpTradeCell.AfterSaleState == 4)
  11112. {
  11113. ApiVo apiVo = new ApiVo();
  11114. apiVo.orderNumber = ceErpTradeCell.ctid;
  11115. apiVo.actionName = "afterOver";
  11116. designHelper.API_WorkCore(apiVo); //afterOver
  11117. }
  11118. ceErpTradeCell.Update();
  11119. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11120. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11121. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11122. return true;
  11123. }
  11124. return false;
  11125. }
  11126. public void get_erp_wechatorder()
  11127. {
  11128. DataStruct dStruct = GetPostStruct();
  11129. List<string> lw = new List<string>();
  11130. string tid = GetPostString("tid");
  11131. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11132. string shopname = GetPostString("shopname");
  11133. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11134. string buyernick = GetPostString("buyer_nick");
  11135. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11136. string customer = GetPostString("customer");
  11137. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11138. string returndate1 = GetPostString("returndate1");
  11139. string returndate2 = GetPostString("returndate2");
  11140. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11141. if (dw.Length > 0) lw.Add(dw);
  11142. string finishDate1 = GetPostString("finishdate1");
  11143. string finishDate2 = GetPostString("finishdate2");
  11144. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11145. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11146. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11147. dStruct.Order = "created desc";
  11148. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11149. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11150. writeGridDataTableJson(dStruct.TotalCount, dt);
  11151. }
  11152. public void get_erp_wechatlist_sumprice()
  11153. {
  11154. DataStruct dStruct = GetPostStruct();
  11155. List<string> lw = new List<string>();
  11156. string tid = GetPostString("tid");
  11157. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11158. string shopname = GetPostString("shopname");
  11159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11160. string buyernick = GetPostString("buyer_nick");
  11161. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11162. string customer = GetPostString("customer");
  11163. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11164. string returndate1 = GetPostString("returndate1");
  11165. string returndate2 = GetPostString("returndate2");
  11166. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11167. if (dw.Length > 0) lw.Add(dw);
  11168. string finishDate1 = GetPostString("finishdate1");
  11169. string finishDate2 = GetPostString("finishdate2");
  11170. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11171. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11172. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11173. string mainWhere = string.Join(" and ", lw.ToArray());
  11174. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11175. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11176. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11177. decimal total = 0;
  11178. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11179. {
  11180. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11181. }
  11182. var res = new
  11183. {
  11184. data = total
  11185. };
  11186. string ro_jsond = JsonConvert.SerializeObject(res);
  11187. returnSuccess(ro_jsond);
  11188. return;
  11189. }
  11190. public void get_erp_qr_waitdeliverylist()
  11191. {
  11192. DataStruct dStruct = GetPostStruct();
  11193. List<string> lw = new List<string>();
  11194. string tid = GetPostString("ctid");
  11195. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11196. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11197. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11198. var res_objz = new
  11199. {
  11200. restype = 1,
  11201. data = dt
  11202. };
  11203. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11204. returnSuccess(ro_jsonz);
  11205. }
  11206. public void get_erp_yield_list()
  11207. {
  11208. DataStruct dStruct = GetPostStruct();
  11209. List<string> lw = new List<string>();
  11210. string tid = GetPostString("ctid");
  11211. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11212. string shopname = GetPostString("shopname");
  11213. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11214. string buyernick = GetPostString("buyer_nick");
  11215. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11216. //if (tid.Length == 0 && buyernick.Length == 0)
  11217. //{
  11218. // lw.Add(string.Format("IsRefund<={0}", 1));
  11219. //}
  11220. string customer = GetPostString("customer");
  11221. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11222. string design = GetPostString("design");
  11223. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11224. string orderState = GetPostString("orderState");
  11225. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11226. string address = GetPostString("address");
  11227. 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));
  11228. string sellermemo = GetPostString("seller_memo");
  11229. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11230. string supplier = GetPostString("supplier");
  11231. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11232. string OrderArea = GetPostString("order_area");
  11233. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11234. string placedate1 = GetPostString("placedate1");
  11235. string placedate2 = GetPostString("placedate2");
  11236. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11237. if (fdw.Length > 0) lw.Add(fdw);
  11238. string price1 = GetPostString("price1");
  11239. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11240. string price2 = GetPostString("price2");
  11241. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11242. string unusualCon = GetPostString("unusualcon");
  11243. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11244. string posTag = CurrentUser.UserPost.Post.Code;
  11245. if (posTag == "Supplier")
  11246. {
  11247. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11248. }
  11249. lw.Add(string.Format("OrderState = 6 "));
  11250. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11251. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11253. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11254. writeGridDataTableJson(dStruct.TotalCount, dt);
  11255. }
  11256. public void change_erp_sup_state()
  11257. {
  11258. if (UrlPostParmsCheck("ctid"))
  11259. {
  11260. string ctid = GetPostString("ctid");
  11261. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11262. if (ceErpTradeCell != null)
  11263. {
  11264. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11265. if (ceErpTradeCellExtend == null)
  11266. {
  11267. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11268. ceErpTradeCellExtend.ctid = ctid;
  11269. ceErpTradeCellExtend.SupState = 1;
  11270. ceErpTradeCellExtend.Create();
  11271. }
  11272. else
  11273. {
  11274. ceErpTradeCellExtend.SupState = 1;
  11275. ceErpTradeCellExtend.Update();
  11276. }
  11277. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11278. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11279. return;
  11280. }
  11281. returnErrorMsg("找不到订单");
  11282. }
  11283. }
  11284. public void supplier_all_downs()
  11285. {
  11286. if (UrlPostParmsCheck("tids"))
  11287. {
  11288. string tids = GetPostString("tids");
  11289. if (tids != null && tids.Length > 0)
  11290. {
  11291. StringBuilder sql = new StringBuilder();
  11292. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11293. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11294. sql = new StringBuilder();
  11295. 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, "下载设计文件");
  11296. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11297. string[] list = tids.Split(',');
  11298. foreach (string ctid in list)
  11299. {
  11300. CeErpSukuraData.createInfo(ctid, 3);
  11301. }
  11302. designHelper.api_approveDesign(tids); //approveDesign
  11303. returnSuccessMsg("下载成功!");
  11304. return;
  11305. }
  11306. returnErrorMsg("下载订单更新失败");
  11307. }
  11308. }
  11309. public void uploaderFileSuccess()
  11310. {
  11311. if (UrlPostParmsCheck("fileName"))
  11312. {
  11313. string fileName = GetPostString("fileName");
  11314. ApiVo apiVo = new ApiVo();
  11315. apiVo.orderNumber = fileName;
  11316. apiVo.actionName = "finishDesign";
  11317. designHelper.API_WorkCore(apiVo);//finishDesign
  11318. returnSuccessMsg("");
  11319. }
  11320. }
  11321. public void get_sample2_order()
  11322. {
  11323. if (UrlPostParmsCheck("ctid"))
  11324. {
  11325. string ctid = GetPostString("ctid");
  11326. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11327. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11328. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11329. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11330. double total = 0.0;
  11331. double order_price = 0.0;
  11332. if (dt_bu.Rows.Count > 0)
  11333. {
  11334. foreach (DataRow dr in dt_bu.Rows)
  11335. {
  11336. total += Convert.ToDouble(dr["payment"]);
  11337. }
  11338. }
  11339. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11340. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11341. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11342. string tid = ctid.Replace("S_", "");
  11343. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11344. double paymant = 0.0;
  11345. if (entity != null)
  11346. {
  11347. paymant = entity.payment;
  11348. }
  11349. string return_reason = "";
  11350. if (dt_after != null && dt_after.Rows.Count > 0)
  11351. {
  11352. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11353. }
  11354. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11355. }
  11356. }
  11357. public void get_erp_design_status()
  11358. {
  11359. string designName = GetPostString("designName");
  11360. DataStruct dStruct = GetPostStruct();
  11361. if (designName.Length > 0)
  11362. {
  11363. 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";
  11364. sql_user += " and Name like '%" + designName + "%'";
  11365. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11366. List<string> ids_list = new List<string>();
  11367. if (user_table.Rows.Count > 0)
  11368. {
  11369. foreach (DataRow item in user_table.Rows)
  11370. {
  11371. ids_list.Add(item["id"].ToString());
  11372. string ids_s = item["TeamIds"].ToString();
  11373. if (ids_s.Length > 0)
  11374. {
  11375. ids_list.AddRange(ids_s.Split(','));
  11376. }
  11377. }
  11378. }
  11379. HashSet<string> set = new HashSet<string>(ids_list);
  11380. ids_list = set.ToList();
  11381. if (ids_list.Count > 0)
  11382. {
  11383. 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));
  11384. dStruct.MainWhere = sql;
  11385. DataTable dt = null;
  11386. dt = WebCache.GetData("view_ErpUser", dStruct);
  11387. writeGridDataTableJson(dStruct.TotalCount, dt);
  11388. }
  11389. }
  11390. }
  11391. public void change_erp_order_price()
  11392. {
  11393. string ctid = GetPostString("ctid");
  11394. double price = GetPostDouble("price");
  11395. if (ctid.Length > 0)
  11396. {
  11397. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11398. if (ceErpTradeCellExtend == null)
  11399. {
  11400. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11401. ceErpTradeCellExtend.ctid = ctid;
  11402. ceErpTradeCellExtend.payment_cyt = price;
  11403. ceErpTradeCellExtend.Create();
  11404. }
  11405. else
  11406. {
  11407. ceErpTradeCellExtend.payment_cyt = price;
  11408. ceErpTradeCellExtend.Update();
  11409. }
  11410. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11411. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11412. {
  11413. ceErpDataSendOrderInfo.isSync = false;
  11414. ceErpDataSendOrderInfo.Update();
  11415. }
  11416. if (ceErpDataSendOrderInfo == null)
  11417. {
  11418. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11419. ceErpDataSendOrderInfo.isSync = false;
  11420. ceErpDataSendOrderInfo.ctid = ctid;
  11421. ceErpDataSendOrderInfo.Create();
  11422. }
  11423. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11424. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11425. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11426. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11427. {
  11428. dataSendOrderBean dataSendOrderBean = null;
  11429. foreach (DataRow item in dth.Rows)
  11430. {
  11431. try
  11432. {
  11433. dataSendOrderBean = new dataSendOrderBean();
  11434. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11435. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11436. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11437. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11438. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11439. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11440. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11441. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11442. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11443. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11444. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11445. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11446. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11447. if (result != null)
  11448. {
  11449. if ("0".Equals(result.errcode))
  11450. {
  11451. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11452. }
  11453. else
  11454. {
  11455. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11456. }
  11457. }
  11458. }
  11459. catch (Exception ex)
  11460. {
  11461. }
  11462. }
  11463. }
  11464. returnSuccessMsg("修改成功!");
  11465. return;
  11466. }
  11467. returnErrorMsg("找不到订单");
  11468. }
  11469. public void find_he_together()
  11470. {
  11471. string ctid = GetPostString("ctid");
  11472. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11473. List<string> list = new List<string>();
  11474. if (ceErpTradeCell != null)
  11475. {
  11476. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11477. {
  11478. 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);
  11479. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11480. if (table != null && table.Rows.Count > 0)
  11481. {
  11482. foreach (TableRow row in table.Rows)
  11483. {
  11484. }
  11485. }
  11486. }
  11487. }
  11488. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11489. }
  11490. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11491. {
  11492. //chy----19
  11493. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11494. //GD-CYT-----64
  11495. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11496. //ZHX----3
  11497. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11498. //JK----97
  11499. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11500. //ZT----70
  11501. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11502. //GD-CYTUV---126
  11503. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11504. //LHCY-----98
  11505. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11506. //XD-----90
  11507. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11508. //CYCY-----14
  11509. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}},
  11510. //THLZY----122
  11511. {122, new Dictionary<string, string> {{ "烫画", "烫画" }, { "冷转印", "冷转印" }}}
  11512. };
  11513. //其他改名
  11514. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11515. {
  11516. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11517. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11518. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11519. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11520. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11521. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11522. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11523. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" },{ 129,"种子纸"},{ 125,"胶带"},{ 127,"PET透卡"}
  11524. };
  11525. //不统计
  11526. List<int> no_suppliers = new List<int>()
  11527. {
  11528. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11529. };
  11530. //配件单
  11531. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11532. {
  11533. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11534. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11535. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11536. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11537. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11538. {"旗杆",new List<string>(){ "班旗" } },
  11539. {"牙签",new List<string>(){ "不干胶" } }
  11540. };
  11541. public void get_place_order_data()
  11542. {
  11543. string date1 = GetPostString("date1");
  11544. string date2 = GetPostString("date2");
  11545. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11546. DateTime start = DateTime.Parse(starttime);
  11547. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11548. DateTime end = DateTime.Parse(endtime);
  11549. if (date1 != null && date1.Length > 0)
  11550. {
  11551. DateTime dateTime = DateTime.Parse(date1);
  11552. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11553. start = DateTime.Parse(starttime);
  11554. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11555. end = DateTime.Parse(endtime);
  11556. }
  11557. if (date2 != null && date2.Length > 0)
  11558. {
  11559. DateTime dateTime = DateTime.Parse(date2);
  11560. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11561. end = DateTime.Parse(endtime);
  11562. }
  11563. string startMonthDate = commonHelper.FirstDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 00:00:00");
  11564. string endMonthDate = commonHelper.LastDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 23:59:59");
  11565. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime,AfterSaleState=0,AfterSaleReason = '' 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);
  11566. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11567. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState,AfterSaleReason FROM view_ErpTradeCell WHERE ( AfterSalePreTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime IS NOT NULL", startMonthDate, endMonthDate);
  11568. DataTable afterSaleData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11569. data.Merge(afterSaleData);
  11570. //不干胶-----1,卡片-----29
  11571. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11572. foreach (DataRow row in data.Rows)
  11573. {
  11574. int productId = Convert.ToInt32(row["ProductId"]);
  11575. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11576. if (no_suppliers.Contains(supplierId))
  11577. {
  11578. continue;
  11579. }
  11580. string seller_memo = row["seller_memo"].ToString();
  11581. bool ispj = false;//是否配件单
  11582. bool isfirst = true;//第一个配
  11583. maps.Keys.ForEach(key =>
  11584. {
  11585. //备注包含配件
  11586. if (seller_memo.Contains(key) && isfirst)
  11587. {
  11588. List<string> list = maps[key];
  11589. ispj = true;
  11590. isfirst = false;
  11591. for (int i = 0; i < list.Count; i++)
  11592. {
  11593. if (seller_memo.Contains(list[i]))
  11594. {
  11595. ispj = false;
  11596. break;
  11597. }
  11598. }
  11599. }
  11600. });
  11601. if (ispj)
  11602. {
  11603. continue;
  11604. }
  11605. seller_memo = seller_memo.Replace("UV", "uv");
  11606. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11607. //吊牌归到卡片
  11608. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11609. seller_memo = seller_memo.Replace("卡套", "卡片");
  11610. seller_memo = seller_memo.Replace("封套", "卡片");
  11611. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11612. seller_memo = seller_memo.Replace("腰封", "卡片");
  11613. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11614. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11615. seller_memo = seller_memo.Replace("横幅", "条幅");
  11616. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11617. string map_key = "";
  11618. string type = "";
  11619. if (supplierMap.ContainsKey(supplierId))
  11620. {
  11621. foreach (var kvp in supplierMap[supplierId])
  11622. {
  11623. if (seller_memo.Contains(kvp.Key))
  11624. {
  11625. map_key = kvp.Value;
  11626. type = kvp.Value;
  11627. break;
  11628. }
  11629. }
  11630. }
  11631. if (map_key == "")
  11632. {
  11633. type = "其他";
  11634. map_key = "其他";
  11635. }
  11636. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11637. {
  11638. map_key = suppliers[supplierId];
  11639. }
  11640. if (supplierId == 70)
  11641. {
  11642. supplierId = 70;
  11643. }
  11644. map_key += "_" + row["SupplierName"].ToString();
  11645. Dictionary<string, int> map = null;
  11646. if (other_map.ContainsKey(map_key))
  11647. {
  11648. other_map.TryGetValue(map_key, out map);
  11649. }
  11650. else
  11651. {
  11652. map = new Dictionary<string, int>();
  11653. map.Add("dayDev", 0);//当天出货
  11654. map.Add("dayTotal", 0);//下单总数
  11655. map.Add("payTotal", 0);//500以上
  11656. map.Add("today", 0);//当天出货数量
  11657. map.Add("unusua", 0);//异常数
  11658. map.Add("aftersale", 0);//异常数
  11659. other_map.Add(map_key, map);
  11660. other_map.TryGetValue(map_key, out map);
  11661. }
  11662. int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
  11663. if (afterSaleState == 0)
  11664. {
  11665. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11666. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11667. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11668. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11669. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11670. {
  11671. map["dayTotal"]++;
  11672. if (supplierId == 97)
  11673. {
  11674. supplierId = 97;
  11675. }
  11676. }
  11677. if (Convert.ToDecimal(row["payment"]) >= 500)
  11678. {
  11679. map["payTotal"]++;
  11680. }
  11681. bool istoday = false;
  11682. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11683. {
  11684. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11685. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11686. {
  11687. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11688. {
  11689. map["today"]++;
  11690. }
  11691. }
  11692. else
  11693. {
  11694. if (supplierId == 80 || supplierId == 126)
  11695. {
  11696. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11697. {
  11698. map["today"]++;
  11699. }
  11700. }
  11701. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11702. {
  11703. map["today"]++;
  11704. istoday = true;
  11705. }
  11706. }
  11707. }
  11708. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11709. {
  11710. map["unusua"]++;
  11711. }
  11712. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11713. //GD-CYT-----64
  11714. DateTime two = palceTimeStart.AddHours(14);
  11715. DateTime three = palceTimeStart.AddHours(15);
  11716. DateTime four = palceTimeStart.AddHours(16);
  11717. DateTime six = palceTimeStart.AddHours(18);
  11718. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11719. {
  11720. //下午四点前 500-1000
  11721. string count = row["ProductCount"].ToString();
  11722. if (count != null && count.Length > 0)
  11723. {
  11724. int productCount = commonHelper.getPlaceProductCount(count);
  11725. if (productCount >= 500 && productCount <= 1000)
  11726. {
  11727. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11728. {
  11729. map["dayDev"]++;
  11730. }
  11731. }
  11732. }
  11733. }
  11734. //UV
  11735. else if ("uv".Equals(type))
  11736. {
  11737. //ZT----70
  11738. //ZHX----3
  11739. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11740. {
  11741. map["dayDev"]++;
  11742. }
  11743. //JK----97
  11744. //HZX----105
  11745. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11746. {
  11747. map["dayDev"]++;
  11748. }
  11749. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11750. {
  11751. map["dayDev"]++;
  11752. }
  11753. }
  11754. //帆布---52|条幅---27
  11755. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11756. {
  11757. //LHCY-----98
  11758. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11759. {
  11760. map["dayDev"]++;
  11761. }
  11762. }
  11763. //条幅
  11764. else if ("条幅".Equals(type))
  11765. {
  11766. //XD-----90
  11767. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11768. {
  11769. map["dayDev"]++;
  11770. }
  11771. }
  11772. //桌布
  11773. else if ("桌布".Equals(type))
  11774. {
  11775. //XD-----90
  11776. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11777. {
  11778. map["dayDev"]++;
  11779. }
  11780. }
  11781. //DL---10
  11782. //AYTW---119
  11783. //FS-CYT-DY ----80
  11784. //JK----97
  11785. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11786. {
  11787. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11788. {
  11789. map["dayDev"]++;
  11790. if (supplierId == 80 && istoday)
  11791. {
  11792. Debug.WriteLine(seller_memo);
  11793. }
  11794. }
  11795. }
  11796. // QC---121
  11797. else if (supplierId == 121)
  11798. {
  11799. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11800. {
  11801. map["dayDev"]++;
  11802. }
  11803. }
  11804. }
  11805. else
  11806. {
  11807. if (row["AfterSaleReason"].ToString().Contains("车间责任"))
  11808. {
  11809. map["aftersale"]++;
  11810. }
  11811. }
  11812. }
  11813. DataTable dt = new DataTable();
  11814. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11815. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11816. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11817. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11818. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11819. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11820. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11821. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11822. dt.Columns.Add(new DataColumn("aftersale", typeof(string)));
  11823. other_map.Keys.ForEach(key =>
  11824. {
  11825. DataRow dr = dt.NewRow();
  11826. Dictionary<string, int> map = other_map[key];
  11827. string[] key_list = key.Split('_');
  11828. dr[0] = key_list[0];
  11829. dr[1] = key_list[1];
  11830. if (key_list.Length > 2)
  11831. {
  11832. dr[1] += "(" + key_list[2] + ")";
  11833. }
  11834. dr[2] = map["dayTotal"];
  11835. dr[3] = map["payTotal"];
  11836. dr[4] = map["today"];
  11837. dr[5] = map["unusua"];
  11838. dr[6] = map["dayDev"];
  11839. double rate = 0.00;
  11840. if (map["dayDev"] > 0)
  11841. {
  11842. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11843. }
  11844. dr[7] = rate.ToString();
  11845. dr[8] = map["aftersale"];
  11846. dt.Rows.Add(dr);
  11847. });
  11848. DataView dv = new DataView(dt);
  11849. dv.Sort = "SupplierName";
  11850. //dv.Sort = "ProductName desc";
  11851. DataTable dtNew = dv.ToTable();
  11852. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11853. }
  11854. public void check_order_desing_info()
  11855. {
  11856. string ctid = GetPostString("ctid");
  11857. if (!string.IsNullOrEmpty(ctid))
  11858. {
  11859. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11860. if (ceErpTradeCell != null)
  11861. {
  11862. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11863. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11864. return;
  11865. }
  11866. returnErrorMsg("找不到订单");
  11867. return;
  11868. }
  11869. returnErrorMsg("找不到订单");
  11870. }
  11871. public void get_timeout_detail()
  11872. {
  11873. string poscode = CurrentUser.UserPost.Post.Code;
  11874. DataStruct dStruct = GetPostStruct();
  11875. List<string> lw = new List<string>();
  11876. string id = GetPostString("id");
  11877. string pay_date1 = GetPostString("pay_date1");
  11878. string pay_date2 = GetPostString("pay_date2");
  11879. int type = GetPostInt("type");
  11880. if (type == 0)
  11881. {
  11882. if (pay_date1.Length > 0)
  11883. {
  11884. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11885. }
  11886. if (pay_date2.Length > 0)
  11887. {
  11888. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11889. }
  11890. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11891. }
  11892. if (type == 1)
  11893. {
  11894. if (pay_date1.Length > 0)
  11895. {
  11896. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11897. }
  11898. if (pay_date2.Length > 0)
  11899. {
  11900. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11901. }
  11902. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11903. }
  11904. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11905. DataTable dt = null;
  11906. dt = WebCache.GetData("view_orderlist", dStruct);
  11907. writeGridDataTableJson(dStruct.TotalCount, dt);
  11908. }
  11909. public void saveUrgentChargePrice()
  11910. {
  11911. string ctid = GetPostString("ctid");
  11912. if (!string.IsNullOrEmpty(ctid))
  11913. {
  11914. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11915. if (ceErpTradeCell != null)
  11916. {
  11917. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11918. if (prices <= 100)
  11919. {
  11920. returnErrorMsg("此订单金额不足100元,无法加急。");
  11921. return;
  11922. }
  11923. double price = GetPostDouble("price");
  11924. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11925. if (ceErpTradeCellExtend == null)
  11926. {
  11927. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11928. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11929. }
  11930. ceErpTradeCellExtend.urgentCharge = price;
  11931. if (ceErpTradeCellExtend.ID > 0)
  11932. {
  11933. ceErpTradeCellExtend.Update();
  11934. }
  11935. else
  11936. {
  11937. ceErpTradeCellExtend.Save();
  11938. }
  11939. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11940. returnSuccessMsg("修改成功!");
  11941. return;
  11942. }
  11943. returnErrorMsg("找不到订单");
  11944. return;
  11945. }
  11946. returnErrorMsg("找不到订单");
  11947. }
  11948. public void finish_erp_order()
  11949. {
  11950. string ctid = GetPostString("ctid");
  11951. if (!string.IsNullOrEmpty(ctid))
  11952. {
  11953. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11954. {
  11955. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11956. if (ceErpTradeCell != null)
  11957. {
  11958. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11959. ceErpTradeCell.Update();
  11960. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11961. returnSuccessMsg("修改成功!");
  11962. return;
  11963. }
  11964. }
  11965. }
  11966. returnErrorMsg("找不到订单");
  11967. }
  11968. public void get_trade_order_list()
  11969. {
  11970. string tid = GetPostString("tid");
  11971. if (!string.IsNullOrEmpty(tid))
  11972. {
  11973. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11974. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11975. writeGridDataTableJson(data.Rows.Count, data);
  11976. return;
  11977. }
  11978. returnErrorMsg("找不到订单");
  11979. }
  11980. public void save_cell_spu()
  11981. {
  11982. string ctid = GetPostString("ctid");
  11983. string spu_id = GetPostString("spu_id");
  11984. if (!string.IsNullOrEmpty(ctid))
  11985. {
  11986. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11987. if (ceErpTradeCellExtend == null)
  11988. {
  11989. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11990. ceErpTradeCellExtend.ctid = ctid;
  11991. }
  11992. ceErpTradeCellExtend.spu_id = spu_id;
  11993. if (!string.IsNullOrEmpty(spu_id))
  11994. {
  11995. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11996. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11997. }
  11998. if (ceErpTradeCellExtend.ID == 0)
  11999. {
  12000. ceErpTradeCellExtend.Create();
  12001. }
  12002. else
  12003. {
  12004. ceErpTradeCellExtend.Update();
  12005. }
  12006. returnSuccessMsg("修改成功!");
  12007. return;
  12008. }
  12009. returnErrorMsg("找不到订单");
  12010. }
  12011. public void change_express_info()
  12012. {
  12013. string ctid = GetPostString("ctid");
  12014. string transNo = GetPostString("transNo");
  12015. string transCom = GetPostString("transCom");
  12016. if (!string.IsNullOrEmpty(ctid))
  12017. {
  12018. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12019. if (ceErpTradeCellExtend == null)
  12020. {
  12021. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12022. ceErpTradeCellExtend.ctid = ctid;
  12023. }
  12024. ceErpTradeCellExtend.modExpressNo = transNo;
  12025. ceErpTradeCellExtend.modExpressCom = transCom;
  12026. ceErpTradeCellExtend.readMod = 2;
  12027. if (ceErpTradeCellExtend.ID == 0)
  12028. {
  12029. ceErpTradeCellExtend.Create();
  12030. }
  12031. else
  12032. {
  12033. ceErpTradeCellExtend.Update();
  12034. }
  12035. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12036. returnSuccessMsg("修改成功!");
  12037. return;
  12038. }
  12039. returnErrorMsg("找不到订单");
  12040. }
  12041. public void get_change_express_list()
  12042. {
  12043. DataStruct dStruct = GetPostStruct();
  12044. List<string> lw = new List<string>();
  12045. int st = 2;
  12046. string tid = GetPostString("ctid");
  12047. if (tid.Length > 0)
  12048. {
  12049. string select_tid = getTidByCtid(tid);
  12050. lw.Add(string.Format("tid='{0}'", select_tid));
  12051. }
  12052. string shopname = GetPostString("shopname");
  12053. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12054. string buyernick = GetPostString("buyer_nick");
  12055. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12056. string sellermemo = GetPostString("seller_memo");
  12057. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12058. string supplier = GetPostString("supplier");
  12059. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12060. string customer = GetPostString("customer");
  12061. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12062. string design = GetPostString("design");
  12063. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12064. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12065. string poscode = CurrentUser.UserPost.Post.Code;
  12066. if (poscode != "SysAdmin")
  12067. {
  12068. string shopid = CurrentUser.User.pemShop;
  12069. lw.Add(string.Format("shopId in ({0})", shopid));
  12070. }
  12071. lw.Add("readMod = 2");
  12072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12073. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12074. writeGridDataTableJson(dStruct.TotalCount, dt);
  12075. }
  12076. public void deal_express_complete()
  12077. {
  12078. string ctid = GetPostString("ctid");
  12079. if (!string.IsNullOrEmpty(ctid))
  12080. {
  12081. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12082. if (ceErpTradeCellExtend == null)
  12083. {
  12084. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12085. ceErpTradeCellExtend.ctid = ctid;
  12086. }
  12087. ceErpTradeCellExtend.readMod = 1;
  12088. if (ceErpTradeCellExtend.ID == 0)
  12089. {
  12090. ceErpTradeCellExtend.Create();
  12091. }
  12092. else
  12093. {
  12094. ceErpTradeCellExtend.Update();
  12095. }
  12096. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12097. returnSuccessMsg("修改成功!");
  12098. return;
  12099. }
  12100. returnErrorMsg("找不到订单");
  12101. }
  12102. public void aftersale_return_visit()
  12103. {
  12104. string ctid = GetPostString("ctid");
  12105. if (!string.IsNullOrEmpty(ctid))
  12106. {
  12107. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12108. if (ceErpTradeCellExtend == null)
  12109. {
  12110. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12111. ceErpTradeCellExtend.ctid = ctid;
  12112. }
  12113. ceErpTradeCellExtend.returnVisit = 1;
  12114. if (ceErpTradeCellExtend.ID == 0)
  12115. {
  12116. ceErpTradeCellExtend.Create();
  12117. }
  12118. else
  12119. {
  12120. ceErpTradeCellExtend.Update();
  12121. }
  12122. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12123. if (ceErpTradeAfterSaleExtend != null)
  12124. {
  12125. ceErpTradeAfterSaleExtend.TextResult = "";
  12126. ceErpTradeAfterSaleExtend.Update();
  12127. }
  12128. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12129. returnSuccessMsg("修改成功!");
  12130. return;
  12131. }
  12132. returnErrorMsg("找不到订单");
  12133. }
  12134. public void orderPlaceInfo()
  12135. {
  12136. string ctids = GetPostString("ctids");
  12137. string[] list = ctids.Split(',');
  12138. foreach (string ctid in list)
  12139. {
  12140. CeErpSukuraData.createInfo(ctid, 3);
  12141. }
  12142. StringBuilder sql = new StringBuilder();
  12143. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12144. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12145. designHelper.api_approveDesign(ctids); //approveDesign
  12146. returnSuccessMsg("");
  12147. }
  12148. public void get_issue_list()
  12149. {
  12150. DataStruct dStruct = GetPostStruct();
  12151. List<string> lw = new List<string>();
  12152. int st = 2;
  12153. string tid = GetPostString("ctid");
  12154. if (tid.Length > 0)
  12155. {
  12156. string select_tid = getTidByCtid(tid);
  12157. lw.Add(string.Format("tid='{0}'", select_tid));
  12158. }
  12159. string shopname = GetPostString("shopname");
  12160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12161. string buyernick = GetPostString("buyer_nick");
  12162. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12163. string sellermemo = GetPostString("seller_memo");
  12164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12165. string supplier = GetPostString("supplier");
  12166. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12167. string customer = GetPostString("customer");
  12168. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12169. string design = GetPostString("design");
  12170. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12171. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12172. string poscode = CurrentUser.UserPost.Post.Code;
  12173. if (poscode != "SysAdmin")
  12174. {
  12175. string shopid = CurrentUser.User.pemShop;
  12176. lw.Add(string.Format("shopId in ({0})", shopid));
  12177. }
  12178. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12179. {
  12180. lw.Add("IssueState = 1");
  12181. }
  12182. else
  12183. {
  12184. string iisstate = GetPostString("iisstate");
  12185. if ("1".Equals(iisstate))
  12186. {
  12187. lw.Add("IssueState =1");
  12188. }
  12189. else if ("2".Equals(iisstate))
  12190. {
  12191. lw.Add("IssueState = 2");
  12192. }
  12193. else
  12194. {
  12195. lw.Add("IssueState > 0");
  12196. }
  12197. }
  12198. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12199. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12200. writeGridDataTableJson(dStruct.TotalCount, dt);
  12201. }
  12202. public void saveIssueContent()
  12203. {
  12204. string ctid = GetPostString("ctid");
  12205. if (!string.IsNullOrEmpty(ctid))
  12206. {
  12207. string content = GetPostString("content");
  12208. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12209. if (ceErpTradeAfterSaleExtend == null)
  12210. {
  12211. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12212. ceErpTradeAfterSaleExtend.tid = ctid;
  12213. }
  12214. ceErpTradeAfterSaleExtend.IssueContent = content;
  12215. ceErpTradeAfterSaleExtend.IssueState = 1;
  12216. if (ceErpTradeAfterSaleExtend.ID > 0)
  12217. {
  12218. ceErpTradeAfterSaleExtend.Update();
  12219. }
  12220. else
  12221. {
  12222. ceErpTradeAfterSaleExtend.Create();
  12223. }
  12224. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12225. returnSuccessMsg("添加成功!");
  12226. return;
  12227. }
  12228. returnErrorMsg("找不到订单");
  12229. }
  12230. public void dealIssueContent()
  12231. {
  12232. string ctid = GetPostString("ctid");
  12233. if (!string.IsNullOrEmpty(ctid))
  12234. {
  12235. string content = GetPostString("content");
  12236. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12237. if (ceErpTradeAfterSaleExtend != null)
  12238. {
  12239. ceErpTradeAfterSaleExtend.IssueState = 2;
  12240. ceErpTradeAfterSaleExtend.Update();
  12241. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12242. returnSuccessMsg("修改完成!");
  12243. return;
  12244. }
  12245. }
  12246. returnErrorMsg("找不到订单");
  12247. }
  12248. public void set_tid_attachments()
  12249. {
  12250. string tid = GetPostString("tid");
  12251. string atta = GetPostString("atta");
  12252. if (!string.IsNullOrEmpty(tid))
  12253. {
  12254. if (string.IsNullOrEmpty(atta))
  12255. {
  12256. returnErrorMsg("文件地址为空");
  12257. return;
  12258. }
  12259. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12260. if (ceErpTradeCell != null)
  12261. {
  12262. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12263. if (ceErpTrade == null)
  12264. {
  12265. returnErrorMsg("找不到订单");
  12266. return;
  12267. }
  12268. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12269. bool isSend = false;
  12270. if (dt != null && dt.Rows.Count > 0)
  12271. {
  12272. foreach (DataRow row in dt.Rows)
  12273. {
  12274. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12275. {
  12276. isSend = true;
  12277. }
  12278. }
  12279. if (isSend)
  12280. {
  12281. returnErrorMsg("已发货无法修改");
  12282. return;
  12283. }
  12284. ceErpTrade.Attachments = atta;
  12285. ceErpTrade.Update();
  12286. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12287. returnSuccessMsg("上传成功!");
  12288. return;
  12289. }
  12290. }
  12291. }
  12292. returnErrorMsg("找不到订单");
  12293. }
  12294. public void get_tid_attachments()
  12295. {
  12296. string tid = GetPostString("tid");
  12297. if (!string.IsNullOrEmpty(tid))
  12298. {
  12299. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12300. if (ceErpTradeCell != null)
  12301. {
  12302. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12303. if (ceErpTrade == null)
  12304. {
  12305. returnErrorMsg("找不到订单");
  12306. return;
  12307. }
  12308. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12309. return;
  12310. }
  12311. }
  12312. returnErrorMsg("找不到订单");
  12313. }
  12314. public void check_erp_sameorders()
  12315. {
  12316. if (UrlPostParmsCheck("ctid"))
  12317. {
  12318. string eid = GetPostString("ctid");
  12319. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12320. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12321. if (entity != null && ceErpTrade != null)
  12322. {
  12323. if (entity.OrderState > 6)
  12324. {
  12325. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12326. return;
  12327. }
  12328. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12329. List<string> ids = new List<string>();
  12330. if (dt != null && dt.Rows.Count > 1)
  12331. {
  12332. bool needhe = true;
  12333. foreach (DataRow dr in dt.Rows)
  12334. {
  12335. ids.Add("'" + dr["ctid"] + "'");
  12336. /* //备注有合包
  12337. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12338. {
  12339. needhe = true;
  12340. }
  12341. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12342. {
  12343. needhe = true;
  12344. }
  12345. //顺丰快递
  12346. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12347. {
  12348. needhe = true;
  12349. }*/
  12350. }
  12351. if (!needhe)
  12352. {
  12353. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12354. return;
  12355. }
  12356. StringBuilder sql = new StringBuilder();
  12357. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12358. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12359. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12360. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12361. foreach (DataRow dr in dt.Rows)
  12362. {
  12363. dr["dstate"] = 0;
  12364. dr["dnumber"] = 0;
  12365. foreach (DataRow row in dt1.Rows)
  12366. {
  12367. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12368. {
  12369. dr["dstate"] = 2;
  12370. dr["default"] = 1;
  12371. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12372. }
  12373. }
  12374. if (eid.Equals(dr["ctid"].ToString()))
  12375. {
  12376. dr["dstate"] = 1;
  12377. dr["default"] = 1;
  12378. }
  12379. }
  12380. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12381. return;
  12382. }
  12383. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12384. return;
  12385. }
  12386. returnErrorMsg("未找到订单");
  12387. return;
  12388. }
  12389. returnErrorMsg("缺少必要的参数");
  12390. }
  12391. public void get_mark_number()
  12392. {
  12393. string eid = GetPostString("ctid");
  12394. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12395. if (entity != null)
  12396. {
  12397. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12398. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12399. int current = 1;
  12400. if (ceErpDeliverMark == null)
  12401. {
  12402. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12403. List<string> ids = new List<string>();
  12404. if (dt != null && dt.Rows.Count > 1)
  12405. {
  12406. foreach (DataRow dr in dt.Rows)
  12407. {
  12408. ids.Add("'" + dr["ctid"] + "'");
  12409. }
  12410. //查询已有的编号
  12411. StringBuilder sql = new StringBuilder();
  12412. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12413. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12414. if (dt1 == null || dt1.Rows.Count == 0)
  12415. {
  12416. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12417. List<int> list_number = new List<int>();
  12418. foreach (DataRow row in numbers.Rows)
  12419. {
  12420. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12421. }
  12422. //查询空余编号
  12423. for (int i = 0; i < list_number.Count + 2; i++)
  12424. {
  12425. if (!list_number.Contains(current))
  12426. {
  12427. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12428. //防止查询过程中有新数据生成
  12429. if (ceErpDeliverMark1 == null)
  12430. {
  12431. break;
  12432. }
  12433. }
  12434. current++;
  12435. }
  12436. }
  12437. else
  12438. {
  12439. foreach (DataRow row in dt1.Rows)
  12440. {
  12441. current = Convert.ToInt32(row["markNumber"]);
  12442. }
  12443. }
  12444. ceErpDeliverMark = new CeErpDeliverMark();
  12445. ceErpDeliverMark.ctid = eid;
  12446. ceErpDeliverMark.createtime = DateTime.Now;
  12447. if (ceErpTrade != null)
  12448. {
  12449. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12450. }
  12451. ceErpDeliverMark.markNumber = current;
  12452. ceErpDeliverMark.Create();
  12453. }
  12454. }
  12455. else
  12456. {
  12457. current = ceErpDeliverMark.markNumber;
  12458. }
  12459. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12460. return;
  12461. }
  12462. }
  12463. public void aftersaleCytSend()
  12464. {
  12465. string ctid = GetPostString("ctid");
  12466. if (!string.IsNullOrEmpty(ctid))
  12467. {
  12468. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12469. if (ceErpTradeCell != null)
  12470. {
  12471. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12472. }
  12473. returnSuccessMsg("推送成功");
  12474. return;
  12475. }
  12476. returnErrorMsg("缺少必要的参数");
  12477. }
  12478. public void packOrderInfo()
  12479. {
  12480. string ctids = GetPostString("ctids");
  12481. if (!string.IsNullOrEmpty(ctids))
  12482. {
  12483. string[] ctid_list = ctids.Split(',');
  12484. if (ctid_list.Length > 20)
  12485. {
  12486. returnErrorMsg("单次下载次数不能超过20个");
  12487. return;
  12488. }
  12489. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12490. StringBuilder sql = new StringBuilder();
  12491. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12493. int supplierId = 0;
  12494. StringBuilder insterSql = new StringBuilder();
  12495. for (int i = 0; i < dt.Rows.Count; i++)
  12496. {
  12497. DataRow row = dt.Rows[i];
  12498. if (i == 0)
  12499. {
  12500. supplierId = Convert.ToInt32(row["SupplierId"]);
  12501. }
  12502. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12503. {
  12504. returnErrorMsg("同车间的订单才能一起打包");
  12505. return;
  12506. }
  12507. int orderState = Convert.ToInt32(row["OrderState"]);
  12508. if (orderState != 5)
  12509. {
  12510. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12511. return;
  12512. }
  12513. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12514. }
  12515. CeErpPackData ceErpPackData = new CeErpPackData();
  12516. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12517. ceErpPackData.supplierId = supplierId;
  12518. ceErpPackData.createtime = DateTime.Now;
  12519. ceErpPackData.createBy = CurrentUser.UserID;
  12520. ceErpPackData.createName = CurrentUser.UserName;
  12521. ceErpPackData.Create();
  12522. if (ceErpPackData.ID > 0)
  12523. {
  12524. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12525. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12526. }
  12527. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12528. returnSuccessMsg("打包成功");
  12529. return;
  12530. }
  12531. returnErrorMsg("缺少必要的参数");
  12532. }
  12533. public void rePackOrderInfo()
  12534. {
  12535. string id = GetPostString("id");
  12536. if (!string.IsNullOrEmpty(id))
  12537. {
  12538. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12539. if (ceErpPackData == null)
  12540. {
  12541. returnSuccessMsg("查无数据");
  12542. return;
  12543. }
  12544. ceErpPackData.upStatus = 0;
  12545. ceErpPackData.message = "";
  12546. ceErpPackData.Update();
  12547. returnSuccessMsg("打包成功");
  12548. return;
  12549. }
  12550. returnErrorMsg("缺少必要的参数");
  12551. }
  12552. public void backPackOrderInfo()
  12553. {
  12554. string id = GetPostString("id");
  12555. if (!string.IsNullOrEmpty(id))
  12556. {
  12557. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12558. if (ceErpPackData == null)
  12559. {
  12560. returnSuccessMsg("查无数据");
  12561. return;
  12562. }
  12563. ceErpPackData.upStatus = 4;
  12564. ceErpPackData.Update();
  12565. List<string> list = new List<string>();
  12566. StringBuilder sql = new StringBuilder();
  12567. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12568. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12569. for (int i = 0; i < dt.Rows.Count; i++)
  12570. {
  12571. DataRow row = dt.Rows[i];
  12572. list.Add("'" + row["ctid"].ToString() + "'");
  12573. }
  12574. string textCtids = string.Join(",", list);
  12575. 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));
  12576. 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, "无法打包退回"));
  12577. returnSuccessMsg("退回成功");
  12578. return;
  12579. }
  12580. returnErrorMsg("缺少必要的参数");
  12581. }
  12582. public void addPackDownNum()
  12583. {
  12584. string id = GetPostString("id");
  12585. if (!string.IsNullOrEmpty(id))
  12586. {
  12587. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12588. returnSuccessMsg("下载成功");
  12589. return;
  12590. }
  12591. returnErrorMsg("缺少必要的参数");
  12592. }
  12593. public void get_pack_list()
  12594. {
  12595. DataStruct dStruct = GetPostStruct();
  12596. List<string> lw = new List<string>();
  12597. string supplier = GetPostString("supplier");
  12598. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12599. string posTag = CurrentUser.UserPost.Post.Code;
  12600. if (posTag == "Supplier")
  12601. {
  12602. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12603. }
  12604. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12605. dStruct.Order = "createtime desc";
  12606. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12607. writeGridDataTableJson(dStruct.TotalCount, dt);
  12608. }
  12609. public void get_pack_order_list()
  12610. {
  12611. string packId = GetPostString("packId");
  12612. if (string.IsNullOrEmpty(packId))
  12613. {
  12614. returnErrorMsg("缺少必要的参数");
  12615. return;
  12616. }
  12617. StringBuilder sql = new StringBuilder();
  12618. 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);
  12619. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12620. if (dt == null || dt.Rows.Count == 0)
  12621. {
  12622. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12623. return;
  12624. }
  12625. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12626. return;
  12627. }
  12628. public void get_supplier_product_time_list()
  12629. {
  12630. DataStruct dStruct = GetPostStruct();
  12631. List<string> lw = new List<string>();
  12632. string supplier = GetPostString("supplier");
  12633. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12634. string posTag = CurrentUser.UserPost.Post.Code;
  12635. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12636. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12637. writeGridDataTableJson(dStruct.TotalCount, dt);
  12638. }
  12639. public void saveSupplierProductTime()
  12640. {
  12641. string productId = GetPostString("productId");
  12642. if (string.IsNullOrEmpty(productId))
  12643. {
  12644. returnErrorMsg("缺少必要的参数");
  12645. return;
  12646. }
  12647. string productName = GetPostString("productName");
  12648. int supplierId = GetPostInt("supplierId");
  12649. if (supplierId == 0)
  12650. {
  12651. returnErrorMsg("缺少必要的参数");
  12652. return;
  12653. }
  12654. int quantity = GetPostInt("quantity");
  12655. int sendDay = GetPostInt("sendTime");
  12656. string supplierName = GetPostString("supplierName");
  12657. string craft = GetPostString("craft");
  12658. string deadLine = GetPostString("deadLine");
  12659. string dayDeadLine = GetPostString("dayDeadLine");
  12660. try
  12661. {
  12662. int eid = GetPostInt("eid");
  12663. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12664. if (ceErpSupplierProductTime == null)
  12665. {
  12666. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12667. }
  12668. ceErpSupplierProductTime.productId = productId;
  12669. ceErpSupplierProductTime.productName = productName;
  12670. ceErpSupplierProductTime.supplierId = supplierId;
  12671. ceErpSupplierProductTime.supplierName = supplierName;
  12672. ceErpSupplierProductTime.craft = craft;
  12673. ceErpSupplierProductTime.sendDay = sendDay;
  12674. ceErpSupplierProductTime.quantity = quantity;
  12675. if (!string.IsNullOrEmpty(deadLine))
  12676. {
  12677. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12678. }
  12679. if (!string.IsNullOrEmpty(dayDeadLine))
  12680. {
  12681. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12682. }
  12683. if (ceErpSupplierProductTime.ID == 0)
  12684. {
  12685. ceErpSupplierProductTime.Save();
  12686. }
  12687. else
  12688. {
  12689. ceErpSupplierProductTime.Update();
  12690. }
  12691. }
  12692. catch (Exception e)
  12693. {
  12694. }
  12695. returnSuccessMsg("保存成功");
  12696. return;
  12697. }
  12698. public void delSupplierProductTime()
  12699. {
  12700. int eid = GetPostInt("eid");
  12701. if (eid > 0)
  12702. {
  12703. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12704. if (ceErpSupplierProductTime == null)
  12705. {
  12706. returnErrorMsg("查无数据");
  12707. return;
  12708. }
  12709. ceErpSupplierProductTime.Delete();
  12710. returnSuccessMsg("保存成功");
  12711. return;
  12712. }
  12713. returnErrorMsg("缺少必要的参数");
  12714. }
  12715. public void getExpressInfo()
  12716. {
  12717. string ctid = GetPostString("ctid");
  12718. if (!string.IsNullOrEmpty(ctid))
  12719. {
  12720. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12721. if (ceErpTradeCell != null)
  12722. {
  12723. string outSid = ceErpTradeCell.OutSid;
  12724. if (outSid.Length > 0)
  12725. {
  12726. 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);
  12727. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12728. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12729. return;
  12730. }
  12731. }
  12732. returnErrorMsg("查无记录");
  12733. return;
  12734. }
  12735. returnErrorMsg("缺少必要的参数");
  12736. }
  12737. public void getExpressPostData()
  12738. {
  12739. string express = GetPostString("express");
  12740. if (!string.IsNullOrEmpty(express))
  12741. {
  12742. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12743. if (ceErpExpressInfo != null)
  12744. {
  12745. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12746. return;
  12747. }
  12748. }
  12749. returnErrorMsg("缺少必要的参数");
  12750. }
  12751. public void checkSupplierOrder()
  12752. {
  12753. string ctids = GetPostString("ctids");
  12754. if (ctids != null)
  12755. {
  12756. List<string> list = new List<string>();
  12757. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12758. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12759. for (int i = 0; i < dt.Rows.Count; i++)
  12760. {
  12761. DataRow row = dt.Rows[i];
  12762. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12763. {
  12764. continue;
  12765. }
  12766. list.Add(row["seller_memo"].ToString());
  12767. }
  12768. if (list.Count > 0)
  12769. {
  12770. 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, "点击下载按钮"));
  12771. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12772. return;
  12773. }
  12774. }
  12775. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12776. return;
  12777. }
  12778. public void addPersonId()
  12779. {
  12780. string tid = GetPostString("tid");
  12781. string personId = GetPostString("personId");
  12782. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12783. if (ceErpTrade != null)
  12784. {
  12785. ceErpTrade.receiver_zip = personId;
  12786. ceErpTrade.Update();
  12787. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12788. returnSuccessMsg("保存成功");
  12789. return;
  12790. }
  12791. returnErrorMsg("缺少必要的参数");
  12792. }
  12793. public void addDeliveryPaymant()
  12794. {
  12795. string tid = GetPostString("tid");
  12796. string paymant = GetPostString("paymant");
  12797. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12798. if (ceErpTrade != null)
  12799. {
  12800. if (!string.IsNullOrEmpty(paymant))
  12801. {
  12802. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12803. }
  12804. ceErpTrade.Update();
  12805. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12806. returnSuccessMsg("保存成功");
  12807. return;
  12808. }
  12809. returnErrorMsg("缺少必要的参数");
  12810. }
  12811. public void saveCellFile()
  12812. {
  12813. string tid = GetPostString("tid");
  12814. string ctid = GetPostString("ctid");
  12815. string urls = GetPostString("urls");
  12816. string type = GetPostString("type");
  12817. string del = GetPostString("del");
  12818. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12819. {
  12820. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12821. {
  12822. ctid = tid;
  12823. }
  12824. if ("1".Equals(del))
  12825. {
  12826. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12827. }
  12828. string[] list = urls.Split(',');
  12829. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12830. {
  12831. foreach (string item in list)
  12832. {
  12833. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12834. ceErpTradeCellFile.Create();
  12835. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12836. }
  12837. }
  12838. returnSuccessMsg("保存成功");
  12839. return;
  12840. }
  12841. returnErrorMsg("缺少必要的参数");
  12842. }
  12843. public void getCellFile()
  12844. {
  12845. string tid = GetPostString("tid");
  12846. string ctid = GetPostString("ctid");
  12847. string type = GetPostString("type");
  12848. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12849. {
  12850. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12851. {
  12852. ctid = tid;
  12853. }
  12854. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12855. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12856. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12857. return;
  12858. }
  12859. returnErrorMsg("缺少必要的参数");
  12860. }
  12861. public void delCellFile()
  12862. {
  12863. string id = GetPostString("id");
  12864. if (string.IsNullOrEmpty(id))
  12865. {
  12866. returnErrorMsg("缺少必要的参数");
  12867. return;
  12868. }
  12869. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12870. CeErpTradeCellFile.delByID(id);
  12871. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12872. returnSuccessMsg("保存成功");
  12873. }
  12874. public void getInvoiceOrder()
  12875. {
  12876. string tid = GetPostString("tid");
  12877. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12878. List<string> tids = new List<string>();
  12879. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12880. {
  12881. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WHERE buyer_id = '{0}' AND seller_nick = '{1}' order by pay_time desc;", ceErpTrade.buyer_id, ceErpTrade.seller_nick);
  12882. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12883. foreach (DataRow dr in dt.Rows)
  12884. {
  12885. tids.Add("'" + dr["tid"].ToString() + "'");
  12886. }
  12887. }
  12888. else
  12889. {
  12890. tids.Add("'" + ceErpTrade.tid + "'");
  12891. }
  12892. DataTable cell_dt = new DataTable();
  12893. if (tids.Count > 0)
  12894. {
  12895. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12896. }
  12897. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12898. return;
  12899. }
  12900. }
  12901. }