sync.order.cs 653 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. namespace SiteCore.Handler
  51. {
  52. public partial class sync
  53. {
  54. public void get_erp_orderlist()
  55. {
  56. string poscode = CurrentUser.UserPost.Post.Code;
  57. DataStruct dStruct = GetPostStruct();
  58. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  59. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\镭射银吊牌(1).xlsx");
  60. //apiHelper.Api_SyncOrderByTime("598825");
  61. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  62. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  63. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  64. //banniuApiHelper.sendLogisticsInfo(null);
  65. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  66. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  67. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  68. //int sid = commonHelper.autoDistributeToSupplier(entity);
  69. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  70. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1752654175000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1752826970000,\"lines\":[{\"latestDeliveryTime\":1752826970000,\"mark2\":[],\"num\":23,\"outerId\":\"DGCP\",\"payment\":460.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2200806677467/O1CN01Wlpmej251wOGAuYd2_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":20.0,\"refOlId\":\"4634728491992436446\",\"refSkuId\":\"0\",\"refSpuId\":\"617207822351\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":20.0,\"singleFee\":20.0,\"spuOuterId\":\"DGCP\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"蛋糕logo插牌定制烘焙店插卡插排生日小卡片装饰甜品标签插件设计\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1752658857000,\"openBuyerId\":\"AAHqRHraABkUZRPgSx1P9I8b\",\"openBuyerNick\":\"b**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1752654168000,\"payTime\":1752654170000,\"payment\":460.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"佛山市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"禅城区\",\"receiverId\":\"882d7aaecddc7a9698cc36e36a46ba24$\",\"receiverState\":\"广东省\",\"receiverTown\":\"石湾镇街道\",\"refOid\":\"4634728491992436446\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"60x12mm-2款各500张-插卡-350克铜板纸-直角单面烫金模切-bowie_s-英子-240元-(纯烫金)-老客户204.02.20,40x40mm-2000张-插卡-350克铜板纸-方形直角裁切-bowie_s-英子-220元--老客户2024.02.20\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0,\"type\":\"SALE\"}}");
  71. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  72. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  73. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  74. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  75. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  76. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  77. string tids = File.ReadAllText(path);
  78. List<string> list = tids.Split(',').ToList();
  79. int index = 0;
  80. foreach (string item in list)
  81. {
  82. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  83. try
  84. {
  85. string sql = string.Format("SELECT count(*) as number 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}'", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  86. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  87. if (dataTable != null && dataTable.Rows.Count > 0)
  88. {
  89. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  90. if (count > 0)
  91. {
  92. Debug.WriteLine(index++);
  93. continue;
  94. }
  95. }
  96. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  97. }
  98. catch (Exception e)
  99. {
  100. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  101. }
  102. Debug.WriteLine(index++);
  103. }*/
  104. List<string> lw = new List<string>();
  105. string tid = GetPostString("ctid");
  106. string date1 = GetPostString("date1");
  107. //12-1 修改
  108. string urgent = GetPostString("urgent");
  109. string back = GetPostString("back");
  110. string offlineSearch = GetPostString("offlineSearch");
  111. int paramsCount = 0;
  112. if (!string.IsNullOrWhiteSpace(urgent))
  113. {
  114. if (urgent.Equals("true"))
  115. {
  116. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  117. }
  118. }
  119. if (!string.IsNullOrWhiteSpace(back))
  120. {
  121. if (back.Equals("true"))
  122. {
  123. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  124. }
  125. }
  126. if (!string.IsNullOrWhiteSpace(offlineSearch))
  127. {
  128. if (offlineSearch.Equals("true"))
  129. {
  130. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  131. }
  132. }
  133. //end
  134. string date2 = GetPostString("date2");
  135. string buyernick = GetPostString("buyer_nick");
  136. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  137. {
  138. if (tid.Length <= 0 && buyernick.Length <= 0)
  139. {
  140. return;
  141. }
  142. }
  143. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  144. {
  145. if (tid.Length > 0)
  146. {
  147. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  148. if (ceErpTradeCell != null)
  149. {
  150. tid = ceErpTradeCell.tid;
  151. }
  152. List<string> select_tid = getTidByCtidMore(tid);
  153. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  154. }
  155. if (buyernick.Length > 0)
  156. {
  157. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  158. }
  159. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  160. if (dw.Length > 0)
  161. {
  162. lw.Add(dw);
  163. }
  164. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  165. {
  166. string usershop = CurrentUser.User.pemShop;
  167. lw.Add(string.Format("ShopId in ({0})", usershop));
  168. }
  169. }
  170. else
  171. {
  172. if (ex_psize == 0)
  173. {
  174. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  175. }
  176. if (PKey != "admin" && poscode != "SysAdmin")
  177. {
  178. string usershop = CurrentUser.User.pemShop;
  179. lw.Add(string.Format("ShopId in ({0})", usershop));
  180. paramsCount++;
  181. }
  182. }
  183. string uploaddate1 = GetPostString("uploaddate1");
  184. string uploaddate2 = GetPostString("uploaddate2");
  185. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  186. if (update.Length > 0) lw.Add(update);
  187. string deliverydate1 = GetPostString("deliverydate1");
  188. string deliverydate2 = GetPostString("deliverydate2");
  189. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  190. if (deliverydate.Length > 0)
  191. {
  192. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  193. };
  194. string shopname = GetPostString("shopname");
  195. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  196. string addwechat = GetPostString("addwechat");
  197. if (addwechat.Length > 0)
  198. {
  199. int addWt = Convert.ToInt32(addwechat);
  200. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  201. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  202. }
  203. string customer = GetPostString("customer");
  204. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  205. string design = GetPostString("design");
  206. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  207. string orderState = GetPostString("orderState");
  208. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  209. string address = GetPostString("address");
  210. 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));
  211. string sellermemo = GetPostString("seller_memo");
  212. if (sellermemo.Length > 0)
  213. {
  214. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  215. }
  216. string backReason = GetPostString("backReason");
  217. if (backReason.Length > 0)
  218. {
  219. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  220. }
  221. string apdate1 = GetPostString("apdate1");
  222. string apdate2 = GetPostString("apdate2");
  223. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  224. if (dwap.Length > 0) lw.Add(dwap);
  225. string price1 = GetPostString("price1");
  226. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  227. string price2 = GetPostString("price2");
  228. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  229. string isoldcustomer = GetPostString("isoldcus");
  230. string spudata = GetPostString("spudata");
  231. if ("0".Equals(spudata))
  232. {
  233. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  234. }
  235. if ("1".Equals(spudata))
  236. {
  237. lw.Add(string.Format("spu_id <> ''"));
  238. }
  239. string finishdate1 = GetPostString("finishdate1");
  240. string finishdate2 = GetPostString("finishdate2");
  241. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  242. bool isFinish = false;
  243. if (finishdate.Length > 0)
  244. {
  245. lw.Add(finishdate);
  246. isFinish = true;
  247. paramsCount++;
  248. }
  249. if (isoldcustomer.Length > 0)
  250. {
  251. if ("2".Equals(isoldcustomer))
  252. {
  253. lw.Add(string.Format("VipCustomer=1"));
  254. }
  255. else
  256. {
  257. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  258. }
  259. }
  260. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  261. if (ex_psize > 0)
  262. {
  263. int UserID = CurrentUser.UserID;
  264. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  265. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  266. {
  267. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  268. }
  269. dStruct.Order = "pay_time desc";
  270. }
  271. string isNew = GetPostString("isNew");
  272. if (isNew == "true")
  273. {
  274. lw.Add(string.Format("IsNew = {0}", 1));
  275. }
  276. string overtime = GetPostString("overtime");
  277. if (overtime == "1")
  278. {
  279. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  280. }
  281. String usePost = CurrentUser.UserPost.Post.Code;
  282. if (usePost.Equals("Operation") == true)
  283. {
  284. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  285. }
  286. else
  287. {
  288. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  289. }
  290. //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";
  291. if (dStruct.PageSize == 100000)
  292. {
  293. dStruct.Order = "";
  294. }
  295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  296. DataTable dt = null;
  297. string tablename = "view_orderlist";
  298. if (isFinish)
  299. {
  300. tablename = "view_orderlist_end";
  301. }
  302. dt = WebCache.GetData(tablename, dStruct);
  303. if (dt != null && dt.Rows.Count > 0)
  304. {
  305. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  306. foreach (DataRow dr in dt.Rows)
  307. {
  308. try
  309. {
  310. if (dr["refund_fees"] != null)
  311. {
  312. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  313. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  314. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  315. if (payment == refund_fees)
  316. {
  317. dr["refund_fees"] = Math.Round(refund_fees, 2);
  318. }
  319. else if (refund_fees == total_fee)
  320. {
  321. dr["refund_fees"] = payment;
  322. }
  323. else
  324. {
  325. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  326. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  327. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  328. }
  329. }
  330. // 对象操作
  331. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  332. ceErpTradeCell.ctid = dr["ctid"].ToString();
  333. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  334. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  335. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  336. if (dStruct.PageSize != 100000)
  337. {
  338. if (dr["DispatchSort"].ToString() == "2")
  339. {
  340. dr["gongchuang"] = 200;
  341. }
  342. else if ("外协".Equals(dr["ToType"].ToString()))
  343. {
  344. dr["gongchuang"] = 200;
  345. }
  346. else if ("内部".Equals(dr["ToType"].ToString()))
  347. {
  348. dr["gongchuang"] = -1;
  349. }
  350. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  351. {
  352. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  353. dr["gongchuang"] = response.code;
  354. }
  355. }
  356. }
  357. catch (NullReferenceException ex)
  358. {
  359. // 处理空引用异常
  360. dr["refund_fees"] = "0.00";
  361. }
  362. }
  363. }
  364. writeGridDataTableJson(dStruct.TotalCount, dt);
  365. }
  366. public void get_erp_orderlist_sumprice()
  367. {
  368. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  369. return;
  370. List<string> lw = new List<string>();
  371. string tid = GetPostString("ctid");
  372. string date1 = GetPostString("date1");
  373. string date2 = GetPostString("date2");
  374. if (tid.Length > 0 || date1.Length > 0)
  375. {
  376. lw.Add(string.Format("ctid like '%{0}%'", tid));
  377. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  378. if (dw.Length > 0) lw.Add(dw);
  379. }
  380. else
  381. {
  382. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  383. }
  384. string shopname = GetPostString("shopname");
  385. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  386. string buyernick = GetPostString("buyer_nick");
  387. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  388. string customer = GetPostString("customer");
  389. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  390. string design = GetPostString("design");
  391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  392. string orderState = GetPostString("orderState");
  393. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  394. string address = GetPostString("address");
  395. 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));
  396. string sellermemo = GetPostString("seller_memo");
  397. if (sellermemo.Length > 0)
  398. {
  399. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  400. }
  401. string apdate1 = GetPostString("apdate1");
  402. string apdate2 = GetPostString("apdate2");
  403. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  404. if (dwap.Length > 0) lw.Add(dwap);
  405. string price1 = GetPostString("price1");
  406. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  407. string price2 = GetPostString("price2");
  408. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  409. string isoldcustomer = GetPostString("isoldcus");
  410. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  411. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  412. if (PKey != "admin")
  413. {
  414. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  415. lw.Add(string.Format("shopId in ({0})", usershop));
  416. }
  417. //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";
  418. string mainWhere = string.Join(" and ", lw.ToArray());
  419. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  420. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  421. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  422. decimal total = 0;
  423. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  424. {
  425. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  426. }
  427. var res = new
  428. {
  429. data = total
  430. };
  431. string ro_jsond = JsonConvert.SerializeObject(res);
  432. returnSuccess(ro_jsond);
  433. return;
  434. }
  435. public void get_erp_CustomerServiceGather()
  436. {
  437. string userWhere = "", orderWhere = "";
  438. List<string> lw = new List<string>();
  439. string customer = GetPostString("customer");
  440. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  441. string shopname = GetPostString("shopname");
  442. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  443. string date1 = GetPostString("date1");
  444. string date2 = GetPostString("date2");
  445. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  446. if (dw.Length > 0) lw.Add(dw);
  447. orderWhere = string.Join(" and ", lw.ToArray());
  448. 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 " +
  449. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  450. "left join " +
  451. "( " +
  452. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  453. ") as b on a.ID = b.CustomerUserId " +
  454. "left join " +
  455. "( " +
  456. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  457. ") as d on a.ID = d.CustomerUserId " +
  458. "left join " +
  459. "( " +
  460. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  461. ") as e on a.ID = e.CustomerUserId " +
  462. "left join " +
  463. "( " +
  464. " select CustomerUserId, RefundCount, RefundSum from " +
  465. " ( " +
  466. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  467. " from CE_ErpTradeRefund a " +
  468. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  469. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  470. " group by CustomerUserId " +
  471. " ) as a " +
  472. ") as f on a.ID = f.CustomerUserId " +
  473. "where a.PostCode = 'CustomerService'",
  474. userWhere, orderWhere);
  475. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  476. writeGridDataTableJson(dt.Rows.Count, dt);
  477. //writeGridDataTableJson(dt.Rows.Count, dt);
  478. }
  479. //设计汇总
  480. public void get_erp_DesignerGather()
  481. {
  482. string userWhere = "", orderWhere = "";
  483. List<string> lw = new List<string>();
  484. string Designer = GetPostString("designer");
  485. int org = GetPostInt("org");
  486. if (Designer.Length > 0)
  487. {
  488. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  489. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  490. }
  491. else if (org > 0)
  492. {
  493. userWhere = string.Format(" where OrgID ={0}", org);
  494. }
  495. string shopname = GetPostString("shopname");
  496. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  497. string state = GetPostString("state");
  498. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  499. string OrderArea = GetPostString("order_area");
  500. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  501. string date1 = GetPostString("date1");
  502. string date2 = GetPostString("date2");
  503. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  504. if (dw.Length > 0) lw.Add(dw);
  505. string UpDate1 = GetPostString("UpDate1");
  506. string UpDate2 = GetPostString("UpDate2");
  507. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  508. if (dw.Length > 0) lw.Add(dw);
  509. orderWhere = string.Join(" and ", lw.ToArray());
  510. 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 (" +
  511. "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 " +
  512. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  513. "left join " +
  514. "( " +
  515. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  516. ") as b on a.ID = b.DesignUserId " +
  517. "left join " +
  518. "( " +
  519. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  520. ") as d on a.ID = d.DesignUserId " +
  521. "left join " +
  522. "( " +
  523. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  524. ") as e on a.ID = e.DesignUserId " +
  525. "left join " +
  526. "( " +
  527. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  528. ") as g on a.ID = g.DesignUserId " +
  529. "left join " +
  530. "( " +
  531. " select CustomerUserId, RefundCount, RefundSum from " +
  532. " ( " +
  533. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  534. " from CE_ErpTradeRefund a " +
  535. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  536. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  537. " group by CustomerUserId " +
  538. " ) as a " +
  539. ") as f on a.ID = f.CustomerUserId " +
  540. "where a.PostCode = 'Designer') as z",
  541. userWhere, orderWhere);
  542. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  543. writeGridDataTableJson(dt.Rows.Count, dt);
  544. }
  545. //删除tradecell的订单
  546. public void del_erp_cellorder()
  547. {
  548. if (UrlPostParmsCheck("ctid"))
  549. {
  550. string eid = GetPostString("ctid");
  551. CeErpTradeCell.DelByCtid(eid);
  552. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  553. returnSuccessMsg("删除成功");
  554. }
  555. }
  556. public void clear_erp_refundstate()
  557. {
  558. if (UrlPostParmsCheck("ids"))
  559. {
  560. string eids = GetPostString("ids");
  561. string[] ctidList = eids.Split(',');
  562. foreach (string ctid in ctidList)
  563. {
  564. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  565. if (entity != null)
  566. {
  567. entity.IsRefund = 0;
  568. entity.Update();
  569. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  570. }
  571. else
  572. continue;
  573. }
  574. returnSuccessMsg("操作成功");
  575. return;
  576. }
  577. returnErrorMsg("缺少必要参数");
  578. }
  579. public void set_erp_urgency()
  580. {
  581. if (UrlPostParmsCheck("ctid"))
  582. {
  583. string eid = GetPostString("ctid");
  584. CeErpTradeCell entity = null;
  585. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  586. if (entity != null)
  587. {
  588. double prices = commonHelper.calculationPrice(entity);
  589. if (prices <= 100)
  590. {
  591. returnErrorMsg("此订单金额不足100元,无法加急。");
  592. return;
  593. }
  594. string utime = GetPostString("urgencytime");
  595. if (utime.Length > 0)
  596. {
  597. entity.UrgencyTime = Convert.ToDateTime(utime);
  598. }
  599. else
  600. {
  601. returnErrorMsg("请选择加急时间");
  602. return;
  603. }
  604. if (entity.OrderState <= 4)
  605. {
  606. //entity.seller_memo = entity.seller_memo + "-加急";
  607. string smemo = entity.seller_memo;
  608. int kindex = smemo.IndexOf(")");
  609. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  610. if (lastoneStr != "-")
  611. {
  612. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  613. }
  614. string prememo = smemo.Substring(0, kindex + 2);
  615. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  616. int lastkindex = lastmemo.IndexOf("(");
  617. DateTime urgtime = Convert.ToDateTime(utime);
  618. string newlastmemo = "";
  619. if (lastkindex == 0)
  620. {
  621. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  622. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  623. }
  624. else
  625. {
  626. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  627. }
  628. entity.seller_memo = prememo + newlastmemo;
  629. }
  630. entity.IsUrgency = true;
  631. entity.UpdateTime = DateTime.Now;
  632. entity.Update();
  633. ApiVo apiVo = new ApiVo();
  634. apiVo.orderNumber = entity.ctid;
  635. apiVo.actionName = "changeDesign";
  636. apiVo.orderRemarks = entity.seller_memo;
  637. apiVo.remarkSign = 3;
  638. designHelper.API_WorkCore(apiVo); //changeDesign
  639. CeErpSukuraData.createInfo(entity.ctid, 7);
  640. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  641. returnSuccessMsg("设置成功!");
  642. return;
  643. }
  644. returnErrorMsg("找不到记录");
  645. }
  646. }
  647. public void set_erp_reset()
  648. {
  649. if (UrlPostParmsCheck("ctid"))
  650. {
  651. string eid = GetPostString("ctid");
  652. CeErpTradeCell entity = null;
  653. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  654. if (entity != null)
  655. {
  656. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  657. {
  658. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  659. {
  660. returnErrorMsg("财务要求已下单已发货无法重置");
  661. return;
  662. }
  663. }
  664. entity.IsUrgency = false;
  665. entity.seller_memo = "";
  666. entity.OtherMemo = "";
  667. entity.OrderState = 0;
  668. entity.IsReturn = 0;
  669. //entity.IsRefund = 0;
  670. entity.MemoOpt = 0;
  671. entity.AfterSaleState = 0;
  672. entity.AfterSaleResponsible = "";
  673. entity.AfterSaleUserId = 0;
  674. entity.IsNeedBill = 0;
  675. entity.CustomerUserId = 0;
  676. entity.DesignUserId = 0;
  677. entity.SupplierId = 0;
  678. entity.PlaceUserId = 0;
  679. entity.ptid = "";
  680. entity.IsSample = 0;
  681. entity.IsXianHuo = 0;
  682. entity.isDianziOrder = 0;
  683. entity.DispatchSort = 0;
  684. entity.IsVerifyToSupplier = false;
  685. entity.FinishPlaceTime = null;
  686. entity.Update();
  687. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  688. if (trade != null)
  689. {
  690. trade.seller_memo = "";
  691. trade.Update();
  692. }
  693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  694. returnSuccessMsg("重置成功!");
  695. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  696. if (desginBill != null)
  697. {
  698. desginBill.isDel = 1;
  699. desginBill.Update();
  700. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  701. }
  702. ApiVo apiVo = new ApiVo();
  703. apiVo.orderNumber = entity.ctid;
  704. apiVo.actionName = "resetDesign";
  705. designHelper.API_WorkCore(apiVo);//resetDesign
  706. return;
  707. }
  708. returnErrorMsg("找不到记录");
  709. }
  710. }
  711. public void save_erp_sellermemo()
  712. {
  713. if (UrlPostParmsCheck("ctid"))
  714. {
  715. string ctid = GetPostString("ctid");
  716. CeErpTradeCell entity = null;
  717. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  718. if (entity != null)
  719. {
  720. string memo = GetPostString("seller_memo");
  721. memo = memo.Replace(" ", "");
  722. if (memo.Contains("补差"))
  723. {
  724. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  725. return;
  726. }
  727. List<string> bitList = new List<string>
  728. {
  729. "\\","/",":","*","?", "\"","<" ,">","|"
  730. };
  731. bool isIn = false;
  732. foreach (string bit in bitList)
  733. {
  734. if (memo.Contains(bit))
  735. {
  736. isIn = true;
  737. }
  738. }
  739. if (isIn)
  740. {
  741. returnErrorMsg("不能使用 一些符合作为文件名");
  742. return;
  743. }
  744. if (entity.seller_memo != memo)
  745. {
  746. if (entity.IsSample == 2)
  747. {
  748. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  749. return;
  750. }
  751. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  752. {
  753. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  754. {
  755. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  756. return;
  757. }
  758. /*if (CurrentUser.UserPost.Post.Code != "Place")
  759. {
  760. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  761. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  762. {
  763. returnErrorMsg("售前系统订单无法再此修改!");
  764. return;
  765. }
  766. }*/
  767. }
  768. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  769. }
  770. commonHelper.getCytPrice(entity);
  771. int memoopt = GetPostInt("MemoOpt");
  772. Boolean ismemoopt = false;
  773. if (memoopt > 0)
  774. {
  775. string stropt = "";
  776. if (memoopt == 1)
  777. {
  778. stropt = "“改稿”";
  779. ismemoopt = true;
  780. }
  781. else if (memoopt == 2)
  782. {
  783. stropt = "“定稿”";
  784. }
  785. else if (memoopt == 3)
  786. {
  787. stropt = "“查货”";
  788. CeErpSukuraData.createInfo(entity.ctid, 6);
  789. }
  790. entity.MemoOpt = Convert.ToInt32(memoopt);
  791. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  792. }
  793. if (entity.OrderState < 5)
  794. {
  795. memo = memo.Replace("(", "(");
  796. memo = memo.Replace(")", ")");
  797. }
  798. if (entity.OrderState < 3)
  799. {
  800. entity.DispatchSort = 0;
  801. }
  802. entity.seller_memo = memo;
  803. entity.UpdateTime = DateTime.Now;
  804. entity.Update();
  805. ApiVo apiVo = new ApiVo();
  806. apiVo.orderNumber = entity.ctid;
  807. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  808. apiVo.orderRemarks = memo;
  809. apiVo.remarkSign = memoopt;
  810. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  811. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  812. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  813. {
  814. dataHelper.api_orderBack(entity.ctid, "0", "");
  815. }
  816. if (entity.seller_memo.Contains("改稿"))
  817. {
  818. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  819. }
  820. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  821. returnSuccessMsg("保存成功!");
  822. return;
  823. }
  824. returnErrorMsg("找不到记录");
  825. }
  826. }
  827. public void ins_erp_checkorder()
  828. {
  829. if (UrlPostParmsCheck("ctid"))
  830. {
  831. string ctid = GetPostString("ctid");
  832. CeErpTradeCell entity = null;
  833. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  834. if (entity != null)
  835. {
  836. if (entity.OrderState < 6)
  837. {
  838. returnErrorMsg("下单完成后才可查货");
  839. return;
  840. }
  841. /*if (entity.OrderState > 6)
  842. {
  843. returnErrorMsg("订单已发货");
  844. return;
  845. }*/
  846. if (entity.FinishPlaceTime != null)
  847. {
  848. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  849. {
  850. returnErrorMsg("下单时间不足,无法查货");
  851. return;
  852. }
  853. }
  854. entity.MemoOpt = 3;
  855. entity.CheckOrderTime = DateTime.Now;
  856. entity.UpdateTime = DateTime.Now;
  857. entity.Update();
  858. CeErpSukuraData.createInfo(entity.ctid, 6);
  859. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  860. returnSuccessMsg("操作成功!");
  861. return;
  862. }
  863. returnErrorMsg("找不到记录");
  864. }
  865. }
  866. public void save_erp_othermemo()
  867. {
  868. if (UrlPostParmsCheck("ctid"))
  869. {
  870. string ctid = GetPostString("ctid");
  871. CeErpTradeCell entity = null;
  872. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  873. if (entity != null)
  874. {
  875. entity.OtherMemo = GetPostString("otherMemo");
  876. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  877. {
  878. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  879. StringBuilder sql = new StringBuilder();
  880. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  881. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  882. if (dt != null && dt.Rows.Count > 0)
  883. {
  884. foreach (DataRow dr in dt.Rows)
  885. {
  886. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  887. {
  888. //品类一直
  889. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  890. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  891. if (ceErpSampleCustomer == null)
  892. {
  893. ceErpSampleCustomer = new CeErpSampleCustomer();
  894. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  895. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  896. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  897. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  898. ceErpSampleCustomer.shopId = entity.ShopId;
  899. }
  900. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  901. ceErpSampleCustomer.lastTid = entity.tid;
  902. if (ceErpSampleCustomer.ID > 0)
  903. {
  904. ceErpSampleCustomer.Update();
  905. }
  906. else
  907. {
  908. ceErpSampleCustomer.Create();
  909. }
  910. }
  911. }
  912. }
  913. }
  914. //if (entity.IsOldCustomer == 1)
  915. //{
  916. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  917. //{
  918. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  919. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  920. //}
  921. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  922. //{
  923. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  924. // {
  925. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  926. // {
  927. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  928. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  929. // }
  930. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  931. // {
  932. // entity.OrderState = 2;
  933. // entity.DesignUserId = 0;
  934. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  935. // }
  936. // else
  937. // {
  938. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  939. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  940. // }
  941. // }
  942. //}
  943. //}
  944. entity.UpdateTime = DateTime.Now;
  945. entity.Update();
  946. returnSuccessMsg("保存成功!");
  947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  948. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  949. if (entity.OtherMemo.Contains("改稿"))
  950. {
  951. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  952. }
  953. return;
  954. }
  955. returnErrorMsg("找不到记录");
  956. }
  957. }
  958. public void save_erp_customermemo()
  959. {
  960. if (UrlPostParmsCheck("ctid"))
  961. {
  962. string ctid = GetPostString("ctid");
  963. CeErpTradeCell entity = null;
  964. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  965. if (entity != null)
  966. {
  967. entity.UpdateTime = DateTime.Now;
  968. entity.CustomerMemo = GetPostString("CustomerMemo");
  969. entity.Update();
  970. ApiVo apiVo = new ApiVo();
  971. apiVo.orderNumber = entity.ctid;
  972. apiVo.actionName = "followRemarks";
  973. apiVo.orderRemarks = entity.CustomerMemo;
  974. designHelper.API_WorkCore(apiVo);//followRemarks
  975. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  976. returnSuccessMsg("保存成功!");
  977. return;
  978. }
  979. returnErrorMsg("找不到记录");
  980. }
  981. }
  982. public void upd_erp_addmemotag()
  983. {
  984. if (UrlPostParmsCheck("ctid"))
  985. {
  986. ;
  987. string eid = GetPostString("ctid");
  988. string sfTagstr = GetPostString("memotag");
  989. CeErpTradeCell entity = null;
  990. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  991. if (entity != null)
  992. {
  993. ApiVo apiVo = new ApiVo();
  994. if (entity.OrderState == 0)
  995. {
  996. returnErrorMsg("请先领单");
  997. return;
  998. }
  999. //撤销顺丰
  1000. if (sfTagstr == "撤销顺丰")
  1001. {
  1002. entity.IsSF = 0;
  1003. string reMsg = "";
  1004. string oldmemo = entity.seller_memo;
  1005. if (entity.OrderState < 5)
  1006. {
  1007. oldmemo = oldmemo.Replace("顺丰到付", "");
  1008. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1009. entity.seller_memo = oldmemo;
  1010. }
  1011. else
  1012. {
  1013. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1014. {
  1015. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1016. }
  1017. }
  1018. entity.Update();
  1019. apiVo.orderNumber = entity.ctid;
  1020. apiVo.actionName = "orderRemarks";
  1021. apiVo.orderRemarks = entity.seller_memo;
  1022. apiVo.isSf = entity.IsSF.ToString();
  1023. designHelper.API_WorkCore(apiVo);//orderRemarks
  1024. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1025. returnSuccessMsg("撤销成功!" + reMsg);
  1026. return;
  1027. }
  1028. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1029. {
  1030. //string oldmemo = entity.seller_memo;
  1031. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1032. string sfStr = GetPostString("memotag");
  1033. string smemo = entity.seller_memo;
  1034. int kindex = smemo.IndexOf(")");
  1035. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1036. if (lastoneStr != "-")
  1037. {
  1038. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1039. }
  1040. string prememo = smemo.Substring(0, kindex + 2);
  1041. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1042. int lastkindex = lastmemo.IndexOf("(");
  1043. string newlastmemo = "";
  1044. if (lastkindex == 0)
  1045. {
  1046. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1047. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1048. }
  1049. else
  1050. {
  1051. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1052. }
  1053. entity.seller_memo = prememo + newlastmemo;
  1054. }
  1055. string sfTagMSg = "";
  1056. if (sfTagstr == "顺丰寄付")
  1057. {
  1058. entity.IsSF = 1;
  1059. sfTagMSg = "顺丰寄付";
  1060. }
  1061. else if (sfTagstr == "顺丰到付")
  1062. {
  1063. entity.IsSF = 2;
  1064. sfTagMSg = "顺丰到付";
  1065. }
  1066. entity.Update();
  1067. apiVo = new ApiVo();
  1068. apiVo.orderNumber = entity.ctid;
  1069. apiVo.actionName = "orderRemarks";
  1070. apiVo.orderRemarks = entity.seller_memo;
  1071. apiVo.isSf = entity.IsSF.ToString();
  1072. designHelper.API_WorkCore(apiVo);//orderRemarks
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1074. returnSuccessMsg("标记成功!");
  1075. return;
  1076. }
  1077. returnErrorMsg("找不到记录");
  1078. }
  1079. }
  1080. public void upd_erp_ordertag()
  1081. {
  1082. if (UrlPostParmsCheck("ctid"))
  1083. {
  1084. string eid = GetPostString("ctid");
  1085. CeErpTradeCell entity = null;
  1086. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1087. if (entity != null)
  1088. {
  1089. int tag = GetPostInt("wechattag");
  1090. //if(tag==4 && entity.IsSample == 2)
  1091. //{
  1092. // returnErrorMsg("补差价单不能标记微信单");
  1093. // return;
  1094. //}
  1095. entity.wechatTag = tag;
  1096. entity.Update();
  1097. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1098. if (tag == 1)
  1099. {
  1100. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1101. if (cash == null)
  1102. {
  1103. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1104. cash = new CeErpReturnCash();
  1105. cash.tid = entity.tid;
  1106. cash.seller_nick = main.seller_nick;
  1107. cash.payment = trade.payment;
  1108. cash.buyer_nick = main.buyer_nick;
  1109. cash.cashstate = 0;
  1110. cash.rtype = "微信返现";
  1111. cash.returnprice = 0;
  1112. cash.created = DateTime.Now;
  1113. cash.con = "订单标记微信单";
  1114. cash.img = "";
  1115. cash.applyuserid = CurrentUser.UserID;
  1116. cash.Create();
  1117. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1118. }
  1119. else
  1120. {
  1121. cash.cashstate = 0;
  1122. cash.Update();
  1123. }
  1124. CeErpSukuraData.createInfo(entity.ctid, 9);
  1125. }
  1126. else if (tag == 2)
  1127. {
  1128. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1129. if (cash == null)
  1130. {
  1131. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1132. cash = new CeErpReturnCash();
  1133. cash.tid = entity.tid;
  1134. cash.seller_nick = main.seller_nick;
  1135. cash.payment = trade.payment;
  1136. cash.buyer_nick = main.buyer_nick;
  1137. cash.cashstate = 0;
  1138. cash.rtype = "推购返现";
  1139. cash.returnprice = 5;
  1140. cash.created = DateTime.Now;
  1141. cash.con = "订单标记推购单";
  1142. cash.img = "";
  1143. cash.applyuserid = CurrentUser.UserID;
  1144. cash.Create();
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1146. }
  1147. else
  1148. {
  1149. cash.cashstate = 0;
  1150. cash.Update();
  1151. }
  1152. CeErpSukuraData.createInfo(entity.ctid, 9);
  1153. }
  1154. else if (tag == 3)
  1155. {
  1156. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1157. if (pers == null)
  1158. {
  1159. pers = new CeErpPersuade();
  1160. pers.ctid = entity.ctid;
  1161. pers.pstate = 0;
  1162. pers.created = DateTime.Now;
  1163. pers.applyuserid = CurrentUser.UserID;
  1164. pers.Create();
  1165. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1166. }
  1167. else
  1168. {
  1169. pers.pstate = 0;
  1170. pers.Update();
  1171. }
  1172. }
  1173. else if (tag == 4 || tag == 5)
  1174. {
  1175. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1176. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1177. if (pers == null)
  1178. {
  1179. pers = CeErpStayGoods.GetByTid(entity.tid);
  1180. }
  1181. if (pers == null)
  1182. {
  1183. pers = new CeErpStayGoods();
  1184. pers.t_id = entity.tid;
  1185. pers.ctid = entity.ctid;
  1186. pers.status = "待审核";
  1187. pers.audit_type = 0;
  1188. if (tag == 4)
  1189. {
  1190. pers.stay_type = "微信推购";
  1191. }
  1192. else
  1193. {
  1194. pers.stay_type = "旺旺推购";
  1195. }
  1196. if (entity.IsXianHuo == 0)
  1197. {
  1198. pers.product_id = entity.ProductId;
  1199. }
  1200. pers.wangwang = main.buyer_nick;
  1201. pers.shop_name = main.seller_nick;
  1202. pers.creata_time = DateTime.Now;
  1203. pers.create_u_id = CurrentUser.UserID;
  1204. pers.create_u_name = CurrentUser.UserName;
  1205. pers.Create();
  1206. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1207. }
  1208. else
  1209. {
  1210. pers.ctid = entity.ctid;
  1211. pers.audit_type = 0;
  1212. pers.Update();
  1213. }
  1214. CeErpSukuraData.createInfo(entity.ctid, 10);
  1215. }
  1216. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1217. returnSuccessMsg("标记成功!");
  1218. return;
  1219. }
  1220. returnErrorMsg("找不到记录");
  1221. }
  1222. }
  1223. public void upd_erp_ordertag_cancel()
  1224. {
  1225. if (UrlPostParmsCheck("ctid"))
  1226. {
  1227. string eid = GetPostString("ctid");
  1228. CeErpTradeCell entity = null;
  1229. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1230. if (entity != null)
  1231. {
  1232. entity.wechatTag = 0;
  1233. entity.Update();
  1234. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1235. if (pers != null)
  1236. {
  1237. pers.status = "取消推购";
  1238. pers.audit_type = 3;
  1239. pers.Update();
  1240. }
  1241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1242. returnSuccessMsg("标记成功!");
  1243. return;
  1244. }
  1245. returnErrorMsg("找不到记录");
  1246. }
  1247. }
  1248. public void upd_erp_addweichattag()
  1249. {
  1250. if (UrlPostParmsCheck("ctid"))
  1251. {
  1252. ;
  1253. string eid = GetPostString("ctid");
  1254. CeErpTradeCell entity = null;
  1255. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1256. if (entity != null)
  1257. {
  1258. if (entity.IsAddWechat > 0)
  1259. {
  1260. returnErrorMsg("此单已经标记过了");
  1261. return;
  1262. }
  1263. 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);
  1264. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1265. if (dt.Rows.Count > 0)
  1266. {
  1267. entity.IsAddWechat = 2;
  1268. }
  1269. else
  1270. {
  1271. entity.IsAddWechat = 1;
  1272. }
  1273. entity.Update();
  1274. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1275. returnSuccessMsg("标记成功!");
  1276. return;
  1277. }
  1278. returnErrorMsg("找不到记录");
  1279. }
  1280. }
  1281. public void upd_erp_getmyorder()
  1282. {
  1283. if (UrlPostParmsCheck("ctid"))
  1284. {
  1285. string eid = GetPostString("ctid");
  1286. CeErpTradeCell entity = null;
  1287. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1288. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1289. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1290. {
  1291. returnErrorMsg("台湾客户需填写身份证号!");
  1292. return;
  1293. }
  1294. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1295. {
  1296. returnErrorMsg("偏远地区需要填写物流费!");
  1297. return;
  1298. }
  1299. if (entity != null)
  1300. {
  1301. if (entity.ctid.IndexOf("C") != -1)
  1302. {
  1303. StringBuilder sql = new StringBuilder();
  1304. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1305. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1306. if (dt.Rows.Count > 0)
  1307. {
  1308. decimal total = 0;
  1309. foreach (DataRow dr in dt.Rows)
  1310. {
  1311. total += Convert.ToDecimal(dr["payment"]);
  1312. }
  1313. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1314. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1315. {
  1316. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1317. return;
  1318. }
  1319. }
  1320. }
  1321. if (entity.OrderState == -1)
  1322. {
  1323. returnErrorMsg("待审核订单无法领取!");
  1324. return;
  1325. }
  1326. entity.CustomerUserId = CurrentUser.UserID;
  1327. if (entity.OrderState < 2)
  1328. {
  1329. entity.OrderState = 2;
  1330. if (entity.ShopId != 0)
  1331. {
  1332. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1333. }
  1334. }
  1335. entity.UpdateTime = DateTime.Now;
  1336. entity.Update();
  1337. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1338. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1339. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1340. {
  1341. dataHelper.api_orderBack(entity.ctid, "0", "");
  1342. }
  1343. returnSuccessMsg("领单成功!");
  1344. return;
  1345. }
  1346. returnErrorMsg("找不到记录");
  1347. }
  1348. }
  1349. public void getmyorder_from_init()
  1350. {
  1351. if (UrlPostParmsCheck("ctid"))
  1352. {
  1353. string eid = GetPostString("ctid");
  1354. CeErpTradeCell entity = null;
  1355. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1356. if (entity != null)
  1357. {
  1358. string sellerMemo = GetPostString("sellerMemo");
  1359. if (sellerMemo.Length > 0)
  1360. {
  1361. entity.seller_memo = sellerMemo;
  1362. }
  1363. string oterhMemo = GetPostString("otherMemo");
  1364. if (oterhMemo.Length > 0)
  1365. {
  1366. entity.OtherMemo = oterhMemo;
  1367. }
  1368. int urg = GetPostInt("urgency");
  1369. entity.IsUrgency = (urg == 1 ? true : false);
  1370. int wechat = GetPostInt("wechat");
  1371. int command = GetPostInt("command");
  1372. if (wechat == 1)
  1373. {
  1374. entity.wechatTag = 1;
  1375. }
  1376. if (command == 1)
  1377. {
  1378. entity.wechatTag = 2;
  1379. }
  1380. string pPro = GetPostString("pprofession");
  1381. if (pPro.Length > 0)
  1382. {
  1383. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1384. string spro = GetPostString("profession");
  1385. if (spro.Length > 0)
  1386. {
  1387. entity.ProfessionId = Convert.ToInt32(spro);
  1388. }
  1389. }
  1390. string proId = GetPostString("productId");
  1391. if (proId.Length > 0)
  1392. {
  1393. entity.ProductId = Convert.ToInt32(proId);
  1394. }
  1395. entity.Material = GetPostString("material");
  1396. entity.Craft = GetPostString("craft");
  1397. entity.CustomerUserId = CurrentUser.UserID;
  1398. if (entity.OrderState < 2)
  1399. {
  1400. entity.OrderState = 2;
  1401. if (entity.ShopId != 0)
  1402. {
  1403. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1404. }
  1405. }
  1406. entity.Update();
  1407. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1408. returnSuccessMsg("领单成功!");
  1409. return;
  1410. }
  1411. returnErrorMsg("找不到记录");
  1412. }
  1413. }
  1414. public void upd_erp_setrelationorder()
  1415. {
  1416. if (UrlPostParmsCheck("ctid"))
  1417. {
  1418. ;
  1419. string eid = GetPostString("ctid");
  1420. string ftid = GetPostString("ftid");
  1421. CeErpTradeCell entity = null;
  1422. CeErpTradeCell fentity = null;
  1423. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1424. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1425. if (fentity == null)
  1426. {
  1427. returnErrorMsg("找不到关联的主订单");
  1428. return;
  1429. }
  1430. if (entity != null)
  1431. {
  1432. if (entity.OrderState >= 5)
  1433. {
  1434. returnErrorMsg("本单已经设计完成无法关联");
  1435. return;
  1436. }
  1437. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1438. {
  1439. returnErrorMsg("线下单续审核后才能关联!");
  1440. return;
  1441. }
  1442. entity.ptid = ftid;
  1443. entity.OrderState = fentity.OrderState;
  1444. //entity.status = fentity.status;
  1445. entity.CustomerUserId = fentity.CustomerUserId;
  1446. entity.DesignUserId = fentity.DesignUserId;
  1447. entity.seller_memo = "补差价单:" + ftid;
  1448. entity.IsSample = 2;
  1449. entity.Update();
  1450. ApiVo apiVo = new ApiVo();
  1451. apiVo.orderNumber = ftid;
  1452. apiVo.payment = entity.payment;
  1453. apiVo.actionName = "repairDesign";
  1454. designHelper.API_WorkCore(apiVo);//repairDesign
  1455. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1456. returnSuccessMsg("关联成功!");
  1457. return;
  1458. }
  1459. else
  1460. returnErrorMsg("找不到记录");
  1461. }
  1462. }
  1463. public void download_erp_neworder()
  1464. {
  1465. string seller = GetPostString("seller_nick");
  1466. string tid = GetPostString("tid");
  1467. if (seller.Length <= 0 || tid.Length <= 0)
  1468. {
  1469. returnErrorMsg("数据错误");
  1470. }
  1471. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1472. //{
  1473. // returnErrorMsg("找不到店铺Sessionkey");
  1474. //}
  1475. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1476. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1477. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1478. if (res.IndexOf("refOid") == -1)
  1479. {
  1480. returnErrorMsg("下载订单数据失败");
  1481. return;
  1482. }
  1483. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1484. returnSuccessMsg("下载完成");
  1485. //tmcHelper.createNewOrder(res);
  1486. //CeErpTrade entr = null;
  1487. //entr = CeErpTrade.Get(tid);
  1488. //if (entr != null)
  1489. //{
  1490. // returnSuccess("下载成功");
  1491. // //下载成功之后,Cell表生成对应的订单;
  1492. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1493. //}
  1494. //else
  1495. //{
  1496. // returnErrorMsg("下载失败或者创建订单失败");
  1497. //}
  1498. }
  1499. public void set_erp_atersale()
  1500. {
  1501. if (UrlPostParmsCheck("ctid"))
  1502. {
  1503. string eid = GetPostString("ctid");
  1504. string reason = GetPostString("AfterSaleReason");
  1505. CeErpTradeCell entity = null;
  1506. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1507. if (entity != null)
  1508. {
  1509. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1510. {
  1511. returnErrorMsg("此订单已经在售后");
  1512. return;
  1513. }*/
  1514. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1515. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1516. entity.AfterSaleTime = DateTime.Now;
  1517. entity.Update();
  1518. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1519. returnSuccessMsg("转售后成功!");
  1520. return;
  1521. }
  1522. returnErrorMsg("找不到记录");
  1523. }
  1524. }
  1525. public void set_erp_withdraw()
  1526. {
  1527. if (UrlPostParmsCheck("ctid"))
  1528. {
  1529. try
  1530. {
  1531. string eid = GetPostString("ctid");//商品id
  1532. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1533. CeWithdraw ceWithdrawSelect = null;
  1534. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1535. if (ceWithdrawSelect != null)
  1536. {
  1537. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1538. {
  1539. ceWithdrawSelect.status = -1;
  1540. ceWithdrawSelect.Update();
  1541. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1542. returnSuccessMsg("重新发起审核成功");
  1543. return;
  1544. }
  1545. else
  1546. {
  1547. returnSuccessMsg("请勿重复申请!");
  1548. return;
  1549. }
  1550. }
  1551. else
  1552. {
  1553. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1554. if (string.IsNullOrEmpty(CustomerUserId))
  1555. {
  1556. CustomerUserId = "-1";
  1557. }
  1558. int Userid = CurrentUser.UserID;//用户id
  1559. CeWithdraw ceWithdraw = new CeWithdraw();
  1560. ceWithdraw.tid = eid;
  1561. ceWithdraw.userid = Userid;
  1562. ceWithdraw.providerid = CustomerUserId;
  1563. ceWithdraw.status = 3;
  1564. ceWithdraw.creationtime = DateTime.Now;
  1565. ceWithdraw.Create();
  1566. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1567. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1568. return;
  1569. }
  1570. }
  1571. catch
  1572. {
  1573. returnErrorMsg("申请撤回订单失败");
  1574. return;
  1575. }
  1576. }
  1577. }
  1578. public void ins_erp_billinfo()
  1579. {
  1580. if (UrlPostParmsCheck("ctid"))
  1581. {
  1582. string eid = GetPostString("ctid");
  1583. CeErpTradeCell entity = null;
  1584. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1585. if (entity != null)
  1586. {
  1587. CeErpBill bill = CeErpBill.GetByTid(eid);
  1588. bool isHave = false;
  1589. if (bill != null)
  1590. {
  1591. isHave = true;
  1592. if (bill.state != 4)
  1593. {
  1594. returnErrorMsg("此单已经申请过发票了");
  1595. return;
  1596. }
  1597. }
  1598. if (entity.IsNeedBill == 0)
  1599. {
  1600. entity.IsNeedBill = 1;
  1601. }
  1602. entity.Update();
  1603. string errjson = "";
  1604. try
  1605. {
  1606. CeErpBill bill_entity = new CeErpBill();
  1607. bill_entity.tid = entity.tid;
  1608. bill_entity.title = GetPostString("title");
  1609. string taxstr = GetPostString("tax");
  1610. taxstr = taxstr.Replace(" ", "");
  1611. bill_entity.tax = taxstr;
  1612. bill_entity.bank = GetPostString("bank");
  1613. string bankacstr = GetPostString("bankac");
  1614. bankacstr = bankacstr.Replace(" ", "");
  1615. bill_entity.bankac = bankacstr;
  1616. bill_entity.address = GetPostString("address");
  1617. bill_entity.phone = GetPostString("phone");
  1618. bill_entity.price = GetPostString("price");
  1619. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1620. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1621. {
  1622. billCount += 1;
  1623. }
  1624. string prebill = "ltb";
  1625. for (int idx = 1; idx <= billCount; idx++)
  1626. {
  1627. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1628. string billoid = prebill + idx + dtstr;
  1629. bill_entity.billOrderId += billoid;
  1630. if (idx < billCount)
  1631. {
  1632. bill_entity.billOrderId += ",";
  1633. }
  1634. }
  1635. bill_entity.productId = GetPostInt("ProductName");
  1636. bill_entity.num = GetPostInt("num");
  1637. bill_entity.unit = GetPostString("unit");
  1638. bill_entity.type = GetPostString("type");
  1639. bill_entity.sendType = GetPostString("SendType");
  1640. bill_entity.email = GetPostString("email");
  1641. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1642. bill_entity.shopName = GetPostString("ShopName");
  1643. bill_entity.applymemo = GetPostString("applyMemo");
  1644. bill_entity.createTime = DateTime.Now;
  1645. bill_entity.state = 0;
  1646. bill_entity.userId = CurrentUser.UserID;
  1647. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1648. bill_entity.Create();
  1649. }
  1650. catch (Exception ex)
  1651. {
  1652. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1653. returnErrorMsg("创建发票出错!");
  1654. return;
  1655. }
  1656. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1657. returnSuccessMsg("发票申请成功!");
  1658. return;
  1659. }
  1660. returnErrorMsg("找不到记录");
  1661. }
  1662. }
  1663. public void ins_erp_neworder()
  1664. {
  1665. if (UrlPostParmsCheck("receiver_name"))
  1666. {
  1667. CeErpTrade entity = new CeErpTrade();
  1668. string plat_form = GetPostString("platform");
  1669. string preStr = "N_";
  1670. if (plat_form == "拼多多")
  1671. {
  1672. preStr = "P_";
  1673. }
  1674. else if (plat_form == "阿里巴巴")
  1675. {
  1676. preStr = "A_";
  1677. }
  1678. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1679. entity.seller_nick = GetPostString("seller_nick");
  1680. entity.buyer_nick = GetPostString("buyer_nick");
  1681. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1682. entity.total_fee = entity.payment;
  1683. entity.pay_time = DateTime.Now;
  1684. entity.status = "NOT_SHIPPED";
  1685. entity.receiver_name = GetPostString("receiver_name");
  1686. entity.receiver_mobile = GetPostString("receiver_mobile");
  1687. entity.receiver_state = GetPostString("receiver_state");
  1688. entity.receiver_city = GetPostString("receiver_city");
  1689. entity.receiver_district = GetPostString("receiver_district");
  1690. entity.receiver_address = GetPostString("receiver_address");
  1691. if (entity.receiver_state == "" || entity.receiver_city == "")
  1692. {
  1693. returnErrorMsg("收件地址不能为空");
  1694. return;
  1695. }
  1696. int shopId = 0;
  1697. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1698. if (nShop != null)
  1699. {
  1700. shopId = nShop.ID;
  1701. }
  1702. if (shopId != 34 && entity.payment == 0)
  1703. {
  1704. returnErrorMsg("公司自用的单金额才能为0");
  1705. return;
  1706. }
  1707. entity.Create();
  1708. CeErpTradeCell entitycell = new CeErpTradeCell();
  1709. entitycell.ctid = entity.tid;
  1710. entitycell.tid = entity.tid;
  1711. entitycell.ShopId = shopId;
  1712. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1713. entitycell.OrderState = 0;
  1714. entitycell.pay_time = entity.pay_time;
  1715. entitycell.IsOffLineOrder = 1;
  1716. entitycell.Create();
  1717. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1718. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1719. return;
  1720. }
  1721. }
  1722. public void ins_erp_neworder2()
  1723. {
  1724. if (UrlPostParmsCheck("receiver_name"))
  1725. {
  1726. //string plat_form = GetPostString("platform");
  1727. string preStr = "X_";
  1728. string memo = GetPostString("memo");
  1729. string productId = GetPostString("productId");
  1730. string primg = GetPostString("proofimg");
  1731. string sellerNick = GetPostString("seller_nick");
  1732. string addFrom = GetPostString("addfrom");
  1733. if (addFrom == "1")
  1734. {
  1735. preStr = "N_";
  1736. }
  1737. int shopId = 0;
  1738. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1739. if (nShop != null)
  1740. {
  1741. shopId = nShop.ID;
  1742. }
  1743. else
  1744. {
  1745. returnErrorMsg("找不到对应店铺");
  1746. return;
  1747. }
  1748. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1749. {
  1750. returnErrorMsg("必须上传付款凭证");
  1751. return;
  1752. }
  1753. CeErpTrade entity = new CeErpTrade();
  1754. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1755. entity.seller_nick = sellerNick;
  1756. entity.buyer_nick = GetPostString("buyer_nick");
  1757. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1758. entity.total_fee = entity.payment;
  1759. entity.pay_time = DateTime.Now;
  1760. entity.status = "NOT_SHIPPED";
  1761. entity.receiver_name = GetPostString("receiver_name");
  1762. entity.receiver_mobile = GetPostString("receiver_mobile");
  1763. entity.receiver_state = GetPostString("receiver_state");
  1764. entity.receiver_city = GetPostString("receiver_city");
  1765. entity.receiver_district = GetPostString("receiver_district");
  1766. entity.receiver_address = GetPostString("receiver_address");
  1767. entity.seller_memo = memo;
  1768. entity.orderFrom = 20;
  1769. entity.orderType = 15;
  1770. if (entity.receiver_state == "" || entity.receiver_city == "")
  1771. {
  1772. returnErrorMsg("收件地址不能为空");
  1773. return;
  1774. }
  1775. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1776. {
  1777. returnErrorMsg("公司自用的单金额才能为0");
  1778. return;
  1779. }
  1780. entity.Create();
  1781. string toWhere = GetPostString("towhere");
  1782. CeErpTradeCell entitycell = new CeErpTradeCell();
  1783. entitycell.ctid = entity.tid;
  1784. //唯一标识
  1785. entitycell.OrderSn = entity.tid;
  1786. string orderSn = dataHelper.getSaleOrderSn();
  1787. if (orderSn != "")
  1788. {
  1789. entitycell.OrderSn = orderSn;
  1790. }
  1791. entitycell.tid = entity.tid;
  1792. //if (preStr == "X_")
  1793. //{
  1794. entitycell.IsOffLineOrder = 1;
  1795. //}
  1796. entitycell.CustomerUserId = CurrentUser.UserID;
  1797. entitycell.PayProofImg = primg;
  1798. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1799. entitycell.ProductId = Convert.ToInt32(productId);
  1800. entitycell.ShopId = shopId;
  1801. entitycell.UpdateTime = DateTime.Now;
  1802. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1803. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1804. {
  1805. entitycell.IsXianHuo = 1;
  1806. }
  1807. entitycell.pay_time = entity.pay_time;
  1808. if (toWhere == "1")
  1809. {
  1810. entitycell.OrderState = 2;
  1811. }
  1812. else
  1813. {
  1814. entitycell.OrderState = 6;
  1815. entitycell.FinishPlaceTime = entitycell.pay_time;
  1816. }
  1817. if (shopId == 94)
  1818. {
  1819. entitycell.OrderState = 4;
  1820. entitycell.WaitDesignTime = entitycell.pay_time;
  1821. entitycell.StartDesignTime = entitycell.pay_time;
  1822. entitycell.DesignUserId = 218;
  1823. }
  1824. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1825. {
  1826. entitycell.OrderState = -1;//修改12-5
  1827. CeWithdraw ceWithdraw = new CeWithdraw();
  1828. ceWithdraw.tid = entity.tid;
  1829. ceWithdraw.providerid = "-1";
  1830. ceWithdraw.status = -1;
  1831. ceWithdraw.creationtime = DateTime.Now;
  1832. ceWithdraw.userid = 742;
  1833. ceWithdraw.Create();
  1834. }
  1835. entitycell.Create();
  1836. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1837. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1838. {
  1839. addPlaceRegist(entitycell, CurrentUser.UserID);
  1840. }
  1841. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1842. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1843. return;
  1844. }
  1845. }
  1846. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1847. {
  1848. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1849. entity.PlactTime = tradecell.pay_time;
  1850. entity.AddUserId = userid;
  1851. entity.FileName = tradecell.seller_memo;
  1852. entity.Supplier = 24;
  1853. entity.CreateTime = DateTime.Now;
  1854. entity.Did = tradecell.ctid;
  1855. entity.tid = tradecell.tid;
  1856. entity.splitTag = tradecell.SplitTag;
  1857. entity.CurState = "未完成";
  1858. entity.Create();
  1859. }
  1860. public void get_erp_offlinelist()
  1861. {
  1862. DataStruct dStruct = GetPostStruct();
  1863. List<string> lw = new List<string>();
  1864. string tid = GetPostString("ctid");
  1865. string date1 = GetPostString("date1");
  1866. string date2 = GetPostString("date2");
  1867. if (tid.Length > 0 || date1.Length > 0)
  1868. {
  1869. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1870. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1871. if (dw.Length > 0) lw.Add(dw);
  1872. }
  1873. else
  1874. {
  1875. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1876. }
  1877. string shopname = GetPostString("shopname");
  1878. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1879. string buyernick = GetPostString("buyer_nick");
  1880. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1881. string customer = GetPostString("customer");
  1882. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1883. string design = GetPostString("design");
  1884. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1885. string orderState = GetPostString("orderState");
  1886. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1887. string address = GetPostString("address");
  1888. 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));
  1889. string sellermemo = GetPostString("seller_memo");
  1890. if (sellermemo.Length > 0)
  1891. {
  1892. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1893. }
  1894. string price1 = GetPostString("price1");
  1895. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1896. string price2 = GetPostString("price2");
  1897. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1898. //if (PKey != "admin")
  1899. //{
  1900. // string usershop = CurrentUser.User.pemShop;
  1901. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1902. //}
  1903. //if (ex_psize > 0)
  1904. //{
  1905. dStruct.Order = "pay_time desc";
  1906. //}
  1907. //else
  1908. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1909. lw.Add(string.Format("IsOffLineOrder=1"));
  1910. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1911. DataTable dt = null;
  1912. dt = WebCache.GetData("view_erptradecell", dStruct);
  1913. writeGridDataTableJson(dStruct.TotalCount, dt);
  1914. }
  1915. public void get_erp_returncashrecord()
  1916. {
  1917. DataStruct dStruct = GetPostStruct();
  1918. List<string> lw = new List<string>();
  1919. string tid = GetPostString("ctid");
  1920. if (tid.Length > 0)
  1921. {
  1922. lw.Add(string.Format("tid like '%{0}%'", tid));
  1923. dStruct.Order = "id desc";
  1924. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1925. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1926. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1927. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1928. return;
  1929. }
  1930. returnErrorMsg("id数据错误!");
  1931. }
  1932. public void ins_erp_returncashrecord()
  1933. {
  1934. if (UrlPostParmsCheck("tid"))
  1935. {
  1936. string tid = GetPostString("tid");
  1937. string retype = GetPostString("type");
  1938. StringBuilder sql = new StringBuilder();
  1939. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1940. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1941. if (dt.Rows.Count > 0)
  1942. {
  1943. returnErrorMsg("相同返现类型记录已存在");
  1944. return;
  1945. }
  1946. CeErpReturnCash entity = new CeErpReturnCash();
  1947. entity.tid = tid;
  1948. entity.seller_nick = GetPostString("seller_nick");
  1949. string pment = GetPostString("payment");
  1950. if (pment.Length > 0)
  1951. {
  1952. entity.payment = Convert.ToDouble(pment);
  1953. }
  1954. entity.buyer_nick = GetPostString("buyer_nick");
  1955. entity.cashstate = 0;
  1956. entity.rtype = retype;
  1957. string rPrice = GetPostString("returnprice");
  1958. if (rPrice.Length > 0)
  1959. {
  1960. entity.returnprice = Convert.ToDouble(rPrice);
  1961. }
  1962. entity.created = DateTime.Now;
  1963. entity.con = GetPostString("con");
  1964. entity.img = GetPostString("img");
  1965. entity.applyuserid = CurrentUser.UserID;
  1966. entity.Create();
  1967. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1968. returnSuccessMsg("操作成功!");
  1969. return;
  1970. }
  1971. }
  1972. public void set_erp_predelivery()
  1973. {
  1974. if (UrlPostParmsCheck("ctid"))
  1975. {
  1976. string eid = GetPostString("ctid");
  1977. CeErpTradeCell entity = null;
  1978. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1979. if (entity != null)
  1980. {
  1981. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1982. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1983. //{
  1984. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1985. // return;
  1986. //}
  1987. entity.IsPreDelivery = 1;
  1988. entity.Update();
  1989. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1990. returnSuccessMsg("预发货成功!");
  1991. return;
  1992. //string shop = GetPostString("seller_nick");
  1993. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1994. //string comName = GetPostString("comName");
  1995. //string comCode = GetPostString("comCode");
  1996. //string outSid = GetPostString("outSid");//运单号
  1997. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1998. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1999. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2000. //string apires = "";
  2001. //if (deliveryType == "虚拟发货")
  2002. //{
  2003. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2004. //}
  2005. //else
  2006. //{
  2007. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2008. //}
  2009. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2010. ////{
  2011. //if (apires.IndexOf("发货成功") != -1)
  2012. //{
  2013. // if (deliveryType != "虚拟发货")
  2014. // {
  2015. // //还要插入快递信息到 快递信息表
  2016. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2017. // exinfo.tid = eid;
  2018. // exinfo.out_sid = outSid;
  2019. // exinfo.company_code = comCode;
  2020. // exinfo.company_name = comName;
  2021. // exinfo.delivery_memo = deliveryMemo;
  2022. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2023. // exinfo.deliveryType = deliveryType;
  2024. // exinfo.Create();
  2025. // }
  2026. // returnSuccessMsg("发货成功!");
  2027. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2028. //}
  2029. //else
  2030. //{
  2031. // returnErrorMsg("淘宝发货失败!!");
  2032. //}
  2033. //return;
  2034. }
  2035. returnErrorMsg("找不到订单记录");
  2036. }
  2037. }
  2038. public void get_erp_unusuallist()
  2039. {
  2040. DataStruct dStruct = GetPostStruct();
  2041. List<string> lw = new List<string>();
  2042. string tid = GetPostString("ctid");
  2043. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2044. string shopname = GetPostString("shopname");
  2045. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2046. string buyernick = GetPostString("buyer_nick");
  2047. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2048. string ResponsibleMan = GetPostString("responsible");
  2049. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2050. string date1 = GetPostString("date1");
  2051. string date2 = GetPostString("date2");
  2052. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2053. if (dw.Length > 0) lw.Add(dw);
  2054. string price1 = GetPostString("price1");
  2055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2056. string price2 = GetPostString("price2");
  2057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2058. string orderState = GetPostString("orderState");
  2059. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2060. string sellermemo = GetPostString("seller_memo");
  2061. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2062. lw.Add(string.Format("UnusualTag > 0"));
  2063. lw.Add(string.Format("IsRefund<={0}", 1));
  2064. dStruct.Order = "pay_time desc";
  2065. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2066. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2067. writeGridDataTableJson(dStruct.TotalCount, dt);
  2068. }
  2069. public void set_erp_unusualtonomal()
  2070. {
  2071. if (UrlPostParmsCheck("ctid"))
  2072. {
  2073. string eid = GetPostString("ctid");
  2074. CeErpTradeCell entity = null;
  2075. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2076. if (entity != null)
  2077. {
  2078. entity.UnusualTag = -1;
  2079. entity.Update();
  2080. returnSuccessMsg("忽略成功!");
  2081. return;
  2082. }
  2083. returnErrorMsg("找不到记录");
  2084. }
  2085. }
  2086. public void ins_erp_unusualreason()
  2087. {
  2088. if (UrlPostParmsCheck("ctid"))
  2089. {
  2090. string eid = GetPostString("ctid");
  2091. CeErpTradeCell entity = null;
  2092. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2093. if (entity != null)
  2094. {
  2095. entity.MemoOpt = 4;
  2096. entity.UnusualCon = GetPostString("con");
  2097. entity.Update();
  2098. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2099. if (trade != null)
  2100. {
  2101. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2102. }
  2103. //查货是否超时
  2104. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2105. if (ceErpTradeCellExtend == null)
  2106. {
  2107. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2108. ceErpTradeCellExtend.ctid = entity.ctid;
  2109. }
  2110. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2111. {
  2112. ceErpTradeCellExtend.CheckOut += 1;
  2113. }
  2114. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2115. if (ceErpTradeCellExtend.ID > 0)
  2116. {
  2117. ceErpTradeCellExtend.Update();
  2118. }
  2119. else
  2120. {
  2121. ceErpTradeCellExtend.Create();
  2122. }
  2123. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2124. returnSuccessMsg("操作成功!");
  2125. return;
  2126. }
  2127. returnErrorMsg("找不到记录");
  2128. }
  2129. }
  2130. public void upd_erp_sampleorder()
  2131. {
  2132. if (UrlPostParmsCheck("ctid"))
  2133. {
  2134. string eid = GetPostString("ctid");
  2135. string[] eArr = eid.Split(',');
  2136. if (eArr.Length > 1)
  2137. {
  2138. List<string> eLst = new List<string>();
  2139. for (int i = 0; i < eArr.Length; i++)
  2140. {
  2141. eLst.Add("'" + eArr[i] + "'");
  2142. }
  2143. eid = string.Join(",", eLst.ToArray());
  2144. }
  2145. else
  2146. {
  2147. eid = "'" + eid + "'";
  2148. }
  2149. StringBuilder sql = new StringBuilder();
  2150. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2151. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2152. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2153. if (dt.Rows.Count > 0)
  2154. {
  2155. string errmsg = "";
  2156. foreach (DataRow dr in dt.Rows)
  2157. {
  2158. StringBuilder sqlsb = new StringBuilder();
  2159. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2160. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2161. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2162. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2163. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2164. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2165. {
  2166. continue;
  2167. }
  2168. else
  2169. {
  2170. string emsg = commonHelper.KeepChinese(apires);
  2171. errmsg += emsg;
  2172. }
  2173. }
  2174. if (errmsg.Length > 0)
  2175. {
  2176. returnErrorMsg(errmsg);
  2177. return;
  2178. }
  2179. returnSuccessMsg("操作成功");
  2180. return;
  2181. }
  2182. returnErrorMsg("找不到记录");
  2183. }
  2184. }
  2185. public void upd_erp_transcustomer()
  2186. {
  2187. if (UrlPostParmsCheck("ctid"))
  2188. {
  2189. string eid = GetPostString("ctid");
  2190. int userid = GetPostInt("CustomerUserId");
  2191. CeErpTradeCell entity = null;
  2192. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2193. if (entity != null)
  2194. {
  2195. //string[] mlist = entity.seller_memo.Split('-');
  2196. //string sql = "select * from view_erpuser where id=" + userid;
  2197. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2198. //if (dt != null && dt.Rows.Count > 0)
  2199. //{
  2200. // string nmemo = "";
  2201. // for(int i = 0; i < mlist.Length - 1; i++)
  2202. // {
  2203. // nmemo += mlist[i];
  2204. // nmemo += "-";
  2205. // }
  2206. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2207. // entity.seller_memo = nmemo;
  2208. //}
  2209. entity.CustomerUserId = userid;
  2210. entity.Update();
  2211. returnSuccessMsg("操作成功!");
  2212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2213. return;
  2214. }
  2215. returnErrorMsg("找不到记录");
  2216. }
  2217. }
  2218. public void upd_erp_transdesigner()
  2219. {
  2220. if (UrlPostParmsCheck("ctid"))
  2221. {
  2222. string eids = GetPostString("ctid");
  2223. string[] ctidList = eids.Split(',');
  2224. int userid = GetPostInt("DesignUserId");
  2225. foreach (string ctid in ctidList)
  2226. {
  2227. CeErpTradeCell entity = null;
  2228. CeErpDesignerBill entitys = null;
  2229. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2230. entitys = CeErpDesignerBill.GetByTid(ctid);
  2231. if (entity != null)
  2232. {
  2233. if (entity.OrderState > 4)
  2234. {
  2235. continue;
  2236. }
  2237. //存在退款不能流转
  2238. if (entity.IsRefund > 0)
  2239. {
  2240. continue;
  2241. }
  2242. entity.DesignUserId = userid;
  2243. entity.WaitDesignTime = DateTime.Now;
  2244. entity.Update();
  2245. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2246. }
  2247. }
  2248. returnSuccessMsg("操作成功!");
  2249. }
  2250. }
  2251. public void upd_erp_distributedesigner()
  2252. {
  2253. if (UrlPostParmsCheck("ctid"))
  2254. {
  2255. string eid = GetPostString("ctid");
  2256. int userid = GetPostInt("DesignUserId");
  2257. string[] idlist = eid.Split(',');
  2258. if (idlist.Length <= 0)
  2259. {
  2260. returnErrorMsg("订单不能为空");
  2261. return;
  2262. }
  2263. foreach (string ctid in idlist)
  2264. {
  2265. CeErpTradeCell entity = null;
  2266. CeErpDesignerBill entitys = null;
  2267. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2268. else continue;
  2269. if (entity != null)
  2270. {
  2271. if (userid == 2125 || userid == 3542)
  2272. { }
  2273. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2274. {
  2275. returnErrorMsg("金额错误的订单无法指派");
  2276. return;
  2277. }
  2278. if (entity.OrderState >= 5)
  2279. {
  2280. returnErrorMsg("已经设计完成无法指派");
  2281. return;
  2282. }
  2283. if (entity.OrderState == -1)
  2284. {
  2285. returnErrorMsg("审核中的订单无法指派");
  2286. return;
  2287. }
  2288. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2289. {
  2290. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2291. return;
  2292. }
  2293. //157赖橙帆 159林晨 73 静之颖
  2294. 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)
  2295. {
  2296. returnErrorMsg("指派设计共创无法再次指派!");
  2297. return;
  2298. }
  2299. entity.OrderState = 3;
  2300. if (entity.SupplierId == 0)
  2301. {
  2302. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2303. entity.SupplierId = suid;
  2304. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2305. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2306. }
  2307. if (userid == 2125 && entity.seller_memo != "")
  2308. {
  2309. apiDesign.API_GetPrintData_CreateOrder(entity);
  2310. }
  2311. if (userid == 3542 && entity.seller_memo != "")
  2312. {
  2313. string userPost = CurrentUser.UserPost.Post.Code;
  2314. if (CurrentUser.UserID == 73)
  2315. {
  2316. userPost = "SysAdmin";
  2317. }
  2318. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2319. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2320. if (response.msg != "设计共创:成功")
  2321. {
  2322. returnErrorMsg(response.msg);
  2323. return;
  2324. }
  2325. entity.DispatchSort = 2;
  2326. }
  2327. else
  2328. {
  2329. if (entity.DispatchSort == 2)
  2330. {
  2331. ApiVo apiVo = new ApiVo();
  2332. apiVo.actionName = "closeDesign";
  2333. apiVo.orderNumber = entity.ctid;
  2334. designHelper.API_WorkCore(apiVo);//closeDesign
  2335. }
  2336. entity.DispatchSort = 0;
  2337. }
  2338. entity.DesignUserId = userid;
  2339. entity.WaitDesignTime = DateTime.Now;
  2340. entity.UpdateTime = DateTime.Now;
  2341. entity.Update();
  2342. string name = commonHelper.getUserNameById(userid);
  2343. commonHelper.UpdateRelationOrder(entity.ctid);
  2344. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2345. }
  2346. }
  2347. returnSuccessMsg("操作成功!");
  2348. return;
  2349. }
  2350. }
  2351. public string getTidByCtid(string ctid)
  2352. {
  2353. string tid = "";
  2354. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2355. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2356. if (dataTable != null && dataTable.Rows.Count > 0)
  2357. {
  2358. tid = dataTable.Rows[0]["tid"].ToString();
  2359. }
  2360. return tid;
  2361. }
  2362. public List<string> getTidByCtidMore(string ctid)
  2363. {
  2364. 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);
  2365. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2366. List<string> list = new List<string>();
  2367. if (dataTable != null && dataTable.Rows.Count > 0)
  2368. {
  2369. foreach (DataRow item in dataTable.Rows)
  2370. {
  2371. list.Add("'" + item["tid"].ToString() + "'");
  2372. }
  2373. }
  2374. return list;
  2375. }
  2376. public List<string> getTidByCtidLike(string ctid)
  2377. {
  2378. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2379. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2380. List<string> list = new List<string>();
  2381. if (dataTable != null && dataTable.Rows.Count > 0)
  2382. {
  2383. foreach (DataRow item in dataTable.Rows)
  2384. {
  2385. list.Add("'" + item["tid"].ToString() + "'");
  2386. }
  2387. }
  2388. return list;
  2389. }
  2390. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2391. {
  2392. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2393. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2394. List<string> list = new List<string>();
  2395. if (dataTable != null && dataTable.Rows.Count > 0)
  2396. {
  2397. foreach (DataRow item in dataTable.Rows)
  2398. {
  2399. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2400. {
  2401. continue;
  2402. }
  2403. list.Add("'" + item["receiverId"].ToString() + "'");
  2404. }
  2405. }
  2406. return list;
  2407. }
  2408. public void get_erp_myorderlist()
  2409. {
  2410. DataStruct dStruct = GetPostStruct();
  2411. List<string> lw = new List<string>();
  2412. string tid = GetPostString("ctid");
  2413. if (tid.Length > 0)
  2414. {
  2415. string select_tid = getTidByCtid(tid);
  2416. lw.Add(string.Format("tid='{0}'", select_tid));
  2417. }
  2418. else
  2419. {
  2420. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2421. }
  2422. //12-1 修改
  2423. string urgent = GetPostString("urgent");
  2424. string back = GetPostString("back");
  2425. string offlineSearch = GetPostString("offlineSearch");
  2426. if (!string.IsNullOrWhiteSpace(urgent))
  2427. {
  2428. if (urgent.Equals("true"))
  2429. {
  2430. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2431. }
  2432. }
  2433. if (!string.IsNullOrWhiteSpace(back))
  2434. {
  2435. if (back.Equals("true"))
  2436. {
  2437. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2438. }
  2439. }
  2440. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2441. {
  2442. if (offlineSearch.Equals("true"))
  2443. {
  2444. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2445. }
  2446. }
  2447. //end
  2448. string shopname = GetPostString("shopname");
  2449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2450. string buyernick = GetPostString("buyer_nick");
  2451. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2452. string design = GetPostString("design");
  2453. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2454. string orderState = GetPostString("orderState");
  2455. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2456. string sellermemo = GetPostString("seller_memo");
  2457. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2458. string date1 = GetPostString("date1");
  2459. string date2 = GetPostString("date2");
  2460. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2461. if (dw.Length > 0) lw.Add(dw);
  2462. string price1 = GetPostString("price1");
  2463. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2464. string price2 = GetPostString("price2");
  2465. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2466. string urgency = GetPostString("urgency");
  2467. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2468. string after = GetPostString("after");
  2469. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2470. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2471. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2472. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2473. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2474. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2475. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2476. if (dt != null && dt.Rows.Count > 0)
  2477. {
  2478. foreach (DataRow dr in dt.Rows)
  2479. {
  2480. try
  2481. {
  2482. // 对象操作
  2483. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2484. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2485. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2486. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2487. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2488. if (dStruct.PageSize != 100000)
  2489. {
  2490. if (dr["DispatchSort"].ToString() == "2")
  2491. {
  2492. dr["gongchuang"] = 200;
  2493. }
  2494. else if ("外协".Equals(dr["ToType"].ToString()))
  2495. {
  2496. dr["gongchuang"] = 200;
  2497. }
  2498. else if ("内部".Equals(dr["ToType"].ToString()))
  2499. {
  2500. dr["gongchuang"] = -1;
  2501. }
  2502. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2503. {
  2504. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2505. dr["gongchuang"] = response.code;
  2506. }
  2507. }
  2508. }
  2509. catch (NullReferenceException ex)
  2510. {
  2511. }
  2512. }
  2513. }
  2514. writeGridDataTableJson(dStruct.TotalCount, dt);
  2515. }
  2516. public void get_erp_myreturnorderlist()
  2517. {
  2518. DataStruct dStruct = GetPostStruct();
  2519. List<string> lw = new List<string>();
  2520. string tid = GetPostString("ctid");
  2521. if (tid.Length > 0)
  2522. {
  2523. string select_tid = getTidByCtid(tid);
  2524. lw.Add(string.Format("tid='{0}'", select_tid));
  2525. }
  2526. else
  2527. {
  2528. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2529. }
  2530. string shopname = GetPostString("shopname");
  2531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2532. string buyernick = GetPostString("buyer_nick");
  2533. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2534. string design = GetPostString("design");
  2535. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2536. string orderState = GetPostString("orderState");
  2537. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2538. string sellermemo = GetPostString("seller_memo");
  2539. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2540. string date1 = GetPostString("date1");
  2541. string date2 = GetPostString("date2");
  2542. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2543. if (dw.Length > 0) lw.Add(dw);
  2544. string price1 = GetPostString("price1");
  2545. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2546. string price2 = GetPostString("price2");
  2547. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2548. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2549. {
  2550. lw.Add(string.Format("CusOrgID = 94"));
  2551. }
  2552. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2553. {
  2554. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2555. }
  2556. else
  2557. {
  2558. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2559. }
  2560. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2561. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2562. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2563. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2564. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2565. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2566. if (dt != null && dt.Rows.Count > 0)
  2567. {
  2568. foreach (DataRow dr in dt.Rows)
  2569. {
  2570. try
  2571. {
  2572. // 对象操作
  2573. if (dStruct.PageSize != 100000)
  2574. {
  2575. if (dr["DispatchSort"].ToString() == "2")
  2576. {
  2577. dr["gongchuang"] = 200;
  2578. }
  2579. else if ("外协".Equals(dr["ToType"].ToString()))
  2580. {
  2581. dr["gongchuang"] = 200;
  2582. }
  2583. else if ("内部".Equals(dr["ToType"].ToString()))
  2584. {
  2585. dr["gongchuang"] = -1;
  2586. }
  2587. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2588. {
  2589. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2590. dr["gongchuang"] = response.code;
  2591. }
  2592. }
  2593. }
  2594. catch (NullReferenceException ex)
  2595. {
  2596. // 处理空引用异常
  2597. }
  2598. }
  2599. }
  2600. writeGridDataTableJson(dStruct.TotalCount, dt);
  2601. }
  2602. public void get_erp_myorderlist_pregather()
  2603. {
  2604. string date1 = GetPostString("date1");
  2605. string date2 = GetPostString("date2");
  2606. int userId = CurrentUser.UserID; //客服id
  2607. string orderWhere = "";
  2608. List<string> lw = new List<string>();
  2609. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2610. if (dw.Length > 0) lw.Add(dw);
  2611. lw.Add(string.Format("CustomerUserId={0}", userId));
  2612. lw.Add(string.Format("OrderState<9"));
  2613. orderWhere = string.Join(" and ", lw.ToArray());
  2614. string orderWhere2 = "";
  2615. List<string> lw2 = new List<string>();
  2616. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2617. if (dw2.Length > 0) lw2.Add(dw2);
  2618. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2619. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2620. string sql = string.Format("select *" +
  2621. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2622. "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 " +
  2623. "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 " +
  2624. "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");
  2625. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2626. //writeGridDataTableJson(dt.Rows.Count, dt);
  2627. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2628. }
  2629. public void upd_erp_publishorder()
  2630. {
  2631. if (UrlPostParmsCheck("ctid"))
  2632. {
  2633. string eid = GetPostString("ctid");
  2634. CeErpTradeCell entity = null;
  2635. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2636. if (entity != null)
  2637. {
  2638. entity.OrderState = 0; //发布后,变为待抢单
  2639. entity.Update();
  2640. commonHelper.UpdateRelationOrder(entity.ctid);
  2641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2642. returnSuccessMsg("发布成功!");
  2643. return;
  2644. }
  2645. returnErrorMsg("找不到记录");
  2646. }
  2647. }
  2648. public void get_erp_my_tiporder()
  2649. {
  2650. StringBuilder sql = new StringBuilder();
  2651. int userId = 0;
  2652. if (CurrentUser != null) userId = CurrentUser.UserID;
  2653. string posCode = CurrentUser.UserPost.Post.Code;
  2654. string isTipedAfterSaleVerify = GetPostString("af");
  2655. DataTable dt = new DataTable();
  2656. if (posCode != "Supplier")
  2657. {
  2658. if (posCode == "CustomerService" || posCode == "Director")
  2659. {
  2660. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2661. }
  2662. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2663. {
  2664. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2665. }
  2666. else
  2667. {
  2668. string teamIds = CurrentUser.User.TeamIds;
  2669. if (teamIds == "")
  2670. {
  2671. teamIds = "0";
  2672. }
  2673. 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);
  2674. }
  2675. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2676. }
  2677. if (dt.Rows.Count <= 0)
  2678. {
  2679. string key = "aftersale_order_" + userId;
  2680. if (RedisHelper.HasKey(key))
  2681. {
  2682. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2683. dt.Columns.Add("ctid", typeof(string));
  2684. dt.Columns.Add("IsReadTag", typeof(int));
  2685. foreach (var i in list)
  2686. {
  2687. DataRow data = dt.NewRow();
  2688. data["ctid"] = i;
  2689. data["IsReadTag"] = 4;
  2690. dt.Rows.Add(data);
  2691. }
  2692. RedisHelper.StringDelete(key);
  2693. }
  2694. }
  2695. if (dt.Rows.Count <= 0)
  2696. {
  2697. sql = new StringBuilder();
  2698. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2699. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2700. }
  2701. if (posCode == "Supplier")
  2702. {
  2703. string ids = CurrentUser.User.pemVend;
  2704. if (ids != null && ids.Length > 0)
  2705. {
  2706. string[] ids_list = ids.Split(',');
  2707. foreach (var item in ids_list)
  2708. {
  2709. string key = "return_order_" + item;
  2710. if (RedisHelper.HasKey(key))
  2711. {
  2712. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2713. dt.Columns.Add("ctid", typeof(string));
  2714. dt.Columns.Add("IsReadTag", typeof(int));
  2715. foreach (var i in list)
  2716. {
  2717. DataRow data = dt.NewRow();
  2718. data["ctid"] = i;
  2719. data["IsReadTag"] = 1;
  2720. dt.Rows.Add(data);
  2721. }
  2722. RedisHelper.StringDelete(key);
  2723. }
  2724. }
  2725. }
  2726. if (dt.Rows.Count <= 0)
  2727. {
  2728. sql = new StringBuilder();
  2729. 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);
  2730. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2731. }
  2732. }
  2733. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2734. }
  2735. public void reset_erp_tiporder()
  2736. {
  2737. string ids = GetPostString("ids");
  2738. string[] ctidList = ids.Split(',');
  2739. foreach (string ctid in ctidList)
  2740. {
  2741. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2742. if (enty != null)
  2743. {
  2744. enty.IsReadTag = 0;
  2745. enty.Update();
  2746. }
  2747. }
  2748. returnSuccessMsg("成功!");
  2749. return;
  2750. }
  2751. public void get_erp_designlist()
  2752. {
  2753. DataStruct dStruct = GetPostStruct();
  2754. List<string> lw = new List<string>();
  2755. string tid = GetPostString("ctid");
  2756. if (tid.Length > 0)
  2757. {
  2758. string select_tid = getTidByCtid(tid);
  2759. lw.Add(string.Format("tid='{0}'", select_tid));
  2760. }
  2761. string shopname = GetPostString("shopname");
  2762. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2763. string buyernick = GetPostString("buyer_nick");
  2764. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2765. string customer = GetPostString("customer");
  2766. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2767. string design = GetPostString("design");
  2768. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2769. string orderState = GetPostString("orderState");
  2770. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2771. lw.Add(string.Format("OrderState<6"));
  2772. string address = GetPostString("address");
  2773. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2774. string sellermemo = GetPostString("seller_memo");
  2775. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2776. string date1 = GetPostString("date1");
  2777. string date2 = GetPostString("date2");
  2778. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2779. if (dw.Length > 0) lw.Add(dw);
  2780. string apdate1 = GetPostString("apdate1");
  2781. string apdate2 = GetPostString("apdate2");
  2782. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2783. if (dwap.Length > 0) lw.Add(dwap);
  2784. string price1 = GetPostString("price1");
  2785. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2786. string price2 = GetPostString("price2");
  2787. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2788. string designTime = GetPostString("designtime");
  2789. if (designTime.Length > 0)
  2790. {
  2791. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2792. }
  2793. string usershop = CurrentUser.User.pemShop;
  2794. if (usershop.Length > 0)
  2795. {
  2796. lw.Add(string.Format("shopId in ({0})", usershop));
  2797. }
  2798. int myOrgid = CurrentUser.UserPost.OrgID;
  2799. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2800. if (myOrgCode.IndexOf("Designer") != -1)
  2801. {
  2802. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2803. {
  2804. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2805. }
  2806. else
  2807. {
  2808. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2809. }
  2810. }
  2811. else
  2812. {
  2813. string orgId = GetPostString("designerhd");
  2814. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2815. }
  2816. if (tid.Length > 0 || buyernick.Length > 0)
  2817. {
  2818. lw.Add(string.Format("OrderState >= 3"));
  2819. }
  2820. else
  2821. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2822. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2823. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2824. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2825. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2826. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2827. if (dt != null && dt.Rows.Count > 0)
  2828. {
  2829. foreach (DataRow dr in dt.Rows)
  2830. {
  2831. try
  2832. {
  2833. // 对象操作
  2834. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2835. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2836. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2837. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2838. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2839. if (dStruct.PageSize != 100000)
  2840. {
  2841. if (dr["DispatchSort"].ToString() == "2")
  2842. {
  2843. dr["gongchuang"] = 200;
  2844. }
  2845. else if ("外协".Equals(dr["ToType"].ToString()))
  2846. {
  2847. dr["gongchuang"] = 200;
  2848. }
  2849. else if ("内部".Equals(dr["ToType"].ToString()))
  2850. {
  2851. dr["gongchuang"] = -1;
  2852. }
  2853. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2854. {
  2855. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2856. dr["gongchuang"] = response.code;
  2857. }
  2858. }
  2859. }
  2860. catch (NullReferenceException ex)
  2861. {
  2862. }
  2863. }
  2864. }
  2865. writeGridDataTableJson(dStruct.TotalCount, dt);
  2866. }
  2867. public void get_erp_mydesignlist()
  2868. {
  2869. DataStruct dStruct = GetPostStruct();
  2870. List<string> lw = new List<string>();
  2871. string tid = GetPostString("ctid");
  2872. if (tid.Length > 0)
  2873. {
  2874. string select_tid = getTidByCtid(tid);
  2875. lw.Add(string.Format("tid='{0}'", select_tid));
  2876. }
  2877. string shopname = GetPostString("shopname");
  2878. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2879. string buyernick = GetPostString("buyer_nick");
  2880. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2881. string customer = GetPostString("customer");
  2882. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2883. string orderState = GetPostString("orderState");
  2884. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2885. //lw.Add(string.Format("OrderState<6"));
  2886. string date1 = GetPostString("date1");
  2887. string date2 = GetPostString("date2");
  2888. string dw = GetDateWhere("pay_time", date1, date2);
  2889. if (dw.Length > 0) lw.Add(dw);
  2890. string apdate1 = GetPostString("apdate1");
  2891. string apdate2 = GetPostString("apdate2");
  2892. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2893. if (dwap.Length > 0) lw.Add(dwap);
  2894. string price1 = GetPostString("price1");
  2895. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2896. string price2 = GetPostString("price2");
  2897. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2898. string olddownload = GetPostString("olddown");
  2899. if (olddownload == "1")
  2900. {
  2901. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2902. }
  2903. else if (olddownload == "2")
  2904. {
  2905. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2906. }
  2907. string sellermemo = GetPostString("seller_memo");
  2908. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2909. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2910. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2911. {
  2912. if (CurrentUser.User.TeamIds.Length > 0)
  2913. {
  2914. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2915. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2916. else
  2917. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2918. }
  2919. else
  2920. {
  2921. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2922. }
  2923. }
  2924. if (tid.Length <= 0)
  2925. {
  2926. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2927. }
  2928. lw.Add(string.Format("IsReturn!=3"));
  2929. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2930. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2931. string teamids = CurrentUser.User.TeamIds.ToString();
  2932. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2933. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2934. if (dt != null && dt.Rows.Count > 0)
  2935. {
  2936. foreach (DataRow dr in dt.Rows)
  2937. {
  2938. try
  2939. {
  2940. // 对象操作
  2941. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2942. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2943. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2944. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2945. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2946. if (dStruct.PageSize != 100000)
  2947. {
  2948. if (dr["DispatchSort"].ToString() == "2")
  2949. {
  2950. dr["gongchuang"] = 200;
  2951. }
  2952. else if ("外协".Equals(dr["ToType"].ToString()))
  2953. {
  2954. dr["gongchuang"] = 200;
  2955. }
  2956. else if ("内部".Equals(dr["ToType"].ToString()))
  2957. {
  2958. dr["gongchuang"] = -1;
  2959. }
  2960. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2961. {
  2962. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2963. dr["gongchuang"] = response.code;
  2964. }
  2965. }
  2966. }
  2967. catch (NullReferenceException ex)
  2968. {
  2969. }
  2970. }
  2971. }
  2972. writeGridDataTableJson(dStruct.TotalCount, dt);
  2973. }
  2974. public void set_erp_startdesign()
  2975. {
  2976. if (UrlPostParmsCheck("ctid"))
  2977. {
  2978. string eid = GetPostString("ctid");
  2979. CeErpTradeCell entity = null;
  2980. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2981. if (entity != null)
  2982. {
  2983. if (entity.OrderState != 3)
  2984. {
  2985. returnErrorMsg("请刷新,订单已经设计了");
  2986. return;
  2987. }
  2988. entity.StartDesignTime = DateTime.Now;
  2989. entity.OrderState = 4;
  2990. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2991. {
  2992. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2993. entity.SupplierId = suid;
  2994. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2995. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2996. }
  2997. entity.UpdateTime = DateTime.Now;
  2998. //entity.MakeSupplier = suname;
  2999. entity.Update();
  3000. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3001. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3002. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3003. commonHelper.getCytPrice(entity);
  3004. returnSuccessMsg("操作成功!");
  3005. return;
  3006. }
  3007. returnErrorMsg("找不到记录");
  3008. }
  3009. }
  3010. public void ins_erp_designselfmemo()
  3011. {
  3012. if (UrlPostParmsCheck("ctid"))
  3013. {
  3014. string eid = GetPostString("ctid");
  3015. string con = GetPostString("con");
  3016. CeErpTradeCell entity = null;
  3017. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3018. if (entity != null)
  3019. {
  3020. entity.DesignSelfMemo = con;
  3021. entity.Update();
  3022. returnSuccessMsg("操作成功!");
  3023. return;
  3024. }
  3025. returnErrorMsg("找不到记录");
  3026. }
  3027. }
  3028. public void ins_erp_designprice()
  3029. {
  3030. if (UrlPostParmsCheck("ctid"))
  3031. {
  3032. string eid = GetPostString("ctid");
  3033. int uid = CurrentUser.UserID;
  3034. string userName = CurrentUser.UserName;
  3035. CeErpTradeCell entity = null;
  3036. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3037. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3038. if (entitys == null)
  3039. {
  3040. entitys = new CeErpDesignerBill();
  3041. }
  3042. if (entity != null)
  3043. {
  3044. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3045. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3046. entity.StartDesignTime = DateTime.Now;
  3047. entity.OrderState = 4;
  3048. string suname = "";
  3049. if (entity.SupplierId == 0)
  3050. {
  3051. int sid = commonHelper.autoDistributeToSupplier(entity);
  3052. entity.SupplierId = sid;
  3053. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3054. }
  3055. entity.Update();
  3056. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3057. if (ceErpUserPost != null)
  3058. {
  3059. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3060. if (ceErpPost != null)
  3061. {
  3062. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3063. {
  3064. entitys.tid = entity.ctid;
  3065. entitys.oid = entity.tid;
  3066. entitys.uid = uid;
  3067. entitys.userName = userName;
  3068. entitys.designerType = 1;
  3069. entitys.designerTypeText = "内部设计师";
  3070. entitys.price = Convert.ToDouble(GetPostString("price"));
  3071. entitys.designNum = GetPostInt("designNum");
  3072. entitys.modifyNum = GetPostInt("modifyNum");
  3073. entitys.designSize = GetPostString("designSize");
  3074. entitys.modifySize = GetPostString("modifySize");
  3075. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3076. {
  3077. entitys.create_time = DateTime.Now;
  3078. entitys.create_u_id = uid;
  3079. entitys.create_u_name = userName;
  3080. entitys.Save();
  3081. }
  3082. else
  3083. {
  3084. entitys.update_time = DateTime.Now;
  3085. entitys.update_u_id = uid;
  3086. entitys.update_u_name = userName;
  3087. entitys.Update();
  3088. }
  3089. }
  3090. }
  3091. }
  3092. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3093. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3094. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3095. if (suname != "")
  3096. {
  3097. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3098. }
  3099. commonHelper.getCytPrice(entity);
  3100. returnSuccessMsg("操作成功!");
  3101. return;
  3102. }
  3103. returnErrorMsg("找不到记录");
  3104. }
  3105. }
  3106. public void upload_erp_filecomplete()
  3107. {
  3108. if (UrlPostParmsCheck("ctid"))
  3109. {
  3110. string eid = GetPostString("ctid");
  3111. CeErpTradeCell entity = null;
  3112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3113. if (entity != null)
  3114. {
  3115. entity.OrderState = 5; //设计完成
  3116. entity.Update();
  3117. returnSuccessMsg(eid + "上传成功,设计完成!");
  3118. return;
  3119. }
  3120. returnErrorMsg("找不到订单记录");
  3121. }
  3122. }
  3123. public void get_erp_designovertimelist()
  3124. {
  3125. DataStruct dStruct = GetPostStruct();
  3126. List<string> lw = new List<string>();
  3127. string tid = GetPostString("ctid");
  3128. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3129. string shopname = GetPostString("shopname");
  3130. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3131. string buyernick = GetPostString("buyer_nick");
  3132. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3133. string ResponsibleMan = GetPostString("responsible");
  3134. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3135. string date1 = GetPostString("date1");
  3136. string date2 = GetPostString("date2");
  3137. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3138. if (dw.Length > 0) lw.Add(dw);
  3139. string price1 = GetPostString("price1");
  3140. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3141. string price2 = GetPostString("price2");
  3142. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3143. string orderState = GetPostString("orderState");
  3144. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3145. string sellermemo = GetPostString("seller_memo");
  3146. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3147. lw.Add(string.Format("UnusualTag=3"));
  3148. lw.Add(string.Format("IsRefund<={0}", 1));
  3149. dStruct.Order = "WaitDesignTime desc";
  3150. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3151. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3152. writeGridDataTableJson(dStruct.TotalCount, dt);
  3153. }
  3154. //设计管理 获取抢单大厅列表
  3155. public void get_erp_grabinglist()
  3156. {
  3157. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3158. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3159. bool oldOrder = false;
  3160. if (org != null)
  3161. {
  3162. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3163. }
  3164. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3165. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3166. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3167. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3168. //先处理订单数据
  3169. if (dt.Rows.Count > 0)
  3170. {
  3171. Dictionary<string, int> design = null;
  3172. int count = 0;
  3173. foreach (DataRow row in dt.Rows)
  3174. {
  3175. if (map.ContainsKey(row["ShopId"].ToString()))
  3176. {
  3177. map.TryGetValue(row["ShopId"].ToString(), out design);
  3178. }
  3179. else
  3180. {
  3181. design = new Dictionary<string, int>();
  3182. }
  3183. if (design.ContainsKey(row["ProductId"].ToString()))
  3184. {
  3185. design.TryGetValue(row["ProductId"].ToString(), out count);
  3186. }
  3187. count++;
  3188. design[row["ProductId"].ToString()] = count;
  3189. map[row["ShopId"].ToString()] = design;
  3190. }
  3191. }
  3192. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3193. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3194. //把店铺排序和技能排序分类
  3195. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3196. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3197. if (design_dt.Rows.Count > 0)
  3198. {
  3199. Dictionary<string, string> design = null;
  3200. List<string> shopIds = null;
  3201. foreach (DataRow row in design_dt.Rows)
  3202. {
  3203. if ("0".Equals(row["designId"].ToString()))
  3204. {
  3205. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3206. {
  3207. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3208. }
  3209. else
  3210. {
  3211. shopIds = new List<string>();
  3212. }
  3213. shopIds.Add(row["shopId"].ToString());
  3214. shop_orders[row["orders"].ToString()] = shopIds;
  3215. }
  3216. else
  3217. {
  3218. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3219. {
  3220. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3221. }
  3222. else
  3223. {
  3224. design = new Dictionary<string, string>();
  3225. }
  3226. design[row["orders"].ToString()] = row["designId"].ToString();
  3227. design_orders[row["shopId"].ToString()] = design;
  3228. }
  3229. }
  3230. //处理成key value后根据key排序
  3231. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3232. foreach (List<string> val in shop_orders.Values)
  3233. {
  3234. if (val != null)
  3235. {
  3236. foreach (string key in val)
  3237. {
  3238. if (design_orders.ContainsKey(key.ToString()))
  3239. {
  3240. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3241. }
  3242. }
  3243. }
  3244. }
  3245. }
  3246. //校验哪个优先级有订单
  3247. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3248. foreach (string key in shop_orders.Keys)
  3249. {
  3250. List<string> ids = null;
  3251. shop_orders.TryGetValue(key, out ids);
  3252. //id为shopid
  3253. foreach (string id in ids)
  3254. {
  3255. Dictionary<string, int> list = null;
  3256. Dictionary<string, string> desing = null;
  3257. map.TryGetValue(id, out list);
  3258. design_orders.TryGetValue(id, out desing);
  3259. if (list != null && desing != null)
  3260. {
  3261. foreach (var item in desing)
  3262. {
  3263. int count = 0;
  3264. if (list.ContainsKey(item.Value))
  3265. {
  3266. list.TryGetValue(item.Value, out count);
  3267. if (count > 0)
  3268. {
  3269. designIds[id] = item.Value;
  3270. break;
  3271. }
  3272. }
  3273. }
  3274. }
  3275. }
  3276. if (designIds.Count > 0)
  3277. {
  3278. break;
  3279. }
  3280. }
  3281. DataTable table = new DataTable();
  3282. table.Columns.Add("tid", typeof(string));
  3283. table.Columns.Add("ctid", typeof(string));
  3284. table.Columns.Add("seller_nick", typeof(string));
  3285. table.Columns.Add("productName", typeof(string));
  3286. table.Columns.Add("pay_time", typeof(string));
  3287. table.Columns.Add("seller_memo", typeof(string));
  3288. if (designIds.Count > 0)
  3289. {
  3290. string shopId = "";
  3291. string productId = "";
  3292. foreach (var designInfo in designIds)
  3293. {
  3294. shopId = designInfo.Key;
  3295. productId = designInfo.Value;
  3296. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3297. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3298. if (dt.Rows.Count > 0)
  3299. {
  3300. foreach (DataRow row in dt.Rows)
  3301. {
  3302. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3303. {
  3304. DataRow data = table.NewRow();
  3305. data["ctid"] = row["ctid"].ToString();
  3306. data["tid"] = row["tid"].ToString();
  3307. data["seller_nick"] = ceErpShop.ShopName;
  3308. data["pay_time"] = row["pay_time"].ToString();
  3309. data["seller_memo"] = row["seller_memo"].ToString();
  3310. data["productName"] = ceErpProduct.PType;
  3311. table.Rows.Add(data);
  3312. }
  3313. }
  3314. }
  3315. }
  3316. }
  3317. writeGridDataTableJson(table.Rows.Count, table);
  3318. }
  3319. private object rushLockObject = new object();
  3320. public void set_erp_grabingorder()
  3321. {
  3322. if (UrlPostParmsCheck("ctid"))
  3323. {
  3324. int total = CurrentUser.User.Person.Total;
  3325. int userId = CurrentUser.User.ID;
  3326. int noFinish = CurrentUser.User.Person.NoFinish;
  3327. int finalization = CurrentUser.User.Person.Finalization;
  3328. string eids = GetPostString("ctid");
  3329. string key = "RushKey_" + userId;
  3330. int count = 0;
  3331. if (erpRedis.RedisHelper.KeyExists(key))
  3332. {
  3333. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3334. if (redisCount != null)
  3335. {
  3336. count = Convert.ToInt32(redisCount);
  3337. }
  3338. }
  3339. if (count >= total)
  3340. {
  3341. returnErrorMsg("半小时内已经抢" + total + "单");
  3342. return;
  3343. }
  3344. string[] ctidlist = eids.Split(',');
  3345. if (count + ctidlist.Length > total)
  3346. {
  3347. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3348. return;
  3349. }
  3350. int itag = 0;
  3351. lock (rushLockObject)
  3352. {
  3353. if (ctidlist.Length > 0)
  3354. {
  3355. string[] dtList = new string[ctidlist.Length];
  3356. for (int i = 0; i < ctidlist.Length; i++)
  3357. {
  3358. dtList[i] = "'" + ctidlist[i] + "'";
  3359. }
  3360. 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"));
  3361. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3362. if (dt_user.Rows.Count > 0)
  3363. {
  3364. int doing = 0;//未定稿
  3365. int finish = 0;//已完成
  3366. foreach (DataRow dr in dt_user.Rows)
  3367. {
  3368. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3369. {
  3370. doing++;
  3371. }
  3372. else
  3373. {
  3374. finish++;
  3375. }
  3376. }
  3377. if (doing >= noFinish)
  3378. {
  3379. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3380. return;
  3381. }
  3382. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3383. {
  3384. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3385. return;
  3386. }
  3387. }
  3388. //校验选择单子状态
  3389. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3390. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3391. if (dt.Rows.Count > 0)
  3392. {
  3393. List<string> list = new List<string>();
  3394. foreach (DataRow dr in dt.Rows)
  3395. {
  3396. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3397. {
  3398. list.Add(dr["ctid"].ToString());
  3399. }
  3400. }
  3401. if (list.Count > 0)
  3402. {
  3403. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3404. return;
  3405. }
  3406. }
  3407. foreach (string ctid in ctidlist)
  3408. {
  3409. CeErpTradeCell entity = null;
  3410. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3411. if (entity != null)
  3412. {
  3413. entity.OrderState = 3;
  3414. entity.DesignUserId = CurrentUser.UserID;
  3415. entity.WaitDesignTime = DateTime.Now;
  3416. entity.StartDesignTime = DateTime.Now;
  3417. entity.Update();
  3418. commonHelper.UpdateRelationOrder(entity.ctid);
  3419. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3420. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3421. itag++;
  3422. }
  3423. }
  3424. }
  3425. }
  3426. count += ctidlist.Length;
  3427. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3428. if (itag == 0)
  3429. returnErrorMsg("没有找到相关订单");
  3430. else
  3431. returnSuccessMsg("抢单成功!");
  3432. return;
  3433. }
  3434. }
  3435. public void get_erp_waitorderlist()
  3436. {
  3437. DataStruct dStruct = GetPostStruct();
  3438. List<string> lw = new List<string>();
  3439. string tid = GetPostString("ctid");
  3440. if (tid.Length > 0)
  3441. {
  3442. string select_tid = getTidByCtid(tid);
  3443. lw.Add(string.Format("tid='{0}'", select_tid));
  3444. }
  3445. string shopname = GetPostString("shopname");
  3446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3447. string buyernick = GetPostString("buyer_nick");
  3448. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3449. string customer = GetPostString("customer");
  3450. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3451. string design = GetPostString("design");
  3452. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3453. string orderState = GetPostString("orderState");
  3454. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3455. string supplier = GetPostString("supplier");
  3456. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3457. string sellermemo = GetPostString("seller_memo");
  3458. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3459. string otherMemo = GetPostString("otherMemo");
  3460. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3461. string address = GetPostString("address");
  3462. 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));
  3463. string date1 = GetPostString("date1");
  3464. string date2 = GetPostString("date2");
  3465. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3466. if (dw.Length > 0) lw.Add(dw);
  3467. string price1 = GetPostString("price1");
  3468. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3469. string price2 = GetPostString("price2");
  3470. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3471. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3472. lw.Add(string.Format("IsSample != 2 "));
  3473. lw.Add(string.Format("OrderState = 5 "));
  3474. lw.Add(string.Format("IsRefund<={0}", 1));
  3475. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3476. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3477. string pagesize = GetPostString("pagesize");
  3478. if (pagesize != null)
  3479. {
  3480. dStruct.PageSize = 200;
  3481. }
  3482. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3483. List<string> tids = new List<string>();
  3484. if (dt != null)
  3485. {
  3486. dt.Columns.Add("compenPrice", typeof(double));
  3487. foreach (DataRow dr in dt.Rows)
  3488. {
  3489. if (Convert.IsDBNull(dr["compenPrice"]))
  3490. {
  3491. dr["compenPrice"] = 0;
  3492. }
  3493. tids.Add("'" + dr["tid"].ToString() + "'");
  3494. 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();
  3495. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3496. {
  3497. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3498. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3499. entity.SupplierId = suid;
  3500. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3501. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3502. entity.Update();
  3503. }
  3504. }
  3505. }
  3506. if (tids.Count > 0)
  3507. {
  3508. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3509. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3510. if (dt_price != null && dt_price.Rows.Count > 0)
  3511. {
  3512. foreach (DataRow dr in dt_price.Rows)
  3513. {
  3514. foreach (DataRow row in dt.Rows)
  3515. {
  3516. if (row["tid"].Equals(dr["ptid"]))
  3517. {
  3518. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3519. break;
  3520. }
  3521. }
  3522. }
  3523. }
  3524. }
  3525. writeGridDataTableJson(dStruct.TotalCount, dt);
  3526. }
  3527. public void get_erp_supplierwaitorderlist()
  3528. {
  3529. DataStruct dStruct = GetPostStruct();
  3530. List<string> lw = new List<string>();
  3531. string tid = GetPostString("ctid");
  3532. if (tid.Length > 0)
  3533. {
  3534. string select_tid = getTidByCtid(tid);
  3535. lw.Add(string.Format("tid='{0}'", select_tid));
  3536. }
  3537. string shopname = GetPostString("shopname");
  3538. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3539. string sellermemo = GetPostString("seller_memo");
  3540. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3541. string date1 = GetPostString("date1");
  3542. string date2 = GetPostString("date2");
  3543. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3544. if (dw.Length > 0) lw.Add(dw);
  3545. lw.Add(string.Format("OrderState = 5 "));
  3546. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3547. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3548. {
  3549. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3550. }
  3551. string supplier = GetPostString("supplier");
  3552. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3553. {
  3554. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3555. }
  3556. lw.Add(string.Format("IsRefund<={0}", 1));
  3557. dStruct.Order = "FinishDesignTime desc";
  3558. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3559. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3560. if (dt != null)
  3561. {
  3562. foreach (DataRow dr in dt.Rows)
  3563. {
  3564. 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();
  3565. }
  3566. }
  3567. writeGridDataTableJson(dStruct.TotalCount, dt);
  3568. }
  3569. public void upd_erp_verifytosupplier()
  3570. {
  3571. if (UrlPostParmsCheck("ctid"))
  3572. {
  3573. string eids = GetPostString("ctid");
  3574. CeErpTradeCell entity = null;
  3575. string[] eidsList = eids.Split(',');
  3576. if (eidsList.Length <= 0)
  3577. {
  3578. returnErrorMsg("订单号不能空");
  3579. return;
  3580. }
  3581. List<string> tLst = new List<string>();
  3582. foreach (string ctidstr in eidsList)
  3583. {
  3584. tLst.Add("'" + ctidstr + "'");
  3585. CeErpDataSendOrderInfo.createObject(ctidstr);
  3586. }
  3587. string needtids = string.Join(",", tLst.ToArray());
  3588. StringBuilder sql = new StringBuilder();
  3589. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3590. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3591. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3592. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3593. returnSuccessMsg("操作成功!");
  3594. return;
  3595. /**foreach (string ctidstr in eidsList)
  3596. {
  3597. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3598. if (entity != null)
  3599. {
  3600. if (entity.SupplierId == 0)
  3601. {
  3602. continue;
  3603. }
  3604. entity.IsVerifyToSupplier = true;
  3605. if (entity.IsReturn == 1) //1是供应商打回
  3606. {
  3607. entity.IsReturn = 0;
  3608. }
  3609. entity.FinishPlaceTime = DateTime.Now;
  3610. entity.PlaceUserId = CurrentUser.UserID;
  3611. entity.Update();
  3612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3613. }
  3614. }
  3615. returnSuccessMsg("操作成功!");
  3616. return;**/
  3617. }
  3618. }
  3619. public void upd_erp_supplierback()
  3620. {
  3621. if (UrlPostParmsCheck("ctid"))
  3622. {
  3623. string eid = GetPostString("ctid");
  3624. string reason = GetPostString("returnreason");
  3625. CeErpTradeCell entity = null;
  3626. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3627. if (entity != null)
  3628. {
  3629. string message = "操作成功!";
  3630. string isDown = "";
  3631. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3632. {
  3633. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3634. isDown = "被点击下载";
  3635. }
  3636. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3637. {
  3638. string key = "return_order_" + entity.SupplierId;
  3639. List<string> list = new List<string>();
  3640. if (RedisHelper.HasKey(key))
  3641. {
  3642. object data = RedisHelper.StringGet(key);
  3643. list = Convert.ToString(data).Split(',').ToList();
  3644. }
  3645. list.Add(eid);
  3646. RedisHelper.StringSet(key, string.Join(",", list));
  3647. }
  3648. entity.IsVerifyToSupplier = false;
  3649. entity.IsReturn = 1;
  3650. entity.IsHaveNewOrder = 0;
  3651. entity.ReturnTime = DateTime.Now;
  3652. entity.ReturnReason = reason;
  3653. if (entity.OrderState == 6)
  3654. {
  3655. entity.OrderState = 5;
  3656. }
  3657. entity.Update();
  3658. CeErpSukuraData.createInfo(entity.ctid, 5);
  3659. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3660. returnSuccessMsg(message);
  3661. return;
  3662. }
  3663. returnErrorMsg("找不到订单记录");
  3664. }
  3665. }
  3666. public void upd_erp_toaftersaleorder()
  3667. {
  3668. if (UrlPostParmsCheck("ctid"))
  3669. {
  3670. string eid = GetPostString("ctid");
  3671. string reason = GetPostString("returnreason");
  3672. CeErpTradeCell entity = null;
  3673. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3674. if (entity != null)
  3675. {
  3676. if (entity.isAfterSaleOrder != 1)
  3677. {
  3678. returnErrorMsg("带S的售后单才能打回给售后");
  3679. return;
  3680. }
  3681. if (entity.OrderState >= 5)
  3682. {
  3683. returnErrorMsg("已经设计完成了不能打回给售后");
  3684. return;
  3685. }
  3686. entity.OrderState = 0;
  3687. entity.IsReturn = 3;
  3688. entity.ReturnTime = DateTime.Now;
  3689. entity.UpdateTime = DateTime.Now;
  3690. entity.ReturnReason = reason;
  3691. entity.Update();
  3692. CeErpSukuraData.createInfo(entity.ctid, 5);
  3693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3694. returnSuccessMsg("操作成功!");
  3695. return;
  3696. }
  3697. returnErrorMsg("找不到订单记录");
  3698. }
  3699. }
  3700. public void upd_erp_aftersaletodesign()
  3701. {
  3702. if (UrlPostParmsCheck("ctid"))
  3703. {
  3704. string eid = GetPostString("ctid");
  3705. CeErpTradeCell entity = null;
  3706. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3707. if (entity != null)
  3708. {
  3709. entity.OrderState = 3;
  3710. entity.IsReturn = 0;
  3711. entity.UpdateTime = DateTime.Now;
  3712. entity.Update();
  3713. CeErpSukuraData.createInfo(entity.ctid, 5);
  3714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3715. returnSuccessMsg("操作成功!");
  3716. return;
  3717. }
  3718. returnErrorMsg("找不到订单记录");
  3719. }
  3720. }
  3721. public void assign_erp_supplier()
  3722. {
  3723. if (UrlPostParmsCheck("ctid"))
  3724. {
  3725. string eids = GetPostString("ctid");
  3726. int sid = GetPostInt("SupplierName");
  3727. string fromTag = GetPostString("tag");
  3728. string[] eidList = eids.Split(',');
  3729. if (eidList.Length <= 0)
  3730. {
  3731. returnErrorMsg("指派不能为空");
  3732. return;
  3733. }
  3734. string errMsg = "";
  3735. string suname = commonHelper.getSupplierNameById(sid);
  3736. foreach (string ctid in eidList)
  3737. {
  3738. CeErpTradeCell entity = null;
  3739. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3740. if (entity != null)
  3741. {
  3742. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3743. {
  3744. errMsg += (ctid + "指派失败!!!");
  3745. continue;
  3746. }
  3747. entity.SupplierId = sid;
  3748. entity.Update();
  3749. commonHelper.UpdateRelationOrder(entity.ctid);
  3750. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3751. if (entity.OrderState >= 6)
  3752. {
  3753. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3754. //{
  3755. // string msl = entity.MakeSupplier;
  3756. // string[] mslist = msl.Split(',');
  3757. // 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);
  3758. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3759. //}
  3760. //else
  3761. //{
  3762. StringBuilder sql = new StringBuilder();
  3763. 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);
  3764. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3765. //}
  3766. }
  3767. }
  3768. else
  3769. {
  3770. continue;
  3771. }
  3772. }
  3773. if (errMsg.Length > 0)
  3774. {
  3775. returnErrorMsg(errMsg);
  3776. return;
  3777. }
  3778. returnSuccessMsg("操作成功!");
  3779. return;
  3780. }
  3781. }
  3782. public void assign_erp_makesupplier()
  3783. {
  3784. if (UrlPostParmsCheck("ctid"))
  3785. {
  3786. string eids = GetPostString("ctid");
  3787. string sname = GetPostString("SupplierName");
  3788. string[] eidList = eids.Split(',');
  3789. if (eidList.Length <= 0)
  3790. {
  3791. returnErrorMsg("指派不能为空");
  3792. return;
  3793. }
  3794. List<string> tLst = new List<string>();
  3795. foreach (string ctid in eidList)
  3796. {
  3797. CeErpTradeCell entity = null;
  3798. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3799. if (entity != null)
  3800. {
  3801. entity.MakeSupplier = sname;
  3802. entity.Update();
  3803. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3804. tLst.Add("'" + ctid + "'");
  3805. }
  3806. else
  3807. {
  3808. continue;
  3809. }
  3810. }
  3811. string ctids = string.Join(",", tLst.ToArray());
  3812. StringBuilder sql2 = new StringBuilder();
  3813. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3814. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3815. returnSuccessMsg("操作成功!");
  3816. return;
  3817. }
  3818. }
  3819. public void ins_erp_returnreason()
  3820. {
  3821. if (UrlPostParmsCheck("ctid"))
  3822. {
  3823. string eid = GetPostString("ctid");
  3824. CeErpTradeCell entity = null;
  3825. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3826. string userpost = CurrentUser.UserPost.Post.Code;
  3827. if (entity != null)
  3828. {
  3829. bool isPlace = false;
  3830. if (entity.OrderState > 6)
  3831. {
  3832. returnErrorMsg("已发货无法打回!");
  3833. return;
  3834. }
  3835. if (entity.OrderState == 6)
  3836. {
  3837. isPlace = true;
  3838. }
  3839. bool isNeedUpdateCell2 = false;
  3840. if (entity.OrderState >= 6)
  3841. {
  3842. isNeedUpdateCell2 = true;
  3843. }
  3844. int returnTag = 2;
  3845. if (userpost == "Supplier")
  3846. {
  3847. returnTag = 1;
  3848. }
  3849. int toType = GetPostInt("totype");
  3850. string fromType = "3";
  3851. if (entity.OrderState < 5)
  3852. {
  3853. fromType = "3";
  3854. }
  3855. else
  3856. {
  3857. fromType = "4";
  3858. }
  3859. if (entity.IsXianHuo == 0)
  3860. {
  3861. if (returnTag == 2)
  3862. {
  3863. if (toType == 1)
  3864. {
  3865. entity.OrderState = 0;
  3866. entity.ReturnUserType = 1;
  3867. string clearman = GetPostString("clearman");
  3868. if (!string.IsNullOrEmpty(clearman))
  3869. {
  3870. entity.DesignUserId = 0;
  3871. }
  3872. }
  3873. else
  3874. {
  3875. entity.OrderState = 3;
  3876. entity.ReturnUserType = 2;
  3877. }
  3878. entity.IsReadTag = 1;
  3879. }
  3880. else if (returnTag == 1)
  3881. {
  3882. entity.OrderState = 5;
  3883. }
  3884. entity.IsVerifyToSupplier = false;
  3885. }
  3886. if (entity.IsXianHuo == 1)
  3887. {
  3888. entity.OrderState = 5;
  3889. }
  3890. entity.UnusualTag = 0;
  3891. entity.UnusualTime = null;
  3892. entity.UnusualCon = "";
  3893. entity.IsReturn = returnTag;
  3894. entity.ReturnTime = DateTime.Now;
  3895. entity.UpdateTime = DateTime.Now;
  3896. entity.ReturnReason = GetPostString("returnreason");
  3897. entity.Update();
  3898. if (entity.OrderState == 3)
  3899. {
  3900. ApiVo apiVo = new ApiVo();
  3901. apiVo.orderNumber = entity.ctid;
  3902. apiVo.actionName = "rebutDesign";
  3903. apiVo.orderRemarks = entity.ReturnReason;
  3904. designHelper.API_WorkCore(apiVo);//rebutDesign
  3905. }
  3906. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3907. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3908. {
  3909. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3910. }
  3911. CeErpSukuraData.createInfo(entity.ctid, 5);
  3912. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3913. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3914. if (isPlace)
  3915. {
  3916. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3917. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3918. if (dth != null && dth.Rows.Count > 0)
  3919. {
  3920. dataSendOrderBean dataSendOrderBean = null;
  3921. foreach (DataRow item in dth.Rows)
  3922. {
  3923. try
  3924. {
  3925. dataSendOrderBean = new dataSendOrderBean();
  3926. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3927. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3928. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3929. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3930. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3931. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3932. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3933. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3934. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3935. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3936. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3937. dataSendOrderBean.Radio1723534706288 = "打回";
  3938. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3939. if (result != null)
  3940. {
  3941. if ("0".Equals(result.errcode))
  3942. {
  3943. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3944. }
  3945. else
  3946. {
  3947. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3948. }
  3949. }
  3950. }
  3951. catch (Exception ex)
  3952. {
  3953. }
  3954. }
  3955. }
  3956. }
  3957. if (isNeedUpdateCell2)
  3958. {
  3959. if (entity.MakeSupplier.IndexOf(",") != -1)
  3960. {
  3961. StringBuilder sql2 = new StringBuilder();
  3962. 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);
  3963. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3964. }
  3965. else
  3966. {
  3967. StringBuilder sql2 = new StringBuilder();
  3968. 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);
  3969. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3970. }
  3971. }
  3972. returnSuccessMsg("操作成功!");
  3973. return;
  3974. }
  3975. returnErrorMsg("找不到订单记录");
  3976. }
  3977. }
  3978. public void cyt_erp_returnreason()
  3979. {
  3980. if (UrlPostParmsCheck("ctid"))
  3981. {
  3982. string eid = GetPostString("ctid");
  3983. CeErpTradeCell entity = null;
  3984. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3985. string userpost = CurrentUser.UserPost.Post.Code;
  3986. if (entity != null)
  3987. {
  3988. if (entity.OrderState > 6)
  3989. {
  3990. returnErrorMsg("已发货无法打回!");
  3991. return;
  3992. }
  3993. JObject jsonObject = new JObject
  3994. {
  3995. { "Userid", "77886" },
  3996. { "Pwd", "lt666888" },
  3997. { "LTOrderId",eid }
  3998. };
  3999. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4000. JObject jsonObjects = JObject.Parse(response);
  4001. string msg = (string)jsonObjects["msg"];
  4002. if (msg != "取消成功")
  4003. {
  4004. returnErrorMsg(msg);
  4005. return;
  4006. }
  4007. bool isNeedUpdateCell2 = false;
  4008. if (entity.OrderState >= 6)
  4009. {
  4010. isNeedUpdateCell2 = true;
  4011. }
  4012. int returnTag = 2;
  4013. if (userpost == "Supplier")
  4014. {
  4015. returnTag = 1;
  4016. }
  4017. if (entity.IsXianHuo == 0)
  4018. {
  4019. if (returnTag == 2)
  4020. {
  4021. int toType = GetPostInt("totype");
  4022. if (toType == 1)
  4023. {
  4024. entity.OrderState = 0;
  4025. entity.ReturnUserType = 1;
  4026. }
  4027. else
  4028. {
  4029. entity.OrderState = 4;
  4030. entity.ReturnUserType = 2;
  4031. }
  4032. entity.IsReadTag = 1;
  4033. }
  4034. else if (returnTag == 1)
  4035. {
  4036. entity.OrderState = 5;
  4037. }
  4038. entity.IsVerifyToSupplier = false;
  4039. }
  4040. entity.UnusualTag = 0;
  4041. entity.UnusualTime = null;
  4042. entity.UnusualCon = "";
  4043. entity.IsReturn = returnTag;
  4044. entity.ReturnTime = DateTime.Now;
  4045. entity.ReturnReason = GetPostString("returnreason");
  4046. entity.Update();
  4047. if (entity.OrderState == 4)
  4048. {
  4049. ApiVo apiVo = new ApiVo();
  4050. apiVo.orderNumber = entity.ctid;
  4051. apiVo.actionName = "rebutDesign";
  4052. apiVo.orderRemarks = entity.ReturnReason;
  4053. designHelper.API_WorkCore(apiVo);//rebutDesign
  4054. }
  4055. CeErpSukuraData.createInfo(entity.ctid, 5);
  4056. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4057. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4058. if (isNeedUpdateCell2)
  4059. {
  4060. if (entity.MakeSupplier.IndexOf(",") != -1)
  4061. {
  4062. StringBuilder sql2 = new StringBuilder();
  4063. 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);
  4064. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4065. }
  4066. else
  4067. {
  4068. StringBuilder sql2 = new StringBuilder();
  4069. 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);
  4070. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4071. }
  4072. }
  4073. returnSuccessMsg("操作成功!");
  4074. return;
  4075. }
  4076. returnErrorMsg("找不到订单记录");
  4077. }
  4078. }
  4079. public void upd_erp_xianhuoreturntag()
  4080. {
  4081. if (UrlPostParmsCheck("ctid"))
  4082. {
  4083. string eids = GetPostString("ctid");
  4084. string[] ctids = eids.Split(',');
  4085. foreach (string ctid in ctids)
  4086. {
  4087. CeErpTradeCell entity = null;
  4088. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4089. if (entity != null)
  4090. {
  4091. entity.IsReturn = 0;
  4092. entity.Update();
  4093. CeErpSukuraData.createInfo(entity.ctid, 5);
  4094. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4095. }
  4096. }
  4097. returnSuccessMsg("操作成功!");
  4098. return;
  4099. }
  4100. }
  4101. public void get_erp_waitdeliverylist()
  4102. {
  4103. DataStruct dStruct = GetPostStruct();
  4104. List<string> lw = new List<string>();
  4105. string tid = GetPostString("ctid");
  4106. if (tid.Length > 0)
  4107. {
  4108. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4109. if (tid.Length > 5)
  4110. {
  4111. List<string> tids = getTidByCtidLike(tid);
  4112. if (tids.Count > 0 && tids.Count < 10)
  4113. {
  4114. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4115. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4116. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4117. {
  4118. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4119. }*/
  4120. }
  4121. }
  4122. lw.Add(tid_sql);
  4123. }
  4124. string shopname = GetPostString("shopname");
  4125. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4126. string buyernick = GetPostString("buyer_nick");
  4127. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4128. //if (tid.Length == 0 && buyernick.Length == 0)
  4129. //{
  4130. // lw.Add(string.Format("IsRefund<={0}", 1));
  4131. //}
  4132. string customer = GetPostString("customer");
  4133. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4134. string design = GetPostString("design");
  4135. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4136. string orderState = GetPostString("orderState");
  4137. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4138. string address = GetPostString("address");
  4139. 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));
  4140. string sellermemo = GetPostString("seller_memo");
  4141. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4142. string supplier = GetPostString("supplier");
  4143. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4144. string OrderArea = GetPostString("order_area");
  4145. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4146. string placedate1 = GetPostString("placedate1");
  4147. string placedate2 = GetPostString("placedate2");
  4148. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4149. if (fdw.Length > 0) lw.Add(fdw);
  4150. string price1 = GetPostString("price1");
  4151. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4152. string price2 = GetPostString("price2");
  4153. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4154. string unusualCon = GetPostString("unusualcon");
  4155. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4156. string otherMemo = GetPostString("otherMemo");
  4157. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4158. string posTag = CurrentUser.UserPost.Post.Code;
  4159. if (posTag == "Supplier")
  4160. {
  4161. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4162. }
  4163. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4164. lw.Add(string.Format("type != 'PDD' "));
  4165. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4166. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4167. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4168. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4169. writeGridDataTableJson(dStruct.TotalCount, dt);
  4170. }
  4171. public void get_erp_changedeliverylist()
  4172. {
  4173. DataStruct dStruct = GetPostStruct();
  4174. List<string> lw = new List<string>();
  4175. string tid = GetPostString("ctid");
  4176. if (tid.Length > 0)
  4177. {
  4178. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4179. if (tid.Length > 5)
  4180. {
  4181. List<string> tids = getTidByCtidLike(tid);
  4182. if (tids.Count > 0 && tids.Count < 10)
  4183. {
  4184. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4185. }
  4186. }
  4187. lw.Add(tid_sql);
  4188. }
  4189. string shopname = GetPostString("shopname");
  4190. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4191. string buyernick = GetPostString("buyer_nick");
  4192. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4193. //if (tid.Length == 0 && buyernick.Length == 0)
  4194. //{
  4195. // lw.Add(string.Format("IsRefund<={0}", 1));
  4196. //}
  4197. string customer = GetPostString("customer");
  4198. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4199. string design = GetPostString("design");
  4200. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4201. string orderState = GetPostString("orderState");
  4202. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4203. string address = GetPostString("address");
  4204. 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));
  4205. string sellermemo = GetPostString("seller_memo");
  4206. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4207. string supplier = GetPostString("supplier");
  4208. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4209. string OrderArea = GetPostString("order_area");
  4210. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4211. string placedate1 = GetPostString("placedate1");
  4212. string placedate2 = GetPostString("placedate2");
  4213. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4214. if (fdw.Length > 0) lw.Add(fdw);
  4215. string price1 = GetPostString("price1");
  4216. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4217. string price2 = GetPostString("price2");
  4218. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4219. string unusualCon = GetPostString("unusualcon");
  4220. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4221. string otherMemo = GetPostString("otherMemo");
  4222. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4223. string posTag = CurrentUser.UserPost.Post.Code;
  4224. if (posTag == "Supplier")
  4225. {
  4226. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4227. }
  4228. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4229. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4230. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4231. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4232. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4233. /*if (tid.Length > 0)
  4234. {
  4235. List<string> tids = new List<string>();
  4236. if (dt != null && dt.Rows.Count > 0)
  4237. {
  4238. foreach (DataRow item in dt.Rows)
  4239. {
  4240. tids.Add("'" + item["tid"] + "'");
  4241. }
  4242. }
  4243. if (tids.Count > 0)
  4244. {
  4245. lw.RemoveAt(0);
  4246. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4247. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4248. dt = WebCache.GetData("view_erptradecell", dStruct);
  4249. }
  4250. }*/
  4251. writeGridDataTableJson(dStruct.TotalCount, dt);
  4252. }
  4253. public void get_erp_pddderiving()
  4254. {
  4255. DataStruct dStruct = GetPostStruct();
  4256. List<string> lw = new List<string>();
  4257. string tid = GetPostString("ctid");
  4258. if (tid.Length > 0)
  4259. {
  4260. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4261. if (tid.Length > 5)
  4262. {
  4263. List<string> tids = getTidByCtidLike(tid);
  4264. if (tids.Count > 0 && tids.Count < 10)
  4265. {
  4266. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4267. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4268. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4269. {
  4270. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4271. }*/
  4272. }
  4273. }
  4274. lw.Add(tid_sql);
  4275. }
  4276. string shopname = GetPostString("shopname");
  4277. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4278. string buyernick = GetPostString("buyer_nick");
  4279. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4280. //if (tid.Length == 0 && buyernick.Length == 0)
  4281. //{
  4282. // lw.Add(string.Format("IsRefund<={0}", 1));
  4283. //}
  4284. string customer = GetPostString("customer");
  4285. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4286. string design = GetPostString("design");
  4287. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4288. string orderState = GetPostString("orderState");
  4289. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4290. string address = GetPostString("address");
  4291. 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));
  4292. string sellermemo = GetPostString("seller_memo");
  4293. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4294. string supplier = GetPostString("supplier");
  4295. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4296. string OrderArea = GetPostString("order_area");
  4297. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4298. string placedate1 = GetPostString("placedate1");
  4299. string placedate2 = GetPostString("placedate2");
  4300. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4301. if (fdw.Length > 0) lw.Add(fdw);
  4302. string price1 = GetPostString("price1");
  4303. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4304. string price2 = GetPostString("price2");
  4305. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4306. string unusualCon = GetPostString("unusualcon");
  4307. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4308. string posTag = CurrentUser.UserPost.Post.Code;
  4309. if (posTag == "Supplier")
  4310. {
  4311. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4312. }
  4313. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4314. lw.Add(string.Format("type = 'PDD' "));
  4315. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4316. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4317. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4318. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4319. /*if (tid.Length > 0)
  4320. {
  4321. List<string> tids = new List<string>();
  4322. if (dt != null && dt.Rows.Count > 0)
  4323. {
  4324. foreach (DataRow item in dt.Rows)
  4325. {
  4326. tids.Add("'" + item["tid"] + "'");
  4327. }
  4328. }
  4329. if (tids.Count > 0)
  4330. {
  4331. lw.RemoveAt(0);
  4332. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4334. dt = WebCache.GetData("view_erptradecell", dStruct);
  4335. }
  4336. }*/
  4337. writeGridDataTableJson(dStruct.TotalCount, dt);
  4338. }
  4339. public void get_erp_jdderiving()
  4340. {
  4341. DataStruct dStruct = GetPostStruct();
  4342. List<string> lw = new List<string>();
  4343. string tid = GetPostString("ctid");
  4344. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4345. string shopname = GetPostString("shopname");
  4346. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4347. string buyernick = GetPostString("buyer_nick");
  4348. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4349. //if (tid.Length == 0 && buyernick.Length == 0)
  4350. //{
  4351. // lw.Add(string.Format("IsRefund<={0}", 1));
  4352. //}
  4353. string customer = GetPostString("customer");
  4354. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4355. string design = GetPostString("design");
  4356. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4357. string orderState = GetPostString("orderState");
  4358. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4359. string address = GetPostString("address");
  4360. 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));
  4361. string sellermemo = GetPostString("seller_memo");
  4362. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4363. string supplier = GetPostString("supplier");
  4364. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4365. string OrderArea = GetPostString("order_area");
  4366. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4367. string placedate1 = GetPostString("placedate1");
  4368. string placedate2 = GetPostString("placedate2");
  4369. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4370. if (fdw.Length > 0) lw.Add(fdw);
  4371. string price1 = GetPostString("price1");
  4372. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4373. string price2 = GetPostString("price2");
  4374. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4375. string unusualCon = GetPostString("unusualcon");
  4376. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4377. string posTag = CurrentUser.UserPost.Post.Code;
  4378. if (posTag == "Supplier")
  4379. {
  4380. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4381. }
  4382. lw.Add(string.Format("OrderState = 6 "));
  4383. lw.Add(string.Format("type = 'JD' "));
  4384. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4385. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4386. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4387. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4388. writeGridDataTableJson(dStruct.TotalCount, dt);
  4389. }
  4390. public void get_erp_demoorderlist()
  4391. {
  4392. DataStruct dStruct = GetPostStruct();
  4393. List<string> lw = new List<string>();
  4394. string tid = GetPostString("ctid");
  4395. if (tid.Length > 0)
  4396. {
  4397. string select_tid = getTidByCtid(tid);
  4398. lw.Add(string.Format("tid='{0}'", select_tid));
  4399. }
  4400. string shopname = GetPostString("shopname");
  4401. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4402. string buyernick = GetPostString("buyer_nick");
  4403. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4404. string customer = GetPostString("customer");
  4405. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4406. string design = GetPostString("design");
  4407. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4408. string orderState = GetPostString("orderState");
  4409. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4410. string address = GetPostString("address");
  4411. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4412. string sellermemo = GetPostString("seller_memo");
  4413. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4414. string supplier = GetPostString("supplier");
  4415. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4416. string OrderArea = GetPostString("order_area");
  4417. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4418. string date1 = GetPostString("date1");
  4419. string date2 = GetPostString("date2");
  4420. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4421. if (dw.Length > 0) lw.Add(dw);
  4422. string price1 = GetPostString("price1");
  4423. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4424. string price2 = GetPostString("price2");
  4425. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4426. string posTag = CurrentUser.UserPost.Post.Code;
  4427. if (posTag == "Supplier")
  4428. {
  4429. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4430. }
  4431. //lw.Add(string.Format("OrderState = 6 "));
  4432. lw.Add(string.Format("IsSample={0}", 3));
  4433. lw.Add(string.Format("IsRefund<={0}", 1));
  4434. dStruct.Order = "pay_time desc";
  4435. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4436. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4437. writeGridDataTableJson(dStruct.TotalCount, dt);
  4438. }
  4439. public void save_erp_checkmemo()
  4440. {
  4441. if (UrlPostParmsCheck("ctid"))
  4442. {
  4443. string ctid = GetPostString("ctid");
  4444. CeErpTradeCell entity = null;
  4445. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4446. if (entity != null)
  4447. {
  4448. entity.CheckMemo = GetPostString("CheckMemo");
  4449. entity.Update();
  4450. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4451. if (trade != null)
  4452. {
  4453. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4454. }
  4455. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4456. returnSuccessMsg("保存成功!");
  4457. return;
  4458. }
  4459. returnErrorMsg("找不到记录");
  4460. }
  4461. }
  4462. public void get_erp_returnlist()
  4463. {
  4464. DataStruct dStruct = GetPostStruct();
  4465. List<string> lw = new List<string>();
  4466. string tid = GetPostString("ctid");
  4467. if (tid.Length > 0)
  4468. {
  4469. string select_tid = getTidByCtid(tid);
  4470. lw.Add(string.Format("tid='{0}'", select_tid));
  4471. }
  4472. string shopname = GetPostString("shopname");
  4473. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4474. string buyernick = GetPostString("buyer_nick");
  4475. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4476. string customer = GetPostString("customer");
  4477. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4478. string design = GetPostString("design");
  4479. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4480. string orderState = GetPostString("orderState");
  4481. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4482. string address = GetPostString("address");
  4483. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4484. string sellermemo = GetPostString("seller_memo");
  4485. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4486. string supplier = GetPostString("supplier");
  4487. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4488. string date1 = GetPostString("date1");
  4489. string date2 = GetPostString("date2");
  4490. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4491. if (dw.Length > 0) lw.Add(dw);
  4492. string bdate1 = GetPostString("backdate1");
  4493. string bdate2 = GetPostString("backdate2");
  4494. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4495. if (dw_back.Length > 0) lw.Add(dw_back);
  4496. string price1 = GetPostString("price1");
  4497. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4498. string price2 = GetPostString("price2");
  4499. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4500. lw.Add(string.Format("IsReturn>0"));
  4501. lw.Add(string.Format("IsXianHuo=0"));
  4502. lw.Add(string.Format("IsReturn!=3"));
  4503. string backtype = GetPostString("backtype");
  4504. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4505. dStruct.Order = "FinishDesignTime desc";
  4506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4507. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4508. writeGridDataTableJson(dStruct.TotalCount, dt);
  4509. }
  4510. public void get_erp_today_sumreturn()
  4511. {
  4512. DataStruct dStruct = GetPostStruct();
  4513. List<string> lw = new List<string>();
  4514. string bdate1 = GetPostString("returnTimeS");
  4515. string bdate2 = GetPostString("returnTimeE");
  4516. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4517. if (dw_back.Length > 0) lw.Add(dw_back);
  4518. lw.Add(string.Format("IsReturn=0"));
  4519. lw.Add(string.Format("IsXianHuo=0"));
  4520. string mainWhere = string.Join(" and ", lw.ToArray());
  4521. string sql = "";
  4522. if (dw_back.Length > 0)
  4523. {
  4524. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4525. }
  4526. else
  4527. {
  4528. 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 + "'";
  4529. }
  4530. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4531. decimal total = 0, today_finish = 0;
  4532. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4533. {
  4534. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4535. }
  4536. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4537. {
  4538. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4539. }
  4540. var res = new
  4541. {
  4542. data = total,
  4543. data1 = today_finish,
  4544. };
  4545. string ro_jsond = JsonConvert.SerializeObject(res);
  4546. returnSuccess(ro_jsond);
  4547. return;
  4548. }
  4549. public void get_erp_allreturnlist()
  4550. {
  4551. DataStruct dStruct = GetPostStruct();
  4552. List<string> lw = new List<string>();
  4553. string tid = GetPostString("ctid");
  4554. if (tid.Length > 0)
  4555. {
  4556. string select_tid = getTidByCtid(tid);
  4557. lw.Add(string.Format("tid='{0}'", select_tid));
  4558. }
  4559. string shopname = GetPostString("shopname");
  4560. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4561. string buyernick = GetPostString("buyer_nick");
  4562. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4563. string customer = GetPostString("customer");
  4564. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4565. string design = GetPostString("design");
  4566. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4567. string orderState = GetPostString("orderState");
  4568. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4569. string address = GetPostString("address");
  4570. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4571. string sellermemo = GetPostString("seller_memo");
  4572. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4573. string supplier = GetPostString("supplier");
  4574. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4575. string date1 = GetPostString("date1");
  4576. string date2 = GetPostString("date2");
  4577. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4578. if (dw.Length > 0) lw.Add(dw);
  4579. string bdate1 = GetPostString("backdate1");
  4580. string bdate2 = GetPostString("backdate2");
  4581. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4582. if (dw_back.Length > 0) lw.Add(dw_back);
  4583. string price1 = GetPostString("price1");
  4584. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4585. string price2 = GetPostString("price2");
  4586. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4587. string backreason = GetPostString("backreason");
  4588. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4589. lw.Add(string.Format("IsXianHuo=0"));
  4590. lw.Add(string.Format("ReturnTime != ''"));
  4591. string backtype = GetPostString("backtype");
  4592. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4593. dStruct.Order = "FinishDesignTime desc";
  4594. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4595. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4596. writeGridDataTableJson(dStruct.TotalCount, dt);
  4597. }
  4598. public void get_erp_aftersalereturnlist()
  4599. {
  4600. DataStruct dStruct = GetPostStruct();
  4601. List<string> lw = new List<string>();
  4602. string tid = GetPostString("ctid");
  4603. if (tid.Length > 0)
  4604. {
  4605. string select_tid = getTidByCtid(tid);
  4606. lw.Add(string.Format("tid='{0}'", select_tid));
  4607. }
  4608. string shopname = GetPostString("shopname");
  4609. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4610. string buyernick = GetPostString("buyer_nick");
  4611. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4612. string customer = GetPostString("customer");
  4613. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4614. string design = GetPostString("design");
  4615. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4616. string orderState = GetPostString("orderState");
  4617. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4618. string address = GetPostString("address");
  4619. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4620. string sellermemo = GetPostString("seller_memo");
  4621. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4622. string supplier = GetPostString("supplier");
  4623. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4624. string date1 = GetPostString("date1");
  4625. string date2 = GetPostString("date2");
  4626. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4627. if (dw.Length > 0) lw.Add(dw);
  4628. string bdate1 = GetPostString("backdate1");
  4629. string bdate2 = GetPostString("backdate2");
  4630. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4631. if (dw_back.Length > 0) lw.Add(dw_back);
  4632. string price1 = GetPostString("price1");
  4633. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4634. string price2 = GetPostString("price2");
  4635. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4636. lw.Add(string.Format("IsReturn=3"));
  4637. string backtype = GetPostString("backtype");
  4638. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4639. string backreason = GetPostString("backreason");
  4640. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4641. dStruct.Order = "ReturnTime desc";
  4642. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4643. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4644. writeGridDataTableJson(dStruct.TotalCount, dt);
  4645. }
  4646. public void get_erp_xianhuoreturnlist()
  4647. {
  4648. DataStruct dStruct = GetPostStruct();
  4649. List<string> lw = new List<string>();
  4650. string tid = GetPostString("ctid");
  4651. if (tid.Length > 0)
  4652. {
  4653. string select_tid = getTidByCtid(tid);
  4654. lw.Add(string.Format("tid='{0}'", select_tid));
  4655. }
  4656. string shopname = GetPostString("shopname");
  4657. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4658. string buyernick = GetPostString("buyer_nick");
  4659. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4660. string customer = GetPostString("customer");
  4661. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4662. string design = GetPostString("design");
  4663. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4664. string orderState = GetPostString("orderState");
  4665. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4666. string address = GetPostString("address");
  4667. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4668. string sellermemo = GetPostString("seller_memo");
  4669. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4670. string supplier = GetPostString("supplier");
  4671. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4672. string OrderArea = GetPostString("order_area");
  4673. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4674. string date1 = GetPostString("date1");
  4675. string date2 = GetPostString("date2");
  4676. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4677. if (dw.Length > 0) lw.Add(dw);
  4678. string price1 = GetPostString("price1");
  4679. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4680. string price2 = GetPostString("price2");
  4681. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4682. string posTag = CurrentUser.UserPost.Post.Code;
  4683. if (posTag == "Supplier")
  4684. {
  4685. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4686. }
  4687. lw.Add(string.Format("OrderState=6 "));
  4688. lw.Add(string.Format("IsXianHuo=1 "));
  4689. lw.Add(string.Format("IsReturn>0 "));
  4690. lw.Add(string.Format("IsReturn!=3"));
  4691. lw.Add(string.Format("IsRefund<={0}", 1));
  4692. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4693. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4694. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4695. writeGridDataTableJson(dStruct.TotalCount, dt);
  4696. }
  4697. public void set_erp_orderdelivery()
  4698. {
  4699. if (UrlPostParmsCheck("ctid"))
  4700. {
  4701. string eid = GetPostString("ctid");
  4702. CeErpTradeCell entity = null;
  4703. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4704. if (entity != null)
  4705. {
  4706. if (entity.OrderState >= 7)
  4707. {
  4708. returnErrorMsg("此单已发货,无需重复发货");
  4709. return;
  4710. }
  4711. if (entity.OrderState != 6)
  4712. {
  4713. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4714. return;
  4715. }
  4716. string shop = GetPostString("seller_nick");
  4717. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4718. string comName = GetPostString("comName");
  4719. string comCode = GetPostString("comCode");
  4720. string outSid = GetPostString("outSid");
  4721. string deliveryType = GetPostString("deliveryType");
  4722. string deliveryMemo = GetPostString("deliveryMemo");
  4723. outSid = outSid.Trim();
  4724. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4725. if (mainEn == null)
  4726. {
  4727. returnErrorMsg("找不到原始订单记录");
  4728. return;
  4729. }
  4730. bool isInitOrderDeliv = false;
  4731. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4732. {
  4733. isInitOrderDeliv = true;
  4734. }
  4735. string apires = "";
  4736. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4737. 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)
  4738. {
  4739. apires = "发货成功true";
  4740. }
  4741. else
  4742. {
  4743. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4744. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4745. }
  4746. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4747. {
  4748. entity.OrderState = 7;//发货后订单已发货
  4749. entity.OutSid = outSid;
  4750. entity.MemoOpt = 0;
  4751. entity.UpdateTime = DateTime.Now;
  4752. entity.FinishDeliveryTime = DateTime.Now;
  4753. entity.Update();
  4754. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4755. commonHelper.UpdateRelationOrder(entity.ctid);
  4756. //还要插入快递信息到 快递信息表
  4757. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4758. exinfo.tid = eid;
  4759. exinfo.out_sid = outSid;
  4760. exinfo.company_code = comCode;
  4761. exinfo.company_name = comName;
  4762. exinfo.delivery_memo = deliveryMemo;
  4763. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4764. exinfo.deliveryType = deliveryType;
  4765. exinfo.Create();
  4766. returnSuccessMsg("发货操作成功!");
  4767. commonHelper.UpdateRelationOrder(entity.ctid);
  4768. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4769. CeErpSukuraData.createInfo(entity.ctid, 4);
  4770. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4771. {
  4772. commonHelper.sendCytExpress(exinfo);
  4773. }
  4774. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4775. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4776. }
  4777. else
  4778. {
  4779. string errmsg = commonHelper.KeepChinese(apires);
  4780. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4781. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4782. }
  4783. return;
  4784. }
  4785. returnErrorMsg("找不到订单记录");
  4786. }
  4787. }
  4788. public void set_erp_multidelivery()
  4789. {
  4790. string eids = GetPostString("tids");
  4791. string[] eidList = eids.Split(',');
  4792. if (eidList.Length <= 0)
  4793. {
  4794. returnErrorMsg("发货不能为空");
  4795. return;
  4796. }
  4797. foreach (string ctid in eidList)
  4798. {
  4799. if (ctid.Length <= 0) continue;
  4800. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4801. if (expInfo != null)
  4802. {
  4803. StringBuilder sql = new StringBuilder();
  4804. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4805. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4806. if (dt.Rows.Count > 0)
  4807. {
  4808. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4809. {
  4810. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4811. expInfo.state = "异常";
  4812. expInfo.isMultiDelivery = 1;
  4813. expInfo.Update();
  4814. continue;
  4815. }
  4816. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4817. {
  4818. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4819. expInfo.state = "异常";
  4820. expInfo.Update();
  4821. continue;
  4822. }
  4823. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4824. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4825. bool isInitOrderDeliv = false;
  4826. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4827. {
  4828. isInitOrderDeliv = true;
  4829. expInfo.isMultiDelivery = 1;
  4830. }
  4831. if (ctid.IndexOf("N") != -1)
  4832. {
  4833. StringBuilder sqlbucha = new StringBuilder();
  4834. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4835. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4836. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4837. commonHelper.UpdateRelationOrder(ctid);
  4838. expInfo.delivery_memo = "发货成功";
  4839. expInfo.state = "发货成功";
  4840. expInfo.isMultiDelivery = 1;
  4841. expInfo.Update();
  4842. }
  4843. else
  4844. {
  4845. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4846. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4847. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4848. {
  4849. expInfo.delivery_memo = "发货成功";
  4850. expInfo.state = "发货成功";
  4851. expInfo.isMultiDelivery = 1;
  4852. expInfo.Update();
  4853. commonHelper.UpdateRelationOrder(ctid);
  4854. CeErpSukuraData.createInfo(ctid, 4);
  4855. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4856. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4857. }
  4858. else
  4859. {
  4860. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4861. expInfo.state = "异常";
  4862. expInfo.Update();
  4863. }
  4864. }
  4865. }
  4866. }
  4867. }
  4868. returnSuccessMsg("操作完成");
  4869. }
  4870. public void reset_erp_memoopt()
  4871. {
  4872. if (UrlPostParmsCheck("ctid"))
  4873. {
  4874. string eid = GetPostString("ctid");
  4875. CeErpTradeCell entity = null;
  4876. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4877. if (entity != null)
  4878. {
  4879. string stropt = "";
  4880. if (entity.MemoOpt == 1)
  4881. {
  4882. stropt = "“改稿”";
  4883. }
  4884. else if (entity.MemoOpt == 2)
  4885. {
  4886. stropt = "“定稿”";
  4887. }
  4888. else if (entity.MemoOpt == 3)
  4889. {
  4890. stropt = "“完成查货”";
  4891. CeErpSukuraData.createInfo(entity.ctid, 6);
  4892. }
  4893. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4894. entity.UpdateTime = DateTime.Now;
  4895. entity.MemoOpt = 0;
  4896. entity.Update();
  4897. returnSuccessMsg("操作成功!");
  4898. return;
  4899. }
  4900. returnErrorMsg("找不到记录");
  4901. }
  4902. }
  4903. public void get_erp_deliveryunusual()
  4904. {
  4905. DataStruct dStruct = GetPostStruct();
  4906. List<string> lw = new List<string>();
  4907. string tid = GetPostString("ctid");
  4908. if (tid.Length > 0)
  4909. {
  4910. string select_tid = getTidByCtid(tid);
  4911. lw.Add(string.Format("tid='{0}'", select_tid));
  4912. }
  4913. string shopname = GetPostString("shopname");
  4914. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4915. string buyernick = GetPostString("buyer_nick");
  4916. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4917. string customer = GetPostString("customer");
  4918. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4919. string design = GetPostString("design");
  4920. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4921. string sellermemo = GetPostString("seller_memo");
  4922. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4923. string supplier = GetPostString("supplier");
  4924. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4925. string date1 = GetPostString("date1");
  4926. string date2 = GetPostString("date2");
  4927. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4928. if (dw.Length > 0) lw.Add(dw);
  4929. string placedate1 = GetPostString("placedate1");
  4930. string placedate2 = GetPostString("placedate2");
  4931. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4932. if (dw_place.Length > 0) lw.Add(dw_place);
  4933. string price1 = GetPostString("price1");
  4934. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4935. string price2 = GetPostString("price2");
  4936. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4937. string unusualCon = GetPostString("unusualcon");
  4938. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4939. string posTag = CurrentUser.UserPost.Post.Code;
  4940. if (posTag == "Supplier")
  4941. {
  4942. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4943. }
  4944. lw.Add(string.Format("OrderState = 6"));
  4945. lw.Add(string.Format("UnusualTag = 5"));
  4946. lw.Add(string.Format("IsRefund<={0}", 1));
  4947. dStruct.Order = "FinishPlaceTime desc";
  4948. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4949. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4950. writeGridDataTableJson(dStruct.TotalCount, dt);
  4951. }
  4952. public void get_erp_deliveryedlist()
  4953. {
  4954. DataStruct dStruct = GetPostStruct();
  4955. List<string> lw = new List<string>();
  4956. string tid = GetPostString("ctid");
  4957. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4958. string shopname = GetPostString("shopname");
  4959. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4960. string buyernick = GetPostString("buyer_nick");
  4961. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4962. string customer = GetPostString("customer");
  4963. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4964. string design = GetPostString("design");
  4965. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4966. string sellermemo = GetPostString("seller_memo");
  4967. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4968. string logistics = GetPostString("logistics");
  4969. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4970. string date1 = GetPostString("date1");
  4971. string date2 = GetPostString("date2");
  4972. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4973. //if (dw.Length > 0) lw.Add(dw);
  4974. string placedate1 = GetPostString("placedate1");
  4975. string placedate2 = GetPostString("placedate2");
  4976. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4977. if (fdw.Length > 0) lw.Add(fdw);
  4978. string devdate1 = GetPostString("deliverydate1");
  4979. string devdate2 = GetPostString("deliverydate2");
  4980. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4981. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4982. string price1 = GetPostString("price1");
  4983. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4984. string price2 = GetPostString("price2");
  4985. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4986. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4987. {
  4988. if (tid.Length > 0)
  4989. {
  4990. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4991. if (tid.Length > 5)
  4992. {
  4993. List<string> tids = getTidByCtidLike(tid);
  4994. if (tids.Count > 0 && tids.Count < 10)
  4995. {
  4996. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4997. }
  4998. }
  4999. lw.Add(tid_sql);
  5000. }
  5001. if (buyernick.Length > 0)
  5002. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5003. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5004. if (dw.Length > 0) lw.Add(dw);
  5005. }
  5006. else
  5007. {
  5008. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5009. }
  5010. string posTag = CurrentUser.UserPost.Post.Code;
  5011. if (posTag == "Supplier")
  5012. {
  5013. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5014. }
  5015. else
  5016. {
  5017. string supplier = GetPostString("supplier");
  5018. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5019. }
  5020. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5021. lw.Add(string.Format("type != 'PDD' "));
  5022. lw.Add(string.Format("IsRefund!={0}", 2));
  5023. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5024. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5025. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5026. /*if (tid.Length > 0)
  5027. {
  5028. List<string> tids = new List<string>();
  5029. if (dt != null && dt.Rows.Count > 0)
  5030. {
  5031. foreach (DataRow item in dt.Rows)
  5032. {
  5033. tids.Add("'" + item["tid"] + "'");
  5034. }
  5035. }
  5036. if (tids.Count > 0)
  5037. {
  5038. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5039. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5040. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5041. dt = WebCache.GetData("view_erptradecell", dStruct);
  5042. }
  5043. }*/
  5044. if (dt != null)
  5045. {
  5046. foreach (DataRow dr in dt.Rows)
  5047. {
  5048. 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();
  5049. }
  5050. }
  5051. writeGridDataTableJson(dStruct.TotalCount, dt);
  5052. }
  5053. public void get_erp_pdddeliveryed()
  5054. {
  5055. DataStruct dStruct = GetPostStruct();
  5056. List<string> lw = new List<string>();
  5057. string tid = GetPostString("ctid");
  5058. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5059. string shopname = GetPostString("shopname");
  5060. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5061. string buyernick = GetPostString("buyer_nick");
  5062. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5063. string customer = GetPostString("customer");
  5064. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5065. string design = GetPostString("design");
  5066. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5067. string sellermemo = GetPostString("seller_memo");
  5068. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5069. string logistics = GetPostString("logistics");
  5070. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5071. string date1 = GetPostString("date1");
  5072. string date2 = GetPostString("date2");
  5073. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5074. //if (dw.Length > 0) lw.Add(dw);
  5075. string placedate1 = GetPostString("placedate1");
  5076. string placedate2 = GetPostString("placedate2");
  5077. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5078. if (fdw.Length > 0) lw.Add(fdw);
  5079. string devdate1 = GetPostString("deliverydate1");
  5080. string devdate2 = GetPostString("deliverydate2");
  5081. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5082. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5083. string price1 = GetPostString("price1");
  5084. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5085. string price2 = GetPostString("price2");
  5086. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5087. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5088. {
  5089. if (tid.Length > 0)
  5090. {
  5091. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5092. if (tid.Length > 5)
  5093. {
  5094. List<string> tids = getTidByCtidLike(tid);
  5095. if (tids.Count > 0 && tids.Count < 10)
  5096. {
  5097. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5098. }
  5099. }
  5100. lw.Add(tid_sql);
  5101. }
  5102. if (buyernick.Length > 0)
  5103. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5104. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5105. if (dw.Length > 0) lw.Add(dw);
  5106. }
  5107. else
  5108. {
  5109. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5110. }
  5111. string posTag = CurrentUser.UserPost.Post.Code;
  5112. if (posTag == "Supplier")
  5113. {
  5114. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5115. }
  5116. else
  5117. {
  5118. string supplier = GetPostString("supplier");
  5119. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5120. }
  5121. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5122. lw.Add(string.Format("type = 'PDD' "));
  5123. lw.Add(string.Format("IsRefund!={0}", 2));
  5124. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5125. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5126. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5127. /* if (tid.Length > 0)
  5128. {
  5129. List<string> tids = new List<string>();
  5130. if (dt != null && dt.Rows.Count > 0)
  5131. {
  5132. foreach (DataRow item in dt.Rows)
  5133. {
  5134. tids.Add("'" + item["tid"] + "'");
  5135. }
  5136. }
  5137. if (tids.Count > 0)
  5138. {
  5139. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5140. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5141. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5142. dt = WebCache.GetData("view_erptradecell", dStruct);
  5143. }
  5144. }*/
  5145. foreach (DataRow dr in dt.Rows)
  5146. {
  5147. 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();
  5148. }
  5149. writeGridDataTableJson(dStruct.TotalCount, dt);
  5150. }
  5151. public void get_erp_jddeliveryed()
  5152. {
  5153. DataStruct dStruct = GetPostStruct();
  5154. List<string> lw = new List<string>();
  5155. string tid = GetPostString("ctid");
  5156. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5157. string shopname = GetPostString("shopname");
  5158. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5159. string buyernick = GetPostString("buyer_nick");
  5160. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5161. string customer = GetPostString("customer");
  5162. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5163. string design = GetPostString("design");
  5164. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5165. string sellermemo = GetPostString("seller_memo");
  5166. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5167. string date1 = GetPostString("date1");
  5168. string date2 = GetPostString("date2");
  5169. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5170. //if (dw.Length > 0) lw.Add(dw);
  5171. string placedate1 = GetPostString("placedate1");
  5172. string placedate2 = GetPostString("placedate2");
  5173. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5174. if (fdw.Length > 0) lw.Add(fdw);
  5175. string devdate1 = GetPostString("deliverydate1");
  5176. string devdate2 = GetPostString("deliverydate2");
  5177. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5178. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5179. string price1 = GetPostString("price1");
  5180. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5181. string price2 = GetPostString("price2");
  5182. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5183. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5184. {
  5185. if (tid.Length > 0)
  5186. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5187. if (buyernick.Length > 0)
  5188. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5189. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5190. if (dw.Length > 0) lw.Add(dw);
  5191. }
  5192. else
  5193. {
  5194. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5195. }
  5196. string posTag = CurrentUser.UserPost.Post.Code;
  5197. if (posTag == "Supplier")
  5198. {
  5199. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5200. }
  5201. else
  5202. {
  5203. string supplier = GetPostString("supplier");
  5204. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5205. }
  5206. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5207. lw.Add(string.Format("type = 'JD' "));
  5208. lw.Add(string.Format("IsRefund!={0}", 2));
  5209. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5210. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5211. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5212. foreach (DataRow dr in dt.Rows)
  5213. {
  5214. 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();
  5215. }
  5216. writeGridDataTableJson(dStruct.TotalCount, dt);
  5217. }
  5218. public void get_erp_allplacelist()
  5219. {
  5220. DataStruct dStruct = GetPostStruct();
  5221. List<string> lw = new List<string>();
  5222. string tid = GetPostString("ctid");
  5223. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5224. string shopname = GetPostString("shopname");
  5225. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5226. string buyernick = GetPostString("buyer_nick");
  5227. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5228. string customer = GetPostString("customer");
  5229. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5230. string design = GetPostString("design");
  5231. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5232. string sellermemo = GetPostString("seller_memo");
  5233. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5234. string supplier = GetPostString("supplier");
  5235. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5236. string date1 = GetPostString("date1");
  5237. string date2 = GetPostString("date2");
  5238. string pldate1 = GetPostString("placedate1");
  5239. string pldate2 = GetPostString("placedate2");
  5240. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5241. //if (dw.Length > 0) lw.Add(dw);
  5242. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5243. {
  5244. if (tid.Length > 0)
  5245. {
  5246. string select_tid = getTidByCtid(tid);
  5247. lw.Add(string.Format("tid='{0}'", select_tid));
  5248. }
  5249. if (buyernick.Length > 0)
  5250. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5251. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5252. if (dw.Length > 0) lw.Add(dw);
  5253. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5254. if (dw_place.Length > 0) lw.Add(dw_place);
  5255. }
  5256. else
  5257. {
  5258. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5259. {
  5260. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5261. }
  5262. }
  5263. string price1 = GetPostString("price1");
  5264. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5265. string price2 = GetPostString("price2");
  5266. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5267. string posTag = CurrentUser.UserPost.Post.Code;
  5268. if (posTag == "Supplier")
  5269. {
  5270. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5271. }
  5272. lw.Add(string.Format("OrderState >= 6"));
  5273. lw.Add(string.Format("IsSample != 2 "));
  5274. //lw.Add(string.Format("isDianziOrder = 0 "));
  5275. lw.Add(string.Format("SupplierId > 0 "));
  5276. //lw.Add(string.Format("IsRefund<={0}", 1));
  5277. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5278. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5279. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5280. foreach (DataRow dr in dt.Rows)
  5281. {
  5282. 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();
  5283. }
  5284. writeGridDataTableJson(dStruct.TotalCount, dt);
  5285. }
  5286. public void get_erp_financeallplacelist()
  5287. {
  5288. DataStruct dStruct = GetPostStruct();
  5289. List<string> lw = new List<string>();
  5290. string tid = GetPostString("ctid");
  5291. string shopname = GetPostString("shopname");
  5292. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5293. string buyernick = GetPostString("buyer_nick");
  5294. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5295. string customer = GetPostString("customer");
  5296. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5297. string design = GetPostString("design");
  5298. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5299. string sellermemo = GetPostString("seller_memo");
  5300. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5301. string supplier = GetPostString("supplier");
  5302. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5303. string date1 = GetPostString("date1");
  5304. string date2 = GetPostString("date2");
  5305. string pldate1 = GetPostString("placedate1");
  5306. string pldate2 = GetPostString("placedate2");
  5307. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5308. {
  5309. if (tid.Length > 0)
  5310. {
  5311. string select_tid = getTidByCtid(tid);
  5312. lw.Add(string.Format("tid='{0}'", select_tid));
  5313. }
  5314. if (buyernick.Length > 0)
  5315. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5316. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5317. if (dw.Length > 0) lw.Add(dw);
  5318. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5319. if (dw_place.Length > 0) lw.Add(dw_place);
  5320. }
  5321. else
  5322. {
  5323. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5324. {
  5325. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5326. }
  5327. }
  5328. string price1 = GetPostString("price1");
  5329. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5330. string price2 = GetPostString("price2");
  5331. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5332. string posTag = CurrentUser.UserPost.Post.Code;
  5333. if (posTag == "Supplier")
  5334. {
  5335. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5336. }
  5337. //lw.Add(string.Format("OrderState >= 6"));
  5338. lw.Add(string.Format("IsSample != 2 "));
  5339. lw.Add(string.Format("isDianziOrder = 0 "));
  5340. //lw.Add(string.Format("IsRefund<={0}", 1));
  5341. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5342. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5343. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5344. foreach (DataRow dr in dt.Rows)
  5345. {
  5346. 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();
  5347. }
  5348. writeGridDataTableJson(dStruct.TotalCount, dt);
  5349. }
  5350. public void get_erp_expresslist()
  5351. {
  5352. int listtype = GetInt("ltype");
  5353. DataStruct dStruct = GetPostStruct();
  5354. List<string> lw = new List<string>();
  5355. string tid = GetPostString("tid");
  5356. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5357. string outsid = GetPostString("out_sid");
  5358. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5359. string importer = GetPostString("ImportUserName");
  5360. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5361. string file = GetPostString("import_file");
  5362. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5363. string printman = GetPostString("printman");
  5364. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5365. string date1 = GetPostString("date1");
  5366. string date2 = GetPostString("date2");
  5367. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5368. if (dw.Length > 0) lw.Add(dw);
  5369. string fdate1 = GetPostString("finishdate1");
  5370. string fdate2 = GetPostString("finishdate2");
  5371. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5372. if (fdw.Length > 0) lw.Add(fdw);
  5373. string supplierId = GetPostString("supplierId");
  5374. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5375. if (listtype == 1)
  5376. {
  5377. lw.Add(string.Format("importUserId !=0"));
  5378. }
  5379. string posTag = CurrentUser.UserPost.Post.Code;
  5380. if (posTag == "Supplier")
  5381. {
  5382. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5383. }
  5384. if (dStruct.PageSize != 100000)
  5385. {
  5386. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5387. }
  5388. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5389. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5390. writeGridDataTableJson(dStruct.TotalCount, dt);
  5391. }
  5392. public void set_erp_buchaorderdelivery()
  5393. {
  5394. if (UrlPostParmsCheck("ctid"))
  5395. {
  5396. string eid = GetPostString("ctid");
  5397. CeErpTradeCell entity = null;
  5398. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5399. if (entity != null)
  5400. {
  5401. if (entity.IsSample != 2)
  5402. {
  5403. returnErrorMsg("补差价单才能标记为已发货");
  5404. return;
  5405. }
  5406. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5407. entity.OrderState = 7;
  5408. entity.Update();
  5409. returnSuccessMsg("操作成功!");
  5410. return;
  5411. }
  5412. returnErrorMsg("找不到记录");
  5413. }
  5414. }
  5415. public void get_stdtemplates()
  5416. {
  5417. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5418. //string res = taobaoHelper.test();
  5419. string res = apiHelper.API_PrintTemplate();
  5420. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5421. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5422. {
  5423. int sidx = res.IndexOf("error_code");
  5424. int eidx = res.IndexOf("success");
  5425. string msg = res.Substring(sidx, eidx - sidx);
  5426. returnErrorMsg(msg);
  5427. return;
  5428. }
  5429. if (res.Length <= 0)
  5430. {
  5431. returnErrorMsg("模板数据为空!");
  5432. return;
  5433. }
  5434. ReturnSuccess(res);
  5435. }
  5436. public void cancel_print_order()
  5437. {
  5438. if (UrlPostParmsCheck("ctid"))
  5439. {
  5440. string ctid = GetPostString("ctid");
  5441. CeErpTradeCell entity = null;
  5442. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5443. if (entity != null)
  5444. {
  5445. string res = "";
  5446. string code = entity.LastBillWaybillCode;
  5447. if (code == "")
  5448. {
  5449. code = entity.OutSid;
  5450. }
  5451. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5452. XLog.SaveLog(0, "取消面单" + res);
  5453. }
  5454. }
  5455. }
  5456. public void set_erp_printwaybill()
  5457. {
  5458. if (UrlPostParmsCheck("ctid"))
  5459. {
  5460. string ctid = GetPostString("ctid");
  5461. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5462. string cpName = GetPostString("cpname");
  5463. string isTogether = GetPostString("together");
  5464. string printType = GetPostString("printType");
  5465. //var res_obj = new
  5466. //{
  5467. // restype = 1,
  5468. // 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\"}"
  5469. //};
  5470. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5471. //ReturnSuccess(ro_json);
  5472. //return;
  5473. bool isUseLastWayBillCode = false;
  5474. CeErpTradeCell entity = null;
  5475. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5476. if (entity != null)
  5477. {
  5478. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5479. {
  5480. isUseLastWayBillCode = true;
  5481. }
  5482. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5483. {
  5484. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5485. return;
  5486. }
  5487. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5488. {
  5489. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5490. return;
  5491. }
  5492. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5493. {
  5494. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5495. return;
  5496. }
  5497. }
  5498. string res = "";
  5499. Api_waybill_code_response_Obj fullObj = null;
  5500. string pData_str = "";
  5501. string curUseWayBillCode = "";
  5502. if (isUseLastWayBillCode == false)
  5503. {
  5504. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5505. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5506. if (res.IndexOf("failure") != -1)
  5507. {
  5508. //int idx = res.IndexOf("sub_message");
  5509. //int idx2 = res.IndexOf("flag");
  5510. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5511. string errMsgNeed = commonHelper.KeepChinese(res);
  5512. var res_objd = new
  5513. {
  5514. restype = 0,
  5515. data = "获取面单失败" + errMsgNeed
  5516. };
  5517. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5518. returnSuccess(ro_jsond);
  5519. if (res.IndexOf("停发") != -1)
  5520. {
  5521. entity.UnusualCon = "物流停发";
  5522. entity.Update();
  5523. }
  5524. //returnErrorMsg("获取面单失败,"+emsg);
  5525. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5526. return;
  5527. }
  5528. else if (res.IndexOf("errorMsg") != -1)
  5529. {
  5530. //int idx = res.IndexOf("errorMsg");
  5531. //int idx2 = res.IndexOf("}]}");
  5532. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5533. string errMsgNeed = commonHelper.KeepChinese(res);
  5534. var res_objf = new
  5535. {
  5536. restype = 0,
  5537. data = "获取面单失败2" + errMsgNeed
  5538. };
  5539. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5540. if (res.IndexOf("停发") != -1)
  5541. {
  5542. entity.UnusualCon = "物流停发";
  5543. entity.Update();
  5544. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5545. if (trade != null)
  5546. {
  5547. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5548. }
  5549. }
  5550. returnSuccess(ro_jsonf);
  5551. //returnErrorMsg("获取面单失败," + emsg);
  5552. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5553. return;
  5554. }
  5555. try
  5556. {
  5557. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5558. //res = res.Replace(" ", "");
  5559. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5560. }
  5561. catch (Exception ex)
  5562. {
  5563. XLog.SaveLog(0, "生成fullObj" + res);
  5564. var res_objf = new
  5565. {
  5566. restype = 0,
  5567. data = "生成fullObj发生错误" + ex.Message
  5568. };
  5569. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5570. returnSuccess(ro_jsonf);
  5571. return;
  5572. }
  5573. if (fullObj.response.data.content.Count > 0)
  5574. {
  5575. ContentItem codeObj = fullObj.response.data.content[0];
  5576. if (cpCode.IndexOf("SFFQ-") != -1)
  5577. {
  5578. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5579. }
  5580. else
  5581. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5582. curUseWayBillCode = codeObj.waybillCode;
  5583. }
  5584. else
  5585. {
  5586. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5587. var res_objf = new
  5588. {
  5589. restype = 0,
  5590. data = "生成fullObj找不到快递单号waybillCode"
  5591. };
  5592. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5593. returnSuccess(ro_jsonf);
  5594. return;
  5595. }
  5596. }
  5597. else
  5598. {
  5599. //使用上次打印的快递单号
  5600. if (cpCode == "SFFQ-LY")
  5601. {
  5602. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5603. }
  5604. else
  5605. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5606. curUseWayBillCode = entity.LastBillWaybillCode;
  5607. }
  5608. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5609. {
  5610. var res_obje = new
  5611. {
  5612. restype = 0,
  5613. data = "获取加密打印数据失败"
  5614. };
  5615. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5616. returnSuccess(ro_jsone);
  5617. entity.LastBillCpCode = cpCode;
  5618. entity.LastBillWaybillCode = curUseWayBillCode;
  5619. entity.Update();
  5620. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5621. //returnErrorMsg("获取加密打印数据失败");
  5622. return;
  5623. }
  5624. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5625. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5626. string btnType = "";
  5627. string errorMsg = "";
  5628. if (entity != null)
  5629. {
  5630. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5631. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5632. //cpcode是 YTO-CAINIAO
  5633. //string comCode = cpCode.Split('-')[0].ToString();
  5634. string apires = "";
  5635. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5636. //isTogether=2是新的合包弹窗
  5637. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5638. {
  5639. if (ctid.IndexOf("N") != -1)
  5640. {
  5641. apires = "发货成功";
  5642. }
  5643. else
  5644. {
  5645. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5646. }
  5647. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5648. //打单后发货
  5649. StringBuilder sql = new StringBuilder();
  5650. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5651. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5652. {
  5653. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5654. }
  5655. else
  5656. {
  5657. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5658. }
  5659. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5660. foreach (DataRow row in dt.Rows)
  5661. {
  5662. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5663. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5664. {
  5665. try
  5666. {
  5667. btnType = "待发货";
  5668. entity.OutSid = curUseWayBillCode;
  5669. entity.OrderState = 7;
  5670. entity.IsUrgency = false;
  5671. entity.LastBillCpCode = "";
  5672. entity.LastBillWaybillCode = "";
  5673. entity.FinishDeliveryTime = DateTime.Now;
  5674. entity.IsReturn = 0;
  5675. entity.MemoOpt = 0;
  5676. entity.UpdateTime = DateTime.Now;
  5677. entity.Update();
  5678. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5679. //还要插入快递信息到 快递信息表
  5680. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5681. exinfo.tid = entity.ctid;
  5682. exinfo.out_sid = curUseWayBillCode;
  5683. exinfo.company_code = cpCode;
  5684. exinfo.company_name = cpName;
  5685. exinfo.supplierUserName = supplierName;
  5686. exinfo.deliveryType = "发货成功";
  5687. exinfo.print_time = DateTime.Now;
  5688. exinfo.printUser = CurrentUser.UserName;
  5689. exinfo.postData = pData_str;
  5690. exinfo.Create();
  5691. commonHelper.UpdateRelationOrder(entity.ctid);
  5692. CeErpSukuraData.createInfo(ctid, 4);
  5693. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5694. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5695. {
  5696. commonHelper.sendCytExpress(exinfo);
  5697. }
  5698. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5699. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5700. }
  5701. catch (Exception ex)
  5702. {
  5703. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5704. }
  5705. }
  5706. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5707. {
  5708. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5709. if (entity.OrderState == 6)
  5710. {
  5711. entity.OrderState = 7;
  5712. }
  5713. entity.UpdateTime = DateTime.Now;
  5714. entity.FinishDeliveryTime = DateTime.Now;
  5715. btnType = "已发货";
  5716. entity.Update();
  5717. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5718. exinfo.tid = entity.ctid;
  5719. exinfo.out_sid = curUseWayBillCode;
  5720. exinfo.company_code = cpCode;
  5721. exinfo.company_name = cpName;
  5722. exinfo.supplierUserName = supplierName;
  5723. exinfo.deliveryType = "发货成功";
  5724. exinfo.print_time = DateTime.Now;
  5725. exinfo.printUser = CurrentUser.UserName;
  5726. exinfo.postData = pData_str;
  5727. exinfo.Create();
  5728. commonHelper.UpdateRelationOrder(entity.ctid);
  5729. CeErpSukuraData.createInfo(entity.ctid, 4);
  5730. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5731. {
  5732. commonHelper.sendCytExpress(exinfo);
  5733. }
  5734. //不处理
  5735. }
  5736. else
  5737. {
  5738. entity.UpdateTime = DateTime.Now;
  5739. entity.LastBillCpCode = cpCode;
  5740. entity.LastBillWaybillCode = curUseWayBillCode;
  5741. entity.Update();
  5742. string errmsg = commonHelper.KeepChinese(apires);
  5743. var res_objz = new
  5744. {
  5745. restype = 0,
  5746. data = "打单后发货失败"
  5747. };
  5748. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5749. returnSuccess(ro_jsonz);
  5750. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5751. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5752. return;
  5753. }
  5754. }
  5755. }
  5756. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5757. {
  5758. string ctids = GetPostString("ctids");
  5759. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5760. List<string> list = new List<string>();
  5761. List<string> send_list = new List<string>();
  5762. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5763. CeErpTrade ceErpTrade = new CeErpTrade();
  5764. //可合包的合并一起发货
  5765. if (dt == null && string.IsNullOrEmpty(ctids))
  5766. {
  5767. var res_objz = new
  5768. {
  5769. restype = 0,
  5770. data = "打单后发货失败"
  5771. };
  5772. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5773. returnSuccess(ro_jsonz);
  5774. return;
  5775. }
  5776. if (!string.IsNullOrEmpty(ctids))
  5777. {
  5778. StringBuilder sql = new StringBuilder();
  5779. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5780. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5781. }
  5782. foreach (DataRow row in dt.Rows)
  5783. {
  5784. list.Add("'" + row["ctid"] + "'");
  5785. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5786. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5787. if (ctid.IndexOf("N") != -1)
  5788. {
  5789. apires = "发货成功";
  5790. }
  5791. else
  5792. {
  5793. if (!send_list.Contains(ceErpTrade.tid))
  5794. {
  5795. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5796. }
  5797. else
  5798. {
  5799. apires = "发货成功";
  5800. }
  5801. }
  5802. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5803. {
  5804. send_list.Add(ceErpTrade.tid);
  5805. try
  5806. {
  5807. btnType = "待发货";
  5808. ceErpTradeCell.OutSid = curUseWayBillCode;
  5809. ceErpTradeCell.OrderState = 7;
  5810. ceErpTradeCell.IsUrgency = false;
  5811. ceErpTradeCell.LastBillCpCode = "";
  5812. ceErpTradeCell.LastBillWaybillCode = "";
  5813. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5814. ceErpTradeCell.IsReturn = 0;
  5815. ceErpTradeCell.MemoOpt = 0;
  5816. ceErpTradeCell.UpdateTime = DateTime.Now;
  5817. ceErpTradeCell.Update();
  5818. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5819. //还要插入快递信息到 快递信息表
  5820. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5821. exinfo.tid = ceErpTradeCell.ctid;
  5822. exinfo.out_sid = curUseWayBillCode;
  5823. exinfo.company_code = cpCode;
  5824. exinfo.company_name = cpName;
  5825. exinfo.supplierUserName = supplierName;
  5826. exinfo.deliveryType = "发货成功";
  5827. exinfo.print_time = DateTime.Now;
  5828. exinfo.printUser = CurrentUser.UserName;
  5829. exinfo.postData = pData_str;
  5830. exinfo.Create();
  5831. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5832. CeErpSukuraData.createInfo(ctid, 4);
  5833. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5834. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5835. {
  5836. commonHelper.sendCytExpress(exinfo);
  5837. }
  5838. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5839. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5840. }
  5841. catch (Exception ex)
  5842. {
  5843. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5844. }
  5845. }
  5846. else
  5847. {
  5848. ceErpTradeCell.UpdateTime = DateTime.Now;
  5849. ceErpTradeCell.LastBillCpCode = cpCode;
  5850. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5851. ceErpTradeCell.Update();
  5852. string errmsg = commonHelper.KeepChinese(apires);
  5853. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5854. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5855. }
  5856. }
  5857. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5858. }
  5859. }
  5860. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5861. var res_obj = new
  5862. {
  5863. restype = 1,
  5864. data = pData_str,
  5865. errorMsg
  5866. };
  5867. string ro_json = JsonConvert.SerializeObject(res_obj);
  5868. ReturnSuccess(ro_json);
  5869. return;
  5870. }
  5871. }
  5872. private string GetUTF8String(byte[] vs)
  5873. {
  5874. throw new NotImplementedException();
  5875. }
  5876. public void set_erp_printwaybill_cn()
  5877. {
  5878. if (UrlPostParmsCheck("ctid"))
  5879. {
  5880. string ctid = GetPostString("ctid");
  5881. string cpCode = GetPostString("cpcode");
  5882. string cpName = GetPostString("cpname");
  5883. string tempUrl = GetPostString("tempurl");
  5884. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5885. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5886. //string res = taobaoHelper.test();
  5887. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5888. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5889. {
  5890. int sidx = res.IndexOf("errorMsg");
  5891. int eidx = res.IndexOf("}");
  5892. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5893. var res_objzxx = new
  5894. {
  5895. restype = 0,
  5896. data = msg
  5897. };
  5898. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5899. returnSuccess(ro_jsonzxx);
  5900. //returnErrorMsg(msg);
  5901. return;
  5902. }
  5903. int idx = res.IndexOf("waybillCode");
  5904. int idx2 = res.IndexOf("printData");
  5905. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5906. string eid = GetPostString("ctid");
  5907. CeErpTradeCell entity = null;
  5908. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5909. if (entity != null)
  5910. {
  5911. string osid = entity.OutSid;
  5912. entity.OutSid = osid + "," + outsid;
  5913. entity.FinishDeliveryTime = DateTime.Now;
  5914. entity.OrderState = 7;
  5915. entity.UpdateTime = DateTime.Now;
  5916. entity.IsReturn = 0;
  5917. entity.Update();
  5918. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5919. exinfo.tid = entity.ctid;
  5920. exinfo.out_sid = outsid;
  5921. exinfo.company_code = cpCode;
  5922. exinfo.company_name = cpName;
  5923. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5924. exinfo.deliveryType = "发货成功";
  5925. exinfo.print_time = DateTime.Now;
  5926. exinfo.printUser = CurrentUser.UserName;
  5927. exinfo.Create();
  5928. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5929. {
  5930. commonHelper.sendCytExpress(exinfo);
  5931. }
  5932. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5933. }
  5934. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5935. var res_objz = new
  5936. {
  5937. restype = 1,
  5938. data = res
  5939. };
  5940. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5941. returnSuccess(ro_jsonz);
  5942. //ReturnSuccess(res);
  5943. }
  5944. }
  5945. ////打单,打印面单 获取面单号
  5946. //public void set_erp_printwaybill()
  5947. //{
  5948. // if (UrlPostParmsCheck("ctid"))
  5949. // {
  5950. // string ctid = GetPostString("ctid");
  5951. // string cpCode = GetPostString("cpcode");
  5952. // string tempUrl = GetPostString("tempurl");
  5953. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5954. // //string res = taobaoHelper.test();
  5955. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5956. // if (res.IndexOf("error_response") != -1)
  5957. // {
  5958. // int sidx = res.IndexOf("sub_msg");
  5959. // int eidx = res.IndexOf("request_id");
  5960. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5961. // returnErrorMsg(msg);
  5962. // return;
  5963. // }
  5964. // int idx = res.IndexOf("waybill_code");
  5965. // int idx2 = res.IndexOf("}]}");
  5966. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5967. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5968. // ReturnSuccess(res);
  5969. // }
  5970. //}
  5971. public void cancel_erp_aftersale()
  5972. {
  5973. if (UrlPostParmsCheck("ctid"))
  5974. {
  5975. string eid = GetPostString("ctid");
  5976. CeErpTradeCell entity = null;
  5977. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5978. if (entity != null)
  5979. {
  5980. //有过处理的售后,取消也不能删除 售 字,保留
  5981. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5982. {
  5983. entity.AfterSaleState = 4;
  5984. }
  5985. else
  5986. entity.AfterSaleState = 0;
  5987. entity.UpdateTime = DateTime.Now;
  5988. entity.Update();
  5989. returnSuccessMsg("操作成功!");
  5990. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5991. return;
  5992. }
  5993. returnErrorMsg("找不到订单记录");
  5994. }
  5995. }
  5996. public void get_erp_aftersalelist()
  5997. {
  5998. DataStruct dStruct = GetPostStruct();
  5999. List<string> lw = new List<string>();
  6000. int st = GetInt("st");
  6001. string tid = GetPostString("ctid");
  6002. if (st == 3)
  6003. {
  6004. if (tid.Length > 0)
  6005. {
  6006. string select_tid = getTidByCtid(tid);
  6007. lw.Add(string.Format("tid='{0}'", select_tid));
  6008. }
  6009. }
  6010. else
  6011. {
  6012. if (tid.Length > 0)
  6013. {
  6014. string select_tid = getTidByCtid(tid);
  6015. lw.Add(string.Format("tid='{0}'", select_tid));
  6016. }
  6017. }
  6018. string shopname = GetPostString("shopname");
  6019. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6020. string buyernick = GetPostString("buyer_nick");
  6021. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6022. string sellermemo = GetPostString("seller_memo");
  6023. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6024. string orderState = GetPostString("orderState");
  6025. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6026. string afterState = GetPostString("afterstate");
  6027. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6028. string date1 = GetPostString("date1");
  6029. string date2 = GetPostString("date2");
  6030. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6031. if (dw.Length > 0) lw.Add(dw);
  6032. string price1 = GetPostString("price1");
  6033. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6034. string price2 = GetPostString("price2");
  6035. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6036. //lw.Add(string.Format("IsRefund!={0}", 1));
  6037. string reason = GetPostString("reason");
  6038. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6039. string method = GetPostString("method");
  6040. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6041. string handler = GetPostString("handler");
  6042. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6043. string handledate1 = GetPostString("handledate1");
  6044. string handledate2 = GetPostString("handledate2");
  6045. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6046. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6047. string finish1 = GetPostString("finishdate1");
  6048. string finish2 = GetPostString("finishdate2");
  6049. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6050. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6051. string afterdate1 = GetPostString("afterdate1");
  6052. string afterdate2 = GetPostString("afterdate2");
  6053. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6054. if (afterDate.Length > 0) lw.Add(afterDate);
  6055. string supplier = GetPostString("supplier");
  6056. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6057. string responsible = GetPostString("responsibleman");
  6058. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6059. string customer = GetPostString("customer");
  6060. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6061. string design = GetPostString("design");
  6062. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6063. string afterMemoType = GetPostString("aftermemotype");
  6064. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6065. string posCode = CurrentUser.UserPost.Post.Code;
  6066. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6067. //{
  6068. // string vstate = GetPostString("vstate");
  6069. // if (vstate.Length > 0)
  6070. // {
  6071. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6072. // }
  6073. // if (posCode == "Supplier")
  6074. // {
  6075. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6076. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6077. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6078. // }
  6079. // else
  6080. // {
  6081. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6082. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6083. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6084. // {
  6085. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6086. // }
  6087. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6088. // {
  6089. // int orgid = CurrentUser.UserPost.OrgID;
  6090. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6091. // }
  6092. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6093. // {
  6094. // string shopid = CurrentUser.User.pemShop;
  6095. // lw.Add(string.Format("shopId in ({0})", shopid));
  6096. // }
  6097. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6098. // //{
  6099. // // int org_id = CurrentUser.UserPost.OrgID;
  6100. // // lw.Add(string.Format("OrgID={0}", org_id));
  6101. // //}
  6102. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6103. // }
  6104. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6105. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6106. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6107. //}
  6108. if (st == 5)
  6109. {
  6110. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6111. {
  6112. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6113. {
  6114. string shopid = CurrentUser.User.pemShop;
  6115. lw.Add(string.Format("shopId in ({0})", shopid));
  6116. }
  6117. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6118. {
  6119. int mrOrgid = CurrentUser.UserPost.OrgID;
  6120. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6121. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6122. }
  6123. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6124. //{
  6125. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6126. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6127. //}
  6128. else
  6129. {
  6130. string userIdStr = "";
  6131. if (posCode == "CustomerService")
  6132. {
  6133. userIdStr = CurrentUser.UserID + "_k";
  6134. }
  6135. else if (posCode == "Designer" || posCode == "wxDesigner")
  6136. {
  6137. userIdStr = CurrentUser.UserID + "_s";
  6138. }
  6139. else if (posCode == "Place")
  6140. {
  6141. userIdStr = CurrentUser.UserID + "_x";
  6142. }
  6143. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6144. }
  6145. }
  6146. string placedate1 = GetPostString("placedate1");
  6147. string placedate2 = GetPostString("placedate2");
  6148. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6149. if (dwplace.Length > 0) lw.Add(dwplace);
  6150. string supState = GetPostString("supState");
  6151. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6152. string searchType = GetPostString("searchType");
  6153. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6154. {
  6155. lw.Add(string.Format("BackNum>1"));
  6156. }
  6157. lw.Add(string.Format("AfterSaleState>0"));
  6158. if (ex_psize > 0)
  6159. {
  6160. if (CurrentUser.UserPost.Post.Code == "Finance")
  6161. dStruct.Order = "pay_time desc";
  6162. else
  6163. dStruct.Order = "HandleTime desc";
  6164. }
  6165. else
  6166. dStruct.Order = "HandleTime desc";
  6167. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6168. DataTable dt = WebCache.GetData("view_test", dStruct);
  6169. writeGridDataTableJson(dStruct.TotalCount, dt);
  6170. }
  6171. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6172. //{
  6173. // lw.Add(string.Format("AfterSaleState=4"));
  6174. // string code = CurrentUser.UserPost.Post.Code;
  6175. // if (code == "CustomerService")
  6176. // {
  6177. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6178. // }
  6179. // else if (code == "Designer" || code == "DesignerMr")
  6180. // {
  6181. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6182. // }
  6183. // else if (code == "Place" || code == "PlaceMr")
  6184. // {
  6185. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6186. // }
  6187. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6188. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6189. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6190. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6191. //}
  6192. //else //处理中的售后,待处理和处理中合并
  6193. //{
  6194. // if (afterState.Length <= 0)
  6195. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6196. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6197. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6198. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6199. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6200. //}
  6201. }
  6202. public void get_erp_disagreeftersalelist()
  6203. {
  6204. DataStruct dStruct = GetPostStruct();
  6205. List<string> lw = new List<string>();
  6206. int st = 2;
  6207. string tid = GetPostString("ctid");
  6208. if (tid.Length > 0)
  6209. {
  6210. string select_tid = getTidByCtid(tid);
  6211. lw.Add(string.Format("tid='{0}'", select_tid));
  6212. }
  6213. string shopname = GetPostString("shopname");
  6214. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6215. string buyernick = GetPostString("buyer_nick");
  6216. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6217. string sellermemo = GetPostString("seller_memo");
  6218. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6219. string orderState = GetPostString("orderState");
  6220. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6221. string afterState = GetPostString("afterstate");
  6222. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6223. string date1 = GetPostString("date1");
  6224. string date2 = GetPostString("date2");
  6225. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6226. if (dw.Length > 0) lw.Add(dw);
  6227. string price1 = GetPostString("price1");
  6228. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6229. string price2 = GetPostString("price2");
  6230. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6231. //lw.Add(string.Format("IsRefund!={0}", 1));
  6232. string reason = GetPostString("reason");
  6233. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6234. string method = GetPostString("method");
  6235. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6236. string handler = GetPostString("handler");
  6237. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6238. string handledate1 = GetPostString("handledate1");
  6239. string handledate2 = GetPostString("handledate2");
  6240. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6241. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6242. string afterdate1 = GetPostString("afterdate1");
  6243. string afterdate2 = GetPostString("afterdate2");
  6244. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6245. if (afterDate.Length > 0) lw.Add(afterDate);
  6246. string backdate1 = GetPostString("backdate1");
  6247. string backdate2 = GetPostString("backdate2");
  6248. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6249. if (backDate.Length > 0) lw.Add(backDate);
  6250. string supplier = GetPostString("supplier");
  6251. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6252. string responsible = GetPostString("responsibleman");
  6253. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6254. string customer = GetPostString("customer");
  6255. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6256. string design = GetPostString("design");
  6257. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6258. string afterSaleMemo = GetPostString("afterSaleMemo");
  6259. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6260. string afterMemoType = GetPostString("aftermemotype");
  6261. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6262. string aftersakereason = GetPostString("aftersakereason");
  6263. if (aftersakereason.Length > 0)
  6264. {
  6265. if (aftersakereason == "1")
  6266. {
  6267. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6268. }
  6269. if (aftersakereason == "2")
  6270. {
  6271. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6272. }
  6273. }
  6274. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6275. string poscode = CurrentUser.UserPost.Post.Code;
  6276. if (poscode != "SysAdmin")
  6277. {
  6278. string shopid = CurrentUser.User.pemShop;
  6279. lw.Add(string.Format("shopId in ({0})", shopid));
  6280. }
  6281. string searchType = GetPostString("searchType");
  6282. if (searchType == "wait")
  6283. {
  6284. lw.Add(string.Format("HandleTime is null"));
  6285. }
  6286. if (searchType == "handling")
  6287. {
  6288. lw.Add(string.Format("HandleTime is not null "));
  6289. }
  6290. if (searchType == "back" || searchType == "puBack")
  6291. {
  6292. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6293. }
  6294. if (searchType == "reBack")
  6295. {
  6296. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6297. }
  6298. if (searchType == "moreBack")
  6299. {
  6300. lw.Add(string.Format("backNum > 1"));
  6301. }
  6302. lw.Add(string.Format("(AfterSaleState=5)"));
  6303. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6304. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6305. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6306. writeGridDataTableJson(dStruct.TotalCount, dt);
  6307. }
  6308. public void get_erp_handlingaftersalelist()
  6309. {
  6310. DataStruct dStruct = GetPostStruct();
  6311. List<string> lw = new List<string>();
  6312. int st = 2;
  6313. string tid = GetPostString("ctid");
  6314. if (tid.Length > 0)
  6315. {
  6316. string select_tid = getTidByCtid(tid);
  6317. lw.Add(string.Format("tid='{0}'", select_tid));
  6318. }
  6319. string shopname = GetPostString("shopname");
  6320. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6321. string buyernick = GetPostString("buyer_nick");
  6322. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6323. string sellermemo = GetPostString("seller_memo");
  6324. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6325. string orderState = GetPostString("orderState");
  6326. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6327. string afterState = GetPostString("afterstate");
  6328. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6329. string date1 = GetPostString("date1");
  6330. string date2 = GetPostString("date2");
  6331. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6332. if (dw.Length > 0) lw.Add(dw);
  6333. string price1 = GetPostString("price1");
  6334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6335. string price2 = GetPostString("price2");
  6336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6337. //lw.Add(string.Format("IsRefund!={0}", 1));
  6338. string reason = GetPostString("reason");
  6339. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6340. string method = GetPostString("method");
  6341. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6342. string handler = GetPostString("handler");
  6343. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6344. string handledate1 = GetPostString("handledate1");
  6345. string handledate2 = GetPostString("handledate2");
  6346. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6347. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6348. string afterdate1 = GetPostString("afterdate1");
  6349. string afterdate2 = GetPostString("afterdate2");
  6350. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6351. if (afterDate.Length > 0) lw.Add(afterDate);
  6352. string supplier = GetPostString("supplier");
  6353. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6354. string responsible = GetPostString("responsibleman");
  6355. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6356. string customer = GetPostString("customer");
  6357. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6358. string design = GetPostString("design");
  6359. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6360. string afterSaleMemo = GetPostString("afterSaleMemo");
  6361. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6362. string afterMemoType = GetPostString("aftermemotype");
  6363. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6364. string afterresult = GetPostString("afterresult");
  6365. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6366. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6367. string poscode = CurrentUser.UserPost.Post.Code;
  6368. if (poscode != "SysAdmin")
  6369. {
  6370. string shopid = CurrentUser.User.pemShop;
  6371. lw.Add(string.Format("shopId in ({0})", shopid));
  6372. }
  6373. string searchType = GetPostString("searchType");
  6374. if (searchType == "wait")
  6375. {
  6376. lw.Add(string.Format("HandleTime is null"));
  6377. }
  6378. if (searchType == "documentary")
  6379. {
  6380. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6381. }
  6382. if (searchType == "handling")
  6383. {
  6384. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6385. }
  6386. if (searchType == "back" || searchType == "puBack")
  6387. {
  6388. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6389. }
  6390. if (searchType == "reBack")
  6391. {
  6392. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6393. }
  6394. if (afterState.Length <= 0)
  6395. {
  6396. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6397. }
  6398. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6399. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6400. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6401. writeGridDataTableJson(dStruct.TotalCount, dt);
  6402. }
  6403. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6404. //public void get_erp_back_handlingaftersalelist()
  6405. //{
  6406. // DataStruct dStruct = GetPostStruct();
  6407. // List<string> lw = new List<string>();
  6408. // string tid = GetPostString("ctid");
  6409. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6410. // string shopname = GetPostString("shopname");
  6411. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6412. // string buyernick = GetPostString("buyer_nick");
  6413. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6414. // string sellermemo = GetPostString("seller_memo");
  6415. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6416. // string orderState = GetPostString("orderState");
  6417. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6418. // string afterState = GetPostString("afterstate");
  6419. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6420. // string date1 = GetPostString("date1");
  6421. // string date2 = GetPostString("date2");
  6422. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6423. // if (dw.Length > 0) lw.Add(dw);
  6424. // string price1 = GetPostString("price1");
  6425. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6426. // string price2 = GetPostString("price2");
  6427. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6428. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6429. // string reason = GetPostString("reason");
  6430. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6431. // string method = GetPostString("method");
  6432. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6433. // string handler = GetPostString("handler");
  6434. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6435. // string handledate1 = GetPostString("handledate1");
  6436. // string handledate2 = GetPostString("handledate2");
  6437. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6438. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6439. // string afterdate1 = GetPostString("afterdate1");
  6440. // string afterdate2 = GetPostString("afterdate2");
  6441. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6442. // if (afterDate.Length > 0) lw.Add(afterDate);
  6443. // string supplier = GetPostString("supplier");
  6444. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6445. // string responsible = GetPostString("responsibleman");
  6446. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6447. // string customer = GetPostString("customer");
  6448. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6449. // string design = GetPostString("design");
  6450. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6451. // string afterMemoType = GetPostString("aftermemotype");
  6452. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6453. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6454. // if (afterState.Length <= 0)
  6455. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6456. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6457. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6458. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6459. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6460. //}
  6461. public void get_erp_aftersaleverifylist()
  6462. {
  6463. DataStruct dStruct = GetPostStruct();
  6464. List<string> lw = new List<string>();
  6465. string tid = GetPostString("ctid");
  6466. if (tid.Length > 0)
  6467. {
  6468. string select_tid = getTidByCtid(tid);
  6469. lw.Add(string.Format("otid='{0}'", select_tid));
  6470. }
  6471. string shopname = GetPostString("shopname");
  6472. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6473. string buyernick = GetPostString("buyer_nick");
  6474. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6475. string sellermemo = GetPostString("seller_memo");
  6476. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6477. string orderState = GetPostString("orderState");
  6478. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6479. //lw.Add(string.Format("IsRefund!={0}", 1));
  6480. string reason = GetPostString("reason");
  6481. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6482. string method = GetPostString("method");
  6483. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6484. string handler = GetPostString("handler");
  6485. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6486. string handledate1 = GetPostString("handledate1");
  6487. string handledate2 = GetPostString("handledate2");
  6488. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6489. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6490. string finish1 = GetPostString("finishdate1");
  6491. string finish2 = GetPostString("finishdate2");
  6492. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6493. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6494. string supplier = GetPostString("supplier");
  6495. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6496. string responsible = GetPostString("responsibleman");
  6497. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6498. string posCode = CurrentUser.UserPost.Post.Code;
  6499. string vstate = GetPostString("vstate");
  6500. if (vstate.Length > 0)
  6501. {
  6502. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6503. }
  6504. if (posCode == "Supplier")
  6505. {
  6506. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6507. lw.Add(string.Format("VerifyState = 0"));
  6508. lw.Add("type = 1");
  6509. lw.Add(string.Format("AfterSaleState={0}", 3));
  6510. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6511. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6512. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6513. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6514. writeGridDataTableJson(dStruct.TotalCount, dt);
  6515. }
  6516. else if (posCode == "logistics")
  6517. {
  6518. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6519. lw.Add(string.Format("VerifyState = 0"));
  6520. lw.Add("type = 2");
  6521. lw.Add(string.Format("AfterSaleState={0}", 3));
  6522. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6523. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6524. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6525. writeGridDataTableJson(dStruct.TotalCount, dt);
  6526. }
  6527. else
  6528. {
  6529. lw.Add(string.Format("(AfterSaleState = 3)"));
  6530. lw.Add("type = 0");
  6531. string reasonState = GetPostString("reasonState");
  6532. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6533. {
  6534. if (reasonState == "2")
  6535. {
  6536. lw.Add("VerifyState = 3");
  6537. }
  6538. else if (reasonState == "1")
  6539. {
  6540. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6541. }
  6542. else
  6543. {
  6544. lw.Add("VerifyState in (0,3)");
  6545. }
  6546. //不加条件,可以看全部
  6547. }
  6548. 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")
  6549. {
  6550. int orgid = CurrentUser.UserPost.OrgID;
  6551. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6552. if (string.IsNullOrEmpty(manageOrgId))
  6553. {
  6554. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6555. }
  6556. else
  6557. {
  6558. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6559. }
  6560. if (reasonState == "1")
  6561. {
  6562. lw.Add("VerifyState = 3");
  6563. }
  6564. else if (reasonState == "2")
  6565. {
  6566. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6567. }
  6568. else
  6569. {
  6570. }
  6571. }
  6572. else
  6573. {
  6574. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6575. }
  6576. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6577. //{
  6578. // int org_id = CurrentUser.UserPost.OrgID;
  6579. // lw.Add(string.Format("OrgID={0}", org_id));
  6580. //}
  6581. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6582. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6583. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6584. writeGridDataTableJson(dStruct.TotalCount, dt);
  6585. }
  6586. }
  6587. public void get_erp_finishaftersalelist()
  6588. {
  6589. DataStruct dStruct = GetPostStruct();
  6590. List<string> lw = new List<string>();
  6591. int st = 4;
  6592. string tid = GetPostString("ctid");
  6593. if (tid.Length > 0)
  6594. {
  6595. string select_tid = getTidByCtid(tid);
  6596. lw.Add(string.Format("otid='{0}'", select_tid));
  6597. }
  6598. string shopname = GetPostString("shopname");
  6599. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6600. //lw.Add(string.Format("IsRefund!={0}", 1));
  6601. string reason = GetPostString("reason");
  6602. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6603. string method = GetPostString("method");
  6604. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6605. string buyernick = GetPostString("buyer_nick");
  6606. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6607. string handler = GetPostString("handler");
  6608. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6609. string handledate1 = GetPostString("handledate1");
  6610. string handledate2 = GetPostString("handledate2");
  6611. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6612. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6613. string finish1 = GetPostString("finishdate1");
  6614. string finish2 = GetPostString("finishdate2");
  6615. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6616. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6617. string supplier = GetPostString("supplier");
  6618. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6619. string responsible = GetPostString("responsibleman");
  6620. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6621. string vstate = GetPostString("vstate");
  6622. if (vstate.Length > 0)
  6623. {
  6624. if ("3".Equals(vstate))
  6625. {
  6626. lw.Add(string.Format("IsTem=1"));
  6627. }
  6628. else
  6629. {
  6630. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6631. }
  6632. }
  6633. lw.Add(string.Format("AfterSaleState=4"));
  6634. string code = CurrentUser.UserPost.Post.Code;
  6635. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6636. {
  6637. //不加条件,可以看全部
  6638. }
  6639. else if (code == "Supplier")
  6640. {
  6641. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6642. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6643. lw.Add("type = 1");
  6644. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6645. }
  6646. else if (code == "logistics")
  6647. {
  6648. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6649. lw.Add("type = 2");
  6650. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6651. }
  6652. 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")
  6653. {
  6654. lw.Add("type = 0");
  6655. int orgid = CurrentUser.UserPost.OrgID;
  6656. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6657. if (string.IsNullOrEmpty(manageOrgIds))
  6658. {
  6659. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6660. }
  6661. else
  6662. {
  6663. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6664. }
  6665. }
  6666. else
  6667. {
  6668. lw.Add("type = 0");
  6669. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6670. }
  6671. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6672. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6673. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6674. writeGridDataTableJson(dStruct.TotalCount, dt);
  6675. }
  6676. public void handle_erp_aftersale()
  6677. {
  6678. if (UrlPostParmsCheck("ctid"))
  6679. {
  6680. string eid = GetPostString("ctid");
  6681. string responStr = GetPostString("AfterSaleResponsible");
  6682. if (responStr.Length <= 0)
  6683. {
  6684. returnErrorMsg("售后责任人不能为空");
  6685. return;
  6686. }
  6687. bool isDesign = false;
  6688. double designFree = 0.00;
  6689. int responsibleId = 0;
  6690. CeErpTradeCell entity = null;
  6691. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6692. if (entity != null)
  6693. {
  6694. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6695. string afterMethod = GetPostString("AfterSaleMethod");
  6696. if (isNeedNewOrder == 1)
  6697. {
  6698. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6699. bool ishav = true;
  6700. if (newentity == null)
  6701. {
  6702. newentity = entity.Clone() as CeErpTradeCell;
  6703. ishav = false;
  6704. newentity.ctid = "S_" + entity.ctid;
  6705. newentity.OrderState = 0;
  6706. //唯一标识
  6707. newentity.OrderSn = newentity.ctid;
  6708. string orderSn = dataHelper.getSaleOrderSn();
  6709. if (orderSn != "")
  6710. {
  6711. newentity.OrderSn = orderSn;
  6712. }
  6713. }
  6714. newentity.UpdateTime = DateTime.Now;
  6715. newentity.AfterSaleState = 0;
  6716. newentity.AfterSaleMethod = afterMethod;
  6717. if (!ishav)
  6718. {
  6719. string memo_str = newentity.seller_memo;
  6720. memo_str = memo_str.Replace("(", "(");
  6721. memo_str = memo_str.Replace(")", ")");
  6722. int sIndex = memo_str.IndexOf("(");
  6723. int eIndex = memo_str.IndexOf(")");
  6724. if (sIndex == -1 || eIndex == -1)
  6725. {
  6726. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6727. return;
  6728. }
  6729. string first = memo_str.Substring(0, sIndex + 1);
  6730. string memoCtid = newentity.OrderSn;
  6731. //if (memoCtid.IndexOf("C") != -1)
  6732. //{
  6733. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6734. //if (CIdx.IndexOf("+") != -1)
  6735. //{
  6736. //CIdx = "C" + CIdx.Split('+')[1];
  6737. //}
  6738. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6739. //}
  6740. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6741. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6742. string newMemo = first + memoCtid + last;
  6743. newentity.seller_memo = newMemo;
  6744. newentity.FinishPlaceTime = null;
  6745. newentity.UnusualTag = 0;
  6746. newentity.UnusualCon = "";
  6747. newentity.UnusualTime = null;
  6748. newentity.AfterSaleMemo = "";
  6749. newentity.AfterSaleMethod = afterMethod;
  6750. newentity.AfterSalePreTime = null;
  6751. newentity.AfterSaleReason = "";
  6752. newentity.AfterSaleResponsible = "";
  6753. newentity.AfterSaleState = 0;
  6754. newentity.AfterSaleTime = null;
  6755. newentity.AfterSaleUserId = 0;
  6756. newentity.AfterSaleSupplierState = 0;
  6757. newentity.LastBillWaybillCode = "";
  6758. newentity.LastBillCpCode = "";
  6759. newentity.FinishAfterSaleTime = null;
  6760. newentity.HandleTime = null;
  6761. newentity.IsSF = 0;
  6762. newentity.IsOldCustomer = 0;
  6763. newentity.UrgencyTime = null;
  6764. newentity.ResponsibleUserId = "";
  6765. newentity.IsVerifyToSupplier = false;
  6766. newentity.payment = 0;
  6767. newentity.CheckMemo = "";
  6768. newentity.OutSid = "";
  6769. newentity.CheckOrderTime = null;
  6770. newentity.MemoOpt = 0;
  6771. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6772. }
  6773. newentity.isAfterSaleOrder = 1;
  6774. newentity.IsRefund = 0;
  6775. string receiveMobile = GetPostString("receiver_mobile");
  6776. if (receiveMobile.Length > 0)
  6777. {
  6778. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6779. if (trade != null)
  6780. {
  6781. trade.receiver_name = GetPostString("receiver_name");
  6782. trade.receiver_mobile = receiveMobile;
  6783. trade.receiver_state = GetPostString("receiver_state");
  6784. trade.receiver_city = GetPostString("receiver_city");
  6785. trade.receiver_district = GetPostString("receiver_district");
  6786. trade.receiver_address = GetPostString("receiver_address");
  6787. newentity.IsOffLineOrder = 1;
  6788. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6789. }
  6790. }
  6791. string st = GetPostString("ToState");
  6792. if (st.Length > 0)
  6793. {
  6794. if (newentity.OrderState <= 3)
  6795. {
  6796. newentity.WaitDesignTime = DateTime.Now;
  6797. newentity.StartDesignTime = null;
  6798. newentity.FinishDesignTime = null;
  6799. newentity.OrderState = 3;
  6800. if (st == "下单员")
  6801. {
  6802. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6803. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6804. {
  6805. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6806. }
  6807. }
  6808. else
  6809. {
  6810. newentity.WaitDesignTime = DateTime.Now;
  6811. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6812. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6813. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6814. {
  6815. DataRow user = dt1.Rows[0];
  6816. //找主管
  6817. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6818. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6819. if (dt != null && dt.Rows.Count > 0)
  6820. {
  6821. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6822. newentity.DesignUserId = designMr;
  6823. string key = "aftersale_order_" + designMr;
  6824. if (RedisHelper.HasKey(key))
  6825. {
  6826. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6827. list.Add(newentity.ctid);
  6828. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6829. }
  6830. }
  6831. //账号正常
  6832. if (user["State"].ToString() == "0")
  6833. {
  6834. newentity.DesignUserId = entity.DesignUserId;
  6835. string key = "aftersale_order_" + entity.DesignUserId;
  6836. if (RedisHelper.HasKey(key))
  6837. {
  6838. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6839. list.Add(newentity.ctid);
  6840. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6841. }
  6842. }
  6843. }
  6844. }
  6845. }
  6846. if (entity.IsXianHuo == 1)
  6847. {
  6848. newentity.OrderState = 6;
  6849. entity.FinishPlaceTime = DateTime.Now;
  6850. }
  6851. }
  6852. if (ishav)
  6853. {
  6854. newentity.Update();
  6855. }
  6856. else
  6857. {
  6858. newentity.Create();
  6859. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6860. newCellExtend.ctid = newentity.ctid;
  6861. newCellExtend.orderFrom = 20;
  6862. newCellExtend.orderType = 30;
  6863. if (st == "下单员")
  6864. {
  6865. }
  6866. else
  6867. {
  6868. newCellExtend.ReprintTime = DateTime.Now;
  6869. }
  6870. newCellExtend.Create();
  6871. }
  6872. if (st != "下单员")
  6873. {
  6874. if (entity.DispatchSort == 2)
  6875. {
  6876. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6877. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6878. }
  6879. }
  6880. }
  6881. //处理售后扩展
  6882. string resIdStr = GetPostString("ResponsibleUserId");
  6883. string refundFees = GetPostString("refundFrees");
  6884. int IsComplain = GetPostInt("isComplain");
  6885. int IsBad = GetPostInt("isBad");
  6886. string IsOriginal = GetPostString("isOriginal");
  6887. double diffResultPrice = GetPostDouble("diffResultPrice");
  6888. string textResult = GetPostString("textResult");
  6889. string supplierResponsible = GetPostString("supplierResponsible");
  6890. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6891. if (ceErpTradeAfterSaleExtend == null)
  6892. {
  6893. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6894. ceErpTradeAfterSaleExtend.tid = eid;
  6895. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6896. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6897. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6898. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6899. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6900. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6901. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6902. ceErpTradeAfterSaleExtend.Create();
  6903. }
  6904. else
  6905. {
  6906. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6907. {
  6908. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6909. }
  6910. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6911. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6912. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6913. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6914. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6915. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6916. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6917. ceErpTradeAfterSaleExtend.Update();
  6918. }
  6919. int gysid = GetPostInt("ResponsibleSupId");
  6920. if (entity.AfterSaleUserId == 0)
  6921. {
  6922. entity.AfterSaleUserId = CurrentUser.UserID;
  6923. }
  6924. entity.ResponsibleUserId = resIdStr;
  6925. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6926. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6927. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6928. {
  6929. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6930. int backNum = 0;
  6931. if (number != null)
  6932. {
  6933. backNum = number.BackNum;
  6934. }
  6935. char[] separator = { ',' };
  6936. string[] sArray = resIdStr.Split(separator);
  6937. string[] refundFreeList = { };
  6938. if (refundFees.Length > 0)
  6939. {
  6940. refundFreeList = refundFees.Split(separator);
  6941. }
  6942. int index = -1;
  6943. List<int> responsibleIds = new List<int>();
  6944. foreach (string i in sArray)
  6945. {
  6946. index++;
  6947. if (i.Length <= 0) continue;
  6948. char[] separator2 = { '_' };
  6949. string idstr = i.Split(separator2)[0];
  6950. string idtype = i.Split(separator2)[1];
  6951. double refudFree = 0;
  6952. if (refundFreeList.Length > 0)
  6953. {
  6954. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6955. }
  6956. if (idtype == "s")
  6957. {
  6958. isDesign = true;
  6959. designFree = refudFree;
  6960. }
  6961. int userId = Convert.ToInt32(idstr);
  6962. int type = 0;
  6963. if (idtype == "g")
  6964. {
  6965. type = 1;
  6966. }
  6967. if (idtype == "w")
  6968. {
  6969. type = 2;
  6970. }
  6971. if (idtype == "t")
  6972. {
  6973. type = 3;
  6974. }
  6975. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6976. if (ceErpTradeResponsible == null)
  6977. {
  6978. ceErpTradeResponsible = new CeErpTradeResponsible();
  6979. ceErpTradeResponsible.tid = eid;
  6980. ceErpTradeResponsible.UserId = userId;
  6981. ceErpTradeResponsible.createdTime = DateTime.Now;
  6982. ceErpTradeResponsible.type = type;
  6983. if (type == 1)
  6984. {
  6985. ceErpTradeResponsible.IsSup = 1;
  6986. }
  6987. if (type == 2)
  6988. {
  6989. ceErpTradeResponsible.IsFlow = 1;
  6990. }
  6991. }
  6992. int state = 0;
  6993. //已认可的不需要再次认可
  6994. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  6995. {
  6996. state = 1;
  6997. }
  6998. ceErpTradeResponsible.RefundFee = refudFree;
  6999. ceErpTradeResponsible.VerifyState = state;
  7000. if (userId == 2125 || idtype == "w")
  7001. {
  7002. ceErpTradeResponsible.VerifyState = 1;
  7003. }
  7004. if (idtype == "w" && userId == 101)
  7005. {
  7006. ceErpTradeResponsible.VerifyState = state;
  7007. }
  7008. if (ceErpTradeResponsible.ID > 0)
  7009. {
  7010. ceErpTradeResponsible.Update();
  7011. }
  7012. else
  7013. {
  7014. ceErpTradeResponsible.Create();
  7015. }
  7016. if (isDesign)
  7017. {
  7018. responsibleId = ceErpTradeResponsible.ID;
  7019. }
  7020. responsibleIds.Add(ceErpTradeResponsible.ID);
  7021. }
  7022. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7023. CeErpTradeResponsible.NumByTid(backNum, eid);
  7024. }
  7025. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7026. if (ceErpTradeCellExtend != null)
  7027. {
  7028. ceErpTradeCellExtend.returnVisit = 0;
  7029. ceErpTradeCellExtend.Update();
  7030. }
  7031. if (entity.HandleTime != null)
  7032. {
  7033. if (entity.AfterSaleState == 1)
  7034. {
  7035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7036. }
  7037. else
  7038. {
  7039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7040. }
  7041. }
  7042. else
  7043. {
  7044. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7045. entity.HandleTime = DateTime.Now;
  7046. }
  7047. bool isCompale = false;
  7048. if (entity.AfterSaleState == 5)
  7049. {
  7050. isCompale = true;
  7051. entity.AfterSaleState = 3;
  7052. }
  7053. entity.AfterSaleSupplierState = 0;
  7054. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7055. {
  7056. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7057. }
  7058. string sImgs = GetPostString("img");
  7059. entity.AfterSaleSupplierImg = sImgs;
  7060. entity.supRefundType = GetPostString("supRefundType");
  7061. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7062. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7063. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7064. entity.AfterSaleMemoType = GetPostString("MemoType");
  7065. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7066. {
  7067. //entity.AfterSaleSupplierState = 2;
  7068. }
  7069. string df = GetPostString("DeductFee");
  7070. if (df == "")
  7071. {
  7072. df = "0";
  7073. }
  7074. string rf = GetPostString("RefundFee");
  7075. if (rf == "")
  7076. {
  7077. rf = "0";
  7078. }
  7079. string pm = GetPostString("AfterSalePayment");
  7080. if (pm == "")
  7081. {
  7082. pm = "0";
  7083. }
  7084. entity.AfterSalePayment = Convert.ToDouble(pm);
  7085. entity.DeductFee = Convert.ToDouble(df);
  7086. entity.RefundFee = Convert.ToDouble(rf);
  7087. entity.UpdateTime = DateTime.Now;
  7088. entity.Update();
  7089. string toState = GetPostString("ToState");
  7090. string original = GetPostString("isOriginal");
  7091. ApiVo apiVo = new ApiVo();
  7092. apiVo.orderNumber = entity.ctid;
  7093. apiVo.actionName = "afterDesign";
  7094. apiVo.orderRemarks = entity.AfterSaleMethod;
  7095. apiVo.reasonRemarks = entity.AfterSaleReason;
  7096. apiVo.isDesign = isDesign;
  7097. apiVo.designFree = designFree;
  7098. apiVo.responsibleId = responsibleId;
  7099. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7100. if (toState == "设计师")
  7101. {
  7102. apiVo.isOriginal = Convert.ToBoolean(original);
  7103. }
  7104. designHelper.API_WorkCore(apiVo);//afterDesign
  7105. CeErpMethod methodSql = new CeErpMethod();
  7106. methodSql.con = entity.AfterSaleMethod;
  7107. methodSql.addTime = DateTime.Now;
  7108. methodSql.Create();
  7109. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7110. CeErpMethod.ExecuteNonQuery(delsql);
  7111. if (isCompale)
  7112. {
  7113. aftersale_data_change(entity.ctid);
  7114. }
  7115. returnSuccessMsg("操作成功!");
  7116. return;
  7117. }
  7118. returnErrorMsg("找不到订单记录");
  7119. }
  7120. }
  7121. public void ins_erp_toresponsible()
  7122. {
  7123. if (UrlPostParmsCheck("ctid"))
  7124. {
  7125. string eid = GetPostString("ctid");
  7126. CeErpTradeCell entity = null;
  7127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7128. if (entity != null)
  7129. {
  7130. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7131. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7132. {
  7133. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7134. return;
  7135. }
  7136. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7137. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7138. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7139. if (entity.AfterSalePreTime == null)
  7140. {
  7141. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7142. {
  7143. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7144. }
  7145. }
  7146. entity.AfterSalePreTime = DateTime.Now;
  7147. //预完成给售后主管审核客户问题直接完成
  7148. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7149. {
  7150. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7151. {
  7152. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7153. }
  7154. }
  7155. ceErpTradeAfterSaleExtend.Update();
  7156. entity.AfterSaleState = 2;
  7157. entity.UpdateTime = DateTime.Now;
  7158. entity.Update();
  7159. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7160. aftersale_data_change(entity.ctid);
  7161. returnSuccessMsg("操作成功!");
  7162. return;
  7163. }
  7164. returnErrorMsg("找不到订单记录");
  7165. }
  7166. }
  7167. public void cancel_erp_aftersaleanddelnew()
  7168. {
  7169. if (UrlPostParmsCheck("ctid"))
  7170. {
  7171. string eid = GetPostString("ctid");
  7172. CeErpTradeCell entity = null;
  7173. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7174. if (entity != null)
  7175. {
  7176. entity.AfterSaleState = 0;
  7177. entity.AfterSaleReason = "";
  7178. entity.AfterSaleMethod = "";
  7179. entity.AfterSaleMemo = "";
  7180. entity.AfterSaleResponsible = "";
  7181. entity.ResponsibleUserId = "";
  7182. entity.DeductFee = 0;
  7183. entity.RefundFee = 0;
  7184. entity.IsArbitrate = 0;
  7185. CeErpTradeResponsible.DelByTid(eid, -1);
  7186. entity.Update();
  7187. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7188. if (after != null)
  7189. {
  7190. if (after.OrderState < 5)
  7191. CeErpTradeCell.DelByCtid("S_" + eid);
  7192. }
  7193. returnSuccessMsg("操作成功!");
  7194. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7195. return;
  7196. }
  7197. returnErrorMsg("找不到订单记录");
  7198. }
  7199. }
  7200. public void get_erp_aftersale_pregather()
  7201. {
  7202. List<string> lw = new List<string>();
  7203. int st = GetInt("st");
  7204. string tid = GetPostString("ctid");
  7205. if (tid.Length > 0)
  7206. {
  7207. string select_tid = getTidByCtid(tid);
  7208. lw.Add(string.Format("tid='{0}'", select_tid));
  7209. }
  7210. string shopname = GetPostString("shopname");
  7211. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7212. string buyernick = GetPostString("buyer_nick");
  7213. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7214. string sellermemo = GetPostString("seller_memo");
  7215. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7216. string orderState = GetPostString("orderState");
  7217. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7218. string reason = GetPostString("reason");
  7219. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7220. string method = GetPostString("method");
  7221. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7222. string handler = GetPostString("handler");
  7223. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7224. string handledate1 = GetPostString("handledate1");
  7225. string handledate2 = GetPostString("handledate2");
  7226. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7227. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7228. string supplier = GetPostString("supplier");
  7229. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7230. string responsible = GetPostString("responsibleman");
  7231. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7232. string customer = GetPostString("customer");
  7233. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7234. string design = GetPostString("design");
  7235. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7236. string afterMemoType = GetPostString("aftermemotype");
  7237. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7238. string afterSaleMemo = GetPostString("afterSaleMemo");
  7239. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7240. string afterresult = GetPostString("afterresult");
  7241. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7242. string poscode = CurrentUser.UserPost.Post.Code;
  7243. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7244. {
  7245. string shopid = CurrentUser.User.pemShop;
  7246. lw.Add(string.Format("shopId in ({0})", shopid));
  7247. }
  7248. var mainwhere = string.Join(" and ", lw.ToArray());
  7249. string ro_json = "";
  7250. string type = GetPostString("gather_type");
  7251. int number = 0;
  7252. if (poscode == "AfterSale")
  7253. {
  7254. //处理中
  7255. if (type == "Handling")
  7256. {
  7257. 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) : ""));
  7258. DataTable dt = null;
  7259. try
  7260. {
  7261. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7262. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7263. }
  7264. catch (Exception e)
  7265. {
  7266. dt = new DataTable();
  7267. }
  7268. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7269. return;
  7270. }
  7271. if (type == "Wait")
  7272. {
  7273. //待处理
  7274. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7275. DataTable dt1 = null;
  7276. try
  7277. {
  7278. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7279. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7280. }
  7281. catch (Exception e)
  7282. {
  7283. dt1 = new DataTable();
  7284. }
  7285. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7286. return;
  7287. }
  7288. if (type == "back")
  7289. {
  7290. //打回
  7291. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7292. DataTable dt2 = null;
  7293. try
  7294. {
  7295. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7296. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7297. }
  7298. catch (Exception e)
  7299. {
  7300. dt2 = new DataTable();
  7301. }
  7302. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7303. return;
  7304. }
  7305. if (type == "preCompletion")
  7306. {
  7307. //预完成
  7308. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7309. DataTable dt3 = null;
  7310. try
  7311. {
  7312. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7313. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7314. }
  7315. catch (Exception e)
  7316. {
  7317. dt3 = new DataTable();
  7318. }
  7319. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7320. return;
  7321. }
  7322. if (type == "documentary")
  7323. {
  7324. //跟单中
  7325. 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) : ""));
  7326. DataTable dt4 = null;
  7327. try
  7328. {
  7329. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7330. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7331. }
  7332. catch (Exception e)
  7333. {
  7334. dt4 = new DataTable();
  7335. }
  7336. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7337. return;
  7338. }
  7339. if (type == "reBack")
  7340. {
  7341. //被打回
  7342. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7343. DataTable dt1 = null;
  7344. try
  7345. {
  7346. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7347. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7348. }
  7349. catch (Exception e)
  7350. {
  7351. dt1 = new DataTable();
  7352. }
  7353. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7354. return;
  7355. }
  7356. }
  7357. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7358. {
  7359. if (type == "puBack")
  7360. {
  7361. //退回
  7362. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7363. DataTable dt = null;
  7364. try
  7365. {
  7366. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7367. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7368. }
  7369. catch (Exception e)
  7370. {
  7371. dt = new DataTable();
  7372. }
  7373. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7374. return;
  7375. }
  7376. if (type == "reBack")
  7377. {
  7378. //打回
  7379. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7380. DataTable dt1 = null;
  7381. try
  7382. {
  7383. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7384. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7385. }
  7386. catch (Exception e)
  7387. {
  7388. dt1 = new DataTable();
  7389. }
  7390. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7391. return;
  7392. }
  7393. if (type == "examEd")
  7394. {
  7395. //已审核
  7396. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7397. DataTable dt2 = null;
  7398. try
  7399. {
  7400. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7401. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7402. }
  7403. catch (Exception e)
  7404. {
  7405. dt2 = new DataTable();
  7406. }
  7407. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7408. return;
  7409. }
  7410. if (type == "waitExam")
  7411. {
  7412. //待审核
  7413. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7414. DataTable dt3 = null;
  7415. try
  7416. {
  7417. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7418. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7419. }
  7420. catch (Exception e)
  7421. {
  7422. dt3 = new DataTable();
  7423. }
  7424. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7425. return;
  7426. }
  7427. if (type == "Handling")
  7428. {
  7429. //处理中
  7430. 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) : ""));
  7431. DataTable dt4 = null;
  7432. try
  7433. {
  7434. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7435. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7436. }
  7437. catch (Exception e)
  7438. {
  7439. dt4 = new DataTable();
  7440. }
  7441. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7442. return;
  7443. }
  7444. if (type == "Wait")
  7445. {
  7446. //待处理
  7447. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7448. DataTable dt5 = null;
  7449. try
  7450. {
  7451. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7452. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7453. }
  7454. catch (Exception e)
  7455. {
  7456. dt5 = new DataTable();
  7457. }
  7458. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7459. return;
  7460. }
  7461. if (type == "documentary")
  7462. {
  7463. //跟单中
  7464. 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) : ""));
  7465. DataTable dt6 = null;
  7466. try
  7467. {
  7468. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7469. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7470. }
  7471. catch (Exception e)
  7472. {
  7473. dt6 = new DataTable();
  7474. }
  7475. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7476. return;
  7477. }
  7478. }
  7479. returnSuccess(ro_json);
  7480. }
  7481. public void end_erp_aftersale()
  7482. {
  7483. if (UrlPostParmsCheck("ctid"))
  7484. {
  7485. string eid = GetPostString("ctid");
  7486. CeErpTradeCell entity = null;
  7487. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7488. if (entity != null)
  7489. {
  7490. string stype = GetPostString("stype");
  7491. string typeStr = stype;
  7492. entity.AfterSaleState = 4;
  7493. entity.FinishAfterSaleTime = DateTime.Now;
  7494. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7495. entity.Update();
  7496. ApiVo apiVo = new ApiVo();
  7497. apiVo.orderNumber = entity.ctid;
  7498. apiVo.actionName = "afterOver";
  7499. designHelper.API_WorkCore(apiVo); //afterOver
  7500. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7501. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7502. CeErpSukuraData.createInfo(entity.ctid, 8);
  7503. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7504. returnSuccessMsg("操作成功!");
  7505. return;
  7506. }
  7507. returnErrorMsg("找不到订单记录");
  7508. }
  7509. }
  7510. public void ins_erp_finishaftersale()
  7511. {
  7512. if (UrlPostParmsCheck("id"))
  7513. {
  7514. string eid = GetPostString("id");
  7515. CeErpTradeResponsible entity = null;
  7516. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7517. if (entity != null)
  7518. {
  7519. entity.VerifyState = 1;
  7520. entity.VerifyTime = DateTime.Now;
  7521. entity.Update();
  7522. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7523. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7524. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7525. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7526. if (dt.Rows.Count <= 0)
  7527. {
  7528. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7529. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7530. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7531. CeErpSukuraData.createInfo(entity.tid, 8);
  7532. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7533. {
  7534. CeErpDesignerBill.Del(entity.tid);
  7535. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7536. }
  7537. }
  7538. returnSuccessMsg("操作成功!");
  7539. return;
  7540. }
  7541. returnErrorMsg("找不到订单记录");
  7542. }
  7543. }
  7544. public void upd_erp_arbitrateaftersale()
  7545. {
  7546. if (UrlPostParmsCheck("id"))
  7547. {
  7548. string eid = GetPostString("id");
  7549. CeErpTradeResponsible entity = null;
  7550. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7551. if (entity != null)
  7552. {
  7553. entity.IsArbitrate = 1;
  7554. entity.ArbitradeMemo = GetPostString("reason");
  7555. entity.VerifyState = 2;
  7556. entity.Update();
  7557. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7558. if (tradecell != null)
  7559. {
  7560. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7561. tradecell.IsArbitrate = 1;
  7562. tradecell.Update();
  7563. }
  7564. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7565. returnSuccessMsg("操作成功!");
  7566. return;
  7567. }
  7568. returnErrorMsg("找不到订单记录");
  7569. }
  7570. }
  7571. public void upd_erp_backaftersale()
  7572. {
  7573. if (UrlPostParmsCheck("tid"))
  7574. {
  7575. string eid = GetPostString("tid");
  7576. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7577. int backNum = 0;
  7578. if (number != null)
  7579. {
  7580. backNum = number.BackNum;
  7581. }
  7582. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7583. CeErpTradeCell entity = null;
  7584. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7585. if (entity != null)
  7586. {
  7587. entity.AfterSaleBackReason = GetPostString("backreason");
  7588. entity.AfterSaleState = 1;
  7589. entity.AfterSaleSupplierState = 0;
  7590. entity.UpdateTime = DateTime.Now;
  7591. entity.Update();
  7592. returnSuccessMsg("操作成功!");
  7593. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7594. return;
  7595. }
  7596. returnErrorMsg("找不到订单记录");
  7597. }
  7598. }
  7599. public void get_erp_supplieraftersalelist()
  7600. {
  7601. DataStruct dStruct = GetPostStruct();
  7602. List<string> lw = new List<string>();
  7603. string tid = GetPostString("ctid");
  7604. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7605. string shopname = GetPostString("shopname");
  7606. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7607. string buyernick = GetPostString("buyer_nick");
  7608. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7609. string sellermemo = GetPostString("seller_memo");
  7610. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7611. string orderState = GetPostString("orderState");
  7612. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7613. string afterState = GetPostString("afterstate");
  7614. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7615. string date1 = GetPostString("date1");
  7616. string date2 = GetPostString("date2");
  7617. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7618. if (dw.Length > 0) lw.Add(dw);
  7619. string price1 = GetPostString("price1");
  7620. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7621. string price2 = GetPostString("price2");
  7622. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7623. string reason = GetPostString("reason");
  7624. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7625. string method = GetPostString("method");
  7626. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7627. string handledate1 = GetPostString("handledate1");
  7628. string handledate2 = GetPostString("handledate2");
  7629. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7630. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7631. string handler = GetPostString("handler");
  7632. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7633. string afterdate1 = GetPostString("afterdate1");
  7634. string afterdate2 = GetPostString("afterdate2");
  7635. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7636. if (afterDate.Length > 0) lw.Add(afterDate);
  7637. string customer = GetPostString("customer");
  7638. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7639. string design = GetPostString("design");
  7640. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7641. string afterMemoType = GetPostString("aftermemotype");
  7642. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7643. string vstate = GetPostString("vstate");
  7644. if (vstate.Length > 0)
  7645. {
  7646. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7647. }
  7648. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7649. string supplier = GetPostString("supplier");
  7650. int supid = commonHelper.getSupplierIDByName(supplier);
  7651. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7652. string posCode = CurrentUser.UserPost.Post.Code;
  7653. if (posCode == "Supplier")
  7654. {
  7655. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7656. }
  7657. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7658. {
  7659. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7660. }
  7661. else
  7662. {
  7663. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7664. }
  7665. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7666. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7667. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7668. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7669. writeGridDataTableJson(dStruct.TotalCount, dt);
  7670. }
  7671. public void upd_erp_supverifyaftersale()
  7672. {
  7673. if (UrlPostParmsCheck("id"))
  7674. {
  7675. string id = GetPostString("id");
  7676. int st = GetPostInt("afterstate");
  7677. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7678. CeErpTradeCell entity = null;
  7679. if (ceErpTradeResponsible != null)
  7680. {
  7681. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7682. }
  7683. string afmemo = GetPostString("supmemo");
  7684. string image = GetPostString("image");
  7685. if (entity != null)
  7686. {
  7687. entity.AfterSaleSupplierState = st;
  7688. entity.AfterSaleSupplierMemo = afmemo;
  7689. if (st == 1)
  7690. {
  7691. ceErpTradeResponsible.VerifyState = 1;
  7692. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7693. ceErpTradeResponsible.Update();
  7694. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7695. if (isAll)
  7696. {
  7697. entity.AfterSaleState = 4;
  7698. entity.FinishAfterSaleTime = DateTime.Now;
  7699. }
  7700. }
  7701. else
  7702. {
  7703. CeErpTradeResponsible.dateByTid(entity.ctid);
  7704. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7705. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7706. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7707. if (num <= 1)
  7708. {
  7709. entity.AfterSaleState = 1;
  7710. }
  7711. else
  7712. {
  7713. entity.AfterSaleState = 5;
  7714. }
  7715. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7716. if (ceErpTradeAfterSaleExtend != null)
  7717. {
  7718. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7719. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7720. ceErpTradeAfterSaleExtend.Update();
  7721. }
  7722. else
  7723. {
  7724. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7725. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7726. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7727. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7728. ceErpTradeAfterSaleExtend.Create();
  7729. }
  7730. }
  7731. if (entity.AfterSaleState == 4)
  7732. {
  7733. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7734. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7735. {
  7736. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7737. }
  7738. ApiVo apiVo = new ApiVo();
  7739. apiVo.orderNumber = entity.ctid;
  7740. apiVo.actionName = "afterOver";
  7741. designHelper.API_WorkCore(apiVo); //afterOver
  7742. }
  7743. entity.UpdateTime = DateTime.Now;
  7744. entity.Update();
  7745. returnSuccessMsg("操作成功!");
  7746. CeErpSukuraData.createInfo(entity.ctid, 8);
  7747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7748. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7749. return;
  7750. }
  7751. returnErrorMsg("找不到订单记录");
  7752. }
  7753. }
  7754. public void upd_erp_masteraftersale()
  7755. {
  7756. if (UrlPostParmsCheck("id"))
  7757. {
  7758. string id = GetPostString("id");
  7759. int st = GetPostInt("afterstate");
  7760. string afmemo = GetPostString("supmemo");
  7761. string image = GetPostString("image");
  7762. string textResult = GetPostString("textResult");
  7763. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7764. if (ceErpTradeResponsible != null)
  7765. {
  7766. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7767. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7768. ceErpTradeResponsible.Update();
  7769. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7770. if (entity != null)
  7771. {
  7772. entity.AfterSaleSupplierState = st;
  7773. entity.AfterSaleSupplierMemo = afmemo;
  7774. if (st == 1)
  7775. {
  7776. }
  7777. else
  7778. {
  7779. CeErpTradeResponsible.dateByTid(entity.ctid);
  7780. //退回到售后
  7781. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7782. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7783. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7784. if (num <= 1)
  7785. {
  7786. entity.AfterSaleState = 1;
  7787. }
  7788. else
  7789. {
  7790. entity.AfterSaleState = 5;
  7791. }
  7792. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7793. if (ceErpTradeAfterSaleExtend != null)
  7794. {
  7795. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7796. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7797. ceErpTradeAfterSaleExtend.Update();
  7798. }
  7799. else
  7800. {
  7801. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7802. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7803. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7804. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7805. ceErpTradeAfterSaleExtend.Create();
  7806. }
  7807. }
  7808. entity.UpdateTime = DateTime.Now;
  7809. entity.Update();
  7810. returnSuccessMsg("操作成功!");
  7811. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7812. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7813. return;
  7814. }
  7815. }
  7816. returnErrorMsg("找不到订单记录");
  7817. }
  7818. }
  7819. public void upd_erp_personaftersale()
  7820. {
  7821. if (UrlPostParmsCheck("id"))
  7822. {
  7823. //林小连
  7824. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7825. {
  7826. upd_erp_masteraftersale();
  7827. return;
  7828. }
  7829. string id = GetPostString("id");
  7830. int st = GetPostInt("afterstate");
  7831. string afmemo = GetPostString("supmemo");
  7832. string image = GetPostString("image");
  7833. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7834. if (ceErpTradeResponsible != null)
  7835. {
  7836. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7837. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7838. ceErpTradeResponsible.Update();
  7839. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7840. if (entity != null)
  7841. {
  7842. entity.AfterSaleSupplierMemo = afmemo;
  7843. entity.AfterSaleSupplierState = st;
  7844. if (st == 1)
  7845. {
  7846. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7847. if (isAll)
  7848. {
  7849. entity.AfterSaleState = 4;
  7850. entity.FinishAfterSaleTime = DateTime.Now;
  7851. }
  7852. }
  7853. else
  7854. {
  7855. CeErpTradeResponsible.dateByTid(entity.ctid);
  7856. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7857. if (ceErpTradeAfterSaleExtend != null)
  7858. {
  7859. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7860. ceErpTradeAfterSaleExtend.Update();
  7861. }
  7862. else
  7863. {
  7864. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7865. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7866. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7867. ceErpTradeAfterSaleExtend.Create();
  7868. }
  7869. //退回到主管
  7870. //entity.AfterSaleState = 2;
  7871. }
  7872. if (entity.AfterSaleState == 4)
  7873. {
  7874. ApiVo apiVo = new ApiVo();
  7875. apiVo.orderNumber = entity.ctid;
  7876. apiVo.actionName = "afterOver";
  7877. designHelper.API_WorkCore(apiVo); //afterOver
  7878. }
  7879. entity.UpdateTime = DateTime.Now;
  7880. entity.Update();
  7881. returnSuccessMsg("操作成功!");
  7882. CeErpSukuraData.createInfo(entity.ctid, 8);
  7883. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7884. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7885. return;
  7886. }
  7887. }
  7888. returnErrorMsg("找不到订单记录");
  7889. }
  7890. }
  7891. public void set_erp_supplierrefundtag()
  7892. {
  7893. if (UrlPostParmsCheck("ctid"))
  7894. {
  7895. string eid = GetPostString("ctid");
  7896. CeErpTradeCell entity = null;
  7897. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7898. if (entity != null)
  7899. {
  7900. entity.IsSupplierRefund = GetPostInt("tag");
  7901. entity.Update();
  7902. returnSuccessMsg("操作成功!");
  7903. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7904. return;
  7905. }
  7906. returnErrorMsg("找不到订单记录");
  7907. }
  7908. }
  7909. public void get_erp_refundlist()
  7910. {
  7911. DataStruct dStruct = GetPostStruct();
  7912. List<string> lw = new List<string>();
  7913. string tid = GetPostString("tid");
  7914. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7915. //string rid = GetPostString("refund_id");
  7916. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7917. string shopname = GetPostString("shopname");
  7918. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7919. string buyernick = GetPostString("buyer_nick");
  7920. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7921. string customer = GetPostString("customer");
  7922. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7923. string design = GetPostString("design");
  7924. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7925. string sellermemo = GetPostString("seller_memo");
  7926. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7927. //string date1 = GetPostString("date1");
  7928. //string date2 = GetPostString("date2");
  7929. //string dateType = GetPostString("dateType");
  7930. //if (dateType.Length > 0)
  7931. //{
  7932. // if (dateType == "1001") dateType = "0";
  7933. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7934. // if (searchDT.Count == 2)
  7935. // {
  7936. // date1 = searchDT[0].ToString();
  7937. // date2 = searchDT[1].ToString();
  7938. // }
  7939. //}
  7940. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7941. //if (dw.Length > 0) lw.Add(dw);
  7942. string redate1 = GetPostString("refunddate1");
  7943. string redate2 = GetPostString("refunddate2");
  7944. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7945. if (dwdate.Length > 0) lw.Add(dwdate);
  7946. string price1 = GetPostString("price1");
  7947. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7948. string price2 = GetPostString("price2");
  7949. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7950. string ispartrefund = GetPostString("ispartrefund");
  7951. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7952. string refundState = GetPostString("refundvstate");
  7953. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7954. int st = GetInt("st");
  7955. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7956. {
  7957. string responsible = GetPostString("responsibleman");
  7958. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7959. lw.Add(string.Format("RefundState>={0}", st));
  7960. string code = CurrentUser.UserPost.Post.Code;
  7961. if (code == "CustomerService")
  7962. {
  7963. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7964. }
  7965. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7966. {
  7967. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7968. }
  7969. else if (code == "Place" || code == "PlaceMr")
  7970. {
  7971. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7972. }
  7973. dStruct.Order = "RefundState asc,created desc";
  7974. }
  7975. else if (st == 10)
  7976. {
  7977. string responsible = GetPostString("responsibleman");
  7978. if (responsible == "空白")
  7979. {
  7980. lw.Add(string.Format("ResponsibleUserName = ''"));
  7981. }
  7982. else if (responsible.Length > 0)
  7983. {
  7984. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7985. }
  7986. lw.Add(string.Format("RefundState>=0"));
  7987. dStruct.Order = "created desc";
  7988. }
  7989. else
  7990. {
  7991. string responsible = GetPostString("responsibleman");
  7992. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7993. lw.Add(string.Format("RefundState={0}", st));
  7994. dStruct.Order = "created desc";
  7995. }
  7996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7997. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7998. dt.Columns.Add("refund_fees");
  7999. foreach (DataRow dr in dt.Rows)
  8000. {
  8001. String status = dr["status"].ToString();
  8002. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8003. {
  8004. dr["refund_fees"] = dr["refund_fee"];
  8005. }
  8006. else
  8007. {
  8008. dr["refund_fees"] = "0.0";
  8009. }
  8010. }
  8011. writeGridDataTableJson(dStruct.TotalCount, dt);
  8012. }
  8013. public void get_erp_refunddesignlist()
  8014. {
  8015. DataStruct dStruct = GetPostStruct();
  8016. List<string> lw = new List<string>();
  8017. string tid = GetPostString("tid");
  8018. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8019. string shopname = GetPostString("shopname");
  8020. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8021. string buyernick = GetPostString("buyer_nick");
  8022. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8023. string customer = GetPostString("customer");
  8024. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8025. string design = GetPostString("design");
  8026. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8027. string sellermemo = GetPostString("seller_memo");
  8028. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8029. string redate1 = GetPostString("refunddate1");
  8030. string redate2 = GetPostString("refunddate2");
  8031. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8032. if (dwdate.Length > 0) lw.Add(dwdate);
  8033. string price1 = GetPostString("price1");
  8034. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8035. string price2 = GetPostString("price2");
  8036. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8037. string ispartrefund = GetPostString("ispartrefund");
  8038. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8039. string designerorg = GetPostString("designerorg");
  8040. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8041. string refundState = GetPostString("refundState");
  8042. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8043. int myOrgid = CurrentUser.UserPost.OrgID;
  8044. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8045. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8046. {
  8047. if (CurrentUser.User.TeamIds.Length > 0)
  8048. {
  8049. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8050. }
  8051. else
  8052. {
  8053. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8054. }
  8055. }
  8056. else if ("SysAdmin".Equals(myOrgCode))
  8057. {
  8058. }
  8059. else
  8060. {
  8061. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8062. {
  8063. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8064. }
  8065. else
  8066. {
  8067. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8068. }
  8069. }
  8070. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8071. dStruct.Order = "created desc";
  8072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8073. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8074. dt.Columns.Add("refund_fees");
  8075. foreach (DataRow dr in dt.Rows)
  8076. {
  8077. String status = dr["status"].ToString();
  8078. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8079. {
  8080. dr["refund_fees"] = dr["refund_fee"];
  8081. }
  8082. else
  8083. {
  8084. dr["refund_fees"] = "0.0";
  8085. }
  8086. }
  8087. writeGridDataTableJson(dStruct.TotalCount, dt);
  8088. }
  8089. public void handle_erp_refundtag()
  8090. {
  8091. if (UrlPostParmsCheck("refund_id"))
  8092. {
  8093. string eid = GetPostString("refund_id");
  8094. string respMan = GetPostString("ResponsibleName");
  8095. if (respMan.Length <= 0)
  8096. {
  8097. returnErrorMsg("责任人不能为空");
  8098. return;
  8099. }
  8100. CeErpTradeRefund entity = null;
  8101. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8102. if (entity != null)
  8103. {
  8104. entity.ResponsibleUserName = respMan;
  8105. string userid = GetPostString("ResponsibleUserId");
  8106. if (userid.Length > 0)
  8107. {
  8108. entity.ResponsibleUserId = userid;
  8109. }
  8110. entity.Memo = GetPostString("Memo");
  8111. if (respMan.IndexOf("客服") != -1 ||
  8112. respMan.IndexOf("设计师") != -1 ||
  8113. respMan.IndexOf("下单员") != -1)
  8114. {
  8115. entity.RefundState = 2;
  8116. }
  8117. else
  8118. {
  8119. entity.RefundState = 3;
  8120. }
  8121. entity.modified = DateTime.Now;
  8122. entity.Update();
  8123. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8124. returnSuccessMsg("操作成功!");
  8125. return;
  8126. }
  8127. returnErrorMsg("找不到订单记录");
  8128. }
  8129. }
  8130. public void handle_erp_designrefundtag()
  8131. {
  8132. if (UrlPostParmsCheck("refund_id"))
  8133. {
  8134. string eid = GetPostString("refund_id");
  8135. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8136. if (ceErpTradeCellExtend == null)
  8137. {
  8138. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8139. ceErpTradeCellExtend.ctid = eid;
  8140. }
  8141. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8142. if (ceErpTradeCellExtend.ID > 0)
  8143. {
  8144. ceErpTradeCellExtend.Update();
  8145. }
  8146. else
  8147. {
  8148. ceErpTradeCellExtend.Create();
  8149. }
  8150. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8151. returnSuccessMsg("操作成功!");
  8152. return;
  8153. }
  8154. returnErrorMsg("找不到订单记录");
  8155. }
  8156. public void upd_erp_refundverify()
  8157. {
  8158. if (UrlPostParmsCheck("refund_id"))
  8159. {
  8160. string eid = GetPostString("refund_id");
  8161. CeErpTradeRefund entity = null;
  8162. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8163. if (entity != null)
  8164. {
  8165. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8166. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8167. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8168. {
  8169. entity.RefundState = 2;
  8170. }
  8171. else
  8172. {
  8173. entity.RefundState = 3;
  8174. }
  8175. entity.Update();
  8176. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8177. returnSuccessMsg("操作成功!");
  8178. return;
  8179. }
  8180. returnErrorMsg("找不到订单记录");
  8181. }
  8182. }
  8183. public void upd_erp_refundapprove()
  8184. {
  8185. if (UrlPostParmsCheck("refund_id"))
  8186. {
  8187. string eid = GetPostString("refund_id");
  8188. CeErpTradeRefund entity = null;
  8189. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8190. if (entity != null)
  8191. {
  8192. int apr = GetPostInt("approve");
  8193. if (apr == 0)
  8194. {
  8195. entity.RefundState = 1;
  8196. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8197. }
  8198. else if (apr == 1)
  8199. {
  8200. entity.RefundState = 3;
  8201. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8202. }
  8203. entity.modified = DateTime.Now;
  8204. entity.Update();
  8205. returnSuccessMsg("操作成功!");
  8206. return;
  8207. }
  8208. returnErrorMsg("找不到订单记录");
  8209. }
  8210. }
  8211. public void get_erp_billlist()
  8212. {
  8213. DataStruct dStruct = GetPostStruct();
  8214. List<string> lw = new List<string>();
  8215. string title = GetPostString("title");
  8216. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8217. string tid = GetPostString("tid");
  8218. string tids = GetPostString("tids");
  8219. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8220. if (tids.Length > 0)
  8221. {
  8222. tids = "'" + tids + "'";
  8223. tids = tids.Replace(",", "','");
  8224. lw.Add(string.Format("tid in ({0})", tids));
  8225. }
  8226. string shopname = GetPostString("shopname");
  8227. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8228. string buyernick = GetPostString("buyer_nick");
  8229. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8230. string customer = GetPostString("customer");
  8231. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8232. string date1 = GetPostString("date1");
  8233. string date2 = GetPostString("date2");
  8234. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8235. if (dw.Length > 0) lw.Add(dw);
  8236. string price1 = GetPostString("price1");
  8237. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8238. string price2 = GetPostString("price2");
  8239. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8240. string returndate1 = GetPostString("returndate1");
  8241. string returndate2 = GetPostString("returndate2");
  8242. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8243. if (dw1.Length > 0) lw.Add(dw1);
  8244. string billtype = GetPostString("billtype");
  8245. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8246. string billstate = GetPostString("billstate");
  8247. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8248. string usershop = CurrentUser.User.pemShop;
  8249. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8250. dStruct.Order = "createTime desc";
  8251. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8252. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8253. //foreach (DataRow dr in dt.Rows)
  8254. //{
  8255. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8256. //}
  8257. writeGridDataTableJson(dStruct.TotalCount, dt);
  8258. }
  8259. public void modify_erp_billinfo()
  8260. {
  8261. if (UrlPostParmsCheck("ID"))
  8262. {
  8263. string eid = GetPostString("ID");
  8264. CeErpBill bill_entity = null;
  8265. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8266. if (bill_entity != null)
  8267. {
  8268. bill_entity.tid = GetPostString("tid");
  8269. bill_entity.title = GetPostString("title");
  8270. bill_entity.tax = GetPostString("tax");
  8271. bill_entity.bank = GetPostString("bank");
  8272. bill_entity.bankac = GetPostString("bankac");
  8273. bill_entity.address = GetPostString("address");
  8274. bill_entity.phone = GetPostString("phone");
  8275. bill_entity.price = GetPostString("price");
  8276. bill_entity.productId = GetPostInt("ProductName");
  8277. bill_entity.num = GetPostInt("num");
  8278. bill_entity.unit = GetPostString("unit");
  8279. bill_entity.type = GetPostString("type");
  8280. bill_entity.sendType = GetPostString("SendType");
  8281. bill_entity.email = GetPostString("email");
  8282. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8283. bill_entity.shopName = GetPostString("ShopName");
  8284. bill_entity.applymemo = GetPostString("applymemo");
  8285. bill_entity.modifyTime = DateTime.Now;
  8286. bill_entity.createTime = DateTime.Now;
  8287. bill_entity.state = 0;
  8288. bill_entity.Update();
  8289. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8290. returnSuccessMsg("发票修改成功!");
  8291. return;
  8292. }
  8293. returnErrorMsg("找不到对应记录");
  8294. }
  8295. }
  8296. public void set_erp_invoicing()
  8297. {
  8298. if (UrlPostParmsCheck("id"))
  8299. {
  8300. try
  8301. {
  8302. string eid = GetPostString("id");
  8303. CeErpBill bill_entity = null;
  8304. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8305. if (bill_entity != null)
  8306. {
  8307. int ComId = GetPostInt("ComId");
  8308. //string memo = GetPostString("Memo");
  8309. int allInfo = GetPostInt("allinfo");
  8310. string clert = CurrentUser.User.Name;
  8311. //string detailValue = GetPostString("detailvalue");
  8312. string billId = bill_entity.billOrderId;
  8313. string[] billIdList = billId.Split(',');
  8314. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8315. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8316. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8317. {
  8318. billCount += 1;
  8319. }
  8320. if (billId.Length <= 0 || billIdList.Length != billCount)
  8321. {
  8322. bill_entity.billOrderId = "";
  8323. string prebill = "ltb";
  8324. for (int idx = 1; idx <= billCount; idx++)
  8325. {
  8326. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8327. string billoid = prebill + idx + dtstr;
  8328. bill_entity.billOrderId += billoid;
  8329. if (idx < billCount)
  8330. {
  8331. bill_entity.billOrderId += ",";
  8332. }
  8333. }
  8334. }
  8335. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8336. if (bill_entity.state == 5)
  8337. {
  8338. string errMsg = bill_entity.failerror;
  8339. string[] errlist = errMsg.Split('|');
  8340. string[] errTags = new string[errlist.Length];
  8341. for (int itag = 0; itag < errlist.Length; itag++)
  8342. {
  8343. if (errlist[itag].Length <= 0) continue;
  8344. errTags[itag] = errlist[itag].Split('&')[0];
  8345. }
  8346. for (int iii = 0; iii < errTags.Length; iii++)
  8347. {
  8348. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8349. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8350. if (billOrderList.Length >= erroBillOrderTag)
  8351. {
  8352. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8353. if (needModifyBillId.Length <= 19)
  8354. {
  8355. needModifyBillId = needModifyBillId + "1";
  8356. }
  8357. else
  8358. {
  8359. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8360. last = last + 1;
  8361. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8362. }
  8363. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8364. }
  8365. }
  8366. }
  8367. bool isHaveBillSucces = false;
  8368. string totalRes = "";
  8369. bill_entity.failerror = "";
  8370. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8371. {
  8372. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8373. totalRes += res;
  8374. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8375. {
  8376. isHaveBillSucces = true;
  8377. bill_entity.comId = ComId;
  8378. bill_entity.state = 1;
  8379. bill_entity.executeTime = DateTime.Now;
  8380. bill_entity.executeUser = clert;
  8381. }
  8382. else
  8383. {
  8384. bill_entity.state = 5;
  8385. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8386. }
  8387. }
  8388. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8389. bill_entity.Update();
  8390. if (isHaveBillSucces)
  8391. {
  8392. StringBuilder sql = new StringBuilder();
  8393. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8394. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8395. }
  8396. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8397. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8398. {
  8399. returnErrorMsg("开票失败");
  8400. }
  8401. else
  8402. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8403. return;
  8404. }
  8405. returnErrorMsg("找不到对应记录");
  8406. }
  8407. catch (Exception ex)
  8408. {
  8409. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8410. returnErrorMsg("操作失败");
  8411. }
  8412. }
  8413. }
  8414. public void get_erp_invoicing_back()
  8415. {
  8416. if (UrlPostParmsCheck("id"))
  8417. {
  8418. try
  8419. {
  8420. string id = GetPostString("id");
  8421. CeErpBill entiy = CeErpBill.Get(id);
  8422. if (entiy != null)
  8423. {
  8424. if (entiy.state == 0)
  8425. {
  8426. returnErrorMsg("发票还未开具");
  8427. return;
  8428. }
  8429. string[] billOrderList = entiy.billOrderId.Split(',');
  8430. int iTag = 0;
  8431. entiy.fplsh = "";
  8432. entiy.fpdm = "";
  8433. entiy.fphm = "";
  8434. foreach (string billOrderId in billOrderList)
  8435. {
  8436. iTag++;
  8437. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8438. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8439. {
  8440. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8441. try
  8442. {
  8443. Invoicing_get_response_Obj iObj = null;
  8444. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8445. if (iObj != null)
  8446. {
  8447. entiy.state = 2;
  8448. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8449. entiy.fpdm += iObj.list[0].c_fpdm;
  8450. entiy.fphm += iObj.list[0].c_fphm;
  8451. if (iTag < billOrderList.Length)
  8452. {
  8453. entiy.fplsh += ",";
  8454. entiy.fpdm += ",";
  8455. entiy.fphm += ",";
  8456. }
  8457. entiy.Update();
  8458. }
  8459. StringBuilder sql = new StringBuilder();
  8460. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8461. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8462. returnSuccessMsg("开票成功");
  8463. }
  8464. catch (Exception ex)
  8465. {
  8466. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8467. }
  8468. return;
  8469. }
  8470. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8471. {
  8472. var res_obj = new
  8473. {
  8474. data = "开票中"
  8475. };
  8476. string ro_json = JsonConvert.SerializeObject(res_obj);
  8477. returnSuccess(ro_json);
  8478. return;
  8479. }
  8480. else
  8481. {
  8482. int eidx = res.IndexOf("c_resultmsg");
  8483. int lidx = res.IndexOf("c_status");
  8484. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8485. entiy.state = 5;
  8486. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8487. entiy.Update();
  8488. returnErrorMsg("开票失败");
  8489. return;
  8490. }
  8491. }
  8492. }
  8493. }
  8494. catch (Exception ex)
  8495. {
  8496. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8497. }
  8498. return;
  8499. }
  8500. }
  8501. public void get_erp_invoicing()
  8502. {
  8503. if (UrlPostParmsCheck("id"))
  8504. {
  8505. try
  8506. {
  8507. string id = GetPostString("id");
  8508. CeErpBill entiy = CeErpBill.Get(id);
  8509. if (entiy != null)
  8510. {
  8511. if (entiy.state == 0)
  8512. {
  8513. returnErrorMsg("发票还未开具");
  8514. return;
  8515. }
  8516. if (entiy.sendType == "纸质发票")
  8517. {
  8518. if (entiy.img.Length <= 0)
  8519. {
  8520. returnErrorMsg("查无纸质发票");
  8521. return;
  8522. }
  8523. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8524. returnSuccess(returnres);
  8525. return;
  8526. }
  8527. string[] billOrderList = entiy.billOrderId.Split(',');
  8528. int iTag = 0;
  8529. string fpUrl = "";
  8530. entiy.fplsh = "";
  8531. entiy.fpdm = "";
  8532. entiy.fphm = "";
  8533. foreach (string billOrderId in billOrderList)
  8534. {
  8535. iTag++;
  8536. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8537. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8538. {
  8539. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8540. Invoicing_get_response_Obj iObj = null;
  8541. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8542. if (iObj != null)
  8543. {
  8544. //entiy.state = 2;
  8545. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8546. entiy.fpdm += iObj.list[0].c_fpdm;
  8547. entiy.fphm += iObj.list[0].c_fphm;
  8548. if (iTag < billOrderList.Length)
  8549. {
  8550. entiy.fplsh += ",";
  8551. entiy.fpdm += ",";
  8552. entiy.fphm += ",";
  8553. }
  8554. entiy.Update();
  8555. fpUrl += iObj.list[0].c_url + ",";
  8556. }
  8557. //returnSuccess(res);
  8558. StringBuilder sql = new StringBuilder();
  8559. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8560. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8561. }
  8562. else
  8563. {
  8564. int eidx = res.IndexOf("c_resultmsg");
  8565. //int lidx = res.IndexOf("c_status");
  8566. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8567. //开票失败
  8568. entiy.state = 5;
  8569. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8570. entiy.Update();
  8571. returnErrorMsg("开票失败");
  8572. return;
  8573. }
  8574. }
  8575. var returnObj = new
  8576. {
  8577. data = fpUrl
  8578. };
  8579. string ro_json = JsonConvert.SerializeObject(returnObj);
  8580. returnSuccess(ro_json);
  8581. }
  8582. }
  8583. catch (Exception ex)
  8584. {
  8585. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8586. }
  8587. return;
  8588. }
  8589. }
  8590. public void save_erp_billimg()
  8591. {
  8592. if (UrlPostParmsCheck("id"))
  8593. {
  8594. string eid = GetPostString("id");
  8595. CeErpBill bill_entity = null;
  8596. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8597. if (bill_entity != null)
  8598. {
  8599. bill_entity.img = GetPostString("img");
  8600. bill_entity.executeTime = DateTime.Now;
  8601. bill_entity.state = 2;
  8602. bill_entity.Update();
  8603. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8604. returnSuccessMsg("保存成功");
  8605. }
  8606. return;
  8607. }
  8608. }
  8609. public void upd_erp_billreturnback()
  8610. {
  8611. if (UrlPostParmsCheck("id"))
  8612. {
  8613. int eid = GetPostInt("id");
  8614. CeErpBill bill_entity = null;
  8615. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8616. if (bill_entity != null)
  8617. {
  8618. bill_entity.state = 3;
  8619. bill_entity.returnReason = GetPostString("reason");
  8620. bill_entity.Update();
  8621. returnSuccessMsg("驳回成功!");
  8622. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8623. }
  8624. return;
  8625. }
  8626. }
  8627. public void cancel_erp_bill()
  8628. {
  8629. if (UrlPostParmsCheck("id"))
  8630. {
  8631. int eid = GetPostInt("id");
  8632. int detailValue = GetPostInt("detailvalue");
  8633. CeErpBill bill_entity = null;
  8634. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8635. string cres = "";
  8636. string gres = "";
  8637. if (bill_entity != null)
  8638. {
  8639. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8640. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8641. {
  8642. int iTag = 0;
  8643. bill_entity.fplsh = "";
  8644. bill_entity.fpdm = "";
  8645. bill_entity.fphm = "";
  8646. foreach (string billOrderId in billOrderList)
  8647. {
  8648. iTag++;
  8649. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8650. if (gres.IndexOf("success") != -1)
  8651. {
  8652. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8653. Invoicing_get_response_Obj iObj = null;
  8654. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8655. if (iObj != null)
  8656. {
  8657. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8658. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8659. bill_entity.fphm += iObj.list[0].c_fphm;
  8660. if (iTag < billOrderList.Length)
  8661. {
  8662. bill_entity.fplsh += ",";
  8663. bill_entity.fpdm += ",";
  8664. bill_entity.fphm += ",";
  8665. }
  8666. bill_entity.Update();
  8667. }
  8668. }
  8669. else
  8670. {
  8671. returnErrorMsg(gres);
  8672. return;
  8673. }
  8674. }
  8675. }
  8676. if (bill_entity.sendType == "纸质发票")
  8677. {
  8678. //作废
  8679. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8680. //if (DateTime.Now.Month == extime.Month)
  8681. //{
  8682. //cres = taobaoHelper.cancel_invoicing(eid);
  8683. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8684. //{
  8685. bill_entity.state = 4;//已作废
  8686. bill_entity.Update();
  8687. returnSuccessMsg("发票已作废");
  8688. return;
  8689. //}
  8690. //else
  8691. //{
  8692. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8693. // bill_entity.Update();
  8694. // returnErrorMsg(cres);
  8695. // return;
  8696. //}
  8697. //}
  8698. //else
  8699. //{
  8700. // returnErrorMsg("纸质发票只能作废本月的发票");
  8701. // return;
  8702. //}
  8703. }
  8704. //红冲
  8705. int redTag = 0;
  8706. string[] fpdmList = bill_entity.fpdm.Split(',');
  8707. string[] fphmList = bill_entity.fphm.Split(',');
  8708. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8709. {
  8710. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8711. return;
  8712. }
  8713. foreach (string billOrderId in billOrderList)
  8714. {
  8715. redTag++;
  8716. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8717. cres += onecres;
  8718. cres += ",";
  8719. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8720. {
  8721. bill_entity.state = 4;//已作废
  8722. //bill_entity.Update();
  8723. //returnSuccessMsg("发票已红冲");
  8724. }
  8725. else if (onecres.IndexOf("重复冲红") != -1)
  8726. {
  8727. bill_entity.state = 4;//已作废
  8728. //bill_entity.Update();
  8729. //returnSuccessMsg("发票已红冲");
  8730. }
  8731. else
  8732. {
  8733. string errmsg = commonHelper.KeepChinese(onecres);
  8734. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8735. }
  8736. }
  8737. bill_entity.Update();
  8738. if (cres.IndexOf("失败") != -1)
  8739. returnErrorMsg("红冲失败");
  8740. else
  8741. returnSuccessMsg("发票已红冲");
  8742. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8743. return;
  8744. }
  8745. return;
  8746. }
  8747. }
  8748. public void del_erp_billorder()
  8749. {
  8750. if (UrlPostParmsCheck("id"))
  8751. {
  8752. string eid = GetPostString("id");
  8753. CeErpBill.Del(eid);
  8754. CeErpBill bill = CeErpBill.Get(eid);
  8755. if (bill != null)
  8756. {
  8757. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8758. }
  8759. returnSuccessMsg("删除成功");
  8760. }
  8761. }
  8762. public void finish_erp_bill()
  8763. {
  8764. if (UrlPostParmsCheck("ids"))
  8765. {
  8766. string eids = GetPostString("ids");
  8767. string[] list = eids.Split(',');
  8768. foreach (string eid in list)
  8769. {
  8770. CeErpBill bill = CeErpBill.Get(eid);
  8771. if (bill != null)
  8772. {
  8773. bill.state = 2;
  8774. bill.Update();
  8775. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8776. }
  8777. }
  8778. returnSuccessMsg("操作成功");
  8779. }
  8780. }
  8781. public void get_erp_returncash()
  8782. {
  8783. DataStruct dStruct = GetPostStruct();
  8784. List<string> lw = new List<string>();
  8785. string tid = GetPostString("tid");
  8786. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8787. string shopname = GetPostString("shopname");
  8788. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8789. string buyernick = GetPostString("buyer_nick");
  8790. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8791. string customer = GetPostString("customer");
  8792. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8793. string returndate1 = GetPostString("returndate1");
  8794. string returndate2 = GetPostString("returndate2");
  8795. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8796. if (dw.Length > 0) lw.Add(dw);
  8797. string finishDate1 = GetPostString("finishdate1");
  8798. string finishDate2 = GetPostString("finishdate2");
  8799. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8800. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8801. string returntype = GetPostString("returntype");
  8802. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8803. string returnvstate = GetPostString("returnvstate");
  8804. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8805. dStruct.Order = "created desc";
  8806. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8807. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8808. writeGridDataTableJson(dStruct.TotalCount, dt);
  8809. }
  8810. public void get_erp_staygoods()
  8811. {
  8812. DataStruct dStruct = GetPostStruct();
  8813. List<string> lw = new List<string>();
  8814. string tid = GetPostString("tid");
  8815. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8816. string shopname = GetPostString("shopname");
  8817. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8818. string wangwang = GetPostString("wangwang");
  8819. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8820. string customer = GetPostString("customer");
  8821. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8822. string returndate1 = GetPostString("returndate1");
  8823. string returndate2 = GetPostString("returndate2");
  8824. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8825. if (dw.Length > 0) lw.Add(dw);
  8826. string finishDate1 = GetPostString("finishdate1");
  8827. string finishDate2 = GetPostString("finishdate2");
  8828. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8829. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8830. string returnvstate = GetPostString("returnvstate");
  8831. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8832. string persuadetype = GetPostString("persuadetype");
  8833. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8834. string customerOrg = GetPostString("customerOrg");
  8835. if (customerOrg.Length > 0)
  8836. {
  8837. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8838. }
  8839. dStruct.Order = "creata_time desc";
  8840. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8841. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8842. writeGridDataTableJson(dStruct.TotalCount, dt);
  8843. }
  8844. public void upd_erp_staygoods()
  8845. {
  8846. if (UrlPostParmsCheck("id"))
  8847. {
  8848. int eid = GetPostInt("id");
  8849. CeErpStayGoods entity = null;
  8850. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8851. if (entity != null)
  8852. {
  8853. entity.audit_type = 1;
  8854. entity.audit_time = DateTime.Now;
  8855. entity.audit_u_id = CurrentUser.UserID;
  8856. entity.audit_u_name = CurrentUser.UserName;
  8857. entity.Update();
  8858. returnSuccessMsg("审核成功!");
  8859. return;
  8860. }
  8861. returnErrorMsg("找不到订单记录");
  8862. }
  8863. }
  8864. public void upd_erp_stayGoodsback()
  8865. {
  8866. if (UrlPostParmsCheck("id"))
  8867. {
  8868. int eid = GetPostInt("id");
  8869. CeErpStayGoods entity = null;
  8870. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8871. if (entity != null)
  8872. {
  8873. entity.audit_text = GetPostString("reason");
  8874. entity.audit_type = 2;
  8875. entity.audit_time = DateTime.Now;
  8876. entity.audit_u_id = CurrentUser.UserID;
  8877. entity.audit_u_name = CurrentUser.UserName;
  8878. entity.Update();
  8879. returnSuccessMsg("退回成功!");
  8880. return;
  8881. }
  8882. returnErrorMsg("找不到订单记录");
  8883. }
  8884. }
  8885. public void upd_erp_returncashverify()
  8886. {
  8887. if (UrlPostParmsCheck("ID"))
  8888. {
  8889. int eid = GetPostInt("ID");
  8890. CeErpReturnCash entity = null;
  8891. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8892. if (entity != null)
  8893. {
  8894. entity.cashstate = 1;
  8895. entity.verifytime = DateTime.Now;
  8896. entity.verifyuserid = CurrentUser.UserID;
  8897. entity.Update();
  8898. returnSuccessMsg("审核成功!");
  8899. return;
  8900. }
  8901. returnErrorMsg("找不到订单记录");
  8902. }
  8903. }
  8904. public void upd_all_erp_returncashverify()
  8905. {
  8906. if (UrlPostParmsCheck("ID"))
  8907. {
  8908. String[] list = GetPostString("ID").Split(',');
  8909. CeErpReturnCash entity = null;
  8910. for (int i = 0; i < list.Length; i++)
  8911. {
  8912. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8913. if (entity != null)
  8914. {
  8915. if (entity.cashstate == 1)
  8916. {
  8917. returnErrorMsg("已审核过的订单不需要在审核!");
  8918. return;
  8919. }
  8920. entity.cashstate = 1;
  8921. entity.verifytime = DateTime.Now;
  8922. entity.verifyuserid = CurrentUser.UserID;
  8923. entity.Update();
  8924. }
  8925. }
  8926. returnSuccessMsg("审核成功!");
  8927. return;
  8928. }
  8929. }
  8930. public void upd_erp_returncashback()
  8931. {
  8932. if (UrlPostParmsCheck("ID"))
  8933. {
  8934. int eid = GetPostInt("ID");
  8935. CeErpReturnCash entity = null;
  8936. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8937. if (entity != null)
  8938. {
  8939. entity.backreason = GetPostString("reason");
  8940. entity.cashstate = 2;
  8941. entity.verifytime = DateTime.Now;
  8942. entity.verifyuserid = CurrentUser.UserID;
  8943. entity.Update();
  8944. returnSuccessMsg("退回成功!");
  8945. return;
  8946. }
  8947. returnErrorMsg("找不到订单记录");
  8948. }
  8949. }
  8950. public void upd_erp_returnprice()
  8951. {
  8952. if (UrlPostParmsCheck("ID"))
  8953. {
  8954. int eid = GetPostInt("ID");
  8955. CeErpReturnCash entity = null;
  8956. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8957. if (entity != null)
  8958. {
  8959. if (entity.cashstate == 1)
  8960. {
  8961. returnErrorMsg("审核通过了不能改");
  8962. return;
  8963. }
  8964. entity.returnprice = GetPostDouble("returnprice");
  8965. entity.Update();
  8966. returnSuccessMsg("修改成功!");
  8967. return;
  8968. }
  8969. returnErrorMsg("找不到订单记录");
  8970. }
  8971. }
  8972. public void del_erp_returncash()
  8973. {
  8974. if (UrlPostParmsCheck("ID"))
  8975. {
  8976. int eid = GetPostInt("ID");
  8977. CeErpReturnCash.Del(eid);
  8978. returnSuccessMsg("操作成功");
  8979. return;
  8980. }
  8981. }
  8982. public void test_for_do_sql()
  8983. {
  8984. string sql = GetPostString("sqlstr");
  8985. if (sql.Length > 0)
  8986. {
  8987. try
  8988. {
  8989. DbHelper.DbConn.ExecuteNonQuery(sql);
  8990. var res_obj = new
  8991. {
  8992. data = "成功",
  8993. };
  8994. string ro_json = JsonConvert.SerializeObject(res_obj);
  8995. returnSuccess(ro_json);
  8996. }
  8997. catch (Exception ex)
  8998. {
  8999. var res_obj = new
  9000. {
  9001. data = ex.Message,
  9002. };
  9003. string ro_json = JsonConvert.SerializeObject(res_obj);
  9004. returnSuccess(ro_json);
  9005. }
  9006. }
  9007. }
  9008. public void get_user_info()
  9009. {
  9010. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9011. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9012. }
  9013. public void get_total_data()
  9014. {
  9015. int userId = CurrentUser.UserID;
  9016. string sql = "";
  9017. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9018. {
  9019. 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);
  9020. }
  9021. else
  9022. {
  9023. 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 " +
  9024. "(select ID from CE_ErpUser where ID = {0}) d " +
  9025. "left join " +
  9026. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9027. ") a on d.ID = a.id left join " +
  9028. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9029. ") b on a.id = b.id1 left join" +
  9030. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9031. ") c on a.id = c.id2;", userId);
  9032. }
  9033. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9034. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9035. }
  9036. public void get_date_area_total_data2()
  9037. {
  9038. int userId = CurrentUser.UserID;
  9039. string date_type = GetPostString("timetype");
  9040. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9041. string sql = "";
  9042. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9043. {
  9044. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9045. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9046. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9047. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9048. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9049. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9050. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9051. ") a on e.ID = a.id left join " +
  9052. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9053. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9054. ") b on a.id = b.id1 " +
  9055. "left join " +
  9056. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9057. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9058. ") c on a.id = c.id2 " +
  9059. "left join " +
  9060. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9061. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9062. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9063. }
  9064. else
  9065. {
  9066. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9067. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9068. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9069. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9070. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9071. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9072. ") a on e.ID = a.id left join " +
  9073. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9074. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9075. ") c on a.id = c.id2 " +
  9076. "left join " +
  9077. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9078. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9079. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9080. }
  9081. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9082. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9083. }
  9084. public void get_date_area_total_data()
  9085. {
  9086. int userId = CurrentUser.UserID;
  9087. string date_type = GetPostString("timetype");
  9088. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9089. string date1 = searchDT[0].ToString();
  9090. string date2 = searchDT[1].ToString();
  9091. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9092. {
  9093. SqlParameter[] sqlParameter ={
  9094. new SqlParameter("@userId", SqlDbType.Int,4),
  9095. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9096. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9097. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9098. };
  9099. sqlParameter[0].Value = userId;
  9100. sqlParameter[1].Value = date1;
  9101. sqlParameter[2].Value = date2;
  9102. sqlParameter[3].Direction = ParameterDirection.Output;
  9103. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9104. string res = sqlParameter[3].Value.ToString();
  9105. var res_obj = new
  9106. {
  9107. data = res
  9108. };
  9109. string ro_json = JsonConvert.SerializeObject(res_obj);
  9110. returnSuccess(ro_json);
  9111. }
  9112. else
  9113. {
  9114. SqlParameter[] sqlParameter ={
  9115. new SqlParameter("@userId", SqlDbType.Int,4),
  9116. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9117. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9118. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9119. };
  9120. sqlParameter[0].Value = userId;
  9121. sqlParameter[1].Value = date1;
  9122. sqlParameter[2].Value = date2;
  9123. sqlParameter[3].Direction = ParameterDirection.Output;
  9124. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9125. string res = sqlParameter[3].Value.ToString();
  9126. var res_obj = new
  9127. {
  9128. data = res
  9129. };
  9130. string ro_json = JsonConvert.SerializeObject(res_obj);
  9131. returnSuccess(ro_json);
  9132. }
  9133. //writeGridDataViewJson(dt.Rows.Count, dv);
  9134. }
  9135. public void get_order_list()
  9136. {
  9137. string strFields = GetPostString("paraFields");
  9138. string strOrder = GetPostString("paraOrder");
  9139. string strWhere = GetPostString("paraWhere");
  9140. string strPageSize = GetPostString("paraPageSize");
  9141. DataStruct dStruct = GetPostStruct();
  9142. dStruct.PageSize = int.Parse(strPageSize);
  9143. dStruct.Fileds = strFields;
  9144. dStruct.Order = strOrder;
  9145. dStruct.MainWhere = strWhere;
  9146. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9147. writeGridDataTableJson(dStruct.TotalCount, dt);
  9148. }
  9149. ////获取待开始订单列表
  9150. //public void get_wait_design_order_list()
  9151. //{
  9152. // string date_type = GetPostString("date_type");
  9153. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9154. // DataStruct dStruct = GetPostStruct();
  9155. // dStruct.PageSize = 1000;
  9156. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9157. // List<string> lw = new List<string>();
  9158. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9159. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9160. // dStruct.Order = "WaitDesignTime asc";
  9161. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9162. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9163. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9164. //}
  9165. //获取完成单量排名
  9166. public void get_finish_order_count_ranking()
  9167. {
  9168. /* string date_type = GetPostString("date_type");
  9169. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9170. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9171. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9172. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9173. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9174. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9175. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9176. writeGridDataTableJson(0, new DataTable());
  9177. }
  9178. public void get_finish_order_amount_ranking()
  9179. {
  9180. /*string date_type = GetPostString("date_type");
  9181. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9182. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9183. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9184. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9185. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9186. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9187. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9188. writeGridDataTableJson(0, new DataTable());
  9189. }
  9190. public void get_finish_refund_count_ranking()
  9191. {
  9192. string date_type = GetPostString("date_type");
  9193. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9194. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9195. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9196. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9197. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9198. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9199. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9200. writeGridDataTableJson(dt.Rows.Count, dt);
  9201. }
  9202. public void get_finish_refund_amount_ranking()
  9203. {
  9204. string date_type = GetPostString("date_type");
  9205. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9206. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9207. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9208. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9209. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9210. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9211. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9212. writeGridDataTableJson(dt.Rows.Count, dt);
  9213. }
  9214. public void set_erp_finishorder_director()
  9215. {
  9216. if (UrlPostParmsCheck("ctid"))
  9217. {
  9218. string eid = GetPostString("ctid");
  9219. CeErpTradeCell entity = null;
  9220. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9221. if (entity != null)
  9222. {
  9223. entity.OrderState = 8;
  9224. entity.Update();
  9225. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9226. returnSuccessMsg("操作成功!");
  9227. return;
  9228. }
  9229. returnErrorMsg("找不到记录");
  9230. }
  9231. }
  9232. public void get_erp_placeregistlist()
  9233. {
  9234. DataStruct dStruct = GetPostStruct();
  9235. List<string> lw = new List<string>();
  9236. string outsid = GetPostString("outsid");
  9237. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9238. string memo = GetPostString("memo");
  9239. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9240. string filename = GetPostString("filename");
  9241. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9242. string islate = GetPostString("islate");
  9243. if (islate.Length > 0)
  9244. {
  9245. if (islate == "1")
  9246. lw.Add(string.Format("OutLate>0"));
  9247. else
  9248. lw.Add(string.Format("OutLate=0"));
  9249. }
  9250. string placedate1 = GetPostString("placedate1");
  9251. string placedate2 = GetPostString("placedate2");
  9252. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9253. if (dw.Length > 0) lw.Add(dw);
  9254. string deliveryDate1 = GetPostString("deliverydate1");
  9255. string deliveryDate2 = GetPostString("deliverydate2");
  9256. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9257. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9258. dStruct.Order = "ID desc";
  9259. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9260. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9261. writeGridDataTableJson(dStruct.TotalCount, dt);
  9262. }
  9263. public void ins_erp_placeregist()
  9264. {
  9265. if (UrlPostParmsCheck("id"))
  9266. {
  9267. string eid = GetPostString("id");
  9268. CeErpPlaceRegister entity = null;
  9269. if (eid == "0")//新增
  9270. {
  9271. entity = new CeErpPlaceRegister();
  9272. string xdTime = GetPostString("placeTime");
  9273. if (xdTime.Length > 0)
  9274. {
  9275. entity.PlactTime = Convert.ToDateTime(xdTime);
  9276. }
  9277. string fhTime = GetPostString("deliveryTime");
  9278. if (fhTime.Length > 0)
  9279. {
  9280. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9281. }
  9282. string preTime = GetPostString("preOutTime");
  9283. if (preTime.Length > 0)
  9284. {
  9285. entity.PreOutTime = Convert.ToDateTime(preTime);
  9286. }
  9287. entity.DeliveryCount = GetPostInt("deliveryCount");
  9288. entity.ReceiveCount = GetPostInt("receiveCount");
  9289. entity.OutSid = GetPostString("outSid");
  9290. entity.FileName = GetPostString("fileName");
  9291. entity.Memo = GetPostString("memo");
  9292. entity.AddUserId = CurrentUser.UserID;
  9293. entity.CreateTime = DateTime.Now;
  9294. entity.Img = GetPostString("img");
  9295. entity.Supplier = GetPostInt("supplier");
  9296. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9297. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9298. {
  9299. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9300. DateTime dt2 = (DateTime)entity.PreOutTime;
  9301. TimeSpan span = dt1.Subtract(dt2);
  9302. if (span.Days > 0)
  9303. {
  9304. entity.OutLate = span.Days;
  9305. }
  9306. }
  9307. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9308. entity.Create();
  9309. returnSuccessMsg("添加成功!");
  9310. return;
  9311. }
  9312. else //修改
  9313. {
  9314. entity = CeErpPlaceRegister.Get(eid);
  9315. if (entity != null)
  9316. {
  9317. string xdTime = GetPostString("placeTime");
  9318. if (xdTime.Length > 0)
  9319. {
  9320. entity.PlactTime = Convert.ToDateTime(xdTime);
  9321. }
  9322. string fhTime = GetPostString("deliveryTime");
  9323. if (fhTime.Length > 0)
  9324. {
  9325. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9326. }
  9327. string preTime = GetPostString("preOutTime");
  9328. if (preTime.Length > 0)
  9329. {
  9330. entity.PreOutTime = Convert.ToDateTime(preTime);
  9331. }
  9332. entity.DeliveryCount = GetPostInt("deliveryCount");
  9333. entity.ReceiveCount = GetPostInt("receiveCount");
  9334. if (entity.DeliveryCount == entity.ReceiveCount)
  9335. {
  9336. entity.CurState = "已完成";
  9337. }
  9338. else
  9339. {
  9340. entity.CurState = "未完成";
  9341. }
  9342. entity.OutSid = GetPostString("outSid");
  9343. entity.FileName = GetPostString("fileName");
  9344. entity.Memo = GetPostString("memo");
  9345. entity.Img = GetPostString("img");
  9346. entity.Supplier = GetPostInt("supplier");
  9347. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9348. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9349. {
  9350. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9351. DateTime dt2 = (DateTime)entity.PreOutTime;
  9352. TimeSpan span = dt1.Subtract(dt2);
  9353. if (span.Days > 0)
  9354. {
  9355. entity.OutLate = span.Days;
  9356. }
  9357. }
  9358. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9359. entity.Update();
  9360. returnSuccessMsg("修改成功");
  9361. return;
  9362. }
  9363. returnErrorMsg("找不到对应的记录");
  9364. return;
  9365. }
  9366. }
  9367. returnErrorMsg("缺少必要参数");
  9368. }
  9369. public void del_erp_placeregist()
  9370. {
  9371. string eid = GetPostString("id");
  9372. CeErpPlaceRegister.Del(eid);
  9373. returnSuccessMsg("删除成功!");
  9374. return;
  9375. }
  9376. public void ins_erp_placeregistbyorder()
  9377. {
  9378. string ctid = GetPostString("ctid");
  9379. if (ctid.Length > 0)
  9380. {
  9381. StringBuilder sql = new StringBuilder();
  9382. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9383. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9384. if (dt.Rows.Count > 0)
  9385. {
  9386. foreach (DataRow dr in dt.Rows)
  9387. {
  9388. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9389. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9390. entity.AddUserId = CurrentUser.UserID;
  9391. entity.tid = dr["tid"].ToString();
  9392. entity.Did = Convert.ToString(dr["ctid"]);
  9393. entity.splitTag = dr["SplitTag"].ToString();
  9394. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9395. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9396. if (pre_ctid.Length > 0)
  9397. {
  9398. sellmemo = sellmemo.Replace(pre_ctid, "");
  9399. }
  9400. sellmemo = sellmemo.Replace("[", "");
  9401. sellmemo = sellmemo.Replace("]", "");
  9402. entity.FileName = sellmemo;
  9403. string count = dr["ProductCount"].ToString();
  9404. int usecount = commonHelper.getIntCountFromString(count);
  9405. entity.DeliveryCount = usecount;
  9406. entity.CurState = "未完成";
  9407. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9408. {
  9409. entity.Supplier = 24;//dl手提袋定制
  9410. }
  9411. else
  9412. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9413. entity.CreateTime = DateTime.Now;
  9414. entity.Create();
  9415. }
  9416. returnSuccessMsg("操作成功");
  9417. return;
  9418. }
  9419. returnErrorMsg("没有找到对应订单");
  9420. return;
  9421. }
  9422. returnErrorMsg("缺少订单编号");
  9423. return;
  9424. }
  9425. public void get_erp_persuadelist()
  9426. {
  9427. DataStruct dStruct = GetPostStruct();
  9428. List<string> lw = new List<string>();
  9429. string ctid = GetPostString("ctid");
  9430. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9431. string shopname = GetPostString("shopname");
  9432. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9433. string buyernick = GetPostString("buyer_nick");
  9434. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9435. string customer = GetPostString("customer");
  9436. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9437. string returndate1 = GetPostString("returndate1");
  9438. string returndate2 = GetPostString("returndate2");
  9439. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9440. if (dw.Length > 0) lw.Add(dw);
  9441. string finishDate1 = GetPostString("finishdate1");
  9442. string finishDate2 = GetPostString("finishdate2");
  9443. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9444. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9445. string persuadetype = GetPostString("persuadetype");
  9446. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9447. string returnvstate = GetPostString("returnvstate");
  9448. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9449. dStruct.Order = "created desc";
  9450. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9451. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9452. writeGridDataTableJson(dStruct.TotalCount, dt);
  9453. }
  9454. public void upd_erp_returnpersuadeback()
  9455. {
  9456. if (UrlPostParmsCheck("ID"))
  9457. {
  9458. int eid = GetPostInt("ID");
  9459. CeErpPersuade entity = null;
  9460. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9461. if (entity != null)
  9462. {
  9463. entity.backreason = GetPostString("reason");
  9464. entity.pstate = 2;
  9465. entity.verifytime = DateTime.Now;
  9466. entity.verifyuserid = CurrentUser.UserID;
  9467. entity.Update();
  9468. returnSuccessMsg("退回成功!");
  9469. return;
  9470. }
  9471. returnErrorMsg("找不到订单记录");
  9472. }
  9473. }
  9474. public void upd_erp_returnpersuadeverify()
  9475. {
  9476. if (UrlPostParmsCheck("ID"))
  9477. {
  9478. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9479. {
  9480. returnErrorMsg("暂无权限审核");
  9481. return;
  9482. }
  9483. int eid = GetPostInt("ID");
  9484. CeErpPersuade entity = null;
  9485. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9486. if (entity != null)
  9487. {
  9488. entity.pstate = 1;
  9489. entity.verifytime = DateTime.Now;
  9490. entity.verifyuserid = CurrentUser.UserID;
  9491. entity.Update();
  9492. returnSuccessMsg("审核成功!");
  9493. return;
  9494. }
  9495. returnErrorMsg("找不到订单记录");
  9496. }
  9497. }
  9498. public void del_erp_persuade()
  9499. {
  9500. if (UrlPostParmsCheck("ID"))
  9501. {
  9502. int eid = GetPostInt("ID");
  9503. CeErpPersuade.Del(eid);
  9504. returnSuccessMsg("操作成功");
  9505. return;
  9506. }
  9507. }
  9508. public void get_erp_oldcustoupload()
  9509. {
  9510. DataStruct dStruct = GetPostStruct();
  9511. List<string> lw = new List<string>();
  9512. string buyernick = GetPostString("buyer_nick");
  9513. if (buyernick.Length > 0)
  9514. {
  9515. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9516. }
  9517. else
  9518. return;
  9519. dStruct.Order = "pay_time desc";
  9520. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9521. DataTable dt = null;
  9522. dt = WebCache.GetData("view_erptradecell", dStruct);
  9523. writeGridDataTableJson(dStruct.TotalCount, dt);
  9524. }
  9525. public void get_erp_checkorderlist()
  9526. {
  9527. DataStruct dStruct = GetPostStruct();
  9528. List<string> lw = new List<string>();
  9529. string tid = GetPostString("ctid");
  9530. if (tid.Length > 0)
  9531. {
  9532. string select_tid = getTidByCtid(tid);
  9533. lw.Add(string.Format("tid='{0}'", select_tid));
  9534. }
  9535. string shopname = GetPostString("shopname");
  9536. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9537. string buyernick = GetPostString("buyer_nick");
  9538. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9539. string customer = GetPostString("customer");
  9540. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9541. string design = GetPostString("design");
  9542. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9543. string orderState = GetPostString("orderState");
  9544. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9545. string address = GetPostString("address");
  9546. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9547. string sellermemo = GetPostString("seller_memo");
  9548. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9549. string supplier = GetPostString("supplier");
  9550. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9551. {
  9552. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9553. }
  9554. else
  9555. {
  9556. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9557. }
  9558. string date1 = GetPostString("date1");
  9559. string date2 = GetPostString("date2");
  9560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9561. if (dw.Length > 0) lw.Add(dw);
  9562. string placedate1 = GetPostString("placedate1");
  9563. string placedate2 = GetPostString("placedate2");
  9564. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9565. if (fdw.Length > 0) lw.Add(fdw);
  9566. string price1 = GetPostString("price1");
  9567. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9568. string price2 = GetPostString("price2");
  9569. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9570. string checkst = GetPostString("checkstate");
  9571. if (checkst.Length > 0 && "10".Equals(checkst))
  9572. {
  9573. lw.Add(string.Format("CheckOut>0"));
  9574. }
  9575. else
  9576. {
  9577. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9578. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9579. }
  9580. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9581. {
  9582. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9583. }
  9584. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9585. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9586. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9587. writeGridDataTableJson(dStruct.TotalCount, dt);
  9588. }
  9589. public void ins_erp_startCheck()
  9590. {
  9591. if (UrlPostParmsCheck("ctid"))
  9592. {
  9593. string eid = GetPostString("ctid");
  9594. CeErpTradeCell entity = null;
  9595. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9596. if (entity != null)
  9597. {
  9598. entity.MemoOpt = 4;
  9599. entity.UpdateTime = DateTime.Now;
  9600. entity.Update();
  9601. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9602. CeErpSukuraData.createInfo(entity.ctid, 6);
  9603. returnSuccessMsg("操作成功!");
  9604. return;
  9605. }
  9606. returnErrorMsg("找不到记录");
  9607. }
  9608. }
  9609. public void upd_erp_sendXlw()
  9610. {
  9611. if (UrlPostParmsCheck("ctid"))
  9612. {
  9613. string eid = GetPostString("ctid");
  9614. CeErpTradeCell entity = null;
  9615. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9616. if (entity != null)
  9617. {
  9618. if (entity.IsSendGift == 1)
  9619. {
  9620. returnErrorMsg("请勿重复标记");
  9621. return;
  9622. }
  9623. entity.IsSendGift = 1;
  9624. entity.Update();
  9625. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9626. returnSuccessMsg("操作成功!");
  9627. return;
  9628. }
  9629. returnErrorMsg("找不到记录");
  9630. }
  9631. }
  9632. public void cancel_sendXlw()
  9633. {
  9634. if (UrlPostParmsCheck("ctid"))
  9635. {
  9636. string eid = GetPostString("ctid");
  9637. CeErpTradeCell entity = null;
  9638. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9639. if (entity != null)
  9640. {
  9641. if (entity.IsSendGift == 0)
  9642. {
  9643. returnErrorMsg("未标记小礼物");
  9644. return;
  9645. }
  9646. entity.IsSendGift = 0;
  9647. entity.Update();
  9648. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9649. returnSuccessMsg("操作成功!");
  9650. return;
  9651. }
  9652. returnErrorMsg("找不到记录");
  9653. }
  9654. }
  9655. public void get_erp_designbill()
  9656. {
  9657. DataStruct dStruct = GetPostStruct();
  9658. List<string> lw = new List<string>();
  9659. int isMy = GetInt("my");
  9660. if (isMy == 1)
  9661. {
  9662. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9663. }
  9664. string tid = GetPostString("tid");
  9665. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9666. string userName = GetPostString("design");
  9667. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9668. string price1 = GetPostString("price1");
  9669. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9670. string price2 = GetPostString("price2");
  9671. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9672. string rePrice1 = GetPostString("rePrice1");
  9673. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9674. string rePrice2 = GetPostString("rePrice2");
  9675. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9676. string designerType = GetPostString("designerType");
  9677. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9678. string orderState = GetPostString("orderState");
  9679. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9680. string endTime1 = GetPostString("endTime1");
  9681. string endTime2 = GetPostString("endTime2");
  9682. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9683. if (dw.Length > 0) lw.Add(dw);
  9684. string isDk = GetPostString("isDk");
  9685. if (isDk == "1")
  9686. {
  9687. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9688. }
  9689. else if (isDk == "0")
  9690. {
  9691. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9692. }
  9693. dStruct.Order = "oid, create_time desc";
  9694. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9695. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9696. writeGridDataTableJson(dStruct.TotalCount, dt);
  9697. }
  9698. public void upd_erp_designerbill()
  9699. {
  9700. if (UrlPostParmsCheck("ID"))
  9701. {
  9702. string eid = GetPostString("ID");
  9703. CeErpDesignerBill entity = null;
  9704. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9705. if (entity != null)
  9706. {
  9707. if (GetPostDouble("designerpirce") > 0)
  9708. {
  9709. entity.realPrice = GetPostDouble("designerpirce");
  9710. entity.update_time = DateTime.Now;
  9711. entity.update_u_id = CurrentUser.UserID;
  9712. entity.update_u_name = CurrentUser.UserName;
  9713. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9714. entity.Update();
  9715. returnSuccessMsg("操作成功!");
  9716. return;
  9717. }
  9718. else
  9719. {
  9720. entity.price = GetPostDouble("price");
  9721. entity.update_time = DateTime.Now;
  9722. entity.update_u_id = CurrentUser.UserID;
  9723. entity.update_u_name = CurrentUser.UserName;
  9724. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9725. entity.Update();
  9726. returnSuccessMsg("操作成功!");
  9727. return;
  9728. }
  9729. }
  9730. returnErrorMsg("找不到记录");
  9731. }
  9732. }
  9733. public void audit_erp_designerbill()
  9734. {
  9735. if (UrlPostParmsCheck("ID"))
  9736. {
  9737. string eid = GetPostString("ID");
  9738. CeErpDesignerBill entity = null;
  9739. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9740. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9741. if (entity != null)
  9742. {
  9743. entity.realPrice = GetPostDouble("designerpirce");
  9744. entity.update_time = DateTime.Now;
  9745. entity.update_u_id = CurrentUser.UserID;
  9746. entity.update_u_name = CurrentUser.UserName;
  9747. entity.isAudit = 1;
  9748. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9749. entity.Update();
  9750. if (orderEntity != null)
  9751. {
  9752. orderEntity.IsReadTag = 3;
  9753. orderEntity.Update();
  9754. }
  9755. returnSuccessMsg("操作成功!");
  9756. return;
  9757. }
  9758. returnErrorMsg("找不到记录");
  9759. }
  9760. }
  9761. public void all_audit_erp_designerbill()
  9762. {
  9763. if (UrlPostParmsCheck("idList"))
  9764. {
  9765. string[] list = GetPostString("idList").Split(',');
  9766. CeErpDesignerBill entity = null;
  9767. for (int i = 0; i < list.Length; i++)
  9768. {
  9769. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9770. if (entity == null) return;
  9771. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9772. if (orderEntity == null) return;
  9773. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9774. entity.update_time = DateTime.Now;
  9775. entity.update_u_id = CurrentUser.UserID;
  9776. entity.update_u_name = CurrentUser.UserName;
  9777. entity.isAudit = 1;
  9778. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9779. entity.Update();
  9780. orderEntity.IsReadTag = 3;
  9781. orderEntity.Update();
  9782. }
  9783. returnSuccessMsg("操作成功!");
  9784. return;
  9785. }
  9786. }
  9787. public void get_erp_sameorders()
  9788. {
  9789. if (UrlPostParmsCheck("ctid"))
  9790. {
  9791. string eid = GetPostString("ctid");
  9792. CeErpTradeCell entity = null;
  9793. entity = CeErpTradeCell.GetByCtid(eid);
  9794. if (entity != null)
  9795. {
  9796. StringBuilder sql = new StringBuilder();
  9797. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9798. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9799. var res = new
  9800. {
  9801. data = dt.Rows.Count
  9802. };
  9803. string ro_jsond = JsonConvert.SerializeObject(res);
  9804. returnSuccess(ro_jsond);
  9805. return;
  9806. }
  9807. returnErrorMsg("未找到订单");
  9808. return;
  9809. }
  9810. returnErrorMsg("缺少必要的参数");
  9811. }
  9812. public void get_erp_islasthavesameorder()
  9813. {
  9814. if (UrlPostParmsCheck("ctid"))
  9815. {
  9816. string eid = GetPostString("ctid");
  9817. string[] ctidList = eid.Split(',');
  9818. StringBuilder sql = new StringBuilder();
  9819. string tisCtid = "";
  9820. foreach (string ctid in ctidList)
  9821. {
  9822. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9823. if (entity != null)
  9824. {
  9825. sql = new StringBuilder();
  9826. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9827. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9828. if (dth.Rows.Count > 0)
  9829. {
  9830. tisCtid += entity.ctid;
  9831. tisCtid += ",";
  9832. }
  9833. }
  9834. }
  9835. if (tisCtid.Length > 0)
  9836. {
  9837. var res = new
  9838. {
  9839. data = tisCtid
  9840. };
  9841. string ro_jsond = JsonConvert.SerializeObject(res);
  9842. returnSuccess(ro_jsond);
  9843. }
  9844. else
  9845. {
  9846. var res = new
  9847. {
  9848. data = ""
  9849. };
  9850. string ro_jsond = JsonConvert.SerializeObject(res);
  9851. returnSuccess(ro_jsond);
  9852. }
  9853. return;
  9854. }
  9855. returnErrorMsg("缺少必要的参数");
  9856. }
  9857. public void file_client_down_url()
  9858. {
  9859. if (!UrlPostParmsCheck("userId"))
  9860. {
  9861. returnErrorMsg("缺少必要的参数");
  9862. }
  9863. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9864. }
  9865. public void checkout_form_data()
  9866. {
  9867. if (!UrlPostParmsCheck("tid"))
  9868. {
  9869. returnErrorMsg("缺少必要的参数");
  9870. }
  9871. string tid = GetPostString("tid");
  9872. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9873. if (ceErpOrderFormData != null)
  9874. {
  9875. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9876. returnSuccess(ro_jsond);
  9877. return;
  9878. }
  9879. returnErrorMsg("尚未有文件!");
  9880. }
  9881. public void back_supplier_audit()
  9882. {
  9883. int userId = CurrentUser.UserID;
  9884. StringBuilder sql = new StringBuilder();
  9885. 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);
  9886. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9887. if (dt.Rows.Count > 0)
  9888. {
  9889. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9890. }
  9891. else
  9892. {
  9893. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9894. }
  9895. }
  9896. public void back_supplier_query()
  9897. {
  9898. string eid = GetPostString("ctid");
  9899. if (eid != "")
  9900. {
  9901. StringBuilder sql = new StringBuilder();
  9902. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9903. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9904. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9905. }
  9906. else
  9907. {
  9908. returnErrorMsg("找不到订单记录");
  9909. return;
  9910. }
  9911. }
  9912. public void verified_to_order()
  9913. {
  9914. int userId = CurrentUser.UserID;
  9915. StringBuilder sql = new StringBuilder();
  9916. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9917. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9918. if (dt.Rows.Count > 0)
  9919. {
  9920. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9921. }
  9922. else
  9923. {
  9924. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9925. }
  9926. }
  9927. public void upd_supplier_audit()
  9928. {
  9929. if (UrlPostParmsCheck("ctid"))
  9930. {
  9931. string eid = GetPostString("ctid");
  9932. string reason = GetPostString("returnreason");
  9933. CeErpTradeCell entity = null;
  9934. CeWithdraw withdraw = null;
  9935. withdraw = CeWithdraw.GetByTid(eid);
  9936. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9937. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9938. {
  9939. if (withdraw != null)
  9940. {
  9941. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9942. {
  9943. returnSuccessMsg("您没有权限操作!");
  9944. return;
  9945. }
  9946. else
  9947. {
  9948. if (reason.Equals("1"))
  9949. {
  9950. if (entity.OrderState == -1)
  9951. {
  9952. if (entity.FinishPlaceTime == null)
  9953. {
  9954. entity.OrderState = 2;
  9955. }
  9956. else
  9957. {
  9958. entity.OrderState = 6;
  9959. }
  9960. }
  9961. entity.Update();
  9962. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9963. if (withdraw != null)
  9964. {
  9965. withdraw.status = int.Parse(reason);
  9966. withdraw.Update();
  9967. }
  9968. returnSuccessMsg("操作成功!");
  9969. return;
  9970. }
  9971. else
  9972. {
  9973. withdraw.status = int.Parse(reason);
  9974. withdraw.acknowledgingtime = DateTime.Now;
  9975. withdraw.Update();
  9976. returnSuccessMsg("查看详细请点击线下订单查询");
  9977. return;
  9978. }
  9979. }
  9980. }
  9981. // 第一个字符是 'N'
  9982. }
  9983. if (eid[0] != 'N')
  9984. {
  9985. }
  9986. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9987. {
  9988. entity.IsVerifyToSupplier = false;
  9989. entity.IsReturn = 1;
  9990. entity.ReturnTime = DateTime.Now;
  9991. entity.ReturnReason = reason;
  9992. if (entity.OrderState == 6)
  9993. {
  9994. entity.OrderState = 5;
  9995. }
  9996. entity.Update();
  9997. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9998. if (withdraw != null)
  9999. {
  10000. withdraw.status = int.Parse(reason);
  10001. withdraw.Update();
  10002. }
  10003. returnSuccessMsg("操作成功!");
  10004. return;
  10005. }
  10006. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10007. {
  10008. ;
  10009. if (withdraw != null)
  10010. {
  10011. withdraw.status = int.Parse(reason);
  10012. withdraw.acknowledgingtime = DateTime.Now;
  10013. withdraw.Update();
  10014. returnSuccessMsg("供应商取消撤回!");
  10015. return;
  10016. }
  10017. }
  10018. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10019. {
  10020. if (entity.OrderState == -1)
  10021. {
  10022. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10023. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10024. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10025. {
  10026. returnErrorMsg("台湾客户需填写身份证!");
  10027. return;
  10028. }
  10029. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10030. {
  10031. returnErrorMsg("偏远地区需要填写物流费!");
  10032. return;
  10033. }
  10034. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10035. {
  10036. returnErrorMsg("订单spu没有确认无法通过审核!");
  10037. return;
  10038. }
  10039. if (entity.FinishPlaceTime == null)
  10040. {
  10041. entity.OrderState = 2;
  10042. }
  10043. else
  10044. {
  10045. entity.OrderState = 3;
  10046. }
  10047. commonHelper.getCytPrice(entity);
  10048. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10049. {
  10050. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10051. }
  10052. }
  10053. entity.Update();
  10054. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10055. if (withdraw != null)
  10056. {
  10057. withdraw.status = int.Parse(reason);
  10058. withdraw.Update();
  10059. }
  10060. returnSuccessMsg("操作成功!");
  10061. return;
  10062. }
  10063. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10064. {
  10065. if (withdraw == null)
  10066. {
  10067. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10068. return;
  10069. }
  10070. }
  10071. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10072. {
  10073. if (withdraw != null)
  10074. {
  10075. withdraw.status = int.Parse(reason);
  10076. withdraw.acknowledgingtime = DateTime.Now;
  10077. withdraw.Update();
  10078. returnSuccessMsg("查看详细请点击线下订单查询");
  10079. return;
  10080. }
  10081. }
  10082. return;
  10083. }
  10084. }
  10085. //校验报价
  10086. public void refund_order_tip()
  10087. {
  10088. int userid = CurrentUser.UserID;
  10089. int sectionId = CurrentUser.UserPost.OrgID;
  10090. StringBuilder sql = new StringBuilder();
  10091. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10092. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10093. List<string> ids = new List<string>();
  10094. if (dth.Rows.Count > 0)
  10095. {
  10096. foreach (DataRow dr in dth.Rows)
  10097. {
  10098. ids.Add(dr["ID"].ToString());
  10099. }
  10100. try
  10101. {
  10102. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10103. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10104. }
  10105. catch (Exception ex)
  10106. {
  10107. }
  10108. }
  10109. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10110. }
  10111. public void refund_order_Design()
  10112. {
  10113. int userid = CurrentUser.UserID;
  10114. int sectionId = CurrentUser.UserPost.OrgID;
  10115. StringBuilder sql = new StringBuilder();
  10116. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10117. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10118. List<string> ids = new List<string>();
  10119. if (dth.Rows.Count > 0)
  10120. {
  10121. foreach (DataRow dr in dth.Rows)
  10122. {
  10123. ids.Add(dr["ID"].ToString());
  10124. }
  10125. try
  10126. {
  10127. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10128. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10129. }
  10130. catch (Exception ex)
  10131. {
  10132. }
  10133. }
  10134. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10135. }
  10136. public void change_order_info()
  10137. {
  10138. int userid = CurrentUser.UserID;
  10139. StringBuilder sql = new StringBuilder();
  10140. 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);
  10141. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10142. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10143. }
  10144. public void change_win_mome()
  10145. {
  10146. if (UrlPostParmsCheck("id,ctid"))
  10147. {
  10148. string id = GetPostString("id");
  10149. string ctid = GetPostString("ctid");
  10150. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10151. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10152. if (ce == null || ceErpMessageTip == null)
  10153. {
  10154. returnSuccessMsg("未找到对应的订单!");
  10155. return;
  10156. }
  10157. if (ce.OrderState >= 5)
  10158. {
  10159. ceErpMessageTip.isVisit = true;
  10160. ceErpMessageTip.Update();
  10161. returnSuccessMsg("已上传文件无法修改!");
  10162. return;
  10163. }
  10164. int type = GetPostInt("type");
  10165. string content = GetPostString("content");
  10166. if (type == 0)
  10167. {
  10168. content = content.Replace("(", "(");
  10169. content = content.Replace(")", ")");
  10170. string check = MidStrEx(content, "(", ")").Trim();
  10171. if (string.IsNullOrEmpty(check))
  10172. {
  10173. returnSuccessMsg("文件名格式不正确");
  10174. return;
  10175. }
  10176. }
  10177. ce.seller_memo = content;
  10178. ce.Update();
  10179. ceErpMessageTip.isVisit = true;
  10180. ceErpMessageTip.Update();
  10181. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10182. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10183. ApiVo apiVo = new ApiVo();
  10184. apiVo.orderNumber = ce.ctid;
  10185. apiVo.actionName = "demandDesign";
  10186. apiVo.orderRemarks = content;
  10187. apiVo.demandExamine = type + 1;
  10188. designHelper.API_WorkCore(apiVo);//demandDesign
  10189. returnSuccessMsg("修改成功!");
  10190. }
  10191. }
  10192. public static string MidStrEx(string sourse, string startstr, string endstr)
  10193. {
  10194. string result = string.Empty;
  10195. int startindex, endindex;
  10196. try
  10197. {
  10198. startindex = sourse.IndexOf(startstr);
  10199. if (startindex == -1)
  10200. return result;
  10201. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10202. endindex = tmpstr.IndexOf(endstr);
  10203. if (endindex == -1)
  10204. return result;
  10205. result = tmpstr.Remove(endindex);
  10206. }
  10207. catch (Exception ex)
  10208. {
  10209. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10210. }
  10211. return result;
  10212. }
  10213. public void refund_order_list()
  10214. {
  10215. int userid = CurrentUser.UserID;
  10216. int sectionId = CurrentUser.UserPost.OrgID;
  10217. StringBuilder sql = new StringBuilder();
  10218. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10219. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10220. DataStruct dStruct = GetPostStruct();
  10221. DataTable dt = null;
  10222. List<string> ids = new List<string>();
  10223. List<string> tids = new List<string>();
  10224. if (dth.Rows.Count > 0)
  10225. {
  10226. foreach (DataRow dr in dth.Rows)
  10227. {
  10228. tids.Add("'" + dr["tid"].ToString() + "'");
  10229. ids.Add(dr["id"].ToString());
  10230. }
  10231. try
  10232. {
  10233. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10234. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10235. List<string> lw = new List<string>();
  10236. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10237. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10238. dt = WebCache.GetData("view_orderlist", dStruct);
  10239. }
  10240. catch (Exception ex)
  10241. {
  10242. }
  10243. }
  10244. writeGridDataTableJson(dStruct.TotalCount, dt);
  10245. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10246. }
  10247. //新增
  10248. public void order_batch_downloads()
  10249. {
  10250. string ceid = GetPostString("tid");
  10251. String[] tid = ceid.Split(',');
  10252. order_batch_caiyingtong(tid);
  10253. /* (string success, string errors) = UploadFiles(tid);
  10254. returnSuccessMsg(success + errors);*/
  10255. return;
  10256. }
  10257. //报价接口
  10258. public void Get_To_Quote()
  10259. {
  10260. string ceid = GetPostString("ctid");
  10261. if (ceid != null)
  10262. {
  10263. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10264. if (entity != null)
  10265. {
  10266. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10267. {
  10268. return;
  10269. }
  10270. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10271. double price = 0;
  10272. if (cp == null)
  10273. {
  10274. JObject jsonObject12 = new JObject
  10275. {
  10276. { "UserId", "77886" },
  10277. { "Pwd", "lt666888" },
  10278. { "Filename", entity.seller_memo }
  10279. };
  10280. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10281. JObject jsonObjects1 = JObject.Parse(response1);
  10282. string ms1g = (string)jsonObjects1["msg"];
  10283. if (ms1g == "报价成功")
  10284. {
  10285. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10286. string data = (string)jsonObject1["price"];
  10287. 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 + "');";
  10288. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10289. returnSuccessMsg("获取报价成功:" + data);
  10290. price = Convert.ToDouble(data);
  10291. }
  10292. else
  10293. {
  10294. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10295. return;
  10296. }
  10297. }
  10298. String[] beizhu = entity.seller_memo.Split('-');
  10299. String chanp = "";
  10300. if (beizhu.Length > 0)
  10301. {
  10302. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10303. }
  10304. else
  10305. {
  10306. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10307. }
  10308. JObject jsonObject = new JObject
  10309. {
  10310. { "UserId", "77886" },
  10311. { "Pwd", "lt666888" },
  10312. { "Filename", chanp }
  10313. };
  10314. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10315. JObject jsonObjects = JObject.Parse(response);
  10316. string msg = (string)jsonObjects["msg"];
  10317. if (msg == "报价成功")
  10318. {
  10319. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10320. string data = (string)jsonObject1["price"];
  10321. 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 + "');";
  10322. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10323. returnSuccessMsg("获取报价成功:" + data);
  10324. price = Convert.ToDouble(data);
  10325. }
  10326. else
  10327. {
  10328. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10329. return;
  10330. }
  10331. if (price > 0)
  10332. {
  10333. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10334. if (ceErpTradeCellExtend == null)
  10335. {
  10336. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10337. ceErpTradeCellExtend.ctid = entity.ctid;
  10338. ceErpTradeCellExtend.payment_cyt = price;
  10339. ceErpTradeCellExtend.Create();
  10340. }
  10341. else
  10342. {
  10343. ceErpTradeCellExtend.payment_cyt = price;
  10344. ceErpTradeCellExtend.Update();
  10345. }
  10346. }
  10347. return;
  10348. }
  10349. }
  10350. else
  10351. {
  10352. returnErrorMsg("请至少选择一条数据");
  10353. return;
  10354. }
  10355. }
  10356. //新增
  10357. public void order_To_Supplier()
  10358. {
  10359. string ceid = GetPostString("tid");
  10360. String[] tid = ceid.Split(',');
  10361. if (tid.Length > 0)
  10362. {
  10363. try
  10364. {
  10365. for (int i = 0; i < tid.Length; i++)
  10366. {
  10367. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10368. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10369. entity.SupplierId = suid;
  10370. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10371. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10372. entity.Update();
  10373. }
  10374. }
  10375. catch (Exception ex)
  10376. {
  10377. returnErrorMsg("自动匹配供应商失败");
  10378. return;
  10379. }
  10380. }
  10381. else
  10382. {
  10383. returnErrorMsg("请至少选择一条数据");
  10384. return;
  10385. }
  10386. returnSuccessMsg("自动匹配供应商成功");
  10387. return;
  10388. }
  10389. public (string, string) UploadFiles(string[] urls)
  10390. {
  10391. string success = "";
  10392. string errors = "";
  10393. int userid = CurrentUser.UserID;
  10394. foreach (string url in urls)
  10395. {
  10396. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10397. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10398. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10399. {
  10400. JObject jsonObject = new JObject
  10401. {
  10402. { "Userid", "77886" },
  10403. { "pwd", "cyt86435015" },
  10404. { "content", base64FileContent },
  10405. { "ext", Path.GetExtension(fileName) }
  10406. };
  10407. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10408. JObject jsonObjects = JObject.Parse(response);
  10409. string msg = (string)jsonObjects["msg"];
  10410. if (msg.Equals("上传成功"))
  10411. {
  10412. success += url + " 上传成功";
  10413. }
  10414. else
  10415. {
  10416. errors += url + " 上传失败";
  10417. }
  10418. }
  10419. else
  10420. {
  10421. errors += url + " 格式出现问题";
  10422. }
  10423. }
  10424. if (urls.Length == 0)
  10425. {
  10426. return (success, errors);
  10427. }
  10428. return (success, errors);
  10429. }
  10430. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10431. {
  10432. return true; //总是接受
  10433. }
  10434. public static string HttpPost(string url, string param = null)
  10435. {
  10436. HttpWebRequest request;
  10437. //如果是发送HTTPS请求
  10438. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10439. {
  10440. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10441. request = WebRequest.Create(url) as HttpWebRequest;
  10442. request.ProtocolVersion = HttpVersion.Version10;
  10443. }
  10444. else
  10445. {
  10446. request = WebRequest.Create(url) as HttpWebRequest;
  10447. }
  10448. request.Method = "POST";
  10449. request.ContentType = "application/json";
  10450. request.Accept = "*/*";
  10451. request.Timeout = 120000;
  10452. request.AllowAutoRedirect = false;
  10453. StreamWriter requestStream = null;
  10454. WebResponse response = null;
  10455. string responseStr = null;
  10456. try
  10457. {
  10458. requestStream = new StreamWriter(request.GetRequestStream());
  10459. requestStream.Write(param);
  10460. requestStream.Close();
  10461. response = request.GetResponse();
  10462. if (response != null)
  10463. {
  10464. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10465. responseStr = reader.ReadToEnd();
  10466. reader.Close();
  10467. }
  10468. }
  10469. catch (Exception ex)
  10470. {
  10471. return ex.Message;
  10472. }
  10473. finally
  10474. {
  10475. request = null;
  10476. requestStream = null;
  10477. response = null;
  10478. }
  10479. return responseStr;
  10480. }
  10481. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10482. {
  10483. string base64FileContent;
  10484. string fileName;
  10485. using (WebClient webClient = new WebClient())
  10486. {
  10487. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10488. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10489. {
  10490. using (Stream stream = response.GetResponseStream())
  10491. {
  10492. using (MemoryStream memoryStream = new MemoryStream())
  10493. {
  10494. stream.CopyTo(memoryStream);
  10495. byte[] fileBytes = memoryStream.ToArray();
  10496. base64FileContent = Convert.ToBase64String(fileBytes);
  10497. fileName = response.Headers["Content-Disposition"];
  10498. if (!string.IsNullOrEmpty(fileName))
  10499. {
  10500. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10501. if (index >= 0)
  10502. {
  10503. fileName = fileName.Substring(index + 9).Trim('\"');
  10504. }
  10505. }
  10506. else
  10507. {
  10508. fileName = Path.GetFileName(downloadUrl);
  10509. }
  10510. }
  10511. }
  10512. }
  10513. }
  10514. return (fileName, base64FileContent);
  10515. }
  10516. //新增
  10517. public void order_batch_caiyingtong(string[] downloadUrls)
  10518. {
  10519. try
  10520. {
  10521. //遍历文件
  10522. DataStruct dStruct = GetPostStruct();
  10523. DataTable dt = null;
  10524. int userid = CurrentUser.UserID;
  10525. List<string> ids = new List<string>();//失败组
  10526. List<string> tids = new List<string>();
  10527. using (WebClient webClient = new WebClient())
  10528. {
  10529. foreach (var url in downloadUrls)
  10530. {
  10531. try
  10532. {
  10533. tids.Add("'" + url + "'");
  10534. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10535. if (entity != null)
  10536. {
  10537. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10538. if (cp == null)
  10539. {
  10540. JObject jsonObject = new JObject
  10541. {
  10542. { "Userid", "77886" },
  10543. { "pwd", "lt666888" },
  10544. { "Filename",entity.seller_memo }
  10545. };
  10546. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10547. JObject jsonObjects = JObject.Parse(response);
  10548. string msg = (string)jsonObjects["msg"];
  10549. if (msg == "报价成功")
  10550. {
  10551. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10552. DownloadAndConvertToBase64(url1);
  10553. }
  10554. else
  10555. {
  10556. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10557. }
  10558. }
  10559. else
  10560. {
  10561. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10562. JObject jsonObject = new JObject
  10563. {
  10564. { "Userid", "77886" },
  10565. { "pwd", "lt666888" },
  10566. { "Filename",chanp }
  10567. };
  10568. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10569. JObject jsonObjects = JObject.Parse(response);
  10570. string msg = (string)jsonObjects["msg"];
  10571. if (msg == "报价成功")
  10572. {
  10573. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10574. DownloadAndConvertToBase64(url1);
  10575. }
  10576. else
  10577. {
  10578. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10579. }
  10580. }
  10581. }
  10582. // 上传文件到FTP
  10583. }
  10584. catch (Exception ex)
  10585. {
  10586. Console.WriteLine($"An error occurred: {ex.Message}");
  10587. }
  10588. }
  10589. List<string> lw = new List<string>();
  10590. lw.Add(string.Format("( OrderState < 6 )"));
  10591. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10592. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10593. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10594. if (dt.Rows.Count > 0)
  10595. {
  10596. foreach (DataRow dr in dt.Rows)
  10597. {
  10598. ids.Add(dr["ctid"].ToString());
  10599. }
  10600. }
  10601. String ErrorMsgs = "";
  10602. foreach (String id in ids)
  10603. {
  10604. ErrorMsgs += id + ",";
  10605. }
  10606. if (ErrorMsgs.Length > 1)
  10607. {
  10608. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10609. }
  10610. if (ErrorMsgs.Length < 1)
  10611. {
  10612. ErrorMsgs = "上传成功";
  10613. returnSuccessMsg(ErrorMsgs);
  10614. }
  10615. else
  10616. {
  10617. returnErrorMsg("以下订单" + ErrorMsgs);
  10618. }
  10619. }
  10620. // 删除文件夹及其内容
  10621. /* Directory.Delete(localDirectory, true);*/
  10622. }
  10623. catch { }
  10624. }
  10625. public void get_center_data()
  10626. {
  10627. int userId = CurrentUser.UserID;
  10628. string postCode = CurrentUser.UserPost.Post.Code;
  10629. List<string> lw = new List<string>();
  10630. List<string> ww = new List<string>();
  10631. DateTime currentTime = DateTime.Now;
  10632. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10633. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10634. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10635. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10636. string sql = " SELECT ";
  10637. string startTime = "2023-10-01 11:22:31";
  10638. //设计
  10639. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10640. {
  10641. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10642. 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));
  10643. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10644. 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));
  10645. }
  10646. //客服
  10647. else if (postCode == "CustomerService" || postCode == "Director")
  10648. {
  10649. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10650. 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));
  10651. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10652. 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));
  10653. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10654. 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));
  10655. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10656. 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));
  10657. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10658. 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));
  10659. }
  10660. //售后
  10661. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10662. {
  10663. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10664. 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));
  10665. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10666. 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));
  10667. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10668. 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));
  10669. }
  10670. //下单部
  10671. else if (postCode == "Place" || postCode == "PlaceMr")
  10672. {
  10673. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10674. 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));
  10675. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10676. 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));
  10677. }
  10678. //车间
  10679. else if (postCode == "Supplier")
  10680. {
  10681. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10682. ww.Add(string.Format("( SELECT COUNT ( * ) AS checkCount FROM CE_ErpTradeCell WHERE CheckOrderTime < '{1}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND pay_time > '{0}' AND SupplierId = {2} ) AS cc", startTime, checkOrderTime, userId));
  10683. }
  10684. DataTable dt = new DataTable();
  10685. if (lw.Count > 0)
  10686. {
  10687. sql += string.Join(" , ", lw);
  10688. sql += " FROM ";
  10689. sql += string.Join(" , ", ww);
  10690. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10691. }
  10692. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10693. }
  10694. public void get_center_data_list()
  10695. {
  10696. int userId = CurrentUser.UserID;
  10697. string postCode = CurrentUser.UserPost.Post.Code;
  10698. string shopIds = CurrentUser.User.pemShop;
  10699. DataStruct dStruct = GetPostStruct();
  10700. List<string> lw = new List<string>();
  10701. DateTime currentTime = DateTime.Now;
  10702. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10703. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10704. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10705. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10706. string startTime = "2023-10-01 11:22:31";
  10707. int order_type = GetPostInt("order_type");
  10708. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10709. {
  10710. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10711. if (order_type == 0)
  10712. {
  10713. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10714. }
  10715. else if (order_type == 3)
  10716. {
  10717. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10718. }
  10719. else
  10720. {
  10721. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10722. }
  10723. }
  10724. //客服
  10725. if (postCode == "CustomerService" || postCode == "Director")
  10726. {
  10727. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10728. if (order_type == 0)
  10729. {
  10730. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10731. }
  10732. else if (order_type == 1)
  10733. {
  10734. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10735. }
  10736. else if (order_type == 2)
  10737. {
  10738. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10739. }
  10740. else if (order_type == 3)
  10741. {
  10742. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10743. }
  10744. else if (order_type == 4)
  10745. {
  10746. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10747. }
  10748. else
  10749. {
  10750. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10751. }
  10752. }
  10753. //售后
  10754. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10755. {
  10756. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10757. if (shopIds != "")
  10758. {
  10759. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10760. }
  10761. if (order_type == 2)
  10762. {
  10763. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10764. }
  10765. else if (order_type == 4)
  10766. {
  10767. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10768. }
  10769. else if (order_type == 5)
  10770. {
  10771. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10772. }
  10773. else
  10774. {
  10775. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10776. }
  10777. }
  10778. //下单部
  10779. if (postCode == "Place" || postCode == "PlaceMr")
  10780. {
  10781. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10782. if (shopIds != "")
  10783. {
  10784. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10785. }
  10786. else if (order_type == 1)
  10787. {
  10788. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10789. }
  10790. else if (order_type == 2)
  10791. {
  10792. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10793. }
  10794. else
  10795. {
  10796. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10797. }
  10798. }
  10799. //车间
  10800. if (postCode == "Supplier")
  10801. {
  10802. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10803. if (order_type == 5)
  10804. {
  10805. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10806. }
  10807. else
  10808. {
  10809. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10810. }
  10811. }
  10812. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10813. dStruct.Fileds = "tid,ctid";
  10814. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10815. writeGridDataTableJson(dStruct.TotalCount, dt);
  10816. }
  10817. public void aftersale_audit_master()
  10818. {
  10819. if (UrlPostParmsCheck("ctid"))
  10820. {
  10821. string ctid = GetPostString("ctid");
  10822. if (ctid.Length > 0)
  10823. {
  10824. bool result = aftersale_data_change(ctid);
  10825. if (result)
  10826. {
  10827. returnSuccessMsg("修改成功!");
  10828. return;
  10829. }
  10830. }
  10831. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10832. }
  10833. }
  10834. public void aftersale_batch_audit_master()
  10835. {
  10836. if (UrlPostParmsCheck("ctids"))
  10837. {
  10838. string ctids = GetPostString("ctids");
  10839. if (ctids.Length > 0)
  10840. {
  10841. List<string> list = new List<string>();
  10842. string[] ctid_list = ctids.Split(',');
  10843. foreach (var item in ctid_list)
  10844. {
  10845. bool result = aftersale_data_change(item);
  10846. if (!result)
  10847. {
  10848. list.Add(item);
  10849. }
  10850. }
  10851. if (list.Count > 0)
  10852. {
  10853. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10854. return;
  10855. }
  10856. returnSuccessMsg("修改成功!");
  10857. return;
  10858. }
  10859. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10860. }
  10861. }
  10862. public bool aftersale_data_change(string ctid)
  10863. {
  10864. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10865. if (ceErpTradeCell != null)
  10866. {
  10867. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10868. ceErpTradeCell.AfterSaleSupplierState = 0;
  10869. StringBuilder sql = new StringBuilder();
  10870. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10871. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10872. CeErpTradeResponsible.DelByTid(ctid, 0);
  10873. 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 == "不理赔")
  10874. {
  10875. CeErpTradeResponsible.DelByTid(ctid, 1);
  10876. ceErpTradeCell.AfterSaleSupplierState = 1;
  10877. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10878. ceErpTradeCell.AfterSaleState = 4;
  10879. }
  10880. else
  10881. {
  10882. ceErpTradeCell.AfterSaleState = 3;
  10883. }
  10884. bool needCyt = false;
  10885. if (dt != null)
  10886. {
  10887. if (dt.Rows.Count == 1)
  10888. {
  10889. bool isEnd = false;
  10890. foreach (DataRow dr in dt.Rows)
  10891. {
  10892. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10893. {
  10894. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10895. isEnd = true;
  10896. }
  10897. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10898. {
  10899. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10900. isEnd = true;
  10901. }
  10902. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10903. {
  10904. needCyt = true;
  10905. }
  10906. }
  10907. if (isEnd)
  10908. {
  10909. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10910. ceErpTradeCell.AfterSaleState = 4;
  10911. ceErpTradeCell.AfterSaleSupplierState = 1;
  10912. }
  10913. }
  10914. else
  10915. {
  10916. bool isAll = true;
  10917. foreach (DataRow dr in dt.Rows)
  10918. {
  10919. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10920. {
  10921. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10922. continue;
  10923. }
  10924. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10925. {
  10926. string path = "";
  10927. int OrgID = 0;
  10928. if (!Convert.IsDBNull(dr["OrgPath"]))
  10929. {
  10930. path = dr["OrgPath"].ToString();
  10931. }
  10932. if (!Convert.IsDBNull(dr["OrgID"]))
  10933. {
  10934. OrgID = Convert.ToInt32(dr["OrgID"]);
  10935. }
  10936. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10937. {
  10938. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10939. continue;
  10940. }
  10941. }
  10942. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10943. {
  10944. needCyt = true;
  10945. }
  10946. isAll = false;
  10947. }
  10948. if (isAll)
  10949. {
  10950. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10951. ceErpTradeCell.AfterSaleState = 4;
  10952. ceErpTradeCell.AfterSaleSupplierState = 1;
  10953. }
  10954. }
  10955. }
  10956. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10957. {
  10958. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10959. }
  10960. if (ceErpTradeCell.AfterSaleState == 4)
  10961. {
  10962. ApiVo apiVo = new ApiVo();
  10963. apiVo.orderNumber = ceErpTradeCell.ctid;
  10964. apiVo.actionName = "afterOver";
  10965. designHelper.API_WorkCore(apiVo); //afterOver
  10966. }
  10967. ceErpTradeCell.Update();
  10968. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10969. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10970. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10971. return true;
  10972. }
  10973. return false;
  10974. }
  10975. public void get_erp_wechatorder()
  10976. {
  10977. DataStruct dStruct = GetPostStruct();
  10978. List<string> lw = new List<string>();
  10979. string tid = GetPostString("tid");
  10980. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10981. string shopname = GetPostString("shopname");
  10982. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10983. string buyernick = GetPostString("buyer_nick");
  10984. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10985. string customer = GetPostString("customer");
  10986. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10987. string returndate1 = GetPostString("returndate1");
  10988. string returndate2 = GetPostString("returndate2");
  10989. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10990. if (dw.Length > 0) lw.Add(dw);
  10991. string finishDate1 = GetPostString("finishdate1");
  10992. string finishDate2 = GetPostString("finishdate2");
  10993. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10994. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10995. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10996. dStruct.Order = "created desc";
  10997. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10998. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10999. writeGridDataTableJson(dStruct.TotalCount, dt);
  11000. }
  11001. public void get_erp_wechatlist_sumprice()
  11002. {
  11003. DataStruct dStruct = GetPostStruct();
  11004. List<string> lw = new List<string>();
  11005. string tid = GetPostString("tid");
  11006. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11007. string shopname = GetPostString("shopname");
  11008. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11009. string buyernick = GetPostString("buyer_nick");
  11010. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11011. string customer = GetPostString("customer");
  11012. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11013. string returndate1 = GetPostString("returndate1");
  11014. string returndate2 = GetPostString("returndate2");
  11015. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11016. if (dw.Length > 0) lw.Add(dw);
  11017. string finishDate1 = GetPostString("finishdate1");
  11018. string finishDate2 = GetPostString("finishdate2");
  11019. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11020. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11021. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11022. string mainWhere = string.Join(" and ", lw.ToArray());
  11023. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11024. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11025. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11026. decimal total = 0;
  11027. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11028. {
  11029. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11030. }
  11031. var res = new
  11032. {
  11033. data = total
  11034. };
  11035. string ro_jsond = JsonConvert.SerializeObject(res);
  11036. returnSuccess(ro_jsond);
  11037. return;
  11038. }
  11039. public void get_erp_qr_waitdeliverylist()
  11040. {
  11041. DataStruct dStruct = GetPostStruct();
  11042. List<string> lw = new List<string>();
  11043. string tid = GetPostString("ctid");
  11044. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11046. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11047. var res_objz = new
  11048. {
  11049. restype = 1,
  11050. data = dt
  11051. };
  11052. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11053. returnSuccess(ro_jsonz);
  11054. }
  11055. public void get_erp_yield_list()
  11056. {
  11057. DataStruct dStruct = GetPostStruct();
  11058. List<string> lw = new List<string>();
  11059. string tid = GetPostString("ctid");
  11060. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11061. string shopname = GetPostString("shopname");
  11062. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11063. string buyernick = GetPostString("buyer_nick");
  11064. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11065. //if (tid.Length == 0 && buyernick.Length == 0)
  11066. //{
  11067. // lw.Add(string.Format("IsRefund<={0}", 1));
  11068. //}
  11069. string customer = GetPostString("customer");
  11070. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11071. string design = GetPostString("design");
  11072. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11073. string orderState = GetPostString("orderState");
  11074. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11075. string address = GetPostString("address");
  11076. 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));
  11077. string sellermemo = GetPostString("seller_memo");
  11078. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11079. string supplier = GetPostString("supplier");
  11080. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11081. string OrderArea = GetPostString("order_area");
  11082. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11083. string placedate1 = GetPostString("placedate1");
  11084. string placedate2 = GetPostString("placedate2");
  11085. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11086. if (fdw.Length > 0) lw.Add(fdw);
  11087. string price1 = GetPostString("price1");
  11088. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11089. string price2 = GetPostString("price2");
  11090. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11091. string unusualCon = GetPostString("unusualcon");
  11092. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11093. string posTag = CurrentUser.UserPost.Post.Code;
  11094. if (posTag == "Supplier")
  11095. {
  11096. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11097. }
  11098. lw.Add(string.Format("OrderState = 6 "));
  11099. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11100. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11101. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11102. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11103. writeGridDataTableJson(dStruct.TotalCount, dt);
  11104. }
  11105. public void change_erp_sup_state()
  11106. {
  11107. if (UrlPostParmsCheck("ctid"))
  11108. {
  11109. string ctid = GetPostString("ctid");
  11110. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11111. if (ceErpTradeCell != null)
  11112. {
  11113. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11114. if (ceErpTradeCellExtend == null)
  11115. {
  11116. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11117. ceErpTradeCellExtend.ctid = ctid;
  11118. ceErpTradeCellExtend.SupState = 1;
  11119. ceErpTradeCellExtend.Create();
  11120. }
  11121. else
  11122. {
  11123. ceErpTradeCellExtend.SupState = 1;
  11124. ceErpTradeCellExtend.Update();
  11125. }
  11126. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11127. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11128. return;
  11129. }
  11130. returnErrorMsg("找不到订单");
  11131. }
  11132. }
  11133. public void supplier_all_downs()
  11134. {
  11135. if (UrlPostParmsCheck("tids"))
  11136. {
  11137. string tids = GetPostString("tids");
  11138. if (tids != null && tids.Length > 0)
  11139. {
  11140. StringBuilder sql = new StringBuilder();
  11141. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11142. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11143. sql = new StringBuilder();
  11144. 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, "下载设计文件");
  11145. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11146. string[] list = tids.Split(',');
  11147. foreach (string ctid in list)
  11148. {
  11149. CeErpSukuraData.createInfo(ctid, 3);
  11150. }
  11151. designHelper.api_approveDesign(tids); //approveDesign
  11152. returnSuccessMsg("下载成功!");
  11153. return;
  11154. }
  11155. returnErrorMsg("下载订单更新失败");
  11156. }
  11157. }
  11158. public void uploaderFileSuccess()
  11159. {
  11160. if (UrlPostParmsCheck("fileName"))
  11161. {
  11162. string fileName = GetPostString("fileName");
  11163. ApiVo apiVo = new ApiVo();
  11164. apiVo.orderNumber = fileName;
  11165. apiVo.actionName = "finishDesign";
  11166. designHelper.API_WorkCore(apiVo);//finishDesign
  11167. returnSuccessMsg("");
  11168. }
  11169. }
  11170. public void get_sample2_order()
  11171. {
  11172. if (UrlPostParmsCheck("ctid"))
  11173. {
  11174. string ctid = GetPostString("ctid");
  11175. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11176. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11177. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11178. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11179. double total = 0.0;
  11180. double order_price = 0.0;
  11181. if (dt_bu.Rows.Count > 0)
  11182. {
  11183. foreach (DataRow dr in dt_bu.Rows)
  11184. {
  11185. total += Convert.ToDouble(dr["payment"]);
  11186. }
  11187. }
  11188. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11189. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11190. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11191. string tid = ctid.Replace("S_", "");
  11192. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11193. double paymant = 0.0;
  11194. if (entity != null)
  11195. {
  11196. paymant = entity.payment;
  11197. }
  11198. string return_reason = "";
  11199. if (dt_after != null && dt_after.Rows.Count > 0)
  11200. {
  11201. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11202. }
  11203. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11204. }
  11205. }
  11206. public void get_erp_design_status()
  11207. {
  11208. string designName = GetPostString("designName");
  11209. DataStruct dStruct = GetPostStruct();
  11210. if (designName.Length > 0)
  11211. {
  11212. 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";
  11213. sql_user += " and Name like '%" + designName + "%'";
  11214. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11215. List<string> ids_list = new List<string>();
  11216. if (user_table.Rows.Count > 0)
  11217. {
  11218. foreach (DataRow item in user_table.Rows)
  11219. {
  11220. ids_list.Add(item["id"].ToString());
  11221. string ids_s = item["TeamIds"].ToString();
  11222. if (ids_s.Length > 0)
  11223. {
  11224. ids_list.AddRange(ids_s.Split(','));
  11225. }
  11226. }
  11227. }
  11228. HashSet<string> set = new HashSet<string>(ids_list);
  11229. ids_list = set.ToList();
  11230. if (ids_list.Count > 0)
  11231. {
  11232. 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));
  11233. dStruct.MainWhere = sql;
  11234. DataTable dt = null;
  11235. dt = WebCache.GetData("view_ErpUser", dStruct);
  11236. writeGridDataTableJson(dStruct.TotalCount, dt);
  11237. }
  11238. }
  11239. }
  11240. public void change_erp_order_price()
  11241. {
  11242. string ctid = GetPostString("ctid");
  11243. double price = GetPostDouble("price");
  11244. if (ctid.Length > 0)
  11245. {
  11246. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11247. if (ceErpTradeCellExtend == null)
  11248. {
  11249. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11250. ceErpTradeCellExtend.ctid = ctid;
  11251. ceErpTradeCellExtend.payment_cyt = price;
  11252. ceErpTradeCellExtend.Create();
  11253. }
  11254. else
  11255. {
  11256. ceErpTradeCellExtend.payment_cyt = price;
  11257. ceErpTradeCellExtend.Update();
  11258. }
  11259. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11260. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11261. {
  11262. ceErpDataSendOrderInfo.isSync = false;
  11263. ceErpDataSendOrderInfo.Update();
  11264. }
  11265. if (ceErpDataSendOrderInfo == null)
  11266. {
  11267. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11268. ceErpDataSendOrderInfo.isSync = false;
  11269. ceErpDataSendOrderInfo.ctid = ctid;
  11270. ceErpDataSendOrderInfo.Create();
  11271. }
  11272. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11273. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11274. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11275. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11276. {
  11277. dataSendOrderBean dataSendOrderBean = null;
  11278. foreach (DataRow item in dth.Rows)
  11279. {
  11280. try
  11281. {
  11282. dataSendOrderBean = new dataSendOrderBean();
  11283. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11284. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11285. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11286. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11287. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11288. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11289. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11290. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11291. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11292. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11293. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11294. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11295. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11296. if (result != null)
  11297. {
  11298. if ("0".Equals(result.errcode))
  11299. {
  11300. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11301. }
  11302. else
  11303. {
  11304. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11305. }
  11306. }
  11307. }
  11308. catch (Exception ex)
  11309. {
  11310. }
  11311. }
  11312. }
  11313. returnSuccessMsg("修改成功!");
  11314. return;
  11315. }
  11316. returnErrorMsg("找不到订单");
  11317. }
  11318. public void find_he_together()
  11319. {
  11320. string ctid = GetPostString("ctid");
  11321. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11322. List<string> list = new List<string>();
  11323. if (ceErpTradeCell != null)
  11324. {
  11325. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11326. {
  11327. 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);
  11328. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11329. if (table != null && table.Rows.Count > 0)
  11330. {
  11331. foreach (TableRow row in table.Rows)
  11332. {
  11333. }
  11334. }
  11335. }
  11336. }
  11337. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11338. }
  11339. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11340. {
  11341. //chy----19
  11342. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11343. //GD-CYT-----64
  11344. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11345. //ZHX----3
  11346. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11347. //JK----97
  11348. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11349. //ZT----70
  11350. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11351. //LHCY-----98
  11352. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11353. //XD-----90
  11354. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11355. //CYCY-----14
  11356. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11357. };
  11358. //其他改名
  11359. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11360. {
  11361. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11362. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11363. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11364. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11365. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11366. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11367. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11368. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11369. };
  11370. //不统计
  11371. List<int> no_suppliers = new List<int>()
  11372. {
  11373. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11374. };
  11375. //配件单
  11376. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11377. {
  11378. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11379. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11380. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11381. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11382. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11383. {"旗杆",new List<string>(){ "班旗" } },
  11384. {"牙签",new List<string>(){ "不干胶" } }
  11385. };
  11386. public void get_place_order_data()
  11387. {
  11388. string date1 = GetPostString("date1");
  11389. string date2 = GetPostString("date2");
  11390. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11391. DateTime start = DateTime.Parse(starttime);
  11392. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11393. DateTime end = DateTime.Parse(endtime);
  11394. if (date1 != null && date1.Length > 0)
  11395. {
  11396. DateTime dateTime = DateTime.Parse(date1);
  11397. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11398. start = DateTime.Parse(starttime);
  11399. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11400. end = DateTime.Parse(endtime);
  11401. }
  11402. if (date2 != null && date2.Length > 0)
  11403. {
  11404. DateTime dateTime = DateTime.Parse(date2);
  11405. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11406. end = DateTime.Parse(endtime);
  11407. }
  11408. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierName is not null ", starttime, endtime);
  11409. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11410. //不干胶-----1,卡片-----29
  11411. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11412. foreach (DataRow row in data.Rows)
  11413. {
  11414. int productId = Convert.ToInt32(row["ProductId"]);
  11415. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11416. if (no_suppliers.Contains(supplierId))
  11417. {
  11418. continue;
  11419. }
  11420. string seller_memo = row["seller_memo"].ToString();
  11421. bool ispj = false;//是否配件单
  11422. bool isfirst = true;//第一个配
  11423. maps.Keys.ForEach(key =>
  11424. {
  11425. //备注包含配件
  11426. if (seller_memo.Contains(key) && isfirst)
  11427. {
  11428. List<string> list = maps[key];
  11429. ispj = true;
  11430. isfirst = false;
  11431. for (int i = 0; i < list.Count; i++)
  11432. {
  11433. if (seller_memo.Contains(list[i]))
  11434. {
  11435. ispj = false;
  11436. break;
  11437. }
  11438. }
  11439. }
  11440. });
  11441. if (ispj)
  11442. {
  11443. continue;
  11444. }
  11445. seller_memo = seller_memo.Replace("UV", "uv");
  11446. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11447. //吊牌归到卡片
  11448. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11449. seller_memo = seller_memo.Replace("卡套", "卡片");
  11450. seller_memo = seller_memo.Replace("封套", "卡片");
  11451. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11452. seller_memo = seller_memo.Replace("腰封", "卡片");
  11453. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11454. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11455. seller_memo = seller_memo.Replace("横幅", "条幅");
  11456. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11457. string map_key = "";
  11458. string type = "";
  11459. if (supplierMap.ContainsKey(supplierId))
  11460. {
  11461. foreach (var kvp in supplierMap[supplierId])
  11462. {
  11463. if (seller_memo.Contains(kvp.Key))
  11464. {
  11465. map_key = kvp.Value;
  11466. type = kvp.Value;
  11467. break;
  11468. }
  11469. }
  11470. }
  11471. if (map_key == "")
  11472. {
  11473. type = "其他";
  11474. map_key = "其他";
  11475. }
  11476. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11477. {
  11478. map_key = suppliers[supplierId];
  11479. }
  11480. if (supplierId == 70)
  11481. {
  11482. supplierId = 70;
  11483. }
  11484. map_key += "_" + row["SupplierName"].ToString();
  11485. Dictionary<string, int> map = null;
  11486. if (other_map.ContainsKey(map_key))
  11487. {
  11488. other_map.TryGetValue(map_key, out map);
  11489. }
  11490. else
  11491. {
  11492. map = new Dictionary<string, int>();
  11493. map.Add("dayDev", 0);//当天出货
  11494. map.Add("dayTotal", 0);//下单总数
  11495. map.Add("payTotal", 0);//500以上
  11496. map.Add("today", 0);//当天出货数量
  11497. map.Add("unusua", 0);//异常数
  11498. other_map.Add(map_key, map);
  11499. other_map.TryGetValue(map_key, out map);
  11500. }
  11501. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11502. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11503. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11504. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11505. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11506. {
  11507. map["dayTotal"]++;
  11508. if (supplierId == 97)
  11509. {
  11510. supplierId = 97;
  11511. }
  11512. }
  11513. if (Convert.ToDecimal(row["payment"]) >= 500)
  11514. {
  11515. map["payTotal"]++;
  11516. }
  11517. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11518. {
  11519. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11520. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11521. {
  11522. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11523. {
  11524. map["today"]++;
  11525. }
  11526. }
  11527. else
  11528. {
  11529. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11530. {
  11531. map["today"]++;
  11532. }
  11533. else
  11534. {
  11535. if (supplierId == 119)
  11536. {
  11537. Debug.WriteLine(row["seller_memo"].ToString());
  11538. }
  11539. }
  11540. }
  11541. }
  11542. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11543. {
  11544. map["unusua"]++;
  11545. }
  11546. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11547. //GD-CYT-----64
  11548. DateTime two = palceTimeStart.AddHours(14);
  11549. DateTime three = palceTimeStart.AddHours(15);
  11550. DateTime four = palceTimeStart.AddHours(16);
  11551. DateTime six = palceTimeStart.AddHours(18);
  11552. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11553. {
  11554. //下午四点前 500-1000
  11555. string count = row["ProductCount"].ToString();
  11556. if (count != null && count.Length > 0)
  11557. {
  11558. int productCount = commonHelper.getPlaceProductCount(count);
  11559. if (productCount >= 500 && productCount <= 1000)
  11560. {
  11561. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11562. {
  11563. map["dayDev"]++;
  11564. }
  11565. }
  11566. }
  11567. }
  11568. //UV
  11569. else if ("uv".Equals(type))
  11570. {
  11571. //ZT----70
  11572. //ZHX----3
  11573. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11574. {
  11575. map["dayDev"]++;
  11576. }
  11577. //JK----97
  11578. //HZX----105
  11579. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11580. {
  11581. map["dayDev"]++;
  11582. }
  11583. }
  11584. //帆布---52|条幅---27
  11585. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11586. {
  11587. //LHCY-----98
  11588. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11589. {
  11590. map["dayDev"]++;
  11591. }
  11592. }
  11593. //条幅
  11594. else if ("条幅".Equals(type))
  11595. {
  11596. //XD-----90
  11597. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11598. {
  11599. map["dayDev"]++;
  11600. }
  11601. }
  11602. //桌布
  11603. else if ("桌布".Equals(type))
  11604. {
  11605. //XD-----90
  11606. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11607. {
  11608. map["dayDev"]++;
  11609. }
  11610. }
  11611. //DL---10
  11612. //AYTW---119
  11613. //FS-CYT-DY ----80
  11614. //JK----97
  11615. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11616. {
  11617. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11618. {
  11619. map["dayDev"]++;
  11620. }
  11621. }
  11622. // QC---121
  11623. else if (supplierId == 121)
  11624. {
  11625. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11626. {
  11627. map["dayDev"]++;
  11628. }
  11629. }
  11630. }
  11631. DataTable dt = new DataTable();
  11632. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11633. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11634. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11635. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11636. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11637. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11638. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11639. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11640. other_map.Keys.ForEach(key =>
  11641. {
  11642. DataRow dr = dt.NewRow();
  11643. Dictionary<string, int> map = other_map[key];
  11644. string[] key_list = key.Split('_');
  11645. dr[0] = key_list[0];
  11646. dr[1] = key_list[1];
  11647. if (key_list.Length > 2)
  11648. {
  11649. dr[1] += "(" + key_list[2] + ")";
  11650. }
  11651. dr[2] = map["dayTotal"];
  11652. dr[3] = map["payTotal"];
  11653. dr[4] = map["today"];
  11654. dr[5] = map["unusua"];
  11655. dr[6] = map["dayDev"];
  11656. double rate = 0.00;
  11657. if (map["dayDev"] > 0)
  11658. {
  11659. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11660. }
  11661. dr[7] = rate.ToString();
  11662. dt.Rows.Add(dr);
  11663. });
  11664. DataView dv = new DataView(dt);
  11665. dv.Sort = "SupplierName";
  11666. //dv.Sort = "AllOrder desc";
  11667. DataTable dtNew = dv.ToTable();
  11668. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11669. }
  11670. public void check_order_desing_info()
  11671. {
  11672. string ctid = GetPostString("ctid");
  11673. if (!string.IsNullOrEmpty(ctid))
  11674. {
  11675. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11676. if (ceErpTradeCell != null)
  11677. {
  11678. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11679. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11680. return;
  11681. }
  11682. returnErrorMsg("找不到订单");
  11683. return;
  11684. }
  11685. returnErrorMsg("找不到订单");
  11686. }
  11687. public void get_timeout_detail()
  11688. {
  11689. string poscode = CurrentUser.UserPost.Post.Code;
  11690. DataStruct dStruct = GetPostStruct();
  11691. List<string> lw = new List<string>();
  11692. string id = GetPostString("id");
  11693. string pay_date1 = GetPostString("pay_date1");
  11694. string pay_date2 = GetPostString("pay_date2");
  11695. int type = GetPostInt("type");
  11696. if (type == 0)
  11697. {
  11698. if (pay_date1.Length > 0)
  11699. {
  11700. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11701. }
  11702. if (pay_date2.Length > 0)
  11703. {
  11704. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11705. }
  11706. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11707. }
  11708. if (type == 1)
  11709. {
  11710. if (pay_date1.Length > 0)
  11711. {
  11712. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11713. }
  11714. if (pay_date2.Length > 0)
  11715. {
  11716. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11717. }
  11718. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11719. }
  11720. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11721. DataTable dt = null;
  11722. dt = WebCache.GetData("view_orderlist", dStruct);
  11723. writeGridDataTableJson(dStruct.TotalCount, dt);
  11724. }
  11725. public void saveUrgentChargePrice()
  11726. {
  11727. string ctid = GetPostString("ctid");
  11728. if (!string.IsNullOrEmpty(ctid))
  11729. {
  11730. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11731. if (ceErpTradeCell != null)
  11732. {
  11733. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11734. if (prices <= 100)
  11735. {
  11736. returnErrorMsg("此订单金额不足100元,无法加急。");
  11737. return;
  11738. }
  11739. double price = GetPostDouble("price");
  11740. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11741. if (ceErpTradeCellExtend == null)
  11742. {
  11743. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11744. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11745. }
  11746. ceErpTradeCellExtend.urgentCharge = price;
  11747. if (ceErpTradeCellExtend.ID > 0)
  11748. {
  11749. ceErpTradeCellExtend.Update();
  11750. }
  11751. else
  11752. {
  11753. ceErpTradeCellExtend.Save();
  11754. }
  11755. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11756. returnSuccessMsg("修改成功!");
  11757. return;
  11758. }
  11759. returnErrorMsg("找不到订单");
  11760. return;
  11761. }
  11762. returnErrorMsg("找不到订单");
  11763. }
  11764. public void finish_erp_order()
  11765. {
  11766. string ctid = GetPostString("ctid");
  11767. if (!string.IsNullOrEmpty(ctid))
  11768. {
  11769. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11770. {
  11771. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11772. if (ceErpTradeCell != null)
  11773. {
  11774. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11775. ceErpTradeCell.Update();
  11776. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11777. returnSuccessMsg("修改成功!");
  11778. return;
  11779. }
  11780. }
  11781. }
  11782. returnErrorMsg("找不到订单");
  11783. }
  11784. public void get_trade_order_list()
  11785. {
  11786. string tid = GetPostString("tid");
  11787. if (!string.IsNullOrEmpty(tid))
  11788. {
  11789. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11790. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11791. writeGridDataTableJson(data.Rows.Count, data);
  11792. return;
  11793. }
  11794. returnErrorMsg("找不到订单");
  11795. }
  11796. public void save_cell_spu()
  11797. {
  11798. string ctid = GetPostString("ctid");
  11799. string spu_id = GetPostString("spu_id");
  11800. if (!string.IsNullOrEmpty(ctid))
  11801. {
  11802. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11803. if (ceErpTradeCellExtend == null)
  11804. {
  11805. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11806. ceErpTradeCellExtend.ctid = ctid;
  11807. }
  11808. ceErpTradeCellExtend.spu_id = spu_id;
  11809. if (!string.IsNullOrEmpty(spu_id))
  11810. {
  11811. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11812. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11813. }
  11814. if (ceErpTradeCellExtend.ID == 0)
  11815. {
  11816. ceErpTradeCellExtend.Create();
  11817. }
  11818. else
  11819. {
  11820. ceErpTradeCellExtend.Update();
  11821. }
  11822. returnSuccessMsg("修改成功!");
  11823. return;
  11824. }
  11825. returnErrorMsg("找不到订单");
  11826. }
  11827. public void change_express_info()
  11828. {
  11829. string ctid = GetPostString("ctid");
  11830. string transNo = GetPostString("transNo");
  11831. string transCom = GetPostString("transCom");
  11832. if (!string.IsNullOrEmpty(ctid))
  11833. {
  11834. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11835. if (ceErpTradeCellExtend == null)
  11836. {
  11837. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11838. ceErpTradeCellExtend.ctid = ctid;
  11839. }
  11840. ceErpTradeCellExtend.modExpressNo = transNo;
  11841. ceErpTradeCellExtend.modExpressCom = transCom;
  11842. ceErpTradeCellExtend.readMod = 2;
  11843. if (ceErpTradeCellExtend.ID == 0)
  11844. {
  11845. ceErpTradeCellExtend.Create();
  11846. }
  11847. else
  11848. {
  11849. ceErpTradeCellExtend.Update();
  11850. }
  11851. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11852. returnSuccessMsg("修改成功!");
  11853. return;
  11854. }
  11855. returnErrorMsg("找不到订单");
  11856. }
  11857. public void get_change_express_list()
  11858. {
  11859. DataStruct dStruct = GetPostStruct();
  11860. List<string> lw = new List<string>();
  11861. int st = 2;
  11862. string tid = GetPostString("ctid");
  11863. if (tid.Length > 0)
  11864. {
  11865. string select_tid = getTidByCtid(tid);
  11866. lw.Add(string.Format("tid='{0}'", select_tid));
  11867. }
  11868. string shopname = GetPostString("shopname");
  11869. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11870. string buyernick = GetPostString("buyer_nick");
  11871. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11872. string sellermemo = GetPostString("seller_memo");
  11873. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11874. string supplier = GetPostString("supplier");
  11875. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11876. string customer = GetPostString("customer");
  11877. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11878. string design = GetPostString("design");
  11879. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11880. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11881. string poscode = CurrentUser.UserPost.Post.Code;
  11882. if (poscode != "SysAdmin")
  11883. {
  11884. string shopid = CurrentUser.User.pemShop;
  11885. lw.Add(string.Format("shopId in ({0})", shopid));
  11886. }
  11887. lw.Add("readMod = 2");
  11888. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11889. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11890. writeGridDataTableJson(dStruct.TotalCount, dt);
  11891. }
  11892. public void deal_express_complete()
  11893. {
  11894. string ctid = GetPostString("ctid");
  11895. if (!string.IsNullOrEmpty(ctid))
  11896. {
  11897. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11898. if (ceErpTradeCellExtend == null)
  11899. {
  11900. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11901. ceErpTradeCellExtend.ctid = ctid;
  11902. }
  11903. ceErpTradeCellExtend.readMod = 1;
  11904. if (ceErpTradeCellExtend.ID == 0)
  11905. {
  11906. ceErpTradeCellExtend.Create();
  11907. }
  11908. else
  11909. {
  11910. ceErpTradeCellExtend.Update();
  11911. }
  11912. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11913. returnSuccessMsg("修改成功!");
  11914. return;
  11915. }
  11916. returnErrorMsg("找不到订单");
  11917. }
  11918. public void aftersale_return_visit()
  11919. {
  11920. string ctid = GetPostString("ctid");
  11921. if (!string.IsNullOrEmpty(ctid))
  11922. {
  11923. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11924. if (ceErpTradeCellExtend == null)
  11925. {
  11926. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11927. ceErpTradeCellExtend.ctid = ctid;
  11928. }
  11929. ceErpTradeCellExtend.returnVisit = 1;
  11930. if (ceErpTradeCellExtend.ID == 0)
  11931. {
  11932. ceErpTradeCellExtend.Create();
  11933. }
  11934. else
  11935. {
  11936. ceErpTradeCellExtend.Update();
  11937. }
  11938. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11939. if (ceErpTradeAfterSaleExtend != null)
  11940. {
  11941. ceErpTradeAfterSaleExtend.TextResult = "";
  11942. ceErpTradeAfterSaleExtend.Update();
  11943. }
  11944. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11945. returnSuccessMsg("修改成功!");
  11946. return;
  11947. }
  11948. returnErrorMsg("找不到订单");
  11949. }
  11950. public void orderPlaceInfo()
  11951. {
  11952. string ctids = GetPostString("ctids");
  11953. string[] list = ctids.Split(',');
  11954. foreach (string ctid in list)
  11955. {
  11956. CeErpSukuraData.createInfo(ctid, 3);
  11957. }
  11958. StringBuilder sql = new StringBuilder();
  11959. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11960. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11961. designHelper.api_approveDesign(ctids); //approveDesign
  11962. returnSuccessMsg("");
  11963. }
  11964. public void get_issue_list()
  11965. {
  11966. DataStruct dStruct = GetPostStruct();
  11967. List<string> lw = new List<string>();
  11968. int st = 2;
  11969. string tid = GetPostString("ctid");
  11970. if (tid.Length > 0)
  11971. {
  11972. string select_tid = getTidByCtid(tid);
  11973. lw.Add(string.Format("tid='{0}'", select_tid));
  11974. }
  11975. string shopname = GetPostString("shopname");
  11976. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11977. string buyernick = GetPostString("buyer_nick");
  11978. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11979. string sellermemo = GetPostString("seller_memo");
  11980. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11981. string supplier = GetPostString("supplier");
  11982. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11983. string customer = GetPostString("customer");
  11984. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11985. string design = GetPostString("design");
  11986. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11987. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11988. string poscode = CurrentUser.UserPost.Post.Code;
  11989. if (poscode != "SysAdmin")
  11990. {
  11991. string shopid = CurrentUser.User.pemShop;
  11992. lw.Add(string.Format("shopId in ({0})", shopid));
  11993. }
  11994. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11995. {
  11996. lw.Add("IssueState = 1");
  11997. }
  11998. else
  11999. {
  12000. string iisstate = GetPostString("iisstate");
  12001. if ("1".Equals(iisstate))
  12002. {
  12003. lw.Add("IssueState =1");
  12004. }
  12005. else if ("2".Equals(iisstate))
  12006. {
  12007. lw.Add("IssueState = 2");
  12008. }
  12009. else
  12010. {
  12011. lw.Add("IssueState > 0");
  12012. }
  12013. }
  12014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12015. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12016. writeGridDataTableJson(dStruct.TotalCount, dt);
  12017. }
  12018. public void saveIssueContent()
  12019. {
  12020. string ctid = GetPostString("ctid");
  12021. if (!string.IsNullOrEmpty(ctid))
  12022. {
  12023. string content = GetPostString("content");
  12024. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12025. if (ceErpTradeAfterSaleExtend == null)
  12026. {
  12027. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12028. ceErpTradeAfterSaleExtend.tid = ctid;
  12029. }
  12030. ceErpTradeAfterSaleExtend.IssueContent = content;
  12031. ceErpTradeAfterSaleExtend.IssueState = 1;
  12032. if (ceErpTradeAfterSaleExtend.ID > 0)
  12033. {
  12034. ceErpTradeAfterSaleExtend.Update();
  12035. }
  12036. else
  12037. {
  12038. ceErpTradeAfterSaleExtend.Create();
  12039. }
  12040. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12041. returnSuccessMsg("添加成功!");
  12042. return;
  12043. }
  12044. returnErrorMsg("找不到订单");
  12045. }
  12046. public void dealIssueContent()
  12047. {
  12048. string ctid = GetPostString("ctid");
  12049. if (!string.IsNullOrEmpty(ctid))
  12050. {
  12051. string content = GetPostString("content");
  12052. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12053. if (ceErpTradeAfterSaleExtend != null)
  12054. {
  12055. ceErpTradeAfterSaleExtend.IssueState = 2;
  12056. ceErpTradeAfterSaleExtend.Update();
  12057. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12058. returnSuccessMsg("修改完成!");
  12059. return;
  12060. }
  12061. }
  12062. returnErrorMsg("找不到订单");
  12063. }
  12064. public void set_tid_attachments()
  12065. {
  12066. string tid = GetPostString("tid");
  12067. string atta = GetPostString("atta");
  12068. if (!string.IsNullOrEmpty(tid))
  12069. {
  12070. if (string.IsNullOrEmpty(atta))
  12071. {
  12072. returnErrorMsg("文件地址为空");
  12073. return;
  12074. }
  12075. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12076. if (ceErpTradeCell != null)
  12077. {
  12078. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12079. if (ceErpTrade == null)
  12080. {
  12081. returnErrorMsg("找不到订单");
  12082. return;
  12083. }
  12084. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12085. bool isSend = false;
  12086. if (dt != null && dt.Rows.Count > 0)
  12087. {
  12088. foreach (DataRow row in dt.Rows)
  12089. {
  12090. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12091. {
  12092. isSend = true;
  12093. }
  12094. }
  12095. if (isSend)
  12096. {
  12097. returnErrorMsg("已发货无法修改");
  12098. return;
  12099. }
  12100. ceErpTrade.Attachments = atta;
  12101. ceErpTrade.Update();
  12102. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12103. returnSuccessMsg("上传成功!");
  12104. return;
  12105. }
  12106. }
  12107. }
  12108. returnErrorMsg("找不到订单");
  12109. }
  12110. public void get_tid_attachments()
  12111. {
  12112. string tid = GetPostString("tid");
  12113. if (!string.IsNullOrEmpty(tid))
  12114. {
  12115. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12116. if (ceErpTradeCell != null)
  12117. {
  12118. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12119. if (ceErpTrade == null)
  12120. {
  12121. returnErrorMsg("找不到订单");
  12122. return;
  12123. }
  12124. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12125. return;
  12126. }
  12127. }
  12128. returnErrorMsg("找不到订单");
  12129. }
  12130. public void check_erp_sameorders()
  12131. {
  12132. if (UrlPostParmsCheck("ctid"))
  12133. {
  12134. string eid = GetPostString("ctid");
  12135. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12136. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12137. if (entity != null && ceErpTrade != null)
  12138. {
  12139. if (entity.OrderState > 6)
  12140. {
  12141. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12142. return;
  12143. }
  12144. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12145. List<string> ids = new List<string>();
  12146. if (dt != null && dt.Rows.Count > 1)
  12147. {
  12148. bool needhe = true;
  12149. foreach (DataRow dr in dt.Rows)
  12150. {
  12151. ids.Add("'" + dr["ctid"] + "'");
  12152. /* //备注有合包
  12153. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12154. {
  12155. needhe = true;
  12156. }
  12157. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12158. {
  12159. needhe = true;
  12160. }
  12161. //顺丰快递
  12162. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12163. {
  12164. needhe = true;
  12165. }*/
  12166. }
  12167. if (!needhe)
  12168. {
  12169. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12170. return;
  12171. }
  12172. StringBuilder sql = new StringBuilder();
  12173. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12174. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12175. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12176. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12177. foreach (DataRow dr in dt.Rows)
  12178. {
  12179. dr["dstate"] = 0;
  12180. dr["dnumber"] = 0;
  12181. foreach (DataRow row in dt1.Rows)
  12182. {
  12183. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12184. {
  12185. dr["dstate"] = 2;
  12186. dr["default"] = 1;
  12187. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12188. }
  12189. }
  12190. if (eid.Equals(dr["ctid"].ToString()))
  12191. {
  12192. dr["dstate"] = 1;
  12193. dr["default"] = 1;
  12194. }
  12195. }
  12196. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12197. return;
  12198. }
  12199. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12200. return;
  12201. }
  12202. returnErrorMsg("未找到订单");
  12203. return;
  12204. }
  12205. returnErrorMsg("缺少必要的参数");
  12206. }
  12207. public void get_mark_number()
  12208. {
  12209. string eid = GetPostString("ctid");
  12210. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12211. if (entity != null)
  12212. {
  12213. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12214. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12215. int current = 1;
  12216. if (ceErpDeliverMark == null)
  12217. {
  12218. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12219. List<string> ids = new List<string>();
  12220. if (dt != null && dt.Rows.Count > 1)
  12221. {
  12222. foreach (DataRow dr in dt.Rows)
  12223. {
  12224. ids.Add("'" + dr["ctid"] + "'");
  12225. }
  12226. //查询已有的编号
  12227. StringBuilder sql = new StringBuilder();
  12228. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12229. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12230. if (dt1 == null || dt1.Rows.Count == 0)
  12231. {
  12232. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12233. List<int> list_number = new List<int>();
  12234. foreach (DataRow row in numbers.Rows)
  12235. {
  12236. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12237. }
  12238. //查询空余编号
  12239. for (int i = 0; i < list_number.Count + 2; i++)
  12240. {
  12241. if (!list_number.Contains(current))
  12242. {
  12243. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12244. //防止查询过程中有新数据生成
  12245. if (ceErpDeliverMark1 == null)
  12246. {
  12247. break;
  12248. }
  12249. }
  12250. current++;
  12251. }
  12252. }
  12253. else
  12254. {
  12255. foreach (DataRow row in dt1.Rows)
  12256. {
  12257. current = Convert.ToInt32(row["markNumber"]);
  12258. }
  12259. }
  12260. ceErpDeliverMark = new CeErpDeliverMark();
  12261. ceErpDeliverMark.ctid = eid;
  12262. ceErpDeliverMark.createtime = DateTime.Now;
  12263. if (ceErpTrade != null)
  12264. {
  12265. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12266. }
  12267. ceErpDeliverMark.markNumber = current;
  12268. ceErpDeliverMark.Create();
  12269. }
  12270. }
  12271. else
  12272. {
  12273. current = ceErpDeliverMark.markNumber;
  12274. }
  12275. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12276. return;
  12277. }
  12278. }
  12279. public void aftersaleCytSend()
  12280. {
  12281. string ctid = GetPostString("ctid");
  12282. if (!string.IsNullOrEmpty(ctid))
  12283. {
  12284. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12285. if (ceErpTradeCell != null)
  12286. {
  12287. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12288. }
  12289. returnSuccessMsg("推送成功");
  12290. return;
  12291. }
  12292. returnErrorMsg("缺少必要的参数");
  12293. }
  12294. public void packOrderInfo()
  12295. {
  12296. string ctids = GetPostString("ctids");
  12297. if (!string.IsNullOrEmpty(ctids))
  12298. {
  12299. string[] ctid_list = ctids.Split(',');
  12300. if (ctid_list.Length > 20)
  12301. {
  12302. returnErrorMsg("单次下载次数不能超过20个");
  12303. return;
  12304. }
  12305. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12306. StringBuilder sql = new StringBuilder();
  12307. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12308. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12309. int supplierId = 0;
  12310. StringBuilder insterSql = new StringBuilder();
  12311. for (int i = 0; i < dt.Rows.Count; i++)
  12312. {
  12313. DataRow row = dt.Rows[i];
  12314. if (i == 0)
  12315. {
  12316. supplierId = Convert.ToInt32(row["SupplierId"]);
  12317. }
  12318. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12319. {
  12320. returnErrorMsg("同车间的订单才能一起打包");
  12321. return;
  12322. }
  12323. int orderState = Convert.ToInt32(row["OrderState"]);
  12324. if (orderState != 5)
  12325. {
  12326. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12327. return;
  12328. }
  12329. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12330. }
  12331. CeErpPackData ceErpPackData = new CeErpPackData();
  12332. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12333. ceErpPackData.supplierId = supplierId;
  12334. ceErpPackData.createtime = DateTime.Now;
  12335. ceErpPackData.createBy = CurrentUser.UserID;
  12336. ceErpPackData.createName = CurrentUser.UserName;
  12337. ceErpPackData.Create();
  12338. if (ceErpPackData.ID > 0)
  12339. {
  12340. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12341. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12342. }
  12343. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12344. returnSuccessMsg("打包成功");
  12345. return;
  12346. }
  12347. returnErrorMsg("缺少必要的参数");
  12348. }
  12349. public void rePackOrderInfo()
  12350. {
  12351. string id = GetPostString("id");
  12352. if (!string.IsNullOrEmpty(id))
  12353. {
  12354. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12355. if (ceErpPackData == null)
  12356. {
  12357. returnSuccessMsg("查无数据");
  12358. return;
  12359. }
  12360. ceErpPackData.upStatus = 0;
  12361. ceErpPackData.message = "";
  12362. ceErpPackData.Update();
  12363. returnSuccessMsg("打包成功");
  12364. return;
  12365. }
  12366. returnErrorMsg("缺少必要的参数");
  12367. }
  12368. public void backPackOrderInfo()
  12369. {
  12370. string id = GetPostString("id");
  12371. if (!string.IsNullOrEmpty(id))
  12372. {
  12373. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12374. if (ceErpPackData == null)
  12375. {
  12376. returnSuccessMsg("查无数据");
  12377. return;
  12378. }
  12379. ceErpPackData.upStatus = 4;
  12380. ceErpPackData.Update();
  12381. List<string> list = new List<string>();
  12382. StringBuilder sql = new StringBuilder();
  12383. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12384. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12385. for (int i = 0; i < dt.Rows.Count; i++)
  12386. {
  12387. DataRow row = dt.Rows[i];
  12388. list.Add("'" + row["ctid"].ToString() + "'");
  12389. }
  12390. string textCtids = string.Join(",", list);
  12391. 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));
  12392. 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, "无法打包退回"));
  12393. returnSuccessMsg("退回成功");
  12394. return;
  12395. }
  12396. returnErrorMsg("缺少必要的参数");
  12397. }
  12398. public void addPackDownNum()
  12399. {
  12400. string id = GetPostString("id");
  12401. if (!string.IsNullOrEmpty(id))
  12402. {
  12403. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12404. returnSuccessMsg("下载成功");
  12405. return;
  12406. }
  12407. returnErrorMsg("缺少必要的参数");
  12408. }
  12409. public void get_pack_list()
  12410. {
  12411. DataStruct dStruct = GetPostStruct();
  12412. List<string> lw = new List<string>();
  12413. string supplier = GetPostString("supplier");
  12414. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12415. string posTag = CurrentUser.UserPost.Post.Code;
  12416. if (posTag == "Supplier")
  12417. {
  12418. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12419. }
  12420. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12421. dStruct.Order = "createtime desc";
  12422. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12423. writeGridDataTableJson(dStruct.TotalCount, dt);
  12424. }
  12425. public void get_pack_order_list()
  12426. {
  12427. string packId = GetPostString("packId");
  12428. if (string.IsNullOrEmpty(packId))
  12429. {
  12430. returnErrorMsg("缺少必要的参数");
  12431. return;
  12432. }
  12433. StringBuilder sql = new StringBuilder();
  12434. 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);
  12435. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12436. if (dt == null || dt.Rows.Count == 0)
  12437. {
  12438. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12439. return;
  12440. }
  12441. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12442. return;
  12443. }
  12444. public void get_supplier_product_time_list()
  12445. {
  12446. DataStruct dStruct = GetPostStruct();
  12447. List<string> lw = new List<string>();
  12448. string supplier = GetPostString("supplier");
  12449. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12450. string posTag = CurrentUser.UserPost.Post.Code;
  12451. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12452. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12453. writeGridDataTableJson(dStruct.TotalCount, dt);
  12454. }
  12455. public void saveSupplierProductTime()
  12456. {
  12457. string productId = GetPostString("productId");
  12458. if (string.IsNullOrEmpty(productId))
  12459. {
  12460. returnErrorMsg("缺少必要的参数");
  12461. return;
  12462. }
  12463. string productName = GetPostString("productName");
  12464. int supplierId = GetPostInt("supplierId");
  12465. if (supplierId == 0)
  12466. {
  12467. returnErrorMsg("缺少必要的参数");
  12468. return;
  12469. }
  12470. int quantity = GetPostInt("quantity");
  12471. int sendDay = GetPostInt("sendTime");
  12472. string supplierName = GetPostString("supplierName");
  12473. string craft = GetPostString("craft");
  12474. string deadLine = GetPostString("deadLine");
  12475. string dayDeadLine = GetPostString("dayDeadLine");
  12476. try
  12477. {
  12478. int eid = GetPostInt("eid");
  12479. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12480. if (ceErpSupplierProductTime == null)
  12481. {
  12482. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12483. }
  12484. ceErpSupplierProductTime.productId = productId;
  12485. ceErpSupplierProductTime.productName = productName;
  12486. ceErpSupplierProductTime.supplierId = supplierId;
  12487. ceErpSupplierProductTime.supplierName = supplierName;
  12488. ceErpSupplierProductTime.craft = craft;
  12489. ceErpSupplierProductTime.sendDay = sendDay;
  12490. ceErpSupplierProductTime.quantity = quantity;
  12491. if (!string.IsNullOrEmpty(deadLine))
  12492. {
  12493. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12494. }
  12495. if (!string.IsNullOrEmpty(dayDeadLine))
  12496. {
  12497. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12498. }
  12499. if (ceErpSupplierProductTime.ID == 0)
  12500. {
  12501. ceErpSupplierProductTime.Save();
  12502. }
  12503. else
  12504. {
  12505. ceErpSupplierProductTime.Update();
  12506. }
  12507. }
  12508. catch (Exception e)
  12509. {
  12510. }
  12511. returnSuccessMsg("保存成功");
  12512. return;
  12513. }
  12514. public void delSupplierProductTime()
  12515. {
  12516. int eid = GetPostInt("eid");
  12517. if (eid > 0)
  12518. {
  12519. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12520. if (ceErpSupplierProductTime == null)
  12521. {
  12522. returnErrorMsg("查无数据");
  12523. return;
  12524. }
  12525. ceErpSupplierProductTime.Delete();
  12526. returnSuccessMsg("保存成功");
  12527. return;
  12528. }
  12529. returnErrorMsg("缺少必要的参数");
  12530. }
  12531. public void getExpressInfo()
  12532. {
  12533. string ctid = GetPostString("ctid");
  12534. if (!string.IsNullOrEmpty(ctid))
  12535. {
  12536. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12537. if (ceErpTradeCell != null)
  12538. {
  12539. string outSid = ceErpTradeCell.OutSid;
  12540. if (outSid.Length > 0)
  12541. {
  12542. 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);
  12543. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12544. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12545. return;
  12546. }
  12547. }
  12548. returnErrorMsg("查无记录");
  12549. return;
  12550. }
  12551. returnErrorMsg("缺少必要的参数");
  12552. }
  12553. public void getExpressPostData()
  12554. {
  12555. string express = GetPostString("express");
  12556. if (!string.IsNullOrEmpty(express))
  12557. {
  12558. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12559. if (ceErpExpressInfo != null)
  12560. {
  12561. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12562. return;
  12563. }
  12564. }
  12565. returnErrorMsg("缺少必要的参数");
  12566. }
  12567. public void checkSupplierOrder()
  12568. {
  12569. string ctids = GetPostString("ctids");
  12570. if (ctids != null)
  12571. {
  12572. List<string> list = new List<string>();
  12573. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12574. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12575. for (int i = 0; i < dt.Rows.Count; i++)
  12576. {
  12577. DataRow row = dt.Rows[i];
  12578. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12579. {
  12580. continue;
  12581. }
  12582. list.Add(row["seller_memo"].ToString());
  12583. }
  12584. if (list.Count > 0)
  12585. {
  12586. 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, "点击下载按钮"));
  12587. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12588. return;
  12589. }
  12590. }
  12591. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12592. return;
  12593. }
  12594. public void addPersonId()
  12595. {
  12596. string tid = GetPostString("tid");
  12597. string personId = GetPostString("personId");
  12598. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12599. if (ceErpTrade != null)
  12600. {
  12601. ceErpTrade.receiver_zip = personId;
  12602. ceErpTrade.Update();
  12603. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12604. returnSuccessMsg("保存成功");
  12605. return;
  12606. }
  12607. returnErrorMsg("缺少必要的参数");
  12608. }
  12609. public void addDeliveryPaymant()
  12610. {
  12611. string tid = GetPostString("tid");
  12612. string paymant = GetPostString("paymant");
  12613. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12614. if (ceErpTrade != null)
  12615. {
  12616. if (!string.IsNullOrEmpty(paymant))
  12617. {
  12618. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12619. }
  12620. ceErpTrade.Update();
  12621. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12622. returnSuccessMsg("保存成功");
  12623. return;
  12624. }
  12625. returnErrorMsg("缺少必要的参数");
  12626. }
  12627. public void saveCellFile()
  12628. {
  12629. string tid = GetPostString("tid");
  12630. string ctid = GetPostString("ctid");
  12631. string urls = GetPostString("urls");
  12632. string type = GetPostString("type");
  12633. string del = GetPostString("del");
  12634. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12635. {
  12636. if ("1".Equals(del))
  12637. {
  12638. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12639. }
  12640. string[] list = urls.Split(',');
  12641. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12642. {
  12643. foreach (string item in list)
  12644. {
  12645. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12646. ceErpTradeCellFile.Create();
  12647. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12648. }
  12649. }
  12650. returnSuccessMsg("保存成功");
  12651. return;
  12652. }
  12653. returnErrorMsg("缺少必要的参数");
  12654. }
  12655. public void getCellFile()
  12656. {
  12657. string tid = GetPostString("tid");
  12658. string ctid = GetPostString("ctid");
  12659. string type = GetPostString("type");
  12660. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12661. {
  12662. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12663. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12664. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12665. return;
  12666. }
  12667. returnErrorMsg("缺少必要的参数");
  12668. }
  12669. public void delCellFile()
  12670. {
  12671. string id = GetPostString("id");
  12672. if (string.IsNullOrEmpty(id))
  12673. {
  12674. returnErrorMsg("缺少必要的参数");
  12675. return;
  12676. }
  12677. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12678. CeErpTradeCellFile.delByID(id);
  12679. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12680. returnSuccessMsg("保存成功");
  12681. }
  12682. }
  12683. }