sync.order.cs 651 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962
  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. List<string> lw = new List<string>();
  76. string tid = GetPostString("ctid");
  77. string date1 = GetPostString("date1");
  78. //12-1 修改
  79. string urgent = GetPostString("urgent");
  80. string back = GetPostString("back");
  81. string offlineSearch = GetPostString("offlineSearch");
  82. int paramsCount = 0;
  83. if (!string.IsNullOrWhiteSpace(urgent))
  84. {
  85. if (urgent.Equals("true"))
  86. {
  87. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  88. }
  89. }
  90. if (!string.IsNullOrWhiteSpace(back))
  91. {
  92. if (back.Equals("true"))
  93. {
  94. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  95. }
  96. }
  97. if (!string.IsNullOrWhiteSpace(offlineSearch))
  98. {
  99. if (offlineSearch.Equals("true"))
  100. {
  101. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  102. }
  103. }
  104. //end
  105. string date2 = GetPostString("date2");
  106. string buyernick = GetPostString("buyer_nick");
  107. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  108. {
  109. if (tid.Length <= 0 && buyernick.Length <= 0)
  110. {
  111. return;
  112. }
  113. }
  114. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  115. {
  116. if (tid.Length > 0)
  117. {
  118. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  119. if (ceErpTradeCell != null)
  120. {
  121. tid = ceErpTradeCell.tid;
  122. }
  123. List<string> select_tid = getTidByCtidMore(tid);
  124. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  125. }
  126. if (buyernick.Length > 0)
  127. {
  128. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  129. }
  130. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  131. if (dw.Length > 0)
  132. {
  133. lw.Add(dw);
  134. }
  135. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  136. {
  137. string usershop = CurrentUser.User.pemShop;
  138. lw.Add(string.Format("ShopId in ({0})", usershop));
  139. }
  140. }
  141. else
  142. {
  143. if (ex_psize == 0)
  144. {
  145. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  146. }
  147. if (PKey != "admin" && poscode != "SysAdmin")
  148. {
  149. string usershop = CurrentUser.User.pemShop;
  150. lw.Add(string.Format("ShopId in ({0})", usershop));
  151. paramsCount++;
  152. }
  153. }
  154. string uploaddate1 = GetPostString("uploaddate1");
  155. string uploaddate2 = GetPostString("uploaddate2");
  156. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  157. if (update.Length > 0) lw.Add(update);
  158. string deliverydate1 = GetPostString("deliverydate1");
  159. string deliverydate2 = GetPostString("deliverydate2");
  160. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  161. if (deliverydate.Length > 0)
  162. {
  163. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  164. };
  165. string shopname = GetPostString("shopname");
  166. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  167. string addwechat = GetPostString("addwechat");
  168. if (addwechat.Length > 0)
  169. {
  170. int addWt = Convert.ToInt32(addwechat);
  171. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  172. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  173. }
  174. string customer = GetPostString("customer");
  175. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  176. string design = GetPostString("design");
  177. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  178. string orderState = GetPostString("orderState");
  179. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  180. string address = GetPostString("address");
  181. 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));
  182. string sellermemo = GetPostString("seller_memo");
  183. if (sellermemo.Length > 0)
  184. {
  185. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  186. }
  187. string backReason = GetPostString("backReason");
  188. if (backReason.Length > 0)
  189. {
  190. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  191. }
  192. string apdate1 = GetPostString("apdate1");
  193. string apdate2 = GetPostString("apdate2");
  194. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  195. if (dwap.Length > 0) lw.Add(dwap);
  196. string price1 = GetPostString("price1");
  197. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  198. string price2 = GetPostString("price2");
  199. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  200. string isoldcustomer = GetPostString("isoldcus");
  201. string spudata = GetPostString("spudata");
  202. if ("0".Equals(spudata))
  203. {
  204. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  205. }
  206. if ("1".Equals(spudata))
  207. {
  208. lw.Add(string.Format("spu_id <> ''"));
  209. }
  210. string finishdate1 = GetPostString("finishdate1");
  211. string finishdate2 = GetPostString("finishdate2");
  212. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  213. bool isFinish = false;
  214. if (finishdate.Length > 0)
  215. {
  216. lw.Add(finishdate);
  217. isFinish = true;
  218. paramsCount++;
  219. }
  220. if (isoldcustomer.Length > 0)
  221. {
  222. if ("2".Equals(isoldcustomer))
  223. {
  224. lw.Add(string.Format("VipCustomer=1"));
  225. }
  226. else
  227. {
  228. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  229. }
  230. }
  231. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  232. if (ex_psize > 0)
  233. {
  234. int UserID = CurrentUser.UserID;
  235. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  236. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  237. {
  238. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  239. }
  240. dStruct.Order = "pay_time desc";
  241. }
  242. string isNew = GetPostString("isNew");
  243. if (isNew == "true")
  244. {
  245. lw.Add(string.Format("IsNew = {0}", 1));
  246. }
  247. string overtime = GetPostString("overtime");
  248. if (overtime == "1")
  249. {
  250. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  251. }
  252. String usePost = CurrentUser.UserPost.Post.Code;
  253. if (usePost.Equals("Operation") == true)
  254. {
  255. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  256. }
  257. else
  258. {
  259. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  260. }
  261. //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";
  262. if (dStruct.PageSize == 100000)
  263. {
  264. dStruct.Order = "";
  265. }
  266. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  267. DataTable dt = null;
  268. string tablename = "view_orderlist";
  269. if (isFinish)
  270. {
  271. tablename = "view_orderlist_end";
  272. }
  273. dt = WebCache.GetData(tablename, dStruct);
  274. if (dt != null && dt.Rows.Count > 0)
  275. {
  276. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  277. foreach (DataRow dr in dt.Rows)
  278. {
  279. try
  280. {
  281. if (dr["refund_fees"] != null)
  282. {
  283. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  284. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  285. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  286. if (payment == refund_fees)
  287. {
  288. dr["refund_fees"] = Math.Round(refund_fees, 2);
  289. }
  290. else if (refund_fees == total_fee)
  291. {
  292. dr["refund_fees"] = payment;
  293. }
  294. else
  295. {
  296. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  297. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  298. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  299. }
  300. }
  301. // 对象操作
  302. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  303. ceErpTradeCell.ctid = dr["ctid"].ToString();
  304. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  305. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  306. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  307. if (dStruct.PageSize != 100000)
  308. {
  309. if (dr["DispatchSort"].ToString() == "2")
  310. {
  311. dr["gongchuang"] = 200;
  312. }
  313. else if ("外协".Equals(dr["ToType"].ToString()))
  314. {
  315. dr["gongchuang"] = 200;
  316. }
  317. else if ("内部".Equals(dr["ToType"].ToString()))
  318. {
  319. dr["gongchuang"] = -1;
  320. }
  321. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  322. {
  323. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  324. dr["gongchuang"] = response.code;
  325. }
  326. }
  327. }
  328. catch (NullReferenceException ex)
  329. {
  330. // 处理空引用异常
  331. dr["refund_fees"] = "0.00";
  332. }
  333. }
  334. }
  335. writeGridDataTableJson(dStruct.TotalCount, dt);
  336. }
  337. public void get_erp_orderlist_sumprice()
  338. {
  339. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  340. return;
  341. List<string> lw = new List<string>();
  342. string tid = GetPostString("ctid");
  343. string date1 = GetPostString("date1");
  344. string date2 = GetPostString("date2");
  345. if (tid.Length > 0 || date1.Length > 0)
  346. {
  347. lw.Add(string.Format("ctid like '%{0}%'", tid));
  348. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  349. if (dw.Length > 0) lw.Add(dw);
  350. }
  351. else
  352. {
  353. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  354. }
  355. string shopname = GetPostString("shopname");
  356. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  357. string buyernick = GetPostString("buyer_nick");
  358. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  359. string customer = GetPostString("customer");
  360. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  361. string design = GetPostString("design");
  362. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  363. string orderState = GetPostString("orderState");
  364. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  365. string address = GetPostString("address");
  366. 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));
  367. string sellermemo = GetPostString("seller_memo");
  368. if (sellermemo.Length > 0)
  369. {
  370. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  371. }
  372. string apdate1 = GetPostString("apdate1");
  373. string apdate2 = GetPostString("apdate2");
  374. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  375. if (dwap.Length > 0) lw.Add(dwap);
  376. string price1 = GetPostString("price1");
  377. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  378. string price2 = GetPostString("price2");
  379. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  380. string isoldcustomer = GetPostString("isoldcus");
  381. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  382. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  383. if (PKey != "admin")
  384. {
  385. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  386. lw.Add(string.Format("shopId in ({0})", usershop));
  387. }
  388. //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";
  389. string mainWhere = string.Join(" and ", lw.ToArray());
  390. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  391. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  392. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  393. decimal total = 0;
  394. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  395. {
  396. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  397. }
  398. var res = new
  399. {
  400. data = total
  401. };
  402. string ro_jsond = JsonConvert.SerializeObject(res);
  403. returnSuccess(ro_jsond);
  404. return;
  405. }
  406. public void get_erp_CustomerServiceGather()
  407. {
  408. string userWhere = "", orderWhere = "";
  409. List<string> lw = new List<string>();
  410. string customer = GetPostString("customer");
  411. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  412. string shopname = GetPostString("shopname");
  413. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  414. string date1 = GetPostString("date1");
  415. string date2 = GetPostString("date2");
  416. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  417. if (dw.Length > 0) lw.Add(dw);
  418. orderWhere = string.Join(" and ", lw.ToArray());
  419. 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 " +
  420. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  421. "left join " +
  422. "( " +
  423. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  424. ") as b on a.ID = b.CustomerUserId " +
  425. "left join " +
  426. "( " +
  427. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  428. ") as d on a.ID = d.CustomerUserId " +
  429. "left join " +
  430. "( " +
  431. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  432. ") as e on a.ID = e.CustomerUserId " +
  433. "left join " +
  434. "( " +
  435. " select CustomerUserId, RefundCount, RefundSum from " +
  436. " ( " +
  437. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  438. " from CE_ErpTradeRefund a " +
  439. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  440. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  441. " group by CustomerUserId " +
  442. " ) as a " +
  443. ") as f on a.ID = f.CustomerUserId " +
  444. "where a.PostCode = 'CustomerService'",
  445. userWhere, orderWhere);
  446. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  447. writeGridDataTableJson(dt.Rows.Count, dt);
  448. //writeGridDataTableJson(dt.Rows.Count, dt);
  449. }
  450. //设计汇总
  451. public void get_erp_DesignerGather()
  452. {
  453. string userWhere = "", orderWhere = "";
  454. List<string> lw = new List<string>();
  455. string Designer = GetPostString("designer");
  456. int org = GetPostInt("org");
  457. if (Designer.Length > 0)
  458. {
  459. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  460. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  461. }
  462. else if (org > 0)
  463. {
  464. userWhere = string.Format(" where OrgID ={0}", org);
  465. }
  466. string shopname = GetPostString("shopname");
  467. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  468. string state = GetPostString("state");
  469. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  470. string OrderArea = GetPostString("order_area");
  471. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  472. string date1 = GetPostString("date1");
  473. string date2 = GetPostString("date2");
  474. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  475. if (dw.Length > 0) lw.Add(dw);
  476. string UpDate1 = GetPostString("UpDate1");
  477. string UpDate2 = GetPostString("UpDate2");
  478. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  479. if (dw.Length > 0) lw.Add(dw);
  480. orderWhere = string.Join(" and ", lw.ToArray());
  481. 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 (" +
  482. "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 " +
  483. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  484. "left join " +
  485. "( " +
  486. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  487. ") as b on a.ID = b.DesignUserId " +
  488. "left join " +
  489. "( " +
  490. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  491. ") as d on a.ID = d.DesignUserId " +
  492. "left join " +
  493. "( " +
  494. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  495. ") as e on a.ID = e.DesignUserId " +
  496. "left join " +
  497. "( " +
  498. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  499. ") as g on a.ID = g.DesignUserId " +
  500. "left join " +
  501. "( " +
  502. " select CustomerUserId, RefundCount, RefundSum from " +
  503. " ( " +
  504. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  505. " from CE_ErpTradeRefund a " +
  506. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  507. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  508. " group by CustomerUserId " +
  509. " ) as a " +
  510. ") as f on a.ID = f.CustomerUserId " +
  511. "where a.PostCode = 'Designer') as z",
  512. userWhere, orderWhere);
  513. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  514. writeGridDataTableJson(dt.Rows.Count, dt);
  515. }
  516. //删除tradecell的订单
  517. public void del_erp_cellorder()
  518. {
  519. if (UrlPostParmsCheck("ctid"))
  520. {
  521. string eid = GetPostString("ctid");
  522. CeErpTradeCell.DelByCtid(eid);
  523. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  524. returnSuccessMsg("删除成功");
  525. }
  526. }
  527. public void clear_erp_refundstate()
  528. {
  529. if (UrlPostParmsCheck("ids"))
  530. {
  531. string eids = GetPostString("ids");
  532. string[] ctidList = eids.Split(',');
  533. foreach (string ctid in ctidList)
  534. {
  535. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  536. if (entity != null)
  537. {
  538. entity.IsRefund = 0;
  539. entity.Update();
  540. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  541. }
  542. else
  543. continue;
  544. }
  545. returnSuccessMsg("操作成功");
  546. return;
  547. }
  548. returnErrorMsg("缺少必要参数");
  549. }
  550. public void set_erp_urgency()
  551. {
  552. if (UrlPostParmsCheck("ctid"))
  553. {
  554. string eid = GetPostString("ctid");
  555. CeErpTradeCell entity = null;
  556. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  557. if (entity != null)
  558. {
  559. double prices = commonHelper.calculationPrice(entity);
  560. if (prices <= 100)
  561. {
  562. returnErrorMsg("此订单金额不足100元,无法加急。");
  563. return;
  564. }
  565. string utime = GetPostString("urgencytime");
  566. if (utime.Length > 0)
  567. {
  568. entity.UrgencyTime = Convert.ToDateTime(utime);
  569. }
  570. else
  571. {
  572. returnErrorMsg("请选择加急时间");
  573. return;
  574. }
  575. if (entity.OrderState <= 4)
  576. {
  577. //entity.seller_memo = entity.seller_memo + "-加急";
  578. string smemo = entity.seller_memo;
  579. int kindex = smemo.IndexOf(")");
  580. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  581. if (lastoneStr != "-")
  582. {
  583. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  584. }
  585. string prememo = smemo.Substring(0, kindex + 2);
  586. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  587. int lastkindex = lastmemo.IndexOf("(");
  588. DateTime urgtime = Convert.ToDateTime(utime);
  589. string newlastmemo = "";
  590. if (lastkindex == 0)
  591. {
  592. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  593. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  594. }
  595. else
  596. {
  597. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  598. }
  599. entity.seller_memo = prememo + newlastmemo;
  600. }
  601. entity.IsUrgency = true;
  602. entity.UpdateTime = DateTime.Now;
  603. entity.Update();
  604. ApiVo apiVo = new ApiVo();
  605. apiVo.orderNumber = entity.ctid;
  606. apiVo.actionName = "changeDesign";
  607. apiVo.orderRemarks = entity.seller_memo;
  608. apiVo.remarkSign = 3;
  609. designHelper.API_WorkCore(apiVo); //changeDesign
  610. CeErpSukuraData.createInfo(entity.ctid, 7);
  611. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  612. returnSuccessMsg("设置成功!");
  613. return;
  614. }
  615. returnErrorMsg("找不到记录");
  616. }
  617. }
  618. public void set_erp_reset()
  619. {
  620. if (UrlPostParmsCheck("ctid"))
  621. {
  622. string eid = GetPostString("ctid");
  623. CeErpTradeCell entity = null;
  624. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  625. if (entity != null)
  626. {
  627. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  628. {
  629. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  630. {
  631. returnErrorMsg("财务要求已下单已发货无法重置");
  632. return;
  633. }
  634. }
  635. entity.IsUrgency = false;
  636. entity.seller_memo = "";
  637. entity.OtherMemo = "";
  638. entity.OrderState = 0;
  639. entity.IsReturn = 0;
  640. //entity.IsRefund = 0;
  641. entity.MemoOpt = 0;
  642. entity.AfterSaleState = 0;
  643. entity.AfterSaleResponsible = "";
  644. entity.AfterSaleUserId = 0;
  645. entity.IsNeedBill = 0;
  646. entity.CustomerUserId = 0;
  647. entity.DesignUserId = 0;
  648. entity.SupplierId = 0;
  649. entity.PlaceUserId = 0;
  650. entity.ptid = "";
  651. entity.IsSample = 0;
  652. entity.IsXianHuo = 0;
  653. entity.isDianziOrder = 0;
  654. entity.DispatchSort = 0;
  655. entity.IsVerifyToSupplier = false;
  656. entity.FinishPlaceTime = null;
  657. entity.Update();
  658. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  659. if (trade != null)
  660. {
  661. trade.seller_memo = "";
  662. trade.Update();
  663. }
  664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  665. returnSuccessMsg("重置成功!");
  666. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  667. if (desginBill != null)
  668. {
  669. desginBill.isDel = 1;
  670. desginBill.Update();
  671. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  672. }
  673. ApiVo apiVo = new ApiVo();
  674. apiVo.orderNumber = entity.ctid;
  675. apiVo.actionName = "resetDesign";
  676. designHelper.API_WorkCore(apiVo);//resetDesign
  677. return;
  678. }
  679. returnErrorMsg("找不到记录");
  680. }
  681. }
  682. public void save_erp_sellermemo()
  683. {
  684. if (UrlPostParmsCheck("ctid"))
  685. {
  686. string ctid = GetPostString("ctid");
  687. CeErpTradeCell entity = null;
  688. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  689. if (entity != null)
  690. {
  691. string memo = GetPostString("seller_memo");
  692. memo = memo.Replace(" ", "");
  693. if (memo.Contains("补差"))
  694. {
  695. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  696. return;
  697. }
  698. List<string> bitList = new List<string>
  699. {
  700. "\\","/",":","*","?", "\"","<" ,">","|"
  701. };
  702. bool isIn = false;
  703. foreach (string bit in bitList)
  704. {
  705. if (memo.Contains(bit))
  706. {
  707. isIn = true;
  708. }
  709. }
  710. if (isIn)
  711. {
  712. returnErrorMsg("不能使用 一些符合作为文件名");
  713. return;
  714. }
  715. if (entity.seller_memo != memo)
  716. {
  717. if (entity.IsSample == 2)
  718. {
  719. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  720. return;
  721. }
  722. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  723. {
  724. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  725. {
  726. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  727. return;
  728. }
  729. /*if (CurrentUser.UserPost.Post.Code != "Place")
  730. {
  731. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  732. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  733. {
  734. returnErrorMsg("售前系统订单无法再此修改!");
  735. return;
  736. }
  737. }*/
  738. }
  739. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  740. }
  741. commonHelper.getCytPrice(entity);
  742. int memoopt = GetPostInt("MemoOpt");
  743. Boolean ismemoopt = false;
  744. if (memoopt > 0)
  745. {
  746. string stropt = "";
  747. if (memoopt == 1)
  748. {
  749. stropt = "“改稿”";
  750. ismemoopt = true;
  751. }
  752. else if (memoopt == 2)
  753. {
  754. stropt = "“定稿”";
  755. }
  756. else if (memoopt == 3)
  757. {
  758. stropt = "“查货”";
  759. CeErpSukuraData.createInfo(entity.ctid, 6);
  760. }
  761. entity.MemoOpt = Convert.ToInt32(memoopt);
  762. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  763. }
  764. if (entity.OrderState < 5)
  765. {
  766. memo = memo.Replace("(", "(");
  767. memo = memo.Replace(")", ")");
  768. }
  769. if (entity.OrderState < 3)
  770. {
  771. entity.DispatchSort = 0;
  772. }
  773. entity.seller_memo = memo;
  774. entity.UpdateTime = DateTime.Now;
  775. entity.Update();
  776. ApiVo apiVo = new ApiVo();
  777. apiVo.orderNumber = entity.ctid;
  778. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  779. apiVo.orderRemarks = memo;
  780. apiVo.remarkSign = memoopt;
  781. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  782. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  783. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  784. {
  785. dataHelper.api_orderBack(entity.ctid, "0", "");
  786. }
  787. if (entity.seller_memo.Contains("改稿"))
  788. {
  789. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  790. }
  791. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  792. returnSuccessMsg("保存成功!");
  793. return;
  794. }
  795. returnErrorMsg("找不到记录");
  796. }
  797. }
  798. public void ins_erp_checkorder()
  799. {
  800. if (UrlPostParmsCheck("ctid"))
  801. {
  802. string ctid = GetPostString("ctid");
  803. CeErpTradeCell entity = null;
  804. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  805. if (entity != null)
  806. {
  807. if (entity.OrderState < 6)
  808. {
  809. returnErrorMsg("下单完成后才可查货");
  810. return;
  811. }
  812. /*if (entity.OrderState > 6)
  813. {
  814. returnErrorMsg("订单已发货");
  815. return;
  816. }*/
  817. if (entity.FinishPlaceTime != null)
  818. {
  819. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  820. {
  821. returnErrorMsg("下单时间不足,无法查货");
  822. return;
  823. }
  824. }
  825. entity.MemoOpt = 3;
  826. entity.CheckOrderTime = DateTime.Now;
  827. entity.UpdateTime = DateTime.Now;
  828. entity.Update();
  829. CeErpSukuraData.createInfo(entity.ctid, 6);
  830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  831. returnSuccessMsg("操作成功!");
  832. return;
  833. }
  834. returnErrorMsg("找不到记录");
  835. }
  836. }
  837. public void save_erp_othermemo()
  838. {
  839. if (UrlPostParmsCheck("ctid"))
  840. {
  841. string ctid = GetPostString("ctid");
  842. CeErpTradeCell entity = null;
  843. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  844. if (entity != null)
  845. {
  846. entity.OtherMemo = GetPostString("otherMemo");
  847. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  848. {
  849. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  850. StringBuilder sql = new StringBuilder();
  851. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  852. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  853. if (dt != null && dt.Rows.Count > 0)
  854. {
  855. foreach (DataRow dr in dt.Rows)
  856. {
  857. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  858. {
  859. //品类一直
  860. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  861. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  862. if (ceErpSampleCustomer == null)
  863. {
  864. ceErpSampleCustomer = new CeErpSampleCustomer();
  865. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  866. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  867. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  868. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  869. ceErpSampleCustomer.shopId = entity.ShopId;
  870. }
  871. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  872. ceErpSampleCustomer.lastTid = entity.tid;
  873. if (ceErpSampleCustomer.ID > 0)
  874. {
  875. ceErpSampleCustomer.Update();
  876. }
  877. else
  878. {
  879. ceErpSampleCustomer.Create();
  880. }
  881. }
  882. }
  883. }
  884. }
  885. //if (entity.IsOldCustomer == 1)
  886. //{
  887. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  888. //{
  889. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  890. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  891. //}
  892. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  893. //{
  894. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  895. // {
  896. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  897. // {
  898. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  899. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  900. // }
  901. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  902. // {
  903. // entity.OrderState = 2;
  904. // entity.DesignUserId = 0;
  905. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  906. // }
  907. // else
  908. // {
  909. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  910. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  911. // }
  912. // }
  913. //}
  914. //}
  915. entity.UpdateTime = DateTime.Now;
  916. entity.Update();
  917. returnSuccessMsg("保存成功!");
  918. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  919. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  920. if (entity.OtherMemo.Contains("改稿"))
  921. {
  922. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  923. }
  924. return;
  925. }
  926. returnErrorMsg("找不到记录");
  927. }
  928. }
  929. public void save_erp_customermemo()
  930. {
  931. if (UrlPostParmsCheck("ctid"))
  932. {
  933. string ctid = GetPostString("ctid");
  934. CeErpTradeCell entity = null;
  935. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  936. if (entity != null)
  937. {
  938. entity.UpdateTime = DateTime.Now;
  939. entity.CustomerMemo = GetPostString("CustomerMemo");
  940. entity.Update();
  941. ApiVo apiVo = new ApiVo();
  942. apiVo.orderNumber = entity.ctid;
  943. apiVo.actionName = "followRemarks";
  944. apiVo.orderRemarks = entity.CustomerMemo;
  945. designHelper.API_WorkCore(apiVo);//followRemarks
  946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  947. returnSuccessMsg("保存成功!");
  948. return;
  949. }
  950. returnErrorMsg("找不到记录");
  951. }
  952. }
  953. public void upd_erp_addmemotag()
  954. {
  955. if (UrlPostParmsCheck("ctid"))
  956. {
  957. ;
  958. string eid = GetPostString("ctid");
  959. string sfTagstr = GetPostString("memotag");
  960. CeErpTradeCell entity = null;
  961. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  962. if (entity != null)
  963. {
  964. ApiVo apiVo = new ApiVo();
  965. if (entity.OrderState == 0)
  966. {
  967. returnErrorMsg("请先领单");
  968. return;
  969. }
  970. //撤销顺丰
  971. if (sfTagstr == "撤销顺丰")
  972. {
  973. entity.IsSF = 0;
  974. string reMsg = "";
  975. string oldmemo = entity.seller_memo;
  976. if (entity.OrderState < 5)
  977. {
  978. oldmemo = oldmemo.Replace("顺丰到付", "");
  979. oldmemo = oldmemo.Replace("顺丰寄付", "");
  980. entity.seller_memo = oldmemo;
  981. }
  982. else
  983. {
  984. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  985. {
  986. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  987. }
  988. }
  989. entity.Update();
  990. apiVo.orderNumber = entity.ctid;
  991. apiVo.actionName = "orderRemarks";
  992. apiVo.orderRemarks = entity.seller_memo;
  993. apiVo.isSf = entity.IsSF.ToString();
  994. designHelper.API_WorkCore(apiVo);//orderRemarks
  995. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  996. returnSuccessMsg("撤销成功!" + reMsg);
  997. return;
  998. }
  999. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1000. {
  1001. //string oldmemo = entity.seller_memo;
  1002. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1003. string sfStr = GetPostString("memotag");
  1004. string smemo = entity.seller_memo;
  1005. int kindex = smemo.IndexOf(")");
  1006. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1007. if (lastoneStr != "-")
  1008. {
  1009. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1010. }
  1011. string prememo = smemo.Substring(0, kindex + 2);
  1012. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1013. int lastkindex = lastmemo.IndexOf("(");
  1014. string newlastmemo = "";
  1015. if (lastkindex == 0)
  1016. {
  1017. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1018. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1019. }
  1020. else
  1021. {
  1022. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1023. }
  1024. entity.seller_memo = prememo + newlastmemo;
  1025. }
  1026. string sfTagMSg = "";
  1027. if (sfTagstr == "顺丰寄付")
  1028. {
  1029. entity.IsSF = 1;
  1030. sfTagMSg = "顺丰寄付";
  1031. }
  1032. else if (sfTagstr == "顺丰到付")
  1033. {
  1034. entity.IsSF = 2;
  1035. sfTagMSg = "顺丰到付";
  1036. }
  1037. entity.Update();
  1038. apiVo = new ApiVo();
  1039. apiVo.orderNumber = entity.ctid;
  1040. apiVo.actionName = "orderRemarks";
  1041. apiVo.orderRemarks = entity.seller_memo;
  1042. apiVo.isSf = entity.IsSF.ToString();
  1043. designHelper.API_WorkCore(apiVo);//orderRemarks
  1044. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1045. returnSuccessMsg("标记成功!");
  1046. return;
  1047. }
  1048. returnErrorMsg("找不到记录");
  1049. }
  1050. }
  1051. public void upd_erp_ordertag()
  1052. {
  1053. if (UrlPostParmsCheck("ctid"))
  1054. {
  1055. string eid = GetPostString("ctid");
  1056. CeErpTradeCell entity = null;
  1057. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1058. if (entity != null)
  1059. {
  1060. int tag = GetPostInt("wechattag");
  1061. //if(tag==4 && entity.IsSample == 2)
  1062. //{
  1063. // returnErrorMsg("补差价单不能标记微信单");
  1064. // return;
  1065. //}
  1066. entity.wechatTag = tag;
  1067. entity.Update();
  1068. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1069. if (tag == 1)
  1070. {
  1071. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1072. if (cash == null)
  1073. {
  1074. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1075. cash = new CeErpReturnCash();
  1076. cash.tid = entity.tid;
  1077. cash.seller_nick = main.seller_nick;
  1078. cash.payment = trade.payment;
  1079. cash.buyer_nick = main.buyer_nick;
  1080. cash.cashstate = 0;
  1081. cash.rtype = "微信返现";
  1082. cash.returnprice = 0;
  1083. cash.created = DateTime.Now;
  1084. cash.con = "订单标记微信单";
  1085. cash.img = "";
  1086. cash.applyuserid = CurrentUser.UserID;
  1087. cash.Create();
  1088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1089. }
  1090. else
  1091. {
  1092. cash.cashstate = 0;
  1093. cash.Update();
  1094. }
  1095. CeErpSukuraData.createInfo(entity.ctid, 9);
  1096. }
  1097. else if (tag == 2)
  1098. {
  1099. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1100. if (cash == null)
  1101. {
  1102. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1103. cash = new CeErpReturnCash();
  1104. cash.tid = entity.tid;
  1105. cash.seller_nick = main.seller_nick;
  1106. cash.payment = trade.payment;
  1107. cash.buyer_nick = main.buyer_nick;
  1108. cash.cashstate = 0;
  1109. cash.rtype = "推购返现";
  1110. cash.returnprice = 5;
  1111. cash.created = DateTime.Now;
  1112. cash.con = "订单标记推购单";
  1113. cash.img = "";
  1114. cash.applyuserid = CurrentUser.UserID;
  1115. cash.Create();
  1116. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1117. }
  1118. else
  1119. {
  1120. cash.cashstate = 0;
  1121. cash.Update();
  1122. }
  1123. CeErpSukuraData.createInfo(entity.ctid, 9);
  1124. }
  1125. else if (tag == 3)
  1126. {
  1127. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1128. if (pers == null)
  1129. {
  1130. pers = new CeErpPersuade();
  1131. pers.ctid = entity.ctid;
  1132. pers.pstate = 0;
  1133. pers.created = DateTime.Now;
  1134. pers.applyuserid = CurrentUser.UserID;
  1135. pers.Create();
  1136. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1137. }
  1138. else
  1139. {
  1140. pers.pstate = 0;
  1141. pers.Update();
  1142. }
  1143. }
  1144. else if (tag == 4 || tag == 5)
  1145. {
  1146. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1147. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1148. if (pers == null)
  1149. {
  1150. pers = CeErpStayGoods.GetByTid(entity.tid);
  1151. }
  1152. if (pers == null)
  1153. {
  1154. pers = new CeErpStayGoods();
  1155. pers.t_id = entity.tid;
  1156. pers.ctid = entity.ctid;
  1157. pers.status = "待审核";
  1158. pers.audit_type = 0;
  1159. if (tag == 4)
  1160. {
  1161. pers.stay_type = "微信推购";
  1162. }
  1163. else
  1164. {
  1165. pers.stay_type = "旺旺推购";
  1166. }
  1167. if (entity.IsXianHuo == 0)
  1168. {
  1169. pers.product_id = entity.ProductId;
  1170. }
  1171. pers.wangwang = main.buyer_nick;
  1172. pers.shop_name = main.seller_nick;
  1173. pers.creata_time = DateTime.Now;
  1174. pers.create_u_id = CurrentUser.UserID;
  1175. pers.create_u_name = CurrentUser.UserName;
  1176. pers.Create();
  1177. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1178. }
  1179. else
  1180. {
  1181. pers.ctid = entity.ctid;
  1182. pers.audit_type = 0;
  1183. pers.Update();
  1184. }
  1185. CeErpSukuraData.createInfo(entity.ctid, 10);
  1186. }
  1187. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1188. returnSuccessMsg("标记成功!");
  1189. return;
  1190. }
  1191. returnErrorMsg("找不到记录");
  1192. }
  1193. }
  1194. public void upd_erp_ordertag_cancel()
  1195. {
  1196. if (UrlPostParmsCheck("ctid"))
  1197. {
  1198. string eid = GetPostString("ctid");
  1199. CeErpTradeCell entity = null;
  1200. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1201. if (entity != null)
  1202. {
  1203. entity.wechatTag = 0;
  1204. entity.Update();
  1205. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1206. if (pers != null)
  1207. {
  1208. pers.status = "取消推购";
  1209. pers.audit_type = 3;
  1210. pers.Update();
  1211. }
  1212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1213. returnSuccessMsg("标记成功!");
  1214. return;
  1215. }
  1216. returnErrorMsg("找不到记录");
  1217. }
  1218. }
  1219. public void upd_erp_addweichattag()
  1220. {
  1221. if (UrlPostParmsCheck("ctid"))
  1222. {
  1223. ;
  1224. string eid = GetPostString("ctid");
  1225. CeErpTradeCell entity = null;
  1226. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1227. if (entity != null)
  1228. {
  1229. if (entity.IsAddWechat > 0)
  1230. {
  1231. returnErrorMsg("此单已经标记过了");
  1232. return;
  1233. }
  1234. 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);
  1235. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1236. if (dt.Rows.Count > 0)
  1237. {
  1238. entity.IsAddWechat = 2;
  1239. }
  1240. else
  1241. {
  1242. entity.IsAddWechat = 1;
  1243. }
  1244. entity.Update();
  1245. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1246. returnSuccessMsg("标记成功!");
  1247. return;
  1248. }
  1249. returnErrorMsg("找不到记录");
  1250. }
  1251. }
  1252. public void upd_erp_getmyorder()
  1253. {
  1254. if (UrlPostParmsCheck("ctid"))
  1255. {
  1256. string eid = GetPostString("ctid");
  1257. CeErpTradeCell entity = null;
  1258. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1259. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1260. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1261. {
  1262. returnErrorMsg("台湾客户需填写身份证号!");
  1263. return;
  1264. }
  1265. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1266. {
  1267. returnErrorMsg("偏远地区需要填写物流费!");
  1268. return;
  1269. }
  1270. if (entity != null)
  1271. {
  1272. if (entity.ctid.IndexOf("C") != -1)
  1273. {
  1274. StringBuilder sql = new StringBuilder();
  1275. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1276. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1277. if (dt.Rows.Count > 0)
  1278. {
  1279. decimal total = 0;
  1280. foreach (DataRow dr in dt.Rows)
  1281. {
  1282. total += Convert.ToDecimal(dr["payment"]);
  1283. }
  1284. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1285. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1286. {
  1287. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1288. return;
  1289. }
  1290. }
  1291. }
  1292. if (entity.OrderState == -1)
  1293. {
  1294. returnErrorMsg("待审核订单无法领取!");
  1295. return;
  1296. }
  1297. entity.CustomerUserId = CurrentUser.UserID;
  1298. if (entity.OrderState < 2)
  1299. {
  1300. entity.OrderState = 2;
  1301. if (entity.ShopId != 0)
  1302. {
  1303. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1304. }
  1305. }
  1306. entity.UpdateTime = DateTime.Now;
  1307. entity.Update();
  1308. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1309. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1310. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1311. {
  1312. dataHelper.api_orderBack(entity.ctid, "0", "");
  1313. }
  1314. returnSuccessMsg("领单成功!");
  1315. return;
  1316. }
  1317. returnErrorMsg("找不到记录");
  1318. }
  1319. }
  1320. public void getmyorder_from_init()
  1321. {
  1322. if (UrlPostParmsCheck("ctid"))
  1323. {
  1324. string eid = GetPostString("ctid");
  1325. CeErpTradeCell entity = null;
  1326. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1327. if (entity != null)
  1328. {
  1329. string sellerMemo = GetPostString("sellerMemo");
  1330. if (sellerMemo.Length > 0)
  1331. {
  1332. entity.seller_memo = sellerMemo;
  1333. }
  1334. string oterhMemo = GetPostString("otherMemo");
  1335. if (oterhMemo.Length > 0)
  1336. {
  1337. entity.OtherMemo = oterhMemo;
  1338. }
  1339. int urg = GetPostInt("urgency");
  1340. entity.IsUrgency = (urg == 1 ? true : false);
  1341. int wechat = GetPostInt("wechat");
  1342. int command = GetPostInt("command");
  1343. if (wechat == 1)
  1344. {
  1345. entity.wechatTag = 1;
  1346. }
  1347. if (command == 1)
  1348. {
  1349. entity.wechatTag = 2;
  1350. }
  1351. string pPro = GetPostString("pprofession");
  1352. if (pPro.Length > 0)
  1353. {
  1354. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1355. string spro = GetPostString("profession");
  1356. if (spro.Length > 0)
  1357. {
  1358. entity.ProfessionId = Convert.ToInt32(spro);
  1359. }
  1360. }
  1361. string proId = GetPostString("productId");
  1362. if (proId.Length > 0)
  1363. {
  1364. entity.ProductId = Convert.ToInt32(proId);
  1365. }
  1366. entity.Material = GetPostString("material");
  1367. entity.Craft = GetPostString("craft");
  1368. entity.CustomerUserId = CurrentUser.UserID;
  1369. if (entity.OrderState < 2)
  1370. {
  1371. entity.OrderState = 2;
  1372. if (entity.ShopId != 0)
  1373. {
  1374. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1375. }
  1376. }
  1377. entity.Update();
  1378. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1379. returnSuccessMsg("领单成功!");
  1380. return;
  1381. }
  1382. returnErrorMsg("找不到记录");
  1383. }
  1384. }
  1385. public void upd_erp_setrelationorder()
  1386. {
  1387. if (UrlPostParmsCheck("ctid"))
  1388. {
  1389. ;
  1390. string eid = GetPostString("ctid");
  1391. string ftid = GetPostString("ftid");
  1392. CeErpTradeCell entity = null;
  1393. CeErpTradeCell fentity = null;
  1394. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1395. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1396. if (fentity == null)
  1397. {
  1398. returnErrorMsg("找不到关联的主订单");
  1399. return;
  1400. }
  1401. if (entity != null)
  1402. {
  1403. if (entity.OrderState >= 5)
  1404. {
  1405. returnErrorMsg("本单已经设计完成无法关联");
  1406. return;
  1407. }
  1408. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1409. {
  1410. returnErrorMsg("线下单续审核后才能关联!");
  1411. return;
  1412. }
  1413. entity.ptid = ftid;
  1414. entity.OrderState = fentity.OrderState;
  1415. //entity.status = fentity.status;
  1416. entity.CustomerUserId = fentity.CustomerUserId;
  1417. entity.DesignUserId = fentity.DesignUserId;
  1418. entity.seller_memo = "补差价单:" + ftid;
  1419. entity.IsSample = 2;
  1420. entity.Update();
  1421. ApiVo apiVo = new ApiVo();
  1422. apiVo.orderNumber = ftid;
  1423. apiVo.payment = entity.payment;
  1424. apiVo.actionName = "repairDesign";
  1425. designHelper.API_WorkCore(apiVo);//repairDesign
  1426. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1427. returnSuccessMsg("关联成功!");
  1428. return;
  1429. }
  1430. else
  1431. returnErrorMsg("找不到记录");
  1432. }
  1433. }
  1434. public void download_erp_neworder()
  1435. {
  1436. string seller = GetPostString("seller_nick");
  1437. string tid = GetPostString("tid");
  1438. if (seller.Length <= 0 || tid.Length <= 0)
  1439. {
  1440. returnErrorMsg("数据错误");
  1441. }
  1442. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1443. //{
  1444. // returnErrorMsg("找不到店铺Sessionkey");
  1445. //}
  1446. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1447. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1448. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1449. if (res.IndexOf("refOid") == -1)
  1450. {
  1451. returnErrorMsg("下载订单数据失败");
  1452. return;
  1453. }
  1454. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1455. returnSuccessMsg("下载完成");
  1456. //tmcHelper.createNewOrder(res);
  1457. //CeErpTrade entr = null;
  1458. //entr = CeErpTrade.Get(tid);
  1459. //if (entr != null)
  1460. //{
  1461. // returnSuccess("下载成功");
  1462. // //下载成功之后,Cell表生成对应的订单;
  1463. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1464. //}
  1465. //else
  1466. //{
  1467. // returnErrorMsg("下载失败或者创建订单失败");
  1468. //}
  1469. }
  1470. public void set_erp_atersale()
  1471. {
  1472. if (UrlPostParmsCheck("ctid"))
  1473. {
  1474. string eid = GetPostString("ctid");
  1475. string reason = GetPostString("AfterSaleReason");
  1476. CeErpTradeCell entity = null;
  1477. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1478. if (entity != null)
  1479. {
  1480. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1481. {
  1482. returnErrorMsg("此订单已经在售后");
  1483. return;
  1484. }
  1485. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1486. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1487. entity.AfterSaleTime = DateTime.Now;
  1488. entity.Update();
  1489. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1490. returnSuccessMsg("转售后成功!");
  1491. return;
  1492. }
  1493. returnErrorMsg("找不到记录");
  1494. }
  1495. }
  1496. public void set_erp_withdraw()
  1497. {
  1498. if (UrlPostParmsCheck("ctid"))
  1499. {
  1500. try
  1501. {
  1502. string eid = GetPostString("ctid");//商品id
  1503. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1504. CeWithdraw ceWithdrawSelect = null;
  1505. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1506. if (ceWithdrawSelect != null)
  1507. {
  1508. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1509. {
  1510. ceWithdrawSelect.status = -1;
  1511. ceWithdrawSelect.Update();
  1512. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1513. returnSuccessMsg("重新发起审核成功");
  1514. return;
  1515. }
  1516. else
  1517. {
  1518. returnSuccessMsg("请勿重复申请!");
  1519. return;
  1520. }
  1521. }
  1522. else
  1523. {
  1524. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1525. if (string.IsNullOrEmpty(CustomerUserId))
  1526. {
  1527. CustomerUserId = "-1";
  1528. }
  1529. int Userid = CurrentUser.UserID;//用户id
  1530. CeWithdraw ceWithdraw = new CeWithdraw();
  1531. ceWithdraw.tid = eid;
  1532. ceWithdraw.userid = Userid;
  1533. ceWithdraw.providerid = CustomerUserId;
  1534. ceWithdraw.status = 3;
  1535. ceWithdraw.creationtime = DateTime.Now;
  1536. ceWithdraw.Create();
  1537. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1538. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1539. return;
  1540. }
  1541. }
  1542. catch
  1543. {
  1544. returnErrorMsg("申请撤回订单失败");
  1545. return;
  1546. }
  1547. }
  1548. }
  1549. public void ins_erp_billinfo()
  1550. {
  1551. if (UrlPostParmsCheck("ctid"))
  1552. {
  1553. string eid = GetPostString("ctid");
  1554. CeErpTradeCell entity = null;
  1555. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1556. if (entity != null)
  1557. {
  1558. CeErpBill bill = CeErpBill.GetByTid(eid);
  1559. bool isHave = false;
  1560. if (bill != null)
  1561. {
  1562. isHave = true;
  1563. if (bill.state != 4)
  1564. {
  1565. returnErrorMsg("此单已经申请过发票了");
  1566. return;
  1567. }
  1568. }
  1569. if (entity.IsNeedBill == 0)
  1570. {
  1571. entity.IsNeedBill = 1;
  1572. }
  1573. entity.Update();
  1574. string errjson = "";
  1575. try
  1576. {
  1577. CeErpBill bill_entity = new CeErpBill();
  1578. bill_entity.tid = entity.tid;
  1579. bill_entity.title = GetPostString("title");
  1580. string taxstr = GetPostString("tax");
  1581. taxstr = taxstr.Replace(" ", "");
  1582. bill_entity.tax = taxstr;
  1583. bill_entity.bank = GetPostString("bank");
  1584. string bankacstr = GetPostString("bankac");
  1585. bankacstr = bankacstr.Replace(" ", "");
  1586. bill_entity.bankac = bankacstr;
  1587. bill_entity.address = GetPostString("address");
  1588. bill_entity.phone = GetPostString("phone");
  1589. bill_entity.price = GetPostString("price");
  1590. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1591. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1592. {
  1593. billCount += 1;
  1594. }
  1595. string prebill = "ltb";
  1596. for (int idx = 1; idx <= billCount; idx++)
  1597. {
  1598. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1599. string billoid = prebill + idx + dtstr;
  1600. bill_entity.billOrderId += billoid;
  1601. if (idx < billCount)
  1602. {
  1603. bill_entity.billOrderId += ",";
  1604. }
  1605. }
  1606. bill_entity.productId = GetPostInt("ProductName");
  1607. bill_entity.num = GetPostInt("num");
  1608. bill_entity.unit = GetPostString("unit");
  1609. bill_entity.type = GetPostString("type");
  1610. bill_entity.sendType = GetPostString("SendType");
  1611. bill_entity.email = GetPostString("email");
  1612. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1613. bill_entity.shopName = GetPostString("ShopName");
  1614. bill_entity.applymemo = GetPostString("applyMemo");
  1615. bill_entity.createTime = DateTime.Now;
  1616. bill_entity.state = 0;
  1617. bill_entity.userId = CurrentUser.UserID;
  1618. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1619. bill_entity.Create();
  1620. }
  1621. catch (Exception ex)
  1622. {
  1623. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1624. returnErrorMsg("创建发票出错!");
  1625. return;
  1626. }
  1627. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1628. returnSuccessMsg("发票申请成功!");
  1629. return;
  1630. }
  1631. returnErrorMsg("找不到记录");
  1632. }
  1633. }
  1634. public void ins_erp_neworder()
  1635. {
  1636. if (UrlPostParmsCheck("receiver_name"))
  1637. {
  1638. CeErpTrade entity = new CeErpTrade();
  1639. string plat_form = GetPostString("platform");
  1640. string preStr = "N_";
  1641. if (plat_form == "拼多多")
  1642. {
  1643. preStr = "P_";
  1644. }
  1645. else if (plat_form == "阿里巴巴")
  1646. {
  1647. preStr = "A_";
  1648. }
  1649. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1650. entity.seller_nick = GetPostString("seller_nick");
  1651. entity.buyer_nick = GetPostString("buyer_nick");
  1652. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1653. entity.total_fee = entity.payment;
  1654. entity.pay_time = DateTime.Now;
  1655. entity.status = "NOT_SHIPPED";
  1656. entity.receiver_name = GetPostString("receiver_name");
  1657. entity.receiver_mobile = GetPostString("receiver_mobile");
  1658. entity.receiver_state = GetPostString("receiver_state");
  1659. entity.receiver_city = GetPostString("receiver_city");
  1660. entity.receiver_district = GetPostString("receiver_district");
  1661. entity.receiver_address = GetPostString("receiver_address");
  1662. if (entity.receiver_state == "" || entity.receiver_city == "")
  1663. {
  1664. returnErrorMsg("收件地址不能为空");
  1665. return;
  1666. }
  1667. int shopId = 0;
  1668. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1669. if (nShop != null)
  1670. {
  1671. shopId = nShop.ID;
  1672. }
  1673. if (shopId != 34 && entity.payment == 0)
  1674. {
  1675. returnErrorMsg("公司自用的单金额才能为0");
  1676. return;
  1677. }
  1678. entity.Create();
  1679. CeErpTradeCell entitycell = new CeErpTradeCell();
  1680. entitycell.ctid = entity.tid;
  1681. entitycell.tid = entity.tid;
  1682. entitycell.ShopId = shopId;
  1683. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1684. entitycell.OrderState = 0;
  1685. entitycell.pay_time = entity.pay_time;
  1686. entitycell.IsOffLineOrder = 1;
  1687. entitycell.Create();
  1688. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1689. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1690. return;
  1691. }
  1692. }
  1693. public void ins_erp_neworder2()
  1694. {
  1695. if (UrlPostParmsCheck("receiver_name"))
  1696. {
  1697. //string plat_form = GetPostString("platform");
  1698. string preStr = "X_";
  1699. string memo = GetPostString("memo");
  1700. string productId = GetPostString("productId");
  1701. string primg = GetPostString("proofimg");
  1702. string sellerNick = GetPostString("seller_nick");
  1703. string addFrom = GetPostString("addfrom");
  1704. if (addFrom == "1")
  1705. {
  1706. preStr = "N_";
  1707. }
  1708. int shopId = 0;
  1709. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1710. if (nShop != null)
  1711. {
  1712. shopId = nShop.ID;
  1713. }
  1714. else
  1715. {
  1716. returnErrorMsg("找不到对应店铺");
  1717. return;
  1718. }
  1719. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1720. {
  1721. returnErrorMsg("必须上传付款凭证");
  1722. return;
  1723. }
  1724. CeErpTrade entity = new CeErpTrade();
  1725. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1726. entity.seller_nick = sellerNick;
  1727. entity.buyer_nick = GetPostString("buyer_nick");
  1728. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1729. entity.total_fee = entity.payment;
  1730. entity.pay_time = DateTime.Now;
  1731. entity.status = "NOT_SHIPPED";
  1732. entity.receiver_name = GetPostString("receiver_name");
  1733. entity.receiver_mobile = GetPostString("receiver_mobile");
  1734. entity.receiver_state = GetPostString("receiver_state");
  1735. entity.receiver_city = GetPostString("receiver_city");
  1736. entity.receiver_district = GetPostString("receiver_district");
  1737. entity.receiver_address = GetPostString("receiver_address");
  1738. entity.seller_memo = memo;
  1739. entity.orderFrom = 20;
  1740. entity.orderType = 15;
  1741. if (entity.receiver_state == "" || entity.receiver_city == "")
  1742. {
  1743. returnErrorMsg("收件地址不能为空");
  1744. return;
  1745. }
  1746. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1747. {
  1748. returnErrorMsg("公司自用的单金额才能为0");
  1749. return;
  1750. }
  1751. entity.Create();
  1752. string toWhere = GetPostString("towhere");
  1753. CeErpTradeCell entitycell = new CeErpTradeCell();
  1754. entitycell.ctid = entity.tid;
  1755. //唯一标识
  1756. entitycell.OrderSn = entity.tid;
  1757. string orderSn = dataHelper.getSaleOrderSn();
  1758. if (orderSn != "")
  1759. {
  1760. entitycell.OrderSn = orderSn;
  1761. }
  1762. entitycell.tid = entity.tid;
  1763. //if (preStr == "X_")
  1764. //{
  1765. entitycell.IsOffLineOrder = 1;
  1766. //}
  1767. entitycell.CustomerUserId = CurrentUser.UserID;
  1768. entitycell.PayProofImg = primg;
  1769. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1770. entitycell.ProductId = Convert.ToInt32(productId);
  1771. entitycell.ShopId = shopId;
  1772. entitycell.UpdateTime = DateTime.Now;
  1773. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1774. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1775. {
  1776. entitycell.IsXianHuo = 1;
  1777. }
  1778. entitycell.pay_time = entity.pay_time;
  1779. if (toWhere == "1")
  1780. {
  1781. entitycell.OrderState = 2;
  1782. }
  1783. else
  1784. {
  1785. entitycell.OrderState = 6;
  1786. entitycell.FinishPlaceTime = entitycell.pay_time;
  1787. }
  1788. if (shopId == 94)
  1789. {
  1790. entitycell.OrderState = 4;
  1791. entitycell.WaitDesignTime = entitycell.pay_time;
  1792. entitycell.StartDesignTime = entitycell.pay_time;
  1793. entitycell.DesignUserId = 218;
  1794. }
  1795. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1796. {
  1797. entitycell.OrderState = -1;//修改12-5
  1798. CeWithdraw ceWithdraw = new CeWithdraw();
  1799. ceWithdraw.tid = entity.tid;
  1800. ceWithdraw.providerid = "-1";
  1801. ceWithdraw.status = -1;
  1802. ceWithdraw.creationtime = DateTime.Now;
  1803. ceWithdraw.userid = 1337;
  1804. ceWithdraw.Create();
  1805. }
  1806. entitycell.Create();
  1807. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1808. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1809. {
  1810. addPlaceRegist(entitycell, CurrentUser.UserID);
  1811. }
  1812. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1813. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1814. return;
  1815. }
  1816. }
  1817. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1818. {
  1819. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1820. entity.PlactTime = tradecell.pay_time;
  1821. entity.AddUserId = userid;
  1822. entity.FileName = tradecell.seller_memo;
  1823. entity.Supplier = 24;
  1824. entity.CreateTime = DateTime.Now;
  1825. entity.Did = tradecell.ctid;
  1826. entity.tid = tradecell.tid;
  1827. entity.splitTag = tradecell.SplitTag;
  1828. entity.CurState = "未完成";
  1829. entity.Create();
  1830. }
  1831. public void get_erp_offlinelist()
  1832. {
  1833. DataStruct dStruct = GetPostStruct();
  1834. List<string> lw = new List<string>();
  1835. string tid = GetPostString("ctid");
  1836. string date1 = GetPostString("date1");
  1837. string date2 = GetPostString("date2");
  1838. if (tid.Length > 0 || date1.Length > 0)
  1839. {
  1840. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1841. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1842. if (dw.Length > 0) lw.Add(dw);
  1843. }
  1844. else
  1845. {
  1846. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1847. }
  1848. string shopname = GetPostString("shopname");
  1849. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1850. string buyernick = GetPostString("buyer_nick");
  1851. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1852. string customer = GetPostString("customer");
  1853. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1854. string design = GetPostString("design");
  1855. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1856. string orderState = GetPostString("orderState");
  1857. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1858. string address = GetPostString("address");
  1859. 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));
  1860. string sellermemo = GetPostString("seller_memo");
  1861. if (sellermemo.Length > 0)
  1862. {
  1863. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1864. }
  1865. string price1 = GetPostString("price1");
  1866. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1867. string price2 = GetPostString("price2");
  1868. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1869. //if (PKey != "admin")
  1870. //{
  1871. // string usershop = CurrentUser.User.pemShop;
  1872. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1873. //}
  1874. //if (ex_psize > 0)
  1875. //{
  1876. dStruct.Order = "pay_time desc";
  1877. //}
  1878. //else
  1879. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1880. lw.Add(string.Format("IsOffLineOrder=1"));
  1881. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1882. DataTable dt = null;
  1883. dt = WebCache.GetData("view_erptradecell", dStruct);
  1884. writeGridDataTableJson(dStruct.TotalCount, dt);
  1885. }
  1886. public void get_erp_returncashrecord()
  1887. {
  1888. DataStruct dStruct = GetPostStruct();
  1889. List<string> lw = new List<string>();
  1890. string tid = GetPostString("ctid");
  1891. if (tid.Length > 0)
  1892. {
  1893. lw.Add(string.Format("tid like '%{0}%'", tid));
  1894. dStruct.Order = "id desc";
  1895. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1896. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1897. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1898. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1899. return;
  1900. }
  1901. returnErrorMsg("id数据错误!");
  1902. }
  1903. public void ins_erp_returncashrecord()
  1904. {
  1905. if (UrlPostParmsCheck("tid"))
  1906. {
  1907. string tid = GetPostString("tid");
  1908. string retype = GetPostString("type");
  1909. StringBuilder sql = new StringBuilder();
  1910. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1911. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1912. if (dt.Rows.Count > 0)
  1913. {
  1914. returnErrorMsg("相同返现类型记录已存在");
  1915. return;
  1916. }
  1917. CeErpReturnCash entity = new CeErpReturnCash();
  1918. entity.tid = tid;
  1919. entity.seller_nick = GetPostString("seller_nick");
  1920. string pment = GetPostString("payment");
  1921. if (pment.Length > 0)
  1922. {
  1923. entity.payment = Convert.ToDouble(pment);
  1924. }
  1925. entity.buyer_nick = GetPostString("buyer_nick");
  1926. entity.cashstate = 0;
  1927. entity.rtype = retype;
  1928. string rPrice = GetPostString("returnprice");
  1929. if (rPrice.Length > 0)
  1930. {
  1931. entity.returnprice = Convert.ToDouble(rPrice);
  1932. }
  1933. entity.created = DateTime.Now;
  1934. entity.con = GetPostString("con");
  1935. entity.img = GetPostString("img");
  1936. entity.applyuserid = CurrentUser.UserID;
  1937. entity.Create();
  1938. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1939. returnSuccessMsg("操作成功!");
  1940. return;
  1941. }
  1942. }
  1943. public void set_erp_predelivery()
  1944. {
  1945. if (UrlPostParmsCheck("ctid"))
  1946. {
  1947. string eid = GetPostString("ctid");
  1948. CeErpTradeCell entity = null;
  1949. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1950. if (entity != null)
  1951. {
  1952. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1953. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1954. //{
  1955. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1956. // return;
  1957. //}
  1958. entity.IsPreDelivery = 1;
  1959. entity.Update();
  1960. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1961. returnSuccessMsg("预发货成功!");
  1962. return;
  1963. //string shop = GetPostString("seller_nick");
  1964. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1965. //string comName = GetPostString("comName");
  1966. //string comCode = GetPostString("comCode");
  1967. //string outSid = GetPostString("outSid");//运单号
  1968. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1969. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1970. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1971. //string apires = "";
  1972. //if (deliveryType == "虚拟发货")
  1973. //{
  1974. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1975. //}
  1976. //else
  1977. //{
  1978. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1979. //}
  1980. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1981. ////{
  1982. //if (apires.IndexOf("发货成功") != -1)
  1983. //{
  1984. // if (deliveryType != "虚拟发货")
  1985. // {
  1986. // //还要插入快递信息到 快递信息表
  1987. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1988. // exinfo.tid = eid;
  1989. // exinfo.out_sid = outSid;
  1990. // exinfo.company_code = comCode;
  1991. // exinfo.company_name = comName;
  1992. // exinfo.delivery_memo = deliveryMemo;
  1993. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1994. // exinfo.deliveryType = deliveryType;
  1995. // exinfo.Create();
  1996. // }
  1997. // returnSuccessMsg("发货成功!");
  1998. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1999. //}
  2000. //else
  2001. //{
  2002. // returnErrorMsg("淘宝发货失败!!");
  2003. //}
  2004. //return;
  2005. }
  2006. returnErrorMsg("找不到订单记录");
  2007. }
  2008. }
  2009. public void get_erp_unusuallist()
  2010. {
  2011. DataStruct dStruct = GetPostStruct();
  2012. List<string> lw = new List<string>();
  2013. string tid = GetPostString("ctid");
  2014. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2015. string shopname = GetPostString("shopname");
  2016. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2017. string buyernick = GetPostString("buyer_nick");
  2018. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2019. string ResponsibleMan = GetPostString("responsible");
  2020. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2021. string date1 = GetPostString("date1");
  2022. string date2 = GetPostString("date2");
  2023. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2024. if (dw.Length > 0) lw.Add(dw);
  2025. string price1 = GetPostString("price1");
  2026. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2027. string price2 = GetPostString("price2");
  2028. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2029. string orderState = GetPostString("orderState");
  2030. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2031. string sellermemo = GetPostString("seller_memo");
  2032. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2033. lw.Add(string.Format("UnusualTag > 0"));
  2034. lw.Add(string.Format("IsRefund<={0}", 1));
  2035. dStruct.Order = "pay_time desc";
  2036. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2037. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2038. writeGridDataTableJson(dStruct.TotalCount, dt);
  2039. }
  2040. public void set_erp_unusualtonomal()
  2041. {
  2042. if (UrlPostParmsCheck("ctid"))
  2043. {
  2044. string eid = GetPostString("ctid");
  2045. CeErpTradeCell entity = null;
  2046. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2047. if (entity != null)
  2048. {
  2049. entity.UnusualTag = -1;
  2050. entity.Update();
  2051. returnSuccessMsg("忽略成功!");
  2052. return;
  2053. }
  2054. returnErrorMsg("找不到记录");
  2055. }
  2056. }
  2057. public void ins_erp_unusualreason()
  2058. {
  2059. if (UrlPostParmsCheck("ctid"))
  2060. {
  2061. string eid = GetPostString("ctid");
  2062. CeErpTradeCell entity = null;
  2063. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2064. if (entity != null)
  2065. {
  2066. entity.MemoOpt = 4;
  2067. entity.UnusualCon = GetPostString("con");
  2068. entity.Update();
  2069. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2070. if (trade != null)
  2071. {
  2072. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2073. }
  2074. //查货是否超时
  2075. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2076. if (ceErpTradeCellExtend == null)
  2077. {
  2078. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2079. ceErpTradeCellExtend.ctid = entity.ctid;
  2080. }
  2081. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2082. {
  2083. ceErpTradeCellExtend.CheckOut += 1;
  2084. }
  2085. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2086. if (ceErpTradeCellExtend.ID > 0)
  2087. {
  2088. ceErpTradeCellExtend.Update();
  2089. }
  2090. else
  2091. {
  2092. ceErpTradeCellExtend.Create();
  2093. }
  2094. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2095. returnSuccessMsg("操作成功!");
  2096. return;
  2097. }
  2098. returnErrorMsg("找不到记录");
  2099. }
  2100. }
  2101. public void upd_erp_sampleorder()
  2102. {
  2103. if (UrlPostParmsCheck("ctid"))
  2104. {
  2105. string eid = GetPostString("ctid");
  2106. string[] eArr = eid.Split(',');
  2107. if (eArr.Length > 1)
  2108. {
  2109. List<string> eLst = new List<string>();
  2110. for (int i = 0; i < eArr.Length; i++)
  2111. {
  2112. eLst.Add("'" + eArr[i] + "'");
  2113. }
  2114. eid = string.Join(",", eLst.ToArray());
  2115. }
  2116. else
  2117. {
  2118. eid = "'" + eid + "'";
  2119. }
  2120. StringBuilder sql = new StringBuilder();
  2121. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2122. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2123. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2124. if (dt.Rows.Count > 0)
  2125. {
  2126. string errmsg = "";
  2127. foreach (DataRow dr in dt.Rows)
  2128. {
  2129. StringBuilder sqlsb = new StringBuilder();
  2130. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2131. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2132. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2133. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2134. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2135. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2136. {
  2137. continue;
  2138. }
  2139. else
  2140. {
  2141. string emsg = commonHelper.KeepChinese(apires);
  2142. errmsg += emsg;
  2143. }
  2144. }
  2145. if (errmsg.Length > 0)
  2146. {
  2147. returnErrorMsg(errmsg);
  2148. return;
  2149. }
  2150. returnSuccessMsg("操作成功");
  2151. return;
  2152. }
  2153. returnErrorMsg("找不到记录");
  2154. }
  2155. }
  2156. public void upd_erp_transcustomer()
  2157. {
  2158. if (UrlPostParmsCheck("ctid"))
  2159. {
  2160. string eid = GetPostString("ctid");
  2161. int userid = GetPostInt("CustomerUserId");
  2162. CeErpTradeCell entity = null;
  2163. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2164. if (entity != null)
  2165. {
  2166. //string[] mlist = entity.seller_memo.Split('-');
  2167. //string sql = "select * from view_erpuser where id=" + userid;
  2168. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2169. //if (dt != null && dt.Rows.Count > 0)
  2170. //{
  2171. // string nmemo = "";
  2172. // for(int i = 0; i < mlist.Length - 1; i++)
  2173. // {
  2174. // nmemo += mlist[i];
  2175. // nmemo += "-";
  2176. // }
  2177. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2178. // entity.seller_memo = nmemo;
  2179. //}
  2180. entity.CustomerUserId = userid;
  2181. entity.Update();
  2182. returnSuccessMsg("操作成功!");
  2183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2184. return;
  2185. }
  2186. returnErrorMsg("找不到记录");
  2187. }
  2188. }
  2189. public void upd_erp_transdesigner()
  2190. {
  2191. if (UrlPostParmsCheck("ctid"))
  2192. {
  2193. string eids = GetPostString("ctid");
  2194. string[] ctidList = eids.Split(',');
  2195. int userid = GetPostInt("DesignUserId");
  2196. foreach (string ctid in ctidList)
  2197. {
  2198. CeErpTradeCell entity = null;
  2199. CeErpDesignerBill entitys = null;
  2200. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2201. entitys = CeErpDesignerBill.GetByTid(ctid);
  2202. if (entity != null)
  2203. {
  2204. if (entity.OrderState > 4)
  2205. {
  2206. continue;
  2207. }
  2208. //存在退款不能流转
  2209. if (entity.IsRefund > 0)
  2210. {
  2211. continue;
  2212. }
  2213. entity.DesignUserId = userid;
  2214. entity.WaitDesignTime = DateTime.Now;
  2215. entity.Update();
  2216. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2217. }
  2218. }
  2219. returnSuccessMsg("操作成功!");
  2220. }
  2221. }
  2222. public void upd_erp_distributedesigner()
  2223. {
  2224. if (UrlPostParmsCheck("ctid"))
  2225. {
  2226. string eid = GetPostString("ctid");
  2227. int userid = GetPostInt("DesignUserId");
  2228. string[] idlist = eid.Split(',');
  2229. if (idlist.Length <= 0)
  2230. {
  2231. returnErrorMsg("订单不能为空");
  2232. return;
  2233. }
  2234. foreach (string ctid in idlist)
  2235. {
  2236. CeErpTradeCell entity = null;
  2237. CeErpDesignerBill entitys = null;
  2238. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2239. else continue;
  2240. if (entity != null)
  2241. {
  2242. if (userid == 2125 || userid == 3542)
  2243. { }
  2244. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2245. {
  2246. returnErrorMsg("金额错误的订单无法指派");
  2247. return;
  2248. }
  2249. if (entity.OrderState >= 5)
  2250. {
  2251. returnErrorMsg("已经设计完成无法指派");
  2252. return;
  2253. }
  2254. if (entity.OrderState == -1)
  2255. {
  2256. returnErrorMsg("审核中的订单无法指派");
  2257. return;
  2258. }
  2259. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2260. {
  2261. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2262. return;
  2263. }
  2264. //157赖橙帆 159林晨 73 静之颖
  2265. 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)
  2266. {
  2267. returnErrorMsg("指派设计共创无法再次指派!");
  2268. return;
  2269. }
  2270. entity.OrderState = 3;
  2271. if (entity.SupplierId == 0)
  2272. {
  2273. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2274. entity.SupplierId = suid;
  2275. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2276. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2277. }
  2278. if (userid == 2125 && entity.seller_memo != "")
  2279. {
  2280. apiDesign.API_GetPrintData_CreateOrder(entity);
  2281. }
  2282. if (userid == 3542 && entity.seller_memo != "")
  2283. {
  2284. string userPost = CurrentUser.UserPost.Post.Code;
  2285. if (CurrentUser.UserID == 73)
  2286. {
  2287. userPost = "SysAdmin";
  2288. }
  2289. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2290. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2291. if (response.msg != "设计共创:成功")
  2292. {
  2293. returnErrorMsg(response.msg);
  2294. return;
  2295. }
  2296. entity.DispatchSort = 2;
  2297. }
  2298. else
  2299. {
  2300. if (entity.DispatchSort == 2)
  2301. {
  2302. ApiVo apiVo = new ApiVo();
  2303. apiVo.actionName = "closeDesign";
  2304. apiVo.orderNumber = entity.ctid;
  2305. designHelper.API_WorkCore(apiVo);//closeDesign
  2306. }
  2307. entity.DispatchSort = 0;
  2308. }
  2309. entity.DesignUserId = userid;
  2310. entity.WaitDesignTime = DateTime.Now;
  2311. entity.UpdateTime = DateTime.Now;
  2312. entity.Update();
  2313. string name = commonHelper.getUserNameById(userid);
  2314. commonHelper.UpdateRelationOrder(entity.ctid);
  2315. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2316. }
  2317. }
  2318. returnSuccessMsg("操作成功!");
  2319. return;
  2320. }
  2321. }
  2322. public string getTidByCtid(string ctid)
  2323. {
  2324. string tid = "";
  2325. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2326. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2327. if (dataTable != null && dataTable.Rows.Count > 0)
  2328. {
  2329. tid = dataTable.Rows[0]["tid"].ToString();
  2330. }
  2331. return tid;
  2332. }
  2333. public List<string> getTidByCtidMore(string ctid)
  2334. {
  2335. 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);
  2336. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2337. List<string> list = new List<string>();
  2338. if (dataTable != null && dataTable.Rows.Count > 0)
  2339. {
  2340. foreach (DataRow item in dataTable.Rows)
  2341. {
  2342. list.Add("'" + item["tid"].ToString() + "'");
  2343. }
  2344. }
  2345. return list;
  2346. }
  2347. public List<string> getTidByCtidLike(string ctid)
  2348. {
  2349. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2350. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2351. List<string> list = new List<string>();
  2352. if (dataTable != null && dataTable.Rows.Count > 0)
  2353. {
  2354. foreach (DataRow item in dataTable.Rows)
  2355. {
  2356. list.Add("'" + item["tid"].ToString() + "'");
  2357. }
  2358. }
  2359. return list;
  2360. }
  2361. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2362. {
  2363. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2364. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2365. List<string> list = new List<string>();
  2366. if (dataTable != null && dataTable.Rows.Count > 0)
  2367. {
  2368. foreach (DataRow item in dataTable.Rows)
  2369. {
  2370. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2371. {
  2372. continue;
  2373. }
  2374. list.Add("'" + item["receiverId"].ToString() + "'");
  2375. }
  2376. }
  2377. return list;
  2378. }
  2379. public void get_erp_myorderlist()
  2380. {
  2381. DataStruct dStruct = GetPostStruct();
  2382. List<string> lw = new List<string>();
  2383. string tid = GetPostString("ctid");
  2384. if (tid.Length > 0)
  2385. {
  2386. string select_tid = getTidByCtid(tid);
  2387. lw.Add(string.Format("tid='{0}'", select_tid));
  2388. }
  2389. else
  2390. {
  2391. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2392. }
  2393. //12-1 修改
  2394. string urgent = GetPostString("urgent");
  2395. string back = GetPostString("back");
  2396. string offlineSearch = GetPostString("offlineSearch");
  2397. if (!string.IsNullOrWhiteSpace(urgent))
  2398. {
  2399. if (urgent.Equals("true"))
  2400. {
  2401. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2402. }
  2403. }
  2404. if (!string.IsNullOrWhiteSpace(back))
  2405. {
  2406. if (back.Equals("true"))
  2407. {
  2408. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2409. }
  2410. }
  2411. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2412. {
  2413. if (offlineSearch.Equals("true"))
  2414. {
  2415. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2416. }
  2417. }
  2418. //end
  2419. string shopname = GetPostString("shopname");
  2420. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2421. string buyernick = GetPostString("buyer_nick");
  2422. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2423. string design = GetPostString("design");
  2424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2425. string orderState = GetPostString("orderState");
  2426. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2427. string sellermemo = GetPostString("seller_memo");
  2428. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2429. string date1 = GetPostString("date1");
  2430. string date2 = GetPostString("date2");
  2431. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2432. if (dw.Length > 0) lw.Add(dw);
  2433. string price1 = GetPostString("price1");
  2434. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2435. string price2 = GetPostString("price2");
  2436. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2437. string urgency = GetPostString("urgency");
  2438. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2439. string after = GetPostString("after");
  2440. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2441. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2442. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2443. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2444. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2445. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2446. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2447. if (dt != null && dt.Rows.Count > 0)
  2448. {
  2449. foreach (DataRow dr in dt.Rows)
  2450. {
  2451. try
  2452. {
  2453. // 对象操作
  2454. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2455. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2456. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2457. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2458. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2459. if (dStruct.PageSize != 100000)
  2460. {
  2461. if (dr["DispatchSort"].ToString() == "2")
  2462. {
  2463. dr["gongchuang"] = 200;
  2464. }
  2465. else if ("外协".Equals(dr["ToType"].ToString()))
  2466. {
  2467. dr["gongchuang"] = 200;
  2468. }
  2469. else if ("内部".Equals(dr["ToType"].ToString()))
  2470. {
  2471. dr["gongchuang"] = -1;
  2472. }
  2473. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2474. {
  2475. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2476. dr["gongchuang"] = response.code;
  2477. }
  2478. }
  2479. }
  2480. catch (NullReferenceException ex)
  2481. {
  2482. }
  2483. }
  2484. }
  2485. writeGridDataTableJson(dStruct.TotalCount, dt);
  2486. }
  2487. public void get_erp_myreturnorderlist()
  2488. {
  2489. DataStruct dStruct = GetPostStruct();
  2490. List<string> lw = new List<string>();
  2491. string tid = GetPostString("ctid");
  2492. if (tid.Length > 0)
  2493. {
  2494. string select_tid = getTidByCtid(tid);
  2495. lw.Add(string.Format("tid='{0}'", select_tid));
  2496. }
  2497. else
  2498. {
  2499. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2500. }
  2501. string shopname = GetPostString("shopname");
  2502. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2503. string buyernick = GetPostString("buyer_nick");
  2504. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2505. string design = GetPostString("design");
  2506. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2507. string orderState = GetPostString("orderState");
  2508. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2509. string sellermemo = GetPostString("seller_memo");
  2510. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2511. string date1 = GetPostString("date1");
  2512. string date2 = GetPostString("date2");
  2513. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2514. if (dw.Length > 0) lw.Add(dw);
  2515. string price1 = GetPostString("price1");
  2516. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2517. string price2 = GetPostString("price2");
  2518. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2519. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2520. {
  2521. lw.Add(string.Format("CusOrgID = 94"));
  2522. }
  2523. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2524. {
  2525. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2526. }
  2527. else
  2528. {
  2529. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2530. }
  2531. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2532. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2533. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2534. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2535. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2536. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2537. if (dt != null && dt.Rows.Count > 0)
  2538. {
  2539. foreach (DataRow dr in dt.Rows)
  2540. {
  2541. try
  2542. {
  2543. // 对象操作
  2544. if (dStruct.PageSize != 100000)
  2545. {
  2546. if (dr["DispatchSort"].ToString() == "2")
  2547. {
  2548. dr["gongchuang"] = 200;
  2549. }
  2550. else if ("外协".Equals(dr["ToType"].ToString()))
  2551. {
  2552. dr["gongchuang"] = 200;
  2553. }
  2554. else if ("内部".Equals(dr["ToType"].ToString()))
  2555. {
  2556. dr["gongchuang"] = -1;
  2557. }
  2558. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2559. {
  2560. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2561. dr["gongchuang"] = response.code;
  2562. }
  2563. }
  2564. }
  2565. catch (NullReferenceException ex)
  2566. {
  2567. // 处理空引用异常
  2568. }
  2569. }
  2570. }
  2571. writeGridDataTableJson(dStruct.TotalCount, dt);
  2572. }
  2573. public void get_erp_myorderlist_pregather()
  2574. {
  2575. string date1 = GetPostString("date1");
  2576. string date2 = GetPostString("date2");
  2577. int userId = CurrentUser.UserID; //客服id
  2578. string orderWhere = "";
  2579. List<string> lw = new List<string>();
  2580. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2581. if (dw.Length > 0) lw.Add(dw);
  2582. lw.Add(string.Format("CustomerUserId={0}", userId));
  2583. lw.Add(string.Format("OrderState<9"));
  2584. orderWhere = string.Join(" and ", lw.ToArray());
  2585. string orderWhere2 = "";
  2586. List<string> lw2 = new List<string>();
  2587. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2588. if (dw2.Length > 0) lw2.Add(dw2);
  2589. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2590. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2591. string sql = string.Format("select *" +
  2592. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2593. "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 " +
  2594. "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 " +
  2595. "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");
  2596. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2597. //writeGridDataTableJson(dt.Rows.Count, dt);
  2598. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2599. }
  2600. public void upd_erp_publishorder()
  2601. {
  2602. if (UrlPostParmsCheck("ctid"))
  2603. {
  2604. string eid = GetPostString("ctid");
  2605. CeErpTradeCell entity = null;
  2606. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2607. if (entity != null)
  2608. {
  2609. entity.OrderState = 0; //发布后,变为待抢单
  2610. entity.Update();
  2611. commonHelper.UpdateRelationOrder(entity.ctid);
  2612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2613. returnSuccessMsg("发布成功!");
  2614. return;
  2615. }
  2616. returnErrorMsg("找不到记录");
  2617. }
  2618. }
  2619. public void get_erp_my_tiporder()
  2620. {
  2621. StringBuilder sql = new StringBuilder();
  2622. int userId = 0;
  2623. if (CurrentUser != null) userId = CurrentUser.UserID;
  2624. string posCode = CurrentUser.UserPost.Post.Code;
  2625. string isTipedAfterSaleVerify = GetPostString("af");
  2626. DataTable dt = new DataTable();
  2627. if (posCode != "Supplier")
  2628. {
  2629. if (posCode == "CustomerService" || posCode == "Director")
  2630. {
  2631. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2632. }
  2633. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2634. {
  2635. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2636. }
  2637. else
  2638. {
  2639. string teamIds = CurrentUser.User.TeamIds;
  2640. if (teamIds == "")
  2641. {
  2642. teamIds = "0";
  2643. }
  2644. 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);
  2645. }
  2646. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2647. }
  2648. if (dt.Rows.Count <= 0)
  2649. {
  2650. string key = "aftersale_order_" + userId;
  2651. if (RedisHelper.HasKey(key))
  2652. {
  2653. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2654. dt.Columns.Add("ctid", typeof(string));
  2655. dt.Columns.Add("IsReadTag", typeof(int));
  2656. foreach (var i in list)
  2657. {
  2658. DataRow data = dt.NewRow();
  2659. data["ctid"] = i;
  2660. data["IsReadTag"] = 4;
  2661. dt.Rows.Add(data);
  2662. }
  2663. RedisHelper.StringDelete(key);
  2664. }
  2665. }
  2666. if (dt.Rows.Count <= 0)
  2667. {
  2668. sql = new StringBuilder();
  2669. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2670. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2671. }
  2672. if (posCode == "Supplier")
  2673. {
  2674. string ids = CurrentUser.User.pemVend;
  2675. if (ids != null && ids.Length > 0)
  2676. {
  2677. string[] ids_list = ids.Split(',');
  2678. foreach (var item in ids_list)
  2679. {
  2680. string key = "return_order_" + item;
  2681. if (RedisHelper.HasKey(key))
  2682. {
  2683. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2684. dt.Columns.Add("ctid", typeof(string));
  2685. dt.Columns.Add("IsReadTag", typeof(int));
  2686. foreach (var i in list)
  2687. {
  2688. DataRow data = dt.NewRow();
  2689. data["ctid"] = i;
  2690. data["IsReadTag"] = 1;
  2691. dt.Rows.Add(data);
  2692. }
  2693. RedisHelper.StringDelete(key);
  2694. }
  2695. }
  2696. }
  2697. if (dt.Rows.Count <= 0)
  2698. {
  2699. sql = new StringBuilder();
  2700. 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);
  2701. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2702. }
  2703. }
  2704. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2705. }
  2706. public void reset_erp_tiporder()
  2707. {
  2708. string ids = GetPostString("ids");
  2709. string[] ctidList = ids.Split(',');
  2710. foreach (string ctid in ctidList)
  2711. {
  2712. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2713. if (enty != null)
  2714. {
  2715. enty.IsReadTag = 0;
  2716. enty.Update();
  2717. }
  2718. }
  2719. returnSuccessMsg("成功!");
  2720. return;
  2721. }
  2722. public void get_erp_designlist()
  2723. {
  2724. DataStruct dStruct = GetPostStruct();
  2725. List<string> lw = new List<string>();
  2726. string tid = GetPostString("ctid");
  2727. if (tid.Length > 0)
  2728. {
  2729. string select_tid = getTidByCtid(tid);
  2730. lw.Add(string.Format("tid='{0}'", select_tid));
  2731. }
  2732. string shopname = GetPostString("shopname");
  2733. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2734. string buyernick = GetPostString("buyer_nick");
  2735. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2736. string customer = GetPostString("customer");
  2737. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2738. string design = GetPostString("design");
  2739. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2740. string orderState = GetPostString("orderState");
  2741. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2742. lw.Add(string.Format("OrderState<6"));
  2743. string address = GetPostString("address");
  2744. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2745. string sellermemo = GetPostString("seller_memo");
  2746. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2747. string date1 = GetPostString("date1");
  2748. string date2 = GetPostString("date2");
  2749. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2750. if (dw.Length > 0) lw.Add(dw);
  2751. string apdate1 = GetPostString("apdate1");
  2752. string apdate2 = GetPostString("apdate2");
  2753. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2754. if (dwap.Length > 0) lw.Add(dwap);
  2755. string price1 = GetPostString("price1");
  2756. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2757. string price2 = GetPostString("price2");
  2758. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2759. string designTime = GetPostString("designtime");
  2760. if (designTime.Length > 0)
  2761. {
  2762. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2763. }
  2764. string usershop = CurrentUser.User.pemShop;
  2765. if (usershop.Length > 0)
  2766. {
  2767. lw.Add(string.Format("shopId in ({0})", usershop));
  2768. }
  2769. int myOrgid = CurrentUser.UserPost.OrgID;
  2770. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2771. if (myOrgCode.IndexOf("Designer") != -1)
  2772. {
  2773. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2774. {
  2775. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2776. }
  2777. else
  2778. {
  2779. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2780. }
  2781. }
  2782. else
  2783. {
  2784. string orgId = GetPostString("designerhd");
  2785. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2786. }
  2787. if (tid.Length > 0 || buyernick.Length > 0)
  2788. {
  2789. lw.Add(string.Format("OrderState >= 3"));
  2790. }
  2791. else
  2792. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2793. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2794. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2795. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2796. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2797. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2798. if (dt != null && dt.Rows.Count > 0)
  2799. {
  2800. foreach (DataRow dr in dt.Rows)
  2801. {
  2802. try
  2803. {
  2804. // 对象操作
  2805. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2806. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2807. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2808. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2809. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2810. if (dStruct.PageSize != 100000)
  2811. {
  2812. if (dr["DispatchSort"].ToString() == "2")
  2813. {
  2814. dr["gongchuang"] = 200;
  2815. }
  2816. else if ("外协".Equals(dr["ToType"].ToString()))
  2817. {
  2818. dr["gongchuang"] = 200;
  2819. }
  2820. else if ("内部".Equals(dr["ToType"].ToString()))
  2821. {
  2822. dr["gongchuang"] = -1;
  2823. }
  2824. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2825. {
  2826. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2827. dr["gongchuang"] = response.code;
  2828. }
  2829. }
  2830. }
  2831. catch (NullReferenceException ex)
  2832. {
  2833. }
  2834. }
  2835. }
  2836. writeGridDataTableJson(dStruct.TotalCount, dt);
  2837. }
  2838. public void get_erp_mydesignlist()
  2839. {
  2840. DataStruct dStruct = GetPostStruct();
  2841. List<string> lw = new List<string>();
  2842. string tid = GetPostString("ctid");
  2843. if (tid.Length > 0)
  2844. {
  2845. string select_tid = getTidByCtid(tid);
  2846. lw.Add(string.Format("tid='{0}'", select_tid));
  2847. }
  2848. string shopname = GetPostString("shopname");
  2849. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2850. string buyernick = GetPostString("buyer_nick");
  2851. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2852. string customer = GetPostString("customer");
  2853. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2854. string orderState = GetPostString("orderState");
  2855. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2856. //lw.Add(string.Format("OrderState<6"));
  2857. string date1 = GetPostString("date1");
  2858. string date2 = GetPostString("date2");
  2859. string dw = GetDateWhere("pay_time", date1, date2);
  2860. if (dw.Length > 0) lw.Add(dw);
  2861. string apdate1 = GetPostString("apdate1");
  2862. string apdate2 = GetPostString("apdate2");
  2863. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2864. if (dwap.Length > 0) lw.Add(dwap);
  2865. string price1 = GetPostString("price1");
  2866. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2867. string price2 = GetPostString("price2");
  2868. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2869. string olddownload = GetPostString("olddown");
  2870. if (olddownload == "1")
  2871. {
  2872. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2873. }
  2874. else if (olddownload == "2")
  2875. {
  2876. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2877. }
  2878. string sellermemo = GetPostString("seller_memo");
  2879. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2880. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2881. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2882. {
  2883. if (CurrentUser.User.TeamIds.Length > 0)
  2884. {
  2885. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2886. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2887. else
  2888. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2889. }
  2890. else
  2891. {
  2892. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2893. }
  2894. }
  2895. if (tid.Length <= 0)
  2896. {
  2897. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2898. }
  2899. lw.Add(string.Format("IsReturn!=3"));
  2900. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2901. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2902. string teamids = CurrentUser.User.TeamIds.ToString();
  2903. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2904. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2905. if (dt != null && dt.Rows.Count > 0)
  2906. {
  2907. foreach (DataRow dr in dt.Rows)
  2908. {
  2909. try
  2910. {
  2911. // 对象操作
  2912. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2913. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2914. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2915. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2916. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2917. if (dStruct.PageSize != 100000)
  2918. {
  2919. if (dr["DispatchSort"].ToString() == "2")
  2920. {
  2921. dr["gongchuang"] = 200;
  2922. }
  2923. else if ("外协".Equals(dr["ToType"].ToString()))
  2924. {
  2925. dr["gongchuang"] = 200;
  2926. }
  2927. else if ("内部".Equals(dr["ToType"].ToString()))
  2928. {
  2929. dr["gongchuang"] = -1;
  2930. }
  2931. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2932. {
  2933. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2934. dr["gongchuang"] = response.code;
  2935. }
  2936. }
  2937. }
  2938. catch (NullReferenceException ex)
  2939. {
  2940. }
  2941. }
  2942. }
  2943. writeGridDataTableJson(dStruct.TotalCount, dt);
  2944. }
  2945. public void set_erp_startdesign()
  2946. {
  2947. if (UrlPostParmsCheck("ctid"))
  2948. {
  2949. string eid = GetPostString("ctid");
  2950. CeErpTradeCell entity = null;
  2951. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2952. if (entity != null)
  2953. {
  2954. if (entity.OrderState != 3)
  2955. {
  2956. returnErrorMsg("请刷新,订单已经设计了");
  2957. return;
  2958. }
  2959. entity.StartDesignTime = DateTime.Now;
  2960. entity.OrderState = 4;
  2961. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2962. {
  2963. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2964. entity.SupplierId = suid;
  2965. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2966. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2967. }
  2968. entity.UpdateTime = DateTime.Now;
  2969. //entity.MakeSupplier = suname;
  2970. entity.Update();
  2971. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2972. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2973. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2974. commonHelper.getCytPrice(entity);
  2975. returnSuccessMsg("操作成功!");
  2976. return;
  2977. }
  2978. returnErrorMsg("找不到记录");
  2979. }
  2980. }
  2981. public void ins_erp_designselfmemo()
  2982. {
  2983. if (UrlPostParmsCheck("ctid"))
  2984. {
  2985. string eid = GetPostString("ctid");
  2986. string con = GetPostString("con");
  2987. CeErpTradeCell entity = null;
  2988. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2989. if (entity != null)
  2990. {
  2991. entity.DesignSelfMemo = con;
  2992. entity.Update();
  2993. returnSuccessMsg("操作成功!");
  2994. return;
  2995. }
  2996. returnErrorMsg("找不到记录");
  2997. }
  2998. }
  2999. public void ins_erp_designprice()
  3000. {
  3001. if (UrlPostParmsCheck("ctid"))
  3002. {
  3003. string eid = GetPostString("ctid");
  3004. int uid = CurrentUser.UserID;
  3005. string userName = CurrentUser.UserName;
  3006. CeErpTradeCell entity = null;
  3007. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3008. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3009. if (entitys == null)
  3010. {
  3011. entitys = new CeErpDesignerBill();
  3012. }
  3013. if (entity != null)
  3014. {
  3015. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3016. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3017. entity.StartDesignTime = DateTime.Now;
  3018. entity.OrderState = 4;
  3019. string suname = "";
  3020. if (entity.SupplierId == 0)
  3021. {
  3022. int sid = commonHelper.autoDistributeToSupplier(entity);
  3023. entity.SupplierId = sid;
  3024. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3025. }
  3026. entity.Update();
  3027. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3028. if (ceErpUserPost != null)
  3029. {
  3030. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3031. if (ceErpPost != null)
  3032. {
  3033. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3034. {
  3035. entitys.tid = entity.ctid;
  3036. entitys.oid = entity.tid;
  3037. entitys.uid = uid;
  3038. entitys.userName = userName;
  3039. entitys.designerType = 1;
  3040. entitys.designerTypeText = "内部设计师";
  3041. entitys.price = Convert.ToDouble(GetPostString("price"));
  3042. entitys.designNum = GetPostInt("designNum");
  3043. entitys.modifyNum = GetPostInt("modifyNum");
  3044. entitys.designSize = GetPostString("designSize");
  3045. entitys.modifySize = GetPostString("modifySize");
  3046. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3047. {
  3048. entitys.create_time = DateTime.Now;
  3049. entitys.create_u_id = uid;
  3050. entitys.create_u_name = userName;
  3051. entitys.Save();
  3052. }
  3053. else
  3054. {
  3055. entitys.update_time = DateTime.Now;
  3056. entitys.update_u_id = uid;
  3057. entitys.update_u_name = userName;
  3058. entitys.Update();
  3059. }
  3060. }
  3061. }
  3062. }
  3063. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3064. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3065. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3066. if (suname != "")
  3067. {
  3068. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3069. }
  3070. commonHelper.getCytPrice(entity);
  3071. returnSuccessMsg("操作成功!");
  3072. return;
  3073. }
  3074. returnErrorMsg("找不到记录");
  3075. }
  3076. }
  3077. public void upload_erp_filecomplete()
  3078. {
  3079. if (UrlPostParmsCheck("ctid"))
  3080. {
  3081. string eid = GetPostString("ctid");
  3082. CeErpTradeCell entity = null;
  3083. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3084. if (entity != null)
  3085. {
  3086. entity.OrderState = 5; //设计完成
  3087. entity.Update();
  3088. returnSuccessMsg(eid + "上传成功,设计完成!");
  3089. return;
  3090. }
  3091. returnErrorMsg("找不到订单记录");
  3092. }
  3093. }
  3094. public void get_erp_designovertimelist()
  3095. {
  3096. DataStruct dStruct = GetPostStruct();
  3097. List<string> lw = new List<string>();
  3098. string tid = GetPostString("ctid");
  3099. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3100. string shopname = GetPostString("shopname");
  3101. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3102. string buyernick = GetPostString("buyer_nick");
  3103. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3104. string ResponsibleMan = GetPostString("responsible");
  3105. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3106. string date1 = GetPostString("date1");
  3107. string date2 = GetPostString("date2");
  3108. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3109. if (dw.Length > 0) lw.Add(dw);
  3110. string price1 = GetPostString("price1");
  3111. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3112. string price2 = GetPostString("price2");
  3113. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3114. string orderState = GetPostString("orderState");
  3115. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3116. string sellermemo = GetPostString("seller_memo");
  3117. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3118. lw.Add(string.Format("UnusualTag=3"));
  3119. lw.Add(string.Format("IsRefund<={0}", 1));
  3120. dStruct.Order = "WaitDesignTime desc";
  3121. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3122. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3123. writeGridDataTableJson(dStruct.TotalCount, dt);
  3124. }
  3125. //设计管理 获取抢单大厅列表
  3126. public void get_erp_grabinglist()
  3127. {
  3128. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3129. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3130. bool oldOrder = false;
  3131. if (org != null)
  3132. {
  3133. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3134. }
  3135. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3136. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3137. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3138. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3139. //先处理订单数据
  3140. if (dt.Rows.Count > 0)
  3141. {
  3142. Dictionary<string, int> design = null;
  3143. int count = 0;
  3144. foreach (DataRow row in dt.Rows)
  3145. {
  3146. if (map.ContainsKey(row["ShopId"].ToString()))
  3147. {
  3148. map.TryGetValue(row["ShopId"].ToString(), out design);
  3149. }
  3150. else
  3151. {
  3152. design = new Dictionary<string, int>();
  3153. }
  3154. if (design.ContainsKey(row["ProductId"].ToString()))
  3155. {
  3156. design.TryGetValue(row["ProductId"].ToString(), out count);
  3157. }
  3158. count++;
  3159. design[row["ProductId"].ToString()] = count;
  3160. map[row["ShopId"].ToString()] = design;
  3161. }
  3162. }
  3163. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3164. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3165. //把店铺排序和技能排序分类
  3166. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3167. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3168. if (design_dt.Rows.Count > 0)
  3169. {
  3170. Dictionary<string, string> design = null;
  3171. List<string> shopIds = null;
  3172. foreach (DataRow row in design_dt.Rows)
  3173. {
  3174. if ("0".Equals(row["designId"].ToString()))
  3175. {
  3176. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3177. {
  3178. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3179. }
  3180. else
  3181. {
  3182. shopIds = new List<string>();
  3183. }
  3184. shopIds.Add(row["shopId"].ToString());
  3185. shop_orders[row["orders"].ToString()] = shopIds;
  3186. }
  3187. else
  3188. {
  3189. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3190. {
  3191. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3192. }
  3193. else
  3194. {
  3195. design = new Dictionary<string, string>();
  3196. }
  3197. design[row["orders"].ToString()] = row["designId"].ToString();
  3198. design_orders[row["shopId"].ToString()] = design;
  3199. }
  3200. }
  3201. //处理成key value后根据key排序
  3202. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3203. foreach (List<string> val in shop_orders.Values)
  3204. {
  3205. if (val != null)
  3206. {
  3207. foreach (string key in val)
  3208. {
  3209. if (design_orders.ContainsKey(key.ToString()))
  3210. {
  3211. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3212. }
  3213. }
  3214. }
  3215. }
  3216. }
  3217. //校验哪个优先级有订单
  3218. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3219. foreach (string key in shop_orders.Keys)
  3220. {
  3221. List<string> ids = null;
  3222. shop_orders.TryGetValue(key, out ids);
  3223. //id为shopid
  3224. foreach (string id in ids)
  3225. {
  3226. Dictionary<string, int> list = null;
  3227. Dictionary<string, string> desing = null;
  3228. map.TryGetValue(id, out list);
  3229. design_orders.TryGetValue(id, out desing);
  3230. if (list != null && desing != null)
  3231. {
  3232. foreach (var item in desing)
  3233. {
  3234. int count = 0;
  3235. if (list.ContainsKey(item.Value))
  3236. {
  3237. list.TryGetValue(item.Value, out count);
  3238. if (count > 0)
  3239. {
  3240. designIds[id] = item.Value;
  3241. break;
  3242. }
  3243. }
  3244. }
  3245. }
  3246. }
  3247. if (designIds.Count > 0)
  3248. {
  3249. break;
  3250. }
  3251. }
  3252. DataTable table = new DataTable();
  3253. table.Columns.Add("tid", typeof(string));
  3254. table.Columns.Add("ctid", typeof(string));
  3255. table.Columns.Add("seller_nick", typeof(string));
  3256. table.Columns.Add("productName", typeof(string));
  3257. table.Columns.Add("pay_time", typeof(string));
  3258. table.Columns.Add("seller_memo", typeof(string));
  3259. if (designIds.Count > 0)
  3260. {
  3261. string shopId = "";
  3262. string productId = "";
  3263. foreach (var designInfo in designIds)
  3264. {
  3265. shopId = designInfo.Key;
  3266. productId = designInfo.Value;
  3267. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3268. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3269. if (dt.Rows.Count > 0)
  3270. {
  3271. foreach (DataRow row in dt.Rows)
  3272. {
  3273. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3274. {
  3275. DataRow data = table.NewRow();
  3276. data["ctid"] = row["ctid"].ToString();
  3277. data["tid"] = row["tid"].ToString();
  3278. data["seller_nick"] = ceErpShop.ShopName;
  3279. data["pay_time"] = row["pay_time"].ToString();
  3280. data["seller_memo"] = row["seller_memo"].ToString();
  3281. data["productName"] = ceErpProduct.PType;
  3282. table.Rows.Add(data);
  3283. }
  3284. }
  3285. }
  3286. }
  3287. }
  3288. writeGridDataTableJson(table.Rows.Count, table);
  3289. }
  3290. private object rushLockObject = new object();
  3291. public void set_erp_grabingorder()
  3292. {
  3293. if (UrlPostParmsCheck("ctid"))
  3294. {
  3295. int total = CurrentUser.User.Person.Total;
  3296. int userId = CurrentUser.User.ID;
  3297. int noFinish = CurrentUser.User.Person.NoFinish;
  3298. int finalization = CurrentUser.User.Person.Finalization;
  3299. string eids = GetPostString("ctid");
  3300. string key = "RushKey_" + userId;
  3301. int count = 0;
  3302. if (erpRedis.RedisHelper.KeyExists(key))
  3303. {
  3304. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3305. if (redisCount != null)
  3306. {
  3307. count = Convert.ToInt32(redisCount);
  3308. }
  3309. }
  3310. if (count >= total)
  3311. {
  3312. returnErrorMsg("半小时内已经抢" + total + "单");
  3313. return;
  3314. }
  3315. string[] ctidlist = eids.Split(',');
  3316. if (count + ctidlist.Length > total)
  3317. {
  3318. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3319. return;
  3320. }
  3321. int itag = 0;
  3322. lock (rushLockObject)
  3323. {
  3324. if (ctidlist.Length > 0)
  3325. {
  3326. string[] dtList = new string[ctidlist.Length];
  3327. for (int i = 0; i < ctidlist.Length; i++)
  3328. {
  3329. dtList[i] = "'" + ctidlist[i] + "'";
  3330. }
  3331. 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"));
  3332. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3333. if (dt_user.Rows.Count > 0)
  3334. {
  3335. int doing = 0;//未定稿
  3336. int finish = 0;//已完成
  3337. foreach (DataRow dr in dt_user.Rows)
  3338. {
  3339. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3340. {
  3341. doing++;
  3342. }
  3343. else
  3344. {
  3345. finish++;
  3346. }
  3347. }
  3348. if (doing >= noFinish)
  3349. {
  3350. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3351. return;
  3352. }
  3353. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3354. {
  3355. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3356. return;
  3357. }
  3358. }
  3359. //校验选择单子状态
  3360. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3361. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3362. if (dt.Rows.Count > 0)
  3363. {
  3364. List<string> list = new List<string>();
  3365. foreach (DataRow dr in dt.Rows)
  3366. {
  3367. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3368. {
  3369. list.Add(dr["ctid"].ToString());
  3370. }
  3371. }
  3372. if (list.Count > 0)
  3373. {
  3374. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3375. return;
  3376. }
  3377. }
  3378. foreach (string ctid in ctidlist)
  3379. {
  3380. CeErpTradeCell entity = null;
  3381. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3382. if (entity != null)
  3383. {
  3384. entity.OrderState = 3;
  3385. entity.DesignUserId = CurrentUser.UserID;
  3386. entity.WaitDesignTime = DateTime.Now;
  3387. entity.StartDesignTime = DateTime.Now;
  3388. entity.Update();
  3389. commonHelper.UpdateRelationOrder(entity.ctid);
  3390. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3391. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3392. itag++;
  3393. }
  3394. }
  3395. }
  3396. }
  3397. count += ctidlist.Length;
  3398. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3399. if (itag == 0)
  3400. returnErrorMsg("没有找到相关订单");
  3401. else
  3402. returnSuccessMsg("抢单成功!");
  3403. return;
  3404. }
  3405. }
  3406. public void get_erp_waitorderlist()
  3407. {
  3408. DataStruct dStruct = GetPostStruct();
  3409. List<string> lw = new List<string>();
  3410. string tid = GetPostString("ctid");
  3411. if (tid.Length > 0)
  3412. {
  3413. string select_tid = getTidByCtid(tid);
  3414. lw.Add(string.Format("tid='{0}'", select_tid));
  3415. }
  3416. string shopname = GetPostString("shopname");
  3417. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3418. string buyernick = GetPostString("buyer_nick");
  3419. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3420. string customer = GetPostString("customer");
  3421. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3422. string design = GetPostString("design");
  3423. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3424. string orderState = GetPostString("orderState");
  3425. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3426. string supplier = GetPostString("supplier");
  3427. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3428. string sellermemo = GetPostString("seller_memo");
  3429. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3430. string otherMemo = GetPostString("otherMemo");
  3431. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3432. string address = GetPostString("address");
  3433. 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));
  3434. string date1 = GetPostString("date1");
  3435. string date2 = GetPostString("date2");
  3436. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3437. if (dw.Length > 0) lw.Add(dw);
  3438. string price1 = GetPostString("price1");
  3439. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3440. string price2 = GetPostString("price2");
  3441. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3442. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3443. lw.Add(string.Format("IsSample != 2 "));
  3444. lw.Add(string.Format("OrderState = 5 "));
  3445. lw.Add(string.Format("IsRefund<={0}", 1));
  3446. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3447. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3448. string pagesize = GetPostString("pagesize");
  3449. if (pagesize != null)
  3450. {
  3451. dStruct.PageSize = 200;
  3452. }
  3453. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3454. List<string> tids = new List<string>();
  3455. if (dt != null)
  3456. {
  3457. dt.Columns.Add("compenPrice", typeof(double));
  3458. foreach (DataRow dr in dt.Rows)
  3459. {
  3460. if (Convert.IsDBNull(dr["compenPrice"]))
  3461. {
  3462. dr["compenPrice"] = 0;
  3463. }
  3464. tids.Add("'" + dr["tid"].ToString() + "'");
  3465. 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();
  3466. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3467. {
  3468. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3469. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3470. entity.SupplierId = suid;
  3471. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3472. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3473. entity.Update();
  3474. }
  3475. }
  3476. }
  3477. if (tids.Count > 0)
  3478. {
  3479. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3480. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3481. if (dt_price != null && dt_price.Rows.Count > 0)
  3482. {
  3483. foreach (DataRow dr in dt_price.Rows)
  3484. {
  3485. foreach (DataRow row in dt.Rows)
  3486. {
  3487. if (row["tid"].Equals(dr["ptid"]))
  3488. {
  3489. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3490. break;
  3491. }
  3492. }
  3493. }
  3494. }
  3495. }
  3496. writeGridDataTableJson(dStruct.TotalCount, dt);
  3497. }
  3498. public void get_erp_supplierwaitorderlist()
  3499. {
  3500. DataStruct dStruct = GetPostStruct();
  3501. List<string> lw = new List<string>();
  3502. string tid = GetPostString("ctid");
  3503. if (tid.Length > 0)
  3504. {
  3505. string select_tid = getTidByCtid(tid);
  3506. lw.Add(string.Format("tid='{0}'", select_tid));
  3507. }
  3508. string shopname = GetPostString("shopname");
  3509. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3510. string sellermemo = GetPostString("seller_memo");
  3511. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3512. string date1 = GetPostString("date1");
  3513. string date2 = GetPostString("date2");
  3514. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3515. if (dw.Length > 0) lw.Add(dw);
  3516. lw.Add(string.Format("OrderState = 5 "));
  3517. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3518. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3519. {
  3520. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3521. }
  3522. string supplier = GetPostString("supplier");
  3523. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3524. {
  3525. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3526. }
  3527. lw.Add(string.Format("IsRefund<={0}", 1));
  3528. dStruct.Order = "FinishDesignTime desc";
  3529. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3530. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3531. if (dt != null)
  3532. {
  3533. foreach (DataRow dr in dt.Rows)
  3534. {
  3535. 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();
  3536. }
  3537. }
  3538. writeGridDataTableJson(dStruct.TotalCount, dt);
  3539. }
  3540. public void upd_erp_verifytosupplier()
  3541. {
  3542. if (UrlPostParmsCheck("ctid"))
  3543. {
  3544. string eids = GetPostString("ctid");
  3545. CeErpTradeCell entity = null;
  3546. string[] eidsList = eids.Split(',');
  3547. if (eidsList.Length <= 0)
  3548. {
  3549. returnErrorMsg("订单号不能空");
  3550. return;
  3551. }
  3552. List<string> tLst = new List<string>();
  3553. foreach (string ctidstr in eidsList)
  3554. {
  3555. tLst.Add("'" + ctidstr + "'");
  3556. CeErpDataSendOrderInfo.createObject(ctidstr);
  3557. }
  3558. string needtids = string.Join(",", tLst.ToArray());
  3559. StringBuilder sql = new StringBuilder();
  3560. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3561. 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);
  3562. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3563. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3564. returnSuccessMsg("操作成功!");
  3565. return;
  3566. /**foreach (string ctidstr in eidsList)
  3567. {
  3568. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3569. if (entity != null)
  3570. {
  3571. if (entity.SupplierId == 0)
  3572. {
  3573. continue;
  3574. }
  3575. entity.IsVerifyToSupplier = true;
  3576. if (entity.IsReturn == 1) //1是供应商打回
  3577. {
  3578. entity.IsReturn = 0;
  3579. }
  3580. entity.FinishPlaceTime = DateTime.Now;
  3581. entity.PlaceUserId = CurrentUser.UserID;
  3582. entity.Update();
  3583. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3584. }
  3585. }
  3586. returnSuccessMsg("操作成功!");
  3587. return;**/
  3588. }
  3589. }
  3590. public void upd_erp_supplierback()
  3591. {
  3592. if (UrlPostParmsCheck("ctid"))
  3593. {
  3594. string eid = GetPostString("ctid");
  3595. string reason = GetPostString("returnreason");
  3596. CeErpTradeCell entity = null;
  3597. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3598. if (entity != null)
  3599. {
  3600. string message = "操作成功!";
  3601. string isDown = "";
  3602. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3603. {
  3604. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3605. isDown = "被点击下载";
  3606. }
  3607. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3608. {
  3609. string key = "return_order_" + entity.SupplierId;
  3610. List<string> list = new List<string>();
  3611. if (RedisHelper.HasKey(key))
  3612. {
  3613. object data = RedisHelper.StringGet(key);
  3614. list = Convert.ToString(data).Split(',').ToList();
  3615. }
  3616. list.Add(eid);
  3617. RedisHelper.StringSet(key, string.Join(",", list));
  3618. }
  3619. entity.IsVerifyToSupplier = false;
  3620. entity.IsReturn = 1;
  3621. entity.IsHaveNewOrder = 0;
  3622. entity.ReturnTime = DateTime.Now;
  3623. entity.ReturnReason = reason;
  3624. if (entity.OrderState == 6)
  3625. {
  3626. entity.OrderState = 5;
  3627. }
  3628. entity.Update();
  3629. CeErpSukuraData.createInfo(entity.ctid, 5);
  3630. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3631. returnSuccessMsg(message);
  3632. return;
  3633. }
  3634. returnErrorMsg("找不到订单记录");
  3635. }
  3636. }
  3637. public void upd_erp_toaftersaleorder()
  3638. {
  3639. if (UrlPostParmsCheck("ctid"))
  3640. {
  3641. string eid = GetPostString("ctid");
  3642. string reason = GetPostString("returnreason");
  3643. CeErpTradeCell entity = null;
  3644. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3645. if (entity != null)
  3646. {
  3647. if (entity.isAfterSaleOrder != 1)
  3648. {
  3649. returnErrorMsg("带S的售后单才能打回给售后");
  3650. return;
  3651. }
  3652. if (entity.OrderState >= 5)
  3653. {
  3654. returnErrorMsg("已经设计完成了不能打回给售后");
  3655. return;
  3656. }
  3657. entity.OrderState = 0;
  3658. entity.IsReturn = 3;
  3659. entity.ReturnTime = DateTime.Now;
  3660. entity.UpdateTime = DateTime.Now;
  3661. entity.ReturnReason = reason;
  3662. entity.Update();
  3663. CeErpSukuraData.createInfo(entity.ctid, 5);
  3664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3665. returnSuccessMsg("操作成功!");
  3666. return;
  3667. }
  3668. returnErrorMsg("找不到订单记录");
  3669. }
  3670. }
  3671. public void upd_erp_aftersaletodesign()
  3672. {
  3673. if (UrlPostParmsCheck("ctid"))
  3674. {
  3675. string eid = GetPostString("ctid");
  3676. CeErpTradeCell entity = null;
  3677. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3678. if (entity != null)
  3679. {
  3680. entity.OrderState = 3;
  3681. entity.IsReturn = 0;
  3682. entity.UpdateTime = DateTime.Now;
  3683. entity.Update();
  3684. CeErpSukuraData.createInfo(entity.ctid, 5);
  3685. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3686. returnSuccessMsg("操作成功!");
  3687. return;
  3688. }
  3689. returnErrorMsg("找不到订单记录");
  3690. }
  3691. }
  3692. public void assign_erp_supplier()
  3693. {
  3694. if (UrlPostParmsCheck("ctid"))
  3695. {
  3696. string eids = GetPostString("ctid");
  3697. int sid = GetPostInt("SupplierName");
  3698. string fromTag = GetPostString("tag");
  3699. string[] eidList = eids.Split(',');
  3700. if (eidList.Length <= 0)
  3701. {
  3702. returnErrorMsg("指派不能为空");
  3703. return;
  3704. }
  3705. string errMsg = "";
  3706. string suname = commonHelper.getSupplierNameById(sid);
  3707. foreach (string ctid in eidList)
  3708. {
  3709. CeErpTradeCell entity = null;
  3710. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3711. if (entity != null)
  3712. {
  3713. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3714. {
  3715. errMsg += (ctid + "指派失败!!!");
  3716. continue;
  3717. }
  3718. entity.SupplierId = sid;
  3719. entity.Update();
  3720. commonHelper.UpdateRelationOrder(entity.ctid);
  3721. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3722. if (entity.OrderState >= 6)
  3723. {
  3724. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3725. //{
  3726. // string msl = entity.MakeSupplier;
  3727. // string[] mslist = msl.Split(',');
  3728. // 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);
  3729. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3730. //}
  3731. //else
  3732. //{
  3733. StringBuilder sql = new StringBuilder();
  3734. 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);
  3735. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3736. //}
  3737. }
  3738. }
  3739. else
  3740. {
  3741. continue;
  3742. }
  3743. }
  3744. if (errMsg.Length > 0)
  3745. {
  3746. returnErrorMsg(errMsg);
  3747. return;
  3748. }
  3749. returnSuccessMsg("操作成功!");
  3750. return;
  3751. }
  3752. }
  3753. public void assign_erp_makesupplier()
  3754. {
  3755. if (UrlPostParmsCheck("ctid"))
  3756. {
  3757. string eids = GetPostString("ctid");
  3758. string sname = GetPostString("SupplierName");
  3759. string[] eidList = eids.Split(',');
  3760. if (eidList.Length <= 0)
  3761. {
  3762. returnErrorMsg("指派不能为空");
  3763. return;
  3764. }
  3765. List<string> tLst = new List<string>();
  3766. foreach (string ctid in eidList)
  3767. {
  3768. CeErpTradeCell entity = null;
  3769. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3770. if (entity != null)
  3771. {
  3772. entity.MakeSupplier = sname;
  3773. entity.Update();
  3774. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3775. tLst.Add("'" + ctid + "'");
  3776. }
  3777. else
  3778. {
  3779. continue;
  3780. }
  3781. }
  3782. string ctids = string.Join(",", tLst.ToArray());
  3783. StringBuilder sql2 = new StringBuilder();
  3784. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3785. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3786. returnSuccessMsg("操作成功!");
  3787. return;
  3788. }
  3789. }
  3790. public void ins_erp_returnreason()
  3791. {
  3792. if (UrlPostParmsCheck("ctid"))
  3793. {
  3794. string eid = GetPostString("ctid");
  3795. CeErpTradeCell entity = null;
  3796. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3797. string userpost = CurrentUser.UserPost.Post.Code;
  3798. if (entity != null)
  3799. {
  3800. bool isPlace = false;
  3801. if (entity.OrderState > 6)
  3802. {
  3803. returnErrorMsg("已发货无法打回!");
  3804. return;
  3805. }
  3806. if (entity.OrderState == 6)
  3807. {
  3808. isPlace = true;
  3809. }
  3810. bool isNeedUpdateCell2 = false;
  3811. if (entity.OrderState >= 6)
  3812. {
  3813. isNeedUpdateCell2 = true;
  3814. }
  3815. int returnTag = 2;
  3816. if (userpost == "Supplier")
  3817. {
  3818. returnTag = 1;
  3819. }
  3820. int toType = GetPostInt("totype");
  3821. string fromType = "3";
  3822. if (entity.OrderState < 5)
  3823. {
  3824. fromType = "3";
  3825. }
  3826. else
  3827. {
  3828. fromType = "4";
  3829. }
  3830. if (entity.IsXianHuo == 0)
  3831. {
  3832. if (returnTag == 2)
  3833. {
  3834. if (toType == 1)
  3835. {
  3836. entity.OrderState = 0;
  3837. entity.ReturnUserType = 1;
  3838. string clearman = GetPostString("clearman");
  3839. if (!string.IsNullOrEmpty(clearman))
  3840. {
  3841. entity.DesignUserId = 0;
  3842. }
  3843. }
  3844. else
  3845. {
  3846. entity.OrderState = 3;
  3847. entity.ReturnUserType = 2;
  3848. }
  3849. entity.IsReadTag = 1;
  3850. }
  3851. else if (returnTag == 1)
  3852. {
  3853. entity.OrderState = 5;
  3854. }
  3855. entity.IsVerifyToSupplier = false;
  3856. }
  3857. if (entity.IsXianHuo == 1)
  3858. {
  3859. entity.OrderState = 5;
  3860. }
  3861. entity.UnusualTag = 0;
  3862. entity.UnusualTime = null;
  3863. entity.UnusualCon = "";
  3864. entity.IsReturn = returnTag;
  3865. entity.ReturnTime = DateTime.Now;
  3866. entity.UpdateTime = DateTime.Now;
  3867. entity.ReturnReason = GetPostString("returnreason");
  3868. entity.Update();
  3869. if (entity.OrderState == 3)
  3870. {
  3871. ApiVo apiVo = new ApiVo();
  3872. apiVo.orderNumber = entity.ctid;
  3873. apiVo.actionName = "rebutDesign";
  3874. apiVo.orderRemarks = entity.ReturnReason;
  3875. designHelper.API_WorkCore(apiVo);//rebutDesign
  3876. }
  3877. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3878. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3879. {
  3880. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3881. }
  3882. CeErpSukuraData.createInfo(entity.ctid, 5);
  3883. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3884. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3885. if (isPlace)
  3886. {
  3887. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3888. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3889. if (dth != null && dth.Rows.Count > 0)
  3890. {
  3891. dataSendOrderBean dataSendOrderBean = null;
  3892. foreach (DataRow item in dth.Rows)
  3893. {
  3894. try
  3895. {
  3896. dataSendOrderBean = new dataSendOrderBean();
  3897. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3898. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3899. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3900. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3901. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3902. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3903. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3904. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3905. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3906. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3907. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3908. dataSendOrderBean.Radio1723534706288 = "打回";
  3909. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3910. if (result != null)
  3911. {
  3912. if ("0".Equals(result.errcode))
  3913. {
  3914. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3915. }
  3916. else
  3917. {
  3918. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3919. }
  3920. }
  3921. }
  3922. catch (Exception ex)
  3923. {
  3924. }
  3925. }
  3926. }
  3927. }
  3928. if (isNeedUpdateCell2)
  3929. {
  3930. if (entity.MakeSupplier.IndexOf(",") != -1)
  3931. {
  3932. StringBuilder sql2 = new StringBuilder();
  3933. 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);
  3934. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3935. }
  3936. else
  3937. {
  3938. StringBuilder sql2 = new StringBuilder();
  3939. 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);
  3940. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3941. }
  3942. }
  3943. returnSuccessMsg("操作成功!");
  3944. return;
  3945. }
  3946. returnErrorMsg("找不到订单记录");
  3947. }
  3948. }
  3949. public void cyt_erp_returnreason()
  3950. {
  3951. if (UrlPostParmsCheck("ctid"))
  3952. {
  3953. string eid = GetPostString("ctid");
  3954. CeErpTradeCell entity = null;
  3955. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3956. string userpost = CurrentUser.UserPost.Post.Code;
  3957. if (entity != null)
  3958. {
  3959. if (entity.OrderState > 6)
  3960. {
  3961. returnErrorMsg("已发货无法打回!");
  3962. return;
  3963. }
  3964. JObject jsonObject = new JObject
  3965. {
  3966. { "Userid", "77886" },
  3967. { "Pwd", "lt666888" },
  3968. { "LTOrderId",eid }
  3969. };
  3970. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3971. JObject jsonObjects = JObject.Parse(response);
  3972. string msg = (string)jsonObjects["msg"];
  3973. if (msg != "取消成功")
  3974. {
  3975. returnErrorMsg(msg);
  3976. return;
  3977. }
  3978. bool isNeedUpdateCell2 = false;
  3979. if (entity.OrderState >= 6)
  3980. {
  3981. isNeedUpdateCell2 = true;
  3982. }
  3983. int returnTag = 2;
  3984. if (userpost == "Supplier")
  3985. {
  3986. returnTag = 1;
  3987. }
  3988. if (entity.IsXianHuo == 0)
  3989. {
  3990. if (returnTag == 2)
  3991. {
  3992. int toType = GetPostInt("totype");
  3993. if (toType == 1)
  3994. {
  3995. entity.OrderState = 0;
  3996. entity.ReturnUserType = 1;
  3997. }
  3998. else
  3999. {
  4000. entity.OrderState = 4;
  4001. entity.ReturnUserType = 2;
  4002. }
  4003. entity.IsReadTag = 1;
  4004. }
  4005. else if (returnTag == 1)
  4006. {
  4007. entity.OrderState = 5;
  4008. }
  4009. entity.IsVerifyToSupplier = false;
  4010. }
  4011. entity.UnusualTag = 0;
  4012. entity.UnusualTime = null;
  4013. entity.UnusualCon = "";
  4014. entity.IsReturn = returnTag;
  4015. entity.ReturnTime = DateTime.Now;
  4016. entity.ReturnReason = GetPostString("returnreason");
  4017. entity.Update();
  4018. if (entity.OrderState == 4)
  4019. {
  4020. ApiVo apiVo = new ApiVo();
  4021. apiVo.orderNumber = entity.ctid;
  4022. apiVo.actionName = "rebutDesign";
  4023. apiVo.orderRemarks = entity.ReturnReason;
  4024. designHelper.API_WorkCore(apiVo);//rebutDesign
  4025. }
  4026. CeErpSukuraData.createInfo(entity.ctid, 5);
  4027. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4029. if (isNeedUpdateCell2)
  4030. {
  4031. if (entity.MakeSupplier.IndexOf(",") != -1)
  4032. {
  4033. StringBuilder sql2 = new StringBuilder();
  4034. 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);
  4035. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4036. }
  4037. else
  4038. {
  4039. StringBuilder sql2 = new StringBuilder();
  4040. 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);
  4041. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4042. }
  4043. }
  4044. returnSuccessMsg("操作成功!");
  4045. return;
  4046. }
  4047. returnErrorMsg("找不到订单记录");
  4048. }
  4049. }
  4050. public void upd_erp_xianhuoreturntag()
  4051. {
  4052. if (UrlPostParmsCheck("ctid"))
  4053. {
  4054. string eids = GetPostString("ctid");
  4055. string[] ctids = eids.Split(',');
  4056. foreach (string ctid in ctids)
  4057. {
  4058. CeErpTradeCell entity = null;
  4059. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4060. if (entity != null)
  4061. {
  4062. entity.IsReturn = 0;
  4063. entity.Update();
  4064. CeErpSukuraData.createInfo(entity.ctid, 5);
  4065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4066. }
  4067. }
  4068. returnSuccessMsg("操作成功!");
  4069. return;
  4070. }
  4071. }
  4072. public void get_erp_waitdeliverylist()
  4073. {
  4074. DataStruct dStruct = GetPostStruct();
  4075. List<string> lw = new List<string>();
  4076. string tid = GetPostString("ctid");
  4077. if (tid.Length > 0)
  4078. {
  4079. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4080. if (tid.Length > 5)
  4081. {
  4082. List<string> tids = getTidByCtidLike(tid);
  4083. if (tids.Count > 0 && tids.Count < 10)
  4084. {
  4085. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4086. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4087. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4088. {
  4089. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4090. }*/
  4091. }
  4092. }
  4093. lw.Add(tid_sql);
  4094. }
  4095. string shopname = GetPostString("shopname");
  4096. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4097. string buyernick = GetPostString("buyer_nick");
  4098. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4099. //if (tid.Length == 0 && buyernick.Length == 0)
  4100. //{
  4101. // lw.Add(string.Format("IsRefund<={0}", 1));
  4102. //}
  4103. string customer = GetPostString("customer");
  4104. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4105. string design = GetPostString("design");
  4106. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4107. string orderState = GetPostString("orderState");
  4108. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4109. string address = GetPostString("address");
  4110. 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));
  4111. string sellermemo = GetPostString("seller_memo");
  4112. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4113. string supplier = GetPostString("supplier");
  4114. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4115. string OrderArea = GetPostString("order_area");
  4116. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4117. string placedate1 = GetPostString("placedate1");
  4118. string placedate2 = GetPostString("placedate2");
  4119. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4120. if (fdw.Length > 0) lw.Add(fdw);
  4121. string price1 = GetPostString("price1");
  4122. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4123. string price2 = GetPostString("price2");
  4124. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4125. string unusualCon = GetPostString("unusualcon");
  4126. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4127. string otherMemo = GetPostString("otherMemo");
  4128. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4129. string posTag = CurrentUser.UserPost.Post.Code;
  4130. if (posTag == "Supplier")
  4131. {
  4132. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4133. }
  4134. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4135. lw.Add(string.Format("type != 'PDD' "));
  4136. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4137. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4138. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4139. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4140. writeGridDataTableJson(dStruct.TotalCount, dt);
  4141. }
  4142. public void get_erp_changedeliverylist()
  4143. {
  4144. DataStruct dStruct = GetPostStruct();
  4145. List<string> lw = new List<string>();
  4146. string tid = GetPostString("ctid");
  4147. if (tid.Length > 0)
  4148. {
  4149. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4150. if (tid.Length > 5)
  4151. {
  4152. List<string> tids = getTidByCtidLike(tid);
  4153. if (tids.Count > 0 && tids.Count < 10)
  4154. {
  4155. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4156. }
  4157. }
  4158. lw.Add(tid_sql);
  4159. }
  4160. string shopname = GetPostString("shopname");
  4161. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4162. string buyernick = GetPostString("buyer_nick");
  4163. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4164. //if (tid.Length == 0 && buyernick.Length == 0)
  4165. //{
  4166. // lw.Add(string.Format("IsRefund<={0}", 1));
  4167. //}
  4168. string customer = GetPostString("customer");
  4169. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4170. string design = GetPostString("design");
  4171. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4172. string orderState = GetPostString("orderState");
  4173. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4174. string address = GetPostString("address");
  4175. 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));
  4176. string sellermemo = GetPostString("seller_memo");
  4177. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4178. string supplier = GetPostString("supplier");
  4179. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4180. string OrderArea = GetPostString("order_area");
  4181. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4182. string placedate1 = GetPostString("placedate1");
  4183. string placedate2 = GetPostString("placedate2");
  4184. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4185. if (fdw.Length > 0) lw.Add(fdw);
  4186. string price1 = GetPostString("price1");
  4187. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4188. string price2 = GetPostString("price2");
  4189. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4190. string unusualCon = GetPostString("unusualcon");
  4191. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4192. string otherMemo = GetPostString("otherMemo");
  4193. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4194. string posTag = CurrentUser.UserPost.Post.Code;
  4195. if (posTag == "Supplier")
  4196. {
  4197. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4198. }
  4199. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4200. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4201. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4202. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4203. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4204. /*if (tid.Length > 0)
  4205. {
  4206. List<string> tids = new List<string>();
  4207. if (dt != null && dt.Rows.Count > 0)
  4208. {
  4209. foreach (DataRow item in dt.Rows)
  4210. {
  4211. tids.Add("'" + item["tid"] + "'");
  4212. }
  4213. }
  4214. if (tids.Count > 0)
  4215. {
  4216. lw.RemoveAt(0);
  4217. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4218. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4219. dt = WebCache.GetData("view_erptradecell", dStruct);
  4220. }
  4221. }*/
  4222. writeGridDataTableJson(dStruct.TotalCount, dt);
  4223. }
  4224. public void get_erp_pddderiving()
  4225. {
  4226. DataStruct dStruct = GetPostStruct();
  4227. List<string> lw = new List<string>();
  4228. string tid = GetPostString("ctid");
  4229. if (tid.Length > 0)
  4230. {
  4231. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4232. if (tid.Length > 5)
  4233. {
  4234. List<string> tids = getTidByCtidLike(tid);
  4235. if (tids.Count > 0 && tids.Count < 10)
  4236. {
  4237. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4238. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4239. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4240. {
  4241. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4242. }*/
  4243. }
  4244. }
  4245. lw.Add(tid_sql);
  4246. }
  4247. string shopname = GetPostString("shopname");
  4248. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4249. string buyernick = GetPostString("buyer_nick");
  4250. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4251. //if (tid.Length == 0 && buyernick.Length == 0)
  4252. //{
  4253. // lw.Add(string.Format("IsRefund<={0}", 1));
  4254. //}
  4255. string customer = GetPostString("customer");
  4256. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4257. string design = GetPostString("design");
  4258. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4259. string orderState = GetPostString("orderState");
  4260. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4261. string address = GetPostString("address");
  4262. 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));
  4263. string sellermemo = GetPostString("seller_memo");
  4264. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4265. string supplier = GetPostString("supplier");
  4266. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4267. string OrderArea = GetPostString("order_area");
  4268. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4269. string placedate1 = GetPostString("placedate1");
  4270. string placedate2 = GetPostString("placedate2");
  4271. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4272. if (fdw.Length > 0) lw.Add(fdw);
  4273. string price1 = GetPostString("price1");
  4274. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4275. string price2 = GetPostString("price2");
  4276. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4277. string unusualCon = GetPostString("unusualcon");
  4278. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4279. string posTag = CurrentUser.UserPost.Post.Code;
  4280. if (posTag == "Supplier")
  4281. {
  4282. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4283. }
  4284. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4285. lw.Add(string.Format("type = 'PDD' "));
  4286. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4287. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4289. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4290. /*if (tid.Length > 0)
  4291. {
  4292. List<string> tids = new List<string>();
  4293. if (dt != null && dt.Rows.Count > 0)
  4294. {
  4295. foreach (DataRow item in dt.Rows)
  4296. {
  4297. tids.Add("'" + item["tid"] + "'");
  4298. }
  4299. }
  4300. if (tids.Count > 0)
  4301. {
  4302. lw.RemoveAt(0);
  4303. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4304. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4305. dt = WebCache.GetData("view_erptradecell", dStruct);
  4306. }
  4307. }*/
  4308. writeGridDataTableJson(dStruct.TotalCount, dt);
  4309. }
  4310. public void get_erp_jdderiving()
  4311. {
  4312. DataStruct dStruct = GetPostStruct();
  4313. List<string> lw = new List<string>();
  4314. string tid = GetPostString("ctid");
  4315. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4316. string shopname = GetPostString("shopname");
  4317. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4318. string buyernick = GetPostString("buyer_nick");
  4319. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4320. //if (tid.Length == 0 && buyernick.Length == 0)
  4321. //{
  4322. // lw.Add(string.Format("IsRefund<={0}", 1));
  4323. //}
  4324. string customer = GetPostString("customer");
  4325. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4326. string design = GetPostString("design");
  4327. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4328. string orderState = GetPostString("orderState");
  4329. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4330. string address = GetPostString("address");
  4331. 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));
  4332. string sellermemo = GetPostString("seller_memo");
  4333. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4334. string supplier = GetPostString("supplier");
  4335. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4336. string OrderArea = GetPostString("order_area");
  4337. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4338. string placedate1 = GetPostString("placedate1");
  4339. string placedate2 = GetPostString("placedate2");
  4340. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4341. if (fdw.Length > 0) lw.Add(fdw);
  4342. string price1 = GetPostString("price1");
  4343. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4344. string price2 = GetPostString("price2");
  4345. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4346. string unusualCon = GetPostString("unusualcon");
  4347. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4348. string posTag = CurrentUser.UserPost.Post.Code;
  4349. if (posTag == "Supplier")
  4350. {
  4351. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4352. }
  4353. lw.Add(string.Format("OrderState = 6 "));
  4354. lw.Add(string.Format("type = 'JD' "));
  4355. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4356. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4357. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4358. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4359. writeGridDataTableJson(dStruct.TotalCount, dt);
  4360. }
  4361. public void get_erp_demoorderlist()
  4362. {
  4363. DataStruct dStruct = GetPostStruct();
  4364. List<string> lw = new List<string>();
  4365. string tid = GetPostString("ctid");
  4366. if (tid.Length > 0)
  4367. {
  4368. string select_tid = getTidByCtid(tid);
  4369. lw.Add(string.Format("tid='{0}'", select_tid));
  4370. }
  4371. string shopname = GetPostString("shopname");
  4372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4373. string buyernick = GetPostString("buyer_nick");
  4374. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4375. string customer = GetPostString("customer");
  4376. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4377. string design = GetPostString("design");
  4378. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4379. string orderState = GetPostString("orderState");
  4380. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4381. string address = GetPostString("address");
  4382. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4383. string sellermemo = GetPostString("seller_memo");
  4384. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4385. string supplier = GetPostString("supplier");
  4386. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4387. string OrderArea = GetPostString("order_area");
  4388. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4389. string date1 = GetPostString("date1");
  4390. string date2 = GetPostString("date2");
  4391. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4392. if (dw.Length > 0) lw.Add(dw);
  4393. string price1 = GetPostString("price1");
  4394. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4395. string price2 = GetPostString("price2");
  4396. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4397. string posTag = CurrentUser.UserPost.Post.Code;
  4398. if (posTag == "Supplier")
  4399. {
  4400. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4401. }
  4402. //lw.Add(string.Format("OrderState = 6 "));
  4403. lw.Add(string.Format("IsSample={0}", 3));
  4404. lw.Add(string.Format("IsRefund<={0}", 1));
  4405. dStruct.Order = "pay_time desc";
  4406. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4407. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4408. writeGridDataTableJson(dStruct.TotalCount, dt);
  4409. }
  4410. public void save_erp_checkmemo()
  4411. {
  4412. if (UrlPostParmsCheck("ctid"))
  4413. {
  4414. string ctid = GetPostString("ctid");
  4415. CeErpTradeCell entity = null;
  4416. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4417. if (entity != null)
  4418. {
  4419. entity.CheckMemo = GetPostString("CheckMemo");
  4420. entity.Update();
  4421. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4422. if (trade != null)
  4423. {
  4424. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4425. }
  4426. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4427. returnSuccessMsg("保存成功!");
  4428. return;
  4429. }
  4430. returnErrorMsg("找不到记录");
  4431. }
  4432. }
  4433. public void get_erp_returnlist()
  4434. {
  4435. DataStruct dStruct = GetPostStruct();
  4436. List<string> lw = new List<string>();
  4437. string tid = GetPostString("ctid");
  4438. if (tid.Length > 0)
  4439. {
  4440. string select_tid = getTidByCtid(tid);
  4441. lw.Add(string.Format("tid='{0}'", select_tid));
  4442. }
  4443. string shopname = GetPostString("shopname");
  4444. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4445. string buyernick = GetPostString("buyer_nick");
  4446. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4447. string customer = GetPostString("customer");
  4448. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4449. string design = GetPostString("design");
  4450. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4451. string orderState = GetPostString("orderState");
  4452. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4453. string address = GetPostString("address");
  4454. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4455. string sellermemo = GetPostString("seller_memo");
  4456. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4457. string supplier = GetPostString("supplier");
  4458. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4459. string date1 = GetPostString("date1");
  4460. string date2 = GetPostString("date2");
  4461. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4462. if (dw.Length > 0) lw.Add(dw);
  4463. string bdate1 = GetPostString("backdate1");
  4464. string bdate2 = GetPostString("backdate2");
  4465. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4466. if (dw_back.Length > 0) lw.Add(dw_back);
  4467. string price1 = GetPostString("price1");
  4468. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4469. string price2 = GetPostString("price2");
  4470. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4471. lw.Add(string.Format("IsReturn>0"));
  4472. lw.Add(string.Format("IsXianHuo=0"));
  4473. lw.Add(string.Format("IsReturn!=3"));
  4474. string backtype = GetPostString("backtype");
  4475. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4476. dStruct.Order = "FinishDesignTime desc";
  4477. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4478. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4479. writeGridDataTableJson(dStruct.TotalCount, dt);
  4480. }
  4481. public void get_erp_today_sumreturn()
  4482. {
  4483. DataStruct dStruct = GetPostStruct();
  4484. List<string> lw = new List<string>();
  4485. string bdate1 = GetPostString("returnTimeS");
  4486. string bdate2 = GetPostString("returnTimeE");
  4487. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4488. if (dw_back.Length > 0) lw.Add(dw_back);
  4489. lw.Add(string.Format("IsReturn=0"));
  4490. lw.Add(string.Format("IsXianHuo=0"));
  4491. string mainWhere = string.Join(" and ", lw.ToArray());
  4492. string sql = "";
  4493. if (dw_back.Length > 0)
  4494. {
  4495. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4496. }
  4497. else
  4498. {
  4499. 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 + "'";
  4500. }
  4501. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4502. decimal total = 0, today_finish = 0;
  4503. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4504. {
  4505. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4506. }
  4507. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4508. {
  4509. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4510. }
  4511. var res = new
  4512. {
  4513. data = total,
  4514. data1 = today_finish,
  4515. };
  4516. string ro_jsond = JsonConvert.SerializeObject(res);
  4517. returnSuccess(ro_jsond);
  4518. return;
  4519. }
  4520. public void get_erp_allreturnlist()
  4521. {
  4522. DataStruct dStruct = GetPostStruct();
  4523. List<string> lw = new List<string>();
  4524. string tid = GetPostString("ctid");
  4525. if (tid.Length > 0)
  4526. {
  4527. string select_tid = getTidByCtid(tid);
  4528. lw.Add(string.Format("tid='{0}'", select_tid));
  4529. }
  4530. string shopname = GetPostString("shopname");
  4531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4532. string buyernick = GetPostString("buyer_nick");
  4533. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4534. string customer = GetPostString("customer");
  4535. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4536. string design = GetPostString("design");
  4537. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4538. string orderState = GetPostString("orderState");
  4539. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4540. string address = GetPostString("address");
  4541. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4542. string sellermemo = GetPostString("seller_memo");
  4543. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4544. string supplier = GetPostString("supplier");
  4545. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4546. string date1 = GetPostString("date1");
  4547. string date2 = GetPostString("date2");
  4548. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4549. if (dw.Length > 0) lw.Add(dw);
  4550. string bdate1 = GetPostString("backdate1");
  4551. string bdate2 = GetPostString("backdate2");
  4552. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4553. if (dw_back.Length > 0) lw.Add(dw_back);
  4554. string price1 = GetPostString("price1");
  4555. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4556. string price2 = GetPostString("price2");
  4557. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4558. string backreason = GetPostString("backreason");
  4559. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4560. lw.Add(string.Format("IsXianHuo=0"));
  4561. lw.Add(string.Format("ReturnTime != ''"));
  4562. string backtype = GetPostString("backtype");
  4563. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4564. dStruct.Order = "FinishDesignTime desc";
  4565. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4566. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4567. writeGridDataTableJson(dStruct.TotalCount, dt);
  4568. }
  4569. public void get_erp_aftersalereturnlist()
  4570. {
  4571. DataStruct dStruct = GetPostStruct();
  4572. List<string> lw = new List<string>();
  4573. string tid = GetPostString("ctid");
  4574. if (tid.Length > 0)
  4575. {
  4576. string select_tid = getTidByCtid(tid);
  4577. lw.Add(string.Format("tid='{0}'", select_tid));
  4578. }
  4579. string shopname = GetPostString("shopname");
  4580. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4581. string buyernick = GetPostString("buyer_nick");
  4582. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4583. string customer = GetPostString("customer");
  4584. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4585. string design = GetPostString("design");
  4586. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4587. string orderState = GetPostString("orderState");
  4588. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4589. string address = GetPostString("address");
  4590. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4591. string sellermemo = GetPostString("seller_memo");
  4592. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4593. string supplier = GetPostString("supplier");
  4594. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4595. string date1 = GetPostString("date1");
  4596. string date2 = GetPostString("date2");
  4597. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4598. if (dw.Length > 0) lw.Add(dw);
  4599. string bdate1 = GetPostString("backdate1");
  4600. string bdate2 = GetPostString("backdate2");
  4601. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4602. if (dw_back.Length > 0) lw.Add(dw_back);
  4603. string price1 = GetPostString("price1");
  4604. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4605. string price2 = GetPostString("price2");
  4606. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4607. lw.Add(string.Format("IsReturn=3"));
  4608. string backtype = GetPostString("backtype");
  4609. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4610. string backreason = GetPostString("backreason");
  4611. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4612. dStruct.Order = "ReturnTime desc";
  4613. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4614. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4615. writeGridDataTableJson(dStruct.TotalCount, dt);
  4616. }
  4617. public void get_erp_xianhuoreturnlist()
  4618. {
  4619. DataStruct dStruct = GetPostStruct();
  4620. List<string> lw = new List<string>();
  4621. string tid = GetPostString("ctid");
  4622. if (tid.Length > 0)
  4623. {
  4624. string select_tid = getTidByCtid(tid);
  4625. lw.Add(string.Format("tid='{0}'", select_tid));
  4626. }
  4627. string shopname = GetPostString("shopname");
  4628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4629. string buyernick = GetPostString("buyer_nick");
  4630. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4631. string customer = GetPostString("customer");
  4632. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4633. string design = GetPostString("design");
  4634. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4635. string orderState = GetPostString("orderState");
  4636. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4637. string address = GetPostString("address");
  4638. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4639. string sellermemo = GetPostString("seller_memo");
  4640. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4641. string supplier = GetPostString("supplier");
  4642. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4643. string OrderArea = GetPostString("order_area");
  4644. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4645. string date1 = GetPostString("date1");
  4646. string date2 = GetPostString("date2");
  4647. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4648. if (dw.Length > 0) lw.Add(dw);
  4649. string price1 = GetPostString("price1");
  4650. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4651. string price2 = GetPostString("price2");
  4652. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4653. string posTag = CurrentUser.UserPost.Post.Code;
  4654. if (posTag == "Supplier")
  4655. {
  4656. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4657. }
  4658. lw.Add(string.Format("OrderState=6 "));
  4659. lw.Add(string.Format("IsXianHuo=1 "));
  4660. lw.Add(string.Format("IsReturn>0 "));
  4661. lw.Add(string.Format("IsReturn!=3"));
  4662. lw.Add(string.Format("IsRefund<={0}", 1));
  4663. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4664. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4665. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4666. writeGridDataTableJson(dStruct.TotalCount, dt);
  4667. }
  4668. public void set_erp_orderdelivery()
  4669. {
  4670. if (UrlPostParmsCheck("ctid"))
  4671. {
  4672. string eid = GetPostString("ctid");
  4673. CeErpTradeCell entity = null;
  4674. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4675. if (entity != null)
  4676. {
  4677. if (entity.OrderState >= 7)
  4678. {
  4679. returnErrorMsg("此单已发货,无需重复发货");
  4680. return;
  4681. }
  4682. if (entity.OrderState != 6)
  4683. {
  4684. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4685. return;
  4686. }
  4687. string shop = GetPostString("seller_nick");
  4688. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4689. string comName = GetPostString("comName");
  4690. string comCode = GetPostString("comCode");
  4691. string outSid = GetPostString("outSid");
  4692. string deliveryType = GetPostString("deliveryType");
  4693. string deliveryMemo = GetPostString("deliveryMemo");
  4694. outSid = outSid.Trim();
  4695. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4696. if (mainEn == null)
  4697. {
  4698. returnErrorMsg("找不到原始订单记录");
  4699. return;
  4700. }
  4701. bool isInitOrderDeliv = false;
  4702. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4703. {
  4704. isInitOrderDeliv = true;
  4705. }
  4706. string apires = "";
  4707. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4708. 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)
  4709. {
  4710. apires = "发货成功true";
  4711. }
  4712. else
  4713. {
  4714. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4715. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4716. }
  4717. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4718. {
  4719. entity.OrderState = 7;//发货后订单已发货
  4720. entity.OutSid = outSid;
  4721. entity.MemoOpt = 0;
  4722. entity.UpdateTime = DateTime.Now;
  4723. entity.FinishDeliveryTime = DateTime.Now;
  4724. entity.Update();
  4725. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4726. commonHelper.UpdateRelationOrder(entity.ctid);
  4727. //还要插入快递信息到 快递信息表
  4728. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4729. exinfo.tid = eid;
  4730. exinfo.out_sid = outSid;
  4731. exinfo.company_code = comCode;
  4732. exinfo.company_name = comName;
  4733. exinfo.delivery_memo = deliveryMemo;
  4734. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4735. exinfo.deliveryType = deliveryType;
  4736. exinfo.Create();
  4737. returnSuccessMsg("发货操作成功!");
  4738. commonHelper.UpdateRelationOrder(entity.ctid);
  4739. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4740. CeErpSukuraData.createInfo(entity.ctid, 4);
  4741. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4742. {
  4743. commonHelper.sendCytExpress(exinfo);
  4744. }
  4745. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4746. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4747. }
  4748. else
  4749. {
  4750. string errmsg = commonHelper.KeepChinese(apires);
  4751. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4752. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4753. }
  4754. return;
  4755. }
  4756. returnErrorMsg("找不到订单记录");
  4757. }
  4758. }
  4759. public void set_erp_multidelivery()
  4760. {
  4761. string eids = GetPostString("tids");
  4762. string[] eidList = eids.Split(',');
  4763. if (eidList.Length <= 0)
  4764. {
  4765. returnErrorMsg("发货不能为空");
  4766. return;
  4767. }
  4768. foreach (string ctid in eidList)
  4769. {
  4770. if (ctid.Length <= 0) continue;
  4771. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4772. if (expInfo != null)
  4773. {
  4774. StringBuilder sql = new StringBuilder();
  4775. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4776. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4777. if (dt.Rows.Count > 0)
  4778. {
  4779. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4780. {
  4781. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4782. expInfo.state = "异常";
  4783. expInfo.isMultiDelivery = 1;
  4784. expInfo.Update();
  4785. continue;
  4786. }
  4787. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4788. {
  4789. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4790. expInfo.state = "异常";
  4791. expInfo.Update();
  4792. continue;
  4793. }
  4794. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4795. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4796. bool isInitOrderDeliv = false;
  4797. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4798. {
  4799. isInitOrderDeliv = true;
  4800. expInfo.isMultiDelivery = 1;
  4801. }
  4802. if (ctid.IndexOf("N") != -1)
  4803. {
  4804. StringBuilder sqlbucha = new StringBuilder();
  4805. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4806. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4807. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4808. commonHelper.UpdateRelationOrder(ctid);
  4809. expInfo.delivery_memo = "发货成功";
  4810. expInfo.state = "发货成功";
  4811. expInfo.isMultiDelivery = 1;
  4812. expInfo.Update();
  4813. }
  4814. else
  4815. {
  4816. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4817. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4818. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4819. {
  4820. expInfo.delivery_memo = "发货成功";
  4821. expInfo.state = "发货成功";
  4822. expInfo.isMultiDelivery = 1;
  4823. expInfo.Update();
  4824. commonHelper.UpdateRelationOrder(ctid);
  4825. CeErpSukuraData.createInfo(ctid, 4);
  4826. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4827. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4828. }
  4829. else
  4830. {
  4831. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4832. expInfo.state = "异常";
  4833. expInfo.Update();
  4834. }
  4835. }
  4836. }
  4837. }
  4838. }
  4839. returnSuccessMsg("操作完成");
  4840. }
  4841. public void reset_erp_memoopt()
  4842. {
  4843. if (UrlPostParmsCheck("ctid"))
  4844. {
  4845. string eid = GetPostString("ctid");
  4846. CeErpTradeCell entity = null;
  4847. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4848. if (entity != null)
  4849. {
  4850. string stropt = "";
  4851. if (entity.MemoOpt == 1)
  4852. {
  4853. stropt = "“改稿”";
  4854. }
  4855. else if (entity.MemoOpt == 2)
  4856. {
  4857. stropt = "“定稿”";
  4858. }
  4859. else if (entity.MemoOpt == 3)
  4860. {
  4861. stropt = "“完成查货”";
  4862. CeErpSukuraData.createInfo(entity.ctid, 6);
  4863. }
  4864. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4865. entity.UpdateTime = DateTime.Now;
  4866. entity.MemoOpt = 0;
  4867. entity.Update();
  4868. returnSuccessMsg("操作成功!");
  4869. return;
  4870. }
  4871. returnErrorMsg("找不到记录");
  4872. }
  4873. }
  4874. public void get_erp_deliveryunusual()
  4875. {
  4876. DataStruct dStruct = GetPostStruct();
  4877. List<string> lw = new List<string>();
  4878. string tid = GetPostString("ctid");
  4879. if (tid.Length > 0)
  4880. {
  4881. string select_tid = getTidByCtid(tid);
  4882. lw.Add(string.Format("tid='{0}'", select_tid));
  4883. }
  4884. string shopname = GetPostString("shopname");
  4885. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4886. string buyernick = GetPostString("buyer_nick");
  4887. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4888. string customer = GetPostString("customer");
  4889. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4890. string design = GetPostString("design");
  4891. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4892. string sellermemo = GetPostString("seller_memo");
  4893. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4894. string supplier = GetPostString("supplier");
  4895. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4896. string date1 = GetPostString("date1");
  4897. string date2 = GetPostString("date2");
  4898. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4899. if (dw.Length > 0) lw.Add(dw);
  4900. string placedate1 = GetPostString("placedate1");
  4901. string placedate2 = GetPostString("placedate2");
  4902. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4903. if (dw_place.Length > 0) lw.Add(dw_place);
  4904. string price1 = GetPostString("price1");
  4905. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4906. string price2 = GetPostString("price2");
  4907. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4908. string unusualCon = GetPostString("unusualcon");
  4909. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4910. string posTag = CurrentUser.UserPost.Post.Code;
  4911. if (posTag == "Supplier")
  4912. {
  4913. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4914. }
  4915. lw.Add(string.Format("OrderState = 6"));
  4916. lw.Add(string.Format("UnusualTag = 5"));
  4917. lw.Add(string.Format("IsRefund<={0}", 1));
  4918. dStruct.Order = "FinishPlaceTime desc";
  4919. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4920. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4921. writeGridDataTableJson(dStruct.TotalCount, dt);
  4922. }
  4923. public void get_erp_deliveryedlist()
  4924. {
  4925. DataStruct dStruct = GetPostStruct();
  4926. List<string> lw = new List<string>();
  4927. string tid = GetPostString("ctid");
  4928. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4929. string shopname = GetPostString("shopname");
  4930. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4931. string buyernick = GetPostString("buyer_nick");
  4932. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4933. string customer = GetPostString("customer");
  4934. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4935. string design = GetPostString("design");
  4936. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4937. string sellermemo = GetPostString("seller_memo");
  4938. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4939. string logistics = GetPostString("logistics");
  4940. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4941. string date1 = GetPostString("date1");
  4942. string date2 = GetPostString("date2");
  4943. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4944. //if (dw.Length > 0) lw.Add(dw);
  4945. string placedate1 = GetPostString("placedate1");
  4946. string placedate2 = GetPostString("placedate2");
  4947. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4948. if (fdw.Length > 0) lw.Add(fdw);
  4949. string devdate1 = GetPostString("deliverydate1");
  4950. string devdate2 = GetPostString("deliverydate2");
  4951. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4952. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4953. string price1 = GetPostString("price1");
  4954. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4955. string price2 = GetPostString("price2");
  4956. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4957. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4958. {
  4959. if (tid.Length > 0)
  4960. {
  4961. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4962. if (tid.Length > 5)
  4963. {
  4964. List<string> tids = getTidByCtidLike(tid);
  4965. if (tids.Count > 0 && tids.Count < 10)
  4966. {
  4967. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4968. }
  4969. }
  4970. lw.Add(tid_sql);
  4971. }
  4972. if (buyernick.Length > 0)
  4973. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4974. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4975. if (dw.Length > 0) lw.Add(dw);
  4976. }
  4977. else
  4978. {
  4979. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4980. }
  4981. string posTag = CurrentUser.UserPost.Post.Code;
  4982. if (posTag == "Supplier")
  4983. {
  4984. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4985. }
  4986. else
  4987. {
  4988. string supplier = GetPostString("supplier");
  4989. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4990. }
  4991. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4992. lw.Add(string.Format("type != 'PDD' "));
  4993. lw.Add(string.Format("IsRefund!={0}", 2));
  4994. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4995. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4996. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4997. /*if (tid.Length > 0)
  4998. {
  4999. List<string> tids = new List<string>();
  5000. if (dt != null && dt.Rows.Count > 0)
  5001. {
  5002. foreach (DataRow item in dt.Rows)
  5003. {
  5004. tids.Add("'" + item["tid"] + "'");
  5005. }
  5006. }
  5007. if (tids.Count > 0)
  5008. {
  5009. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5010. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5011. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5012. dt = WebCache.GetData("view_erptradecell", dStruct);
  5013. }
  5014. }*/
  5015. if (dt != null)
  5016. {
  5017. foreach (DataRow dr in dt.Rows)
  5018. {
  5019. 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();
  5020. }
  5021. }
  5022. writeGridDataTableJson(dStruct.TotalCount, dt);
  5023. }
  5024. public void get_erp_pdddeliveryed()
  5025. {
  5026. DataStruct dStruct = GetPostStruct();
  5027. List<string> lw = new List<string>();
  5028. string tid = GetPostString("ctid");
  5029. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5030. string shopname = GetPostString("shopname");
  5031. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5032. string buyernick = GetPostString("buyer_nick");
  5033. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5034. string customer = GetPostString("customer");
  5035. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5036. string design = GetPostString("design");
  5037. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5038. string sellermemo = GetPostString("seller_memo");
  5039. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5040. string logistics = GetPostString("logistics");
  5041. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5042. string date1 = GetPostString("date1");
  5043. string date2 = GetPostString("date2");
  5044. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5045. //if (dw.Length > 0) lw.Add(dw);
  5046. string placedate1 = GetPostString("placedate1");
  5047. string placedate2 = GetPostString("placedate2");
  5048. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5049. if (fdw.Length > 0) lw.Add(fdw);
  5050. string devdate1 = GetPostString("deliverydate1");
  5051. string devdate2 = GetPostString("deliverydate2");
  5052. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5053. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5054. string price1 = GetPostString("price1");
  5055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5056. string price2 = GetPostString("price2");
  5057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5058. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5059. {
  5060. if (tid.Length > 0)
  5061. {
  5062. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5063. if (tid.Length > 5)
  5064. {
  5065. List<string> tids = getTidByCtidLike(tid);
  5066. if (tids.Count > 0 && tids.Count < 10)
  5067. {
  5068. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5069. }
  5070. }
  5071. lw.Add(tid_sql);
  5072. }
  5073. if (buyernick.Length > 0)
  5074. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5075. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5076. if (dw.Length > 0) lw.Add(dw);
  5077. }
  5078. else
  5079. {
  5080. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5081. }
  5082. string posTag = CurrentUser.UserPost.Post.Code;
  5083. if (posTag == "Supplier")
  5084. {
  5085. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5086. }
  5087. else
  5088. {
  5089. string supplier = GetPostString("supplier");
  5090. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5091. }
  5092. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5093. lw.Add(string.Format("type = 'PDD' "));
  5094. lw.Add(string.Format("IsRefund!={0}", 2));
  5095. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5096. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5097. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5098. /* if (tid.Length > 0)
  5099. {
  5100. List<string> tids = new List<string>();
  5101. if (dt != null && dt.Rows.Count > 0)
  5102. {
  5103. foreach (DataRow item in dt.Rows)
  5104. {
  5105. tids.Add("'" + item["tid"] + "'");
  5106. }
  5107. }
  5108. if (tids.Count > 0)
  5109. {
  5110. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5111. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5112. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5113. dt = WebCache.GetData("view_erptradecell", dStruct);
  5114. }
  5115. }*/
  5116. foreach (DataRow dr in dt.Rows)
  5117. {
  5118. 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();
  5119. }
  5120. writeGridDataTableJson(dStruct.TotalCount, dt);
  5121. }
  5122. public void get_erp_jddeliveryed()
  5123. {
  5124. DataStruct dStruct = GetPostStruct();
  5125. List<string> lw = new List<string>();
  5126. string tid = GetPostString("ctid");
  5127. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5128. string shopname = GetPostString("shopname");
  5129. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5130. string buyernick = GetPostString("buyer_nick");
  5131. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5132. string customer = GetPostString("customer");
  5133. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5134. string design = GetPostString("design");
  5135. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5136. string sellermemo = GetPostString("seller_memo");
  5137. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5138. string date1 = GetPostString("date1");
  5139. string date2 = GetPostString("date2");
  5140. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5141. //if (dw.Length > 0) lw.Add(dw);
  5142. string placedate1 = GetPostString("placedate1");
  5143. string placedate2 = GetPostString("placedate2");
  5144. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5145. if (fdw.Length > 0) lw.Add(fdw);
  5146. string devdate1 = GetPostString("deliverydate1");
  5147. string devdate2 = GetPostString("deliverydate2");
  5148. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5149. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5150. string price1 = GetPostString("price1");
  5151. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5152. string price2 = GetPostString("price2");
  5153. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5154. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5155. {
  5156. if (tid.Length > 0)
  5157. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5158. if (buyernick.Length > 0)
  5159. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5160. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5161. if (dw.Length > 0) lw.Add(dw);
  5162. }
  5163. else
  5164. {
  5165. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5166. }
  5167. string posTag = CurrentUser.UserPost.Post.Code;
  5168. if (posTag == "Supplier")
  5169. {
  5170. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5171. }
  5172. else
  5173. {
  5174. string supplier = GetPostString("supplier");
  5175. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5176. }
  5177. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5178. lw.Add(string.Format("type = 'JD' "));
  5179. lw.Add(string.Format("IsRefund!={0}", 2));
  5180. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5182. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5183. foreach (DataRow dr in dt.Rows)
  5184. {
  5185. 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();
  5186. }
  5187. writeGridDataTableJson(dStruct.TotalCount, dt);
  5188. }
  5189. public void get_erp_allplacelist()
  5190. {
  5191. DataStruct dStruct = GetPostStruct();
  5192. List<string> lw = new List<string>();
  5193. string tid = GetPostString("ctid");
  5194. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5195. string shopname = GetPostString("shopname");
  5196. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5197. string buyernick = GetPostString("buyer_nick");
  5198. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5199. string customer = GetPostString("customer");
  5200. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5201. string design = GetPostString("design");
  5202. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5203. string sellermemo = GetPostString("seller_memo");
  5204. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5205. string supplier = GetPostString("supplier");
  5206. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5207. string date1 = GetPostString("date1");
  5208. string date2 = GetPostString("date2");
  5209. string pldate1 = GetPostString("placedate1");
  5210. string pldate2 = GetPostString("placedate2");
  5211. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5212. //if (dw.Length > 0) lw.Add(dw);
  5213. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5214. {
  5215. if (tid.Length > 0)
  5216. {
  5217. string select_tid = getTidByCtid(tid);
  5218. lw.Add(string.Format("tid='{0}'", select_tid));
  5219. }
  5220. if (buyernick.Length > 0)
  5221. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5222. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5223. if (dw.Length > 0) lw.Add(dw);
  5224. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5225. if (dw_place.Length > 0) lw.Add(dw_place);
  5226. }
  5227. else
  5228. {
  5229. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5230. {
  5231. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5232. }
  5233. }
  5234. string price1 = GetPostString("price1");
  5235. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5236. string price2 = GetPostString("price2");
  5237. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5238. string posTag = CurrentUser.UserPost.Post.Code;
  5239. if (posTag == "Supplier")
  5240. {
  5241. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5242. }
  5243. lw.Add(string.Format("OrderState >= 6"));
  5244. lw.Add(string.Format("IsSample != 2 "));
  5245. //lw.Add(string.Format("isDianziOrder = 0 "));
  5246. lw.Add(string.Format("SupplierId > 0 "));
  5247. //lw.Add(string.Format("IsRefund<={0}", 1));
  5248. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5249. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5250. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5251. foreach (DataRow dr in dt.Rows)
  5252. {
  5253. 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();
  5254. }
  5255. writeGridDataTableJson(dStruct.TotalCount, dt);
  5256. }
  5257. public void get_erp_financeallplacelist()
  5258. {
  5259. DataStruct dStruct = GetPostStruct();
  5260. List<string> lw = new List<string>();
  5261. string tid = GetPostString("ctid");
  5262. string shopname = GetPostString("shopname");
  5263. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5264. string buyernick = GetPostString("buyer_nick");
  5265. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5266. string customer = GetPostString("customer");
  5267. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5268. string design = GetPostString("design");
  5269. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5270. string sellermemo = GetPostString("seller_memo");
  5271. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5272. string supplier = GetPostString("supplier");
  5273. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5274. string date1 = GetPostString("date1");
  5275. string date2 = GetPostString("date2");
  5276. string pldate1 = GetPostString("placedate1");
  5277. string pldate2 = GetPostString("placedate2");
  5278. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5279. {
  5280. if (tid.Length > 0)
  5281. {
  5282. string select_tid = getTidByCtid(tid);
  5283. lw.Add(string.Format("tid='{0}'", select_tid));
  5284. }
  5285. if (buyernick.Length > 0)
  5286. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5287. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5288. if (dw.Length > 0) lw.Add(dw);
  5289. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5290. if (dw_place.Length > 0) lw.Add(dw_place);
  5291. }
  5292. else
  5293. {
  5294. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5295. {
  5296. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5297. }
  5298. }
  5299. string price1 = GetPostString("price1");
  5300. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5301. string price2 = GetPostString("price2");
  5302. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5303. string posTag = CurrentUser.UserPost.Post.Code;
  5304. if (posTag == "Supplier")
  5305. {
  5306. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5307. }
  5308. //lw.Add(string.Format("OrderState >= 6"));
  5309. lw.Add(string.Format("IsSample != 2 "));
  5310. lw.Add(string.Format("isDianziOrder = 0 "));
  5311. //lw.Add(string.Format("IsRefund<={0}", 1));
  5312. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5313. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5314. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5315. foreach (DataRow dr in dt.Rows)
  5316. {
  5317. 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();
  5318. }
  5319. writeGridDataTableJson(dStruct.TotalCount, dt);
  5320. }
  5321. public void get_erp_expresslist()
  5322. {
  5323. int listtype = GetInt("ltype");
  5324. DataStruct dStruct = GetPostStruct();
  5325. List<string> lw = new List<string>();
  5326. string tid = GetPostString("tid");
  5327. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5328. string outsid = GetPostString("out_sid");
  5329. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5330. string importer = GetPostString("ImportUserName");
  5331. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5332. string file = GetPostString("import_file");
  5333. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5334. string printman = GetPostString("printman");
  5335. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5336. string date1 = GetPostString("date1");
  5337. string date2 = GetPostString("date2");
  5338. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5339. if (dw.Length > 0) lw.Add(dw);
  5340. string fdate1 = GetPostString("finishdate1");
  5341. string fdate2 = GetPostString("finishdate2");
  5342. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5343. if (fdw.Length > 0) lw.Add(fdw);
  5344. string supplierId = GetPostString("supplierId");
  5345. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5346. if (listtype == 1)
  5347. {
  5348. lw.Add(string.Format("importUserId !=0"));
  5349. }
  5350. string posTag = CurrentUser.UserPost.Post.Code;
  5351. if (posTag == "Supplier")
  5352. {
  5353. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5354. }
  5355. if (dStruct.PageSize != 100000)
  5356. {
  5357. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5358. }
  5359. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5360. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5361. writeGridDataTableJson(dStruct.TotalCount, dt);
  5362. }
  5363. public void set_erp_buchaorderdelivery()
  5364. {
  5365. if (UrlPostParmsCheck("ctid"))
  5366. {
  5367. string eid = GetPostString("ctid");
  5368. CeErpTradeCell entity = null;
  5369. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5370. if (entity != null)
  5371. {
  5372. if (entity.IsSample != 2)
  5373. {
  5374. returnErrorMsg("补差价单才能标记为已发货");
  5375. return;
  5376. }
  5377. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5378. entity.OrderState = 7;
  5379. entity.Update();
  5380. returnSuccessMsg("操作成功!");
  5381. return;
  5382. }
  5383. returnErrorMsg("找不到记录");
  5384. }
  5385. }
  5386. public void get_stdtemplates()
  5387. {
  5388. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5389. //string res = taobaoHelper.test();
  5390. string res = apiHelper.API_PrintTemplate();
  5391. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5392. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5393. {
  5394. int sidx = res.IndexOf("error_code");
  5395. int eidx = res.IndexOf("success");
  5396. string msg = res.Substring(sidx, eidx - sidx);
  5397. returnErrorMsg(msg);
  5398. return;
  5399. }
  5400. if (res.Length <= 0)
  5401. {
  5402. returnErrorMsg("模板数据为空!");
  5403. return;
  5404. }
  5405. ReturnSuccess(res);
  5406. }
  5407. public void cancel_print_order()
  5408. {
  5409. if (UrlPostParmsCheck("ctid"))
  5410. {
  5411. string ctid = GetPostString("ctid");
  5412. CeErpTradeCell entity = null;
  5413. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5414. if (entity != null)
  5415. {
  5416. string res = "";
  5417. string code = entity.LastBillWaybillCode;
  5418. if (code == "")
  5419. {
  5420. code = entity.OutSid;
  5421. }
  5422. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5423. XLog.SaveLog(0, "取消面单" + res);
  5424. }
  5425. }
  5426. }
  5427. public void set_erp_printwaybill()
  5428. {
  5429. if (UrlPostParmsCheck("ctid"))
  5430. {
  5431. string ctid = GetPostString("ctid");
  5432. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5433. string cpName = GetPostString("cpname");
  5434. string isTogether = GetPostString("together");
  5435. string printType = GetPostString("printType");
  5436. //var res_obj = new
  5437. //{
  5438. // restype = 1,
  5439. // 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\"}"
  5440. //};
  5441. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5442. //ReturnSuccess(ro_json);
  5443. //return;
  5444. bool isUseLastWayBillCode = false;
  5445. CeErpTradeCell entity = null;
  5446. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5447. if (entity != null)
  5448. {
  5449. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5450. {
  5451. isUseLastWayBillCode = true;
  5452. }
  5453. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5454. {
  5455. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5456. return;
  5457. }
  5458. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5459. {
  5460. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5461. return;
  5462. }
  5463. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5464. {
  5465. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5466. return;
  5467. }
  5468. }
  5469. string res = "";
  5470. Api_waybill_code_response_Obj fullObj = null;
  5471. string pData_str = "";
  5472. string curUseWayBillCode = "";
  5473. if (isUseLastWayBillCode == false)
  5474. {
  5475. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5476. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5477. if (res.IndexOf("failure") != -1)
  5478. {
  5479. //int idx = res.IndexOf("sub_message");
  5480. //int idx2 = res.IndexOf("flag");
  5481. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5482. string errMsgNeed = commonHelper.KeepChinese(res);
  5483. var res_objd = new
  5484. {
  5485. restype = 0,
  5486. data = "获取面单失败" + errMsgNeed
  5487. };
  5488. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5489. returnSuccess(ro_jsond);
  5490. if (res.IndexOf("停发") != -1)
  5491. {
  5492. entity.UnusualCon = "物流停发";
  5493. entity.Update();
  5494. }
  5495. //returnErrorMsg("获取面单失败,"+emsg);
  5496. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5497. return;
  5498. }
  5499. else if (res.IndexOf("errorMsg") != -1)
  5500. {
  5501. //int idx = res.IndexOf("errorMsg");
  5502. //int idx2 = res.IndexOf("}]}");
  5503. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5504. string errMsgNeed = commonHelper.KeepChinese(res);
  5505. var res_objf = new
  5506. {
  5507. restype = 0,
  5508. data = "获取面单失败2" + errMsgNeed
  5509. };
  5510. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5511. if (res.IndexOf("停发") != -1)
  5512. {
  5513. entity.UnusualCon = "物流停发";
  5514. entity.Update();
  5515. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5516. if (trade != null)
  5517. {
  5518. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5519. }
  5520. }
  5521. returnSuccess(ro_jsonf);
  5522. //returnErrorMsg("获取面单失败," + emsg);
  5523. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5524. return;
  5525. }
  5526. try
  5527. {
  5528. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5529. //res = res.Replace(" ", "");
  5530. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5531. }
  5532. catch (Exception ex)
  5533. {
  5534. XLog.SaveLog(0, "生成fullObj" + res);
  5535. var res_objf = new
  5536. {
  5537. restype = 0,
  5538. data = "生成fullObj发生错误" + ex.Message
  5539. };
  5540. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5541. returnSuccess(ro_jsonf);
  5542. return;
  5543. }
  5544. if (fullObj.response.data.content.Count > 0)
  5545. {
  5546. ContentItem codeObj = fullObj.response.data.content[0];
  5547. if (cpCode.IndexOf("SFFQ-") != -1)
  5548. {
  5549. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5550. }
  5551. else
  5552. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5553. curUseWayBillCode = codeObj.waybillCode;
  5554. }
  5555. else
  5556. {
  5557. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5558. var res_objf = new
  5559. {
  5560. restype = 0,
  5561. data = "生成fullObj找不到快递单号waybillCode"
  5562. };
  5563. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5564. returnSuccess(ro_jsonf);
  5565. return;
  5566. }
  5567. }
  5568. else
  5569. {
  5570. //使用上次打印的快递单号
  5571. if (cpCode == "SFFQ-LY")
  5572. {
  5573. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5574. }
  5575. else
  5576. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5577. curUseWayBillCode = entity.LastBillWaybillCode;
  5578. }
  5579. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5580. {
  5581. var res_obje = new
  5582. {
  5583. restype = 0,
  5584. data = "获取加密打印数据失败"
  5585. };
  5586. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5587. returnSuccess(ro_jsone);
  5588. entity.LastBillCpCode = cpCode;
  5589. entity.LastBillWaybillCode = curUseWayBillCode;
  5590. entity.Update();
  5591. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5592. //returnErrorMsg("获取加密打印数据失败");
  5593. return;
  5594. }
  5595. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5596. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5597. string btnType = "";
  5598. string errorMsg = "";
  5599. if (entity != null)
  5600. {
  5601. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5602. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5603. //cpcode是 YTO-CAINIAO
  5604. //string comCode = cpCode.Split('-')[0].ToString();
  5605. string apires = "";
  5606. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5607. //isTogether=2是新的合包弹窗
  5608. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5609. {
  5610. if (ctid.IndexOf("N") != -1)
  5611. {
  5612. apires = "发货成功";
  5613. }
  5614. else
  5615. {
  5616. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5617. }
  5618. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5619. //打单后发货
  5620. StringBuilder sql = new StringBuilder();
  5621. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5622. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5623. {
  5624. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5625. }
  5626. else
  5627. {
  5628. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5629. }
  5630. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5631. foreach (DataRow row in dt.Rows)
  5632. {
  5633. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5634. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5635. {
  5636. try
  5637. {
  5638. btnType = "待发货";
  5639. entity.OutSid = curUseWayBillCode;
  5640. entity.OrderState = 7;
  5641. entity.IsUrgency = false;
  5642. entity.LastBillCpCode = "";
  5643. entity.LastBillWaybillCode = "";
  5644. entity.FinishDeliveryTime = DateTime.Now;
  5645. entity.IsReturn = 0;
  5646. entity.MemoOpt = 0;
  5647. entity.UpdateTime = DateTime.Now;
  5648. entity.Update();
  5649. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5650. //还要插入快递信息到 快递信息表
  5651. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5652. exinfo.tid = entity.ctid;
  5653. exinfo.out_sid = curUseWayBillCode;
  5654. exinfo.company_code = cpCode;
  5655. exinfo.company_name = cpName;
  5656. exinfo.supplierUserName = supplierName;
  5657. exinfo.deliveryType = "发货成功";
  5658. exinfo.print_time = DateTime.Now;
  5659. exinfo.printUser = CurrentUser.UserName;
  5660. exinfo.postData = pData_str;
  5661. exinfo.Create();
  5662. commonHelper.UpdateRelationOrder(entity.ctid);
  5663. CeErpSukuraData.createInfo(ctid, 4);
  5664. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5665. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5666. {
  5667. commonHelper.sendCytExpress(exinfo);
  5668. }
  5669. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5670. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5671. }
  5672. catch (Exception ex)
  5673. {
  5674. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5675. }
  5676. }
  5677. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5678. {
  5679. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5680. if (entity.OrderState == 6)
  5681. {
  5682. entity.OrderState = 7;
  5683. }
  5684. entity.UpdateTime = DateTime.Now;
  5685. entity.FinishDeliveryTime = DateTime.Now;
  5686. btnType = "已发货";
  5687. entity.Update();
  5688. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5689. exinfo.tid = entity.ctid;
  5690. exinfo.out_sid = curUseWayBillCode;
  5691. exinfo.company_code = cpCode;
  5692. exinfo.company_name = cpName;
  5693. exinfo.supplierUserName = supplierName;
  5694. exinfo.deliveryType = "发货成功";
  5695. exinfo.print_time = DateTime.Now;
  5696. exinfo.printUser = CurrentUser.UserName;
  5697. exinfo.postData = pData_str;
  5698. exinfo.Create();
  5699. commonHelper.UpdateRelationOrder(entity.ctid);
  5700. CeErpSukuraData.createInfo(entity.ctid, 4);
  5701. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5702. {
  5703. commonHelper.sendCytExpress(exinfo);
  5704. }
  5705. //不处理
  5706. }
  5707. else
  5708. {
  5709. entity.UpdateTime = DateTime.Now;
  5710. entity.LastBillCpCode = cpCode;
  5711. entity.LastBillWaybillCode = curUseWayBillCode;
  5712. entity.Update();
  5713. string errmsg = commonHelper.KeepChinese(apires);
  5714. var res_objz = new
  5715. {
  5716. restype = 0,
  5717. data = "打单后发货失败"
  5718. };
  5719. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5720. returnSuccess(ro_jsonz);
  5721. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5722. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5723. return;
  5724. }
  5725. }
  5726. }
  5727. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5728. {
  5729. string ctids = GetPostString("ctids");
  5730. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5731. List<string> list = new List<string>();
  5732. List<string> send_list = new List<string>();
  5733. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5734. CeErpTrade ceErpTrade = new CeErpTrade();
  5735. //可合包的合并一起发货
  5736. if (dt == null && string.IsNullOrEmpty(ctids))
  5737. {
  5738. var res_objz = new
  5739. {
  5740. restype = 0,
  5741. data = "打单后发货失败"
  5742. };
  5743. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5744. returnSuccess(ro_jsonz);
  5745. return;
  5746. }
  5747. if (!string.IsNullOrEmpty(ctids))
  5748. {
  5749. StringBuilder sql = new StringBuilder();
  5750. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5751. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5752. }
  5753. foreach (DataRow row in dt.Rows)
  5754. {
  5755. list.Add("'" + row["ctid"] + "'");
  5756. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5757. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5758. if (ctid.IndexOf("N") != -1)
  5759. {
  5760. apires = "发货成功";
  5761. }
  5762. else
  5763. {
  5764. if (!send_list.Contains(ceErpTrade.tid))
  5765. {
  5766. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5767. }
  5768. else
  5769. {
  5770. apires = "发货成功";
  5771. }
  5772. }
  5773. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5774. {
  5775. send_list.Add(ceErpTrade.tid);
  5776. try
  5777. {
  5778. btnType = "待发货";
  5779. ceErpTradeCell.OutSid = curUseWayBillCode;
  5780. ceErpTradeCell.OrderState = 7;
  5781. ceErpTradeCell.IsUrgency = false;
  5782. ceErpTradeCell.LastBillCpCode = "";
  5783. ceErpTradeCell.LastBillWaybillCode = "";
  5784. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5785. ceErpTradeCell.IsReturn = 0;
  5786. ceErpTradeCell.MemoOpt = 0;
  5787. ceErpTradeCell.UpdateTime = DateTime.Now;
  5788. ceErpTradeCell.Update();
  5789. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5790. //还要插入快递信息到 快递信息表
  5791. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5792. exinfo.tid = ceErpTradeCell.ctid;
  5793. exinfo.out_sid = curUseWayBillCode;
  5794. exinfo.company_code = cpCode;
  5795. exinfo.company_name = cpName;
  5796. exinfo.supplierUserName = supplierName;
  5797. exinfo.deliveryType = "发货成功";
  5798. exinfo.print_time = DateTime.Now;
  5799. exinfo.printUser = CurrentUser.UserName;
  5800. exinfo.postData = pData_str;
  5801. exinfo.Create();
  5802. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5803. CeErpSukuraData.createInfo(ctid, 4);
  5804. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5805. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5806. {
  5807. commonHelper.sendCytExpress(exinfo);
  5808. }
  5809. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5810. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5811. }
  5812. catch (Exception ex)
  5813. {
  5814. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5815. }
  5816. }
  5817. else
  5818. {
  5819. ceErpTradeCell.UpdateTime = DateTime.Now;
  5820. ceErpTradeCell.LastBillCpCode = cpCode;
  5821. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5822. ceErpTradeCell.Update();
  5823. string errmsg = commonHelper.KeepChinese(apires);
  5824. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5825. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5826. }
  5827. }
  5828. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5829. }
  5830. }
  5831. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5832. var res_obj = new
  5833. {
  5834. restype = 1,
  5835. data = pData_str,
  5836. errorMsg
  5837. };
  5838. string ro_json = JsonConvert.SerializeObject(res_obj);
  5839. ReturnSuccess(ro_json);
  5840. return;
  5841. }
  5842. }
  5843. private string GetUTF8String(byte[] vs)
  5844. {
  5845. throw new NotImplementedException();
  5846. }
  5847. public void set_erp_printwaybill_cn()
  5848. {
  5849. if (UrlPostParmsCheck("ctid"))
  5850. {
  5851. string ctid = GetPostString("ctid");
  5852. string cpCode = GetPostString("cpcode");
  5853. string cpName = GetPostString("cpname");
  5854. string tempUrl = GetPostString("tempurl");
  5855. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5856. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5857. //string res = taobaoHelper.test();
  5858. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5859. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5860. {
  5861. int sidx = res.IndexOf("errorMsg");
  5862. int eidx = res.IndexOf("}");
  5863. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5864. var res_objzxx = new
  5865. {
  5866. restype = 0,
  5867. data = msg
  5868. };
  5869. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5870. returnSuccess(ro_jsonzxx);
  5871. //returnErrorMsg(msg);
  5872. return;
  5873. }
  5874. int idx = res.IndexOf("waybillCode");
  5875. int idx2 = res.IndexOf("printData");
  5876. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5877. string eid = GetPostString("ctid");
  5878. CeErpTradeCell entity = null;
  5879. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5880. if (entity != null)
  5881. {
  5882. string osid = entity.OutSid;
  5883. entity.OutSid = osid + "," + outsid;
  5884. entity.FinishDeliveryTime = DateTime.Now;
  5885. entity.OrderState = 7;
  5886. entity.UpdateTime = DateTime.Now;
  5887. entity.IsReturn = 0;
  5888. entity.Update();
  5889. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5890. exinfo.tid = entity.ctid;
  5891. exinfo.out_sid = outsid;
  5892. exinfo.company_code = cpCode;
  5893. exinfo.company_name = cpName;
  5894. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5895. exinfo.deliveryType = "发货成功";
  5896. exinfo.print_time = DateTime.Now;
  5897. exinfo.printUser = CurrentUser.UserName;
  5898. exinfo.Create();
  5899. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5900. {
  5901. commonHelper.sendCytExpress(exinfo);
  5902. }
  5903. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5904. }
  5905. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5906. var res_objz = new
  5907. {
  5908. restype = 1,
  5909. data = res
  5910. };
  5911. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5912. returnSuccess(ro_jsonz);
  5913. //ReturnSuccess(res);
  5914. }
  5915. }
  5916. ////打单,打印面单 获取面单号
  5917. //public void set_erp_printwaybill()
  5918. //{
  5919. // if (UrlPostParmsCheck("ctid"))
  5920. // {
  5921. // string ctid = GetPostString("ctid");
  5922. // string cpCode = GetPostString("cpcode");
  5923. // string tempUrl = GetPostString("tempurl");
  5924. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5925. // //string res = taobaoHelper.test();
  5926. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5927. // if (res.IndexOf("error_response") != -1)
  5928. // {
  5929. // int sidx = res.IndexOf("sub_msg");
  5930. // int eidx = res.IndexOf("request_id");
  5931. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5932. // returnErrorMsg(msg);
  5933. // return;
  5934. // }
  5935. // int idx = res.IndexOf("waybill_code");
  5936. // int idx2 = res.IndexOf("}]}");
  5937. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5938. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5939. // ReturnSuccess(res);
  5940. // }
  5941. //}
  5942. public void cancel_erp_aftersale()
  5943. {
  5944. if (UrlPostParmsCheck("ctid"))
  5945. {
  5946. string eid = GetPostString("ctid");
  5947. CeErpTradeCell entity = null;
  5948. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5949. if (entity != null)
  5950. {
  5951. //有过处理的售后,取消也不能删除 售 字,保留
  5952. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5953. {
  5954. entity.AfterSaleState = 4;
  5955. }
  5956. else
  5957. entity.AfterSaleState = 0;
  5958. entity.UpdateTime = DateTime.Now;
  5959. entity.Update();
  5960. returnSuccessMsg("操作成功!");
  5961. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5962. return;
  5963. }
  5964. returnErrorMsg("找不到订单记录");
  5965. }
  5966. }
  5967. public void get_erp_aftersalelist()
  5968. {
  5969. DataStruct dStruct = GetPostStruct();
  5970. List<string> lw = new List<string>();
  5971. int st = GetInt("st");
  5972. string tid = GetPostString("ctid");
  5973. if (st == 3)
  5974. {
  5975. if (tid.Length > 0)
  5976. {
  5977. string select_tid = getTidByCtid(tid);
  5978. lw.Add(string.Format("tid='{0}'", select_tid));
  5979. }
  5980. }
  5981. else
  5982. {
  5983. if (tid.Length > 0)
  5984. {
  5985. string select_tid = getTidByCtid(tid);
  5986. lw.Add(string.Format("tid='{0}'", select_tid));
  5987. }
  5988. }
  5989. string shopname = GetPostString("shopname");
  5990. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5991. string buyernick = GetPostString("buyer_nick");
  5992. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5993. string sellermemo = GetPostString("seller_memo");
  5994. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5995. string orderState = GetPostString("orderState");
  5996. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5997. string afterState = GetPostString("afterstate");
  5998. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5999. string date1 = GetPostString("date1");
  6000. string date2 = GetPostString("date2");
  6001. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6002. if (dw.Length > 0) lw.Add(dw);
  6003. string price1 = GetPostString("price1");
  6004. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6005. string price2 = GetPostString("price2");
  6006. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6007. //lw.Add(string.Format("IsRefund!={0}", 1));
  6008. string reason = GetPostString("reason");
  6009. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6010. string method = GetPostString("method");
  6011. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6012. string handler = GetPostString("handler");
  6013. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6014. string handledate1 = GetPostString("handledate1");
  6015. string handledate2 = GetPostString("handledate2");
  6016. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6017. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6018. string finish1 = GetPostString("finishdate1");
  6019. string finish2 = GetPostString("finishdate2");
  6020. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6021. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6022. string afterdate1 = GetPostString("afterdate1");
  6023. string afterdate2 = GetPostString("afterdate2");
  6024. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6025. if (afterDate.Length > 0) lw.Add(afterDate);
  6026. string supplier = GetPostString("supplier");
  6027. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6028. string responsible = GetPostString("responsibleman");
  6029. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6030. string customer = GetPostString("customer");
  6031. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6032. string design = GetPostString("design");
  6033. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6034. string afterMemoType = GetPostString("aftermemotype");
  6035. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6036. string posCode = CurrentUser.UserPost.Post.Code;
  6037. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6038. //{
  6039. // string vstate = GetPostString("vstate");
  6040. // if (vstate.Length > 0)
  6041. // {
  6042. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6043. // }
  6044. // if (posCode == "Supplier")
  6045. // {
  6046. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6047. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6048. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6049. // }
  6050. // else
  6051. // {
  6052. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6053. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6054. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6055. // {
  6056. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6057. // }
  6058. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6059. // {
  6060. // int orgid = CurrentUser.UserPost.OrgID;
  6061. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6062. // }
  6063. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6064. // {
  6065. // string shopid = CurrentUser.User.pemShop;
  6066. // lw.Add(string.Format("shopId in ({0})", shopid));
  6067. // }
  6068. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6069. // //{
  6070. // // int org_id = CurrentUser.UserPost.OrgID;
  6071. // // lw.Add(string.Format("OrgID={0}", org_id));
  6072. // //}
  6073. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6074. // }
  6075. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6076. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6077. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6078. //}
  6079. if (st == 5)
  6080. {
  6081. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6082. {
  6083. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6084. {
  6085. string shopid = CurrentUser.User.pemShop;
  6086. lw.Add(string.Format("shopId in ({0})", shopid));
  6087. }
  6088. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6089. {
  6090. int mrOrgid = CurrentUser.UserPost.OrgID;
  6091. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6092. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6093. }
  6094. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6095. //{
  6096. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6097. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6098. //}
  6099. else
  6100. {
  6101. string userIdStr = "";
  6102. if (posCode == "CustomerService")
  6103. {
  6104. userIdStr = CurrentUser.UserID + "_k";
  6105. }
  6106. else if (posCode == "Designer" || posCode == "wxDesigner")
  6107. {
  6108. userIdStr = CurrentUser.UserID + "_s";
  6109. }
  6110. else if (posCode == "Place")
  6111. {
  6112. userIdStr = CurrentUser.UserID + "_x";
  6113. }
  6114. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6115. }
  6116. }
  6117. string placedate1 = GetPostString("placedate1");
  6118. string placedate2 = GetPostString("placedate2");
  6119. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6120. if (dwplace.Length > 0) lw.Add(dwplace);
  6121. string supState = GetPostString("supState");
  6122. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6123. string searchType = GetPostString("searchType");
  6124. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6125. {
  6126. lw.Add(string.Format("BackNum>1"));
  6127. }
  6128. lw.Add(string.Format("AfterSaleState>0"));
  6129. if (ex_psize > 0)
  6130. {
  6131. if (CurrentUser.UserPost.Post.Code == "Finance")
  6132. dStruct.Order = "pay_time desc";
  6133. else
  6134. dStruct.Order = "HandleTime desc";
  6135. }
  6136. else
  6137. dStruct.Order = "HandleTime desc";
  6138. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6139. DataTable dt = WebCache.GetData("view_test", dStruct);
  6140. writeGridDataTableJson(dStruct.TotalCount, dt);
  6141. }
  6142. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6143. //{
  6144. // lw.Add(string.Format("AfterSaleState=4"));
  6145. // string code = CurrentUser.UserPost.Post.Code;
  6146. // if (code == "CustomerService")
  6147. // {
  6148. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6149. // }
  6150. // else if (code == "Designer" || code == "DesignerMr")
  6151. // {
  6152. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6153. // }
  6154. // else if (code == "Place" || code == "PlaceMr")
  6155. // {
  6156. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6157. // }
  6158. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6159. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6160. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6161. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6162. //}
  6163. //else //处理中的售后,待处理和处理中合并
  6164. //{
  6165. // if (afterState.Length <= 0)
  6166. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6167. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6168. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6169. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6170. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6171. //}
  6172. }
  6173. public void get_erp_disagreeftersalelist()
  6174. {
  6175. DataStruct dStruct = GetPostStruct();
  6176. List<string> lw = new List<string>();
  6177. int st = 2;
  6178. string tid = GetPostString("ctid");
  6179. if (tid.Length > 0)
  6180. {
  6181. string select_tid = getTidByCtid(tid);
  6182. lw.Add(string.Format("tid='{0}'", select_tid));
  6183. }
  6184. string shopname = GetPostString("shopname");
  6185. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6186. string buyernick = GetPostString("buyer_nick");
  6187. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6188. string sellermemo = GetPostString("seller_memo");
  6189. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6190. string orderState = GetPostString("orderState");
  6191. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6192. string afterState = GetPostString("afterstate");
  6193. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6194. string date1 = GetPostString("date1");
  6195. string date2 = GetPostString("date2");
  6196. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6197. if (dw.Length > 0) lw.Add(dw);
  6198. string price1 = GetPostString("price1");
  6199. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6200. string price2 = GetPostString("price2");
  6201. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6202. //lw.Add(string.Format("IsRefund!={0}", 1));
  6203. string reason = GetPostString("reason");
  6204. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6205. string method = GetPostString("method");
  6206. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6207. string handler = GetPostString("handler");
  6208. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6209. string handledate1 = GetPostString("handledate1");
  6210. string handledate2 = GetPostString("handledate2");
  6211. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6212. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6213. string afterdate1 = GetPostString("afterdate1");
  6214. string afterdate2 = GetPostString("afterdate2");
  6215. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6216. if (afterDate.Length > 0) lw.Add(afterDate);
  6217. string backdate1 = GetPostString("backdate1");
  6218. string backdate2 = GetPostString("backdate2");
  6219. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6220. if (backDate.Length > 0) lw.Add(backDate);
  6221. string supplier = GetPostString("supplier");
  6222. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6223. string responsible = GetPostString("responsibleman");
  6224. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6225. string customer = GetPostString("customer");
  6226. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6227. string design = GetPostString("design");
  6228. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6229. string afterSaleMemo = GetPostString("afterSaleMemo");
  6230. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6231. string afterMemoType = GetPostString("aftermemotype");
  6232. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6233. string aftersakereason = GetPostString("aftersakereason");
  6234. if (aftersakereason.Length > 0)
  6235. {
  6236. if (aftersakereason == "1")
  6237. {
  6238. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6239. }
  6240. if (aftersakereason == "2")
  6241. {
  6242. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6243. }
  6244. }
  6245. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6246. string poscode = CurrentUser.UserPost.Post.Code;
  6247. if (poscode != "SysAdmin")
  6248. {
  6249. string shopid = CurrentUser.User.pemShop;
  6250. lw.Add(string.Format("shopId in ({0})", shopid));
  6251. }
  6252. string searchType = GetPostString("searchType");
  6253. if (searchType == "wait")
  6254. {
  6255. lw.Add(string.Format("HandleTime is null"));
  6256. }
  6257. if (searchType == "handling")
  6258. {
  6259. lw.Add(string.Format("HandleTime is not null "));
  6260. }
  6261. if (searchType == "back" || searchType == "puBack")
  6262. {
  6263. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6264. }
  6265. if (searchType == "reBack")
  6266. {
  6267. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6268. }
  6269. if (searchType == "moreBack")
  6270. {
  6271. lw.Add(string.Format("backNum > 1"));
  6272. }
  6273. lw.Add(string.Format("(AfterSaleState=5)"));
  6274. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6275. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6276. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6277. writeGridDataTableJson(dStruct.TotalCount, dt);
  6278. }
  6279. public void get_erp_handlingaftersalelist()
  6280. {
  6281. DataStruct dStruct = GetPostStruct();
  6282. List<string> lw = new List<string>();
  6283. int st = 2;
  6284. string tid = GetPostString("ctid");
  6285. if (tid.Length > 0)
  6286. {
  6287. string select_tid = getTidByCtid(tid);
  6288. lw.Add(string.Format("tid='{0}'", select_tid));
  6289. }
  6290. string shopname = GetPostString("shopname");
  6291. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6292. string buyernick = GetPostString("buyer_nick");
  6293. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6294. string sellermemo = GetPostString("seller_memo");
  6295. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6296. string orderState = GetPostString("orderState");
  6297. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6298. string afterState = GetPostString("afterstate");
  6299. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6300. string date1 = GetPostString("date1");
  6301. string date2 = GetPostString("date2");
  6302. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6303. if (dw.Length > 0) lw.Add(dw);
  6304. string price1 = GetPostString("price1");
  6305. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6306. string price2 = GetPostString("price2");
  6307. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6308. //lw.Add(string.Format("IsRefund!={0}", 1));
  6309. string reason = GetPostString("reason");
  6310. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6311. string method = GetPostString("method");
  6312. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6313. string handler = GetPostString("handler");
  6314. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6315. string handledate1 = GetPostString("handledate1");
  6316. string handledate2 = GetPostString("handledate2");
  6317. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6318. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6319. string afterdate1 = GetPostString("afterdate1");
  6320. string afterdate2 = GetPostString("afterdate2");
  6321. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6322. if (afterDate.Length > 0) lw.Add(afterDate);
  6323. string supplier = GetPostString("supplier");
  6324. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6325. string responsible = GetPostString("responsibleman");
  6326. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6327. string customer = GetPostString("customer");
  6328. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6329. string design = GetPostString("design");
  6330. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6331. string afterSaleMemo = GetPostString("afterSaleMemo");
  6332. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6333. string afterMemoType = GetPostString("aftermemotype");
  6334. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6335. string afterresult = GetPostString("afterresult");
  6336. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6337. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6338. string poscode = CurrentUser.UserPost.Post.Code;
  6339. if (poscode != "SysAdmin")
  6340. {
  6341. string shopid = CurrentUser.User.pemShop;
  6342. lw.Add(string.Format("shopId in ({0})", shopid));
  6343. }
  6344. string searchType = GetPostString("searchType");
  6345. if (searchType == "wait")
  6346. {
  6347. lw.Add(string.Format("HandleTime is null"));
  6348. }
  6349. if (searchType == "documentary")
  6350. {
  6351. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6352. }
  6353. if (searchType == "handling")
  6354. {
  6355. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6356. }
  6357. if (searchType == "back" || searchType == "puBack")
  6358. {
  6359. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6360. }
  6361. if (searchType == "reBack")
  6362. {
  6363. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6364. }
  6365. if (afterState.Length <= 0)
  6366. {
  6367. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6368. }
  6369. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6370. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6371. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6372. writeGridDataTableJson(dStruct.TotalCount, dt);
  6373. }
  6374. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6375. //public void get_erp_back_handlingaftersalelist()
  6376. //{
  6377. // DataStruct dStruct = GetPostStruct();
  6378. // List<string> lw = new List<string>();
  6379. // string tid = GetPostString("ctid");
  6380. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6381. // string shopname = GetPostString("shopname");
  6382. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6383. // string buyernick = GetPostString("buyer_nick");
  6384. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6385. // string sellermemo = GetPostString("seller_memo");
  6386. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6387. // string orderState = GetPostString("orderState");
  6388. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6389. // string afterState = GetPostString("afterstate");
  6390. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6391. // string date1 = GetPostString("date1");
  6392. // string date2 = GetPostString("date2");
  6393. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6394. // if (dw.Length > 0) lw.Add(dw);
  6395. // string price1 = GetPostString("price1");
  6396. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6397. // string price2 = GetPostString("price2");
  6398. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6399. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6400. // string reason = GetPostString("reason");
  6401. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6402. // string method = GetPostString("method");
  6403. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6404. // string handler = GetPostString("handler");
  6405. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6406. // string handledate1 = GetPostString("handledate1");
  6407. // string handledate2 = GetPostString("handledate2");
  6408. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6409. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6410. // string afterdate1 = GetPostString("afterdate1");
  6411. // string afterdate2 = GetPostString("afterdate2");
  6412. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6413. // if (afterDate.Length > 0) lw.Add(afterDate);
  6414. // string supplier = GetPostString("supplier");
  6415. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6416. // string responsible = GetPostString("responsibleman");
  6417. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6418. // string customer = GetPostString("customer");
  6419. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6420. // string design = GetPostString("design");
  6421. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6422. // string afterMemoType = GetPostString("aftermemotype");
  6423. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6424. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6425. // if (afterState.Length <= 0)
  6426. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6427. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6428. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6429. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6430. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6431. //}
  6432. public void get_erp_aftersaleverifylist()
  6433. {
  6434. DataStruct dStruct = GetPostStruct();
  6435. List<string> lw = new List<string>();
  6436. string tid = GetPostString("ctid");
  6437. if (tid.Length > 0)
  6438. {
  6439. string select_tid = getTidByCtid(tid);
  6440. lw.Add(string.Format("otid='{0}'", select_tid));
  6441. }
  6442. string shopname = GetPostString("shopname");
  6443. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6444. string buyernick = GetPostString("buyer_nick");
  6445. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6446. string sellermemo = GetPostString("seller_memo");
  6447. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6448. string orderState = GetPostString("orderState");
  6449. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6450. //lw.Add(string.Format("IsRefund!={0}", 1));
  6451. string reason = GetPostString("reason");
  6452. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6453. string method = GetPostString("method");
  6454. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6455. string handler = GetPostString("handler");
  6456. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6457. string handledate1 = GetPostString("handledate1");
  6458. string handledate2 = GetPostString("handledate2");
  6459. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6460. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6461. string finish1 = GetPostString("finishdate1");
  6462. string finish2 = GetPostString("finishdate2");
  6463. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6464. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6465. string supplier = GetPostString("supplier");
  6466. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6467. string responsible = GetPostString("responsibleman");
  6468. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6469. string posCode = CurrentUser.UserPost.Post.Code;
  6470. string vstate = GetPostString("vstate");
  6471. if (vstate.Length > 0)
  6472. {
  6473. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6474. }
  6475. if (posCode == "Supplier")
  6476. {
  6477. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6478. lw.Add(string.Format("VerifyState = 0"));
  6479. lw.Add("type = 1");
  6480. lw.Add(string.Format("AfterSaleState={0}", 3));
  6481. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6482. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6483. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6484. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6485. writeGridDataTableJson(dStruct.TotalCount, dt);
  6486. }
  6487. else if (posCode == "logistics")
  6488. {
  6489. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6490. lw.Add(string.Format("VerifyState = 0"));
  6491. lw.Add("type = 2");
  6492. lw.Add(string.Format("AfterSaleState={0}", 3));
  6493. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6494. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6495. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6496. writeGridDataTableJson(dStruct.TotalCount, dt);
  6497. }
  6498. else
  6499. {
  6500. lw.Add(string.Format("(AfterSaleState = 3)"));
  6501. lw.Add("type = 0");
  6502. string reasonState = GetPostString("reasonState");
  6503. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6504. {
  6505. if (reasonState == "2")
  6506. {
  6507. lw.Add("VerifyState = 3");
  6508. }
  6509. else if (reasonState == "1")
  6510. {
  6511. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6512. }
  6513. else
  6514. {
  6515. lw.Add("VerifyState in (0,3)");
  6516. }
  6517. //不加条件,可以看全部
  6518. }
  6519. 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")
  6520. {
  6521. int orgid = CurrentUser.UserPost.OrgID;
  6522. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6523. if (string.IsNullOrEmpty(manageOrgId))
  6524. {
  6525. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6526. }
  6527. else
  6528. {
  6529. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6530. }
  6531. if (reasonState == "1")
  6532. {
  6533. lw.Add("VerifyState = 3");
  6534. }
  6535. else if (reasonState == "2")
  6536. {
  6537. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6538. }
  6539. else
  6540. {
  6541. }
  6542. }
  6543. else
  6544. {
  6545. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6546. }
  6547. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6548. //{
  6549. // int org_id = CurrentUser.UserPost.OrgID;
  6550. // lw.Add(string.Format("OrgID={0}", org_id));
  6551. //}
  6552. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6553. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6554. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6555. writeGridDataTableJson(dStruct.TotalCount, dt);
  6556. }
  6557. }
  6558. public void get_erp_finishaftersalelist()
  6559. {
  6560. DataStruct dStruct = GetPostStruct();
  6561. List<string> lw = new List<string>();
  6562. int st = 4;
  6563. string tid = GetPostString("ctid");
  6564. if (tid.Length > 0)
  6565. {
  6566. string select_tid = getTidByCtid(tid);
  6567. lw.Add(string.Format("otid='{0}'", select_tid));
  6568. }
  6569. string shopname = GetPostString("shopname");
  6570. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6571. //lw.Add(string.Format("IsRefund!={0}", 1));
  6572. string reason = GetPostString("reason");
  6573. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6574. string method = GetPostString("method");
  6575. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6576. string buyernick = GetPostString("buyer_nick");
  6577. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6578. string handler = GetPostString("handler");
  6579. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6580. string handledate1 = GetPostString("handledate1");
  6581. string handledate2 = GetPostString("handledate2");
  6582. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6583. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6584. string finish1 = GetPostString("finishdate1");
  6585. string finish2 = GetPostString("finishdate2");
  6586. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6587. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6588. string supplier = GetPostString("supplier");
  6589. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6590. string responsible = GetPostString("responsibleman");
  6591. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6592. string vstate = GetPostString("vstate");
  6593. if (vstate.Length > 0)
  6594. {
  6595. if ("3".Equals(vstate))
  6596. {
  6597. lw.Add(string.Format("IsTem=1"));
  6598. }
  6599. else
  6600. {
  6601. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6602. }
  6603. }
  6604. lw.Add(string.Format("AfterSaleState=4"));
  6605. string code = CurrentUser.UserPost.Post.Code;
  6606. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6607. {
  6608. //不加条件,可以看全部
  6609. }
  6610. else if (code == "Supplier")
  6611. {
  6612. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6613. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6614. lw.Add("type = 1");
  6615. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6616. }
  6617. else if (code == "logistics")
  6618. {
  6619. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6620. lw.Add("type = 2");
  6621. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6622. }
  6623. 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")
  6624. {
  6625. lw.Add("type = 0");
  6626. int orgid = CurrentUser.UserPost.OrgID;
  6627. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6628. if (string.IsNullOrEmpty(manageOrgIds))
  6629. {
  6630. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6631. }
  6632. else
  6633. {
  6634. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6635. }
  6636. }
  6637. else
  6638. {
  6639. lw.Add("type = 0");
  6640. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6641. }
  6642. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6643. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6644. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6645. writeGridDataTableJson(dStruct.TotalCount, dt);
  6646. }
  6647. public void handle_erp_aftersale()
  6648. {
  6649. if (UrlPostParmsCheck("ctid"))
  6650. {
  6651. string eid = GetPostString("ctid");
  6652. string responStr = GetPostString("AfterSaleResponsible");
  6653. if (responStr.Length <= 0)
  6654. {
  6655. returnErrorMsg("售后责任人不能为空");
  6656. return;
  6657. }
  6658. bool isDesign = false;
  6659. double designFree = 0.00;
  6660. int responsibleId = 0;
  6661. CeErpTradeCell entity = null;
  6662. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6663. if (entity != null)
  6664. {
  6665. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6666. string afterMethod = GetPostString("AfterSaleMethod");
  6667. if (isNeedNewOrder == 1)
  6668. {
  6669. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6670. bool ishav = true;
  6671. if (newentity == null)
  6672. {
  6673. newentity = entity.Clone() as CeErpTradeCell;
  6674. ishav = false;
  6675. newentity.ctid = "S_" + entity.ctid;
  6676. newentity.OrderState = 0;
  6677. //唯一标识
  6678. newentity.OrderSn = newentity.ctid;
  6679. string orderSn = dataHelper.getSaleOrderSn();
  6680. if (orderSn != "")
  6681. {
  6682. newentity.OrderSn = orderSn;
  6683. }
  6684. }
  6685. newentity.UpdateTime = DateTime.Now;
  6686. newentity.AfterSaleState = 0;
  6687. newentity.AfterSaleMethod = afterMethod;
  6688. if (!ishav)
  6689. {
  6690. string memo_str = newentity.seller_memo;
  6691. memo_str = memo_str.Replace("(", "(");
  6692. memo_str = memo_str.Replace(")", ")");
  6693. int sIndex = memo_str.IndexOf("(");
  6694. int eIndex = memo_str.IndexOf(")");
  6695. if (sIndex == -1 || eIndex == -1)
  6696. {
  6697. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6698. return;
  6699. }
  6700. string first = memo_str.Substring(0, sIndex + 1);
  6701. string memoCtid = newentity.OrderSn;
  6702. //if (memoCtid.IndexOf("C") != -1)
  6703. //{
  6704. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6705. //if (CIdx.IndexOf("+") != -1)
  6706. //{
  6707. //CIdx = "C" + CIdx.Split('+')[1];
  6708. //}
  6709. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6710. //}
  6711. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6712. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6713. string newMemo = first + memoCtid + last;
  6714. newentity.seller_memo = newMemo;
  6715. newentity.FinishPlaceTime = null;
  6716. newentity.UnusualTag = 0;
  6717. newentity.UnusualCon = "";
  6718. newentity.UnusualTime = null;
  6719. newentity.AfterSaleMemo = "";
  6720. newentity.AfterSaleMethod = afterMethod;
  6721. newentity.AfterSalePreTime = null;
  6722. newentity.AfterSaleReason = "";
  6723. newentity.AfterSaleResponsible = "";
  6724. newentity.AfterSaleState = 0;
  6725. newentity.AfterSaleTime = null;
  6726. newentity.AfterSaleUserId = 0;
  6727. newentity.AfterSaleSupplierState = 0;
  6728. newentity.LastBillWaybillCode = "";
  6729. newentity.LastBillCpCode = "";
  6730. newentity.FinishAfterSaleTime = null;
  6731. newentity.HandleTime = null;
  6732. newentity.IsSF = 0;
  6733. newentity.IsOldCustomer = 0;
  6734. newentity.UrgencyTime = null;
  6735. newentity.ResponsibleUserId = "";
  6736. newentity.IsVerifyToSupplier = false;
  6737. newentity.payment = 0;
  6738. newentity.CheckMemo = "";
  6739. newentity.OutSid = "";
  6740. newentity.CheckOrderTime = null;
  6741. newentity.MemoOpt = 0;
  6742. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6743. }
  6744. newentity.isAfterSaleOrder = 1;
  6745. newentity.IsRefund = 0;
  6746. string receiveMobile = GetPostString("receiver_mobile");
  6747. if (receiveMobile.Length > 0)
  6748. {
  6749. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6750. if (trade != null)
  6751. {
  6752. trade.receiver_name = GetPostString("receiver_name");
  6753. trade.receiver_mobile = receiveMobile;
  6754. trade.receiver_state = GetPostString("receiver_state");
  6755. trade.receiver_city = GetPostString("receiver_city");
  6756. trade.receiver_district = GetPostString("receiver_district");
  6757. trade.receiver_address = GetPostString("receiver_address");
  6758. newentity.IsOffLineOrder = 1;
  6759. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6760. }
  6761. }
  6762. string st = GetPostString("ToState");
  6763. if (st.Length > 0)
  6764. {
  6765. if (newentity.OrderState <= 3)
  6766. {
  6767. newentity.WaitDesignTime = DateTime.Now;
  6768. newentity.StartDesignTime = null;
  6769. newentity.FinishDesignTime = null;
  6770. newentity.OrderState = 3;
  6771. if (st == "下单员")
  6772. {
  6773. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6774. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6775. {
  6776. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6777. }
  6778. }
  6779. else
  6780. {
  6781. newentity.WaitDesignTime = DateTime.Now;
  6782. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6783. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6784. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6785. {
  6786. DataRow user = dt1.Rows[0];
  6787. //找主管
  6788. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6789. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6790. if (dt != null && dt.Rows.Count > 0)
  6791. {
  6792. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6793. newentity.DesignUserId = designMr;
  6794. string key = "aftersale_order_" + designMr;
  6795. if (RedisHelper.HasKey(key))
  6796. {
  6797. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6798. list.Add(newentity.ctid);
  6799. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6800. }
  6801. }
  6802. //账号正常
  6803. if (user["State"].ToString() == "0")
  6804. {
  6805. newentity.DesignUserId = entity.DesignUserId;
  6806. string key = "aftersale_order_" + entity.DesignUserId;
  6807. if (RedisHelper.HasKey(key))
  6808. {
  6809. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6810. list.Add(newentity.ctid);
  6811. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6812. }
  6813. }
  6814. }
  6815. }
  6816. }
  6817. if (entity.IsXianHuo == 1)
  6818. {
  6819. newentity.OrderState = 6;
  6820. entity.FinishPlaceTime = DateTime.Now;
  6821. }
  6822. }
  6823. if (ishav)
  6824. {
  6825. newentity.Update();
  6826. }
  6827. else
  6828. {
  6829. newentity.Create();
  6830. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6831. newCellExtend.ctid = newentity.ctid;
  6832. newCellExtend.orderFrom = 20;
  6833. newCellExtend.orderType = 30;
  6834. if (st == "下单员")
  6835. {
  6836. }
  6837. else
  6838. {
  6839. newCellExtend.ReprintTime = DateTime.Now;
  6840. }
  6841. newCellExtend.Create();
  6842. }
  6843. if (st != "下单员")
  6844. {
  6845. if (entity.DispatchSort == 2)
  6846. {
  6847. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6848. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6849. }
  6850. }
  6851. }
  6852. //处理售后扩展
  6853. string resIdStr = GetPostString("ResponsibleUserId");
  6854. string refundFees = GetPostString("refundFrees");
  6855. int IsComplain = GetPostInt("isComplain");
  6856. int IsBad = GetPostInt("isBad");
  6857. string IsOriginal = GetPostString("isOriginal");
  6858. double diffResultPrice = GetPostDouble("diffResultPrice");
  6859. string textResult = GetPostString("textResult");
  6860. string supplierResponsible = GetPostString("supplierResponsible");
  6861. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6862. if (ceErpTradeAfterSaleExtend == null)
  6863. {
  6864. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6865. ceErpTradeAfterSaleExtend.tid = eid;
  6866. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6867. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6868. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6869. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6870. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6871. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6872. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6873. ceErpTradeAfterSaleExtend.Create();
  6874. }
  6875. else
  6876. {
  6877. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6878. {
  6879. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6880. }
  6881. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6882. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6883. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6884. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6885. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6886. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6887. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6888. ceErpTradeAfterSaleExtend.Update();
  6889. }
  6890. int gysid = GetPostInt("ResponsibleSupId");
  6891. if (entity.AfterSaleUserId == 0)
  6892. {
  6893. entity.AfterSaleUserId = CurrentUser.UserID;
  6894. }
  6895. entity.ResponsibleUserId = resIdStr;
  6896. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6897. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6898. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6899. {
  6900. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6901. int backNum = 0;
  6902. if (number != null)
  6903. {
  6904. backNum = number.BackNum;
  6905. }
  6906. char[] separator = { ',' };
  6907. string[] sArray = resIdStr.Split(separator);
  6908. string[] refundFreeList = { };
  6909. if (refundFees.Length > 0)
  6910. {
  6911. refundFreeList = refundFees.Split(separator);
  6912. }
  6913. int index = -1;
  6914. List<int> responsibleIds = new List<int>();
  6915. foreach (string i in sArray)
  6916. {
  6917. index++;
  6918. if (i.Length <= 0) continue;
  6919. char[] separator2 = { '_' };
  6920. string idstr = i.Split(separator2)[0];
  6921. string idtype = i.Split(separator2)[1];
  6922. double refudFree = 0;
  6923. if (refundFreeList.Length > 0)
  6924. {
  6925. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6926. }
  6927. if (idtype == "s")
  6928. {
  6929. isDesign = true;
  6930. designFree = refudFree;
  6931. }
  6932. int userId = Convert.ToInt32(idstr);
  6933. int type = 0;
  6934. if (idtype == "g")
  6935. {
  6936. type = 1;
  6937. }
  6938. if (idtype == "w")
  6939. {
  6940. type = 2;
  6941. }
  6942. if (idtype == "t")
  6943. {
  6944. type = 3;
  6945. }
  6946. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6947. if (ceErpTradeResponsible == null)
  6948. {
  6949. ceErpTradeResponsible = new CeErpTradeResponsible();
  6950. ceErpTradeResponsible.tid = eid;
  6951. ceErpTradeResponsible.UserId = userId;
  6952. ceErpTradeResponsible.createdTime = DateTime.Now;
  6953. ceErpTradeResponsible.type = type;
  6954. if (type == 1)
  6955. {
  6956. ceErpTradeResponsible.IsSup = 1;
  6957. }
  6958. if (type == 2)
  6959. {
  6960. ceErpTradeResponsible.IsFlow = 1;
  6961. }
  6962. }
  6963. int state = 0;
  6964. //已认可的不需要再次认可
  6965. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  6966. {
  6967. state = 1;
  6968. }
  6969. ceErpTradeResponsible.RefundFee = refudFree;
  6970. ceErpTradeResponsible.VerifyState = state;
  6971. if (userId == 2125 || idtype == "w")
  6972. {
  6973. ceErpTradeResponsible.VerifyState = 1;
  6974. }
  6975. if (idtype == "w" && userId == 101)
  6976. {
  6977. ceErpTradeResponsible.VerifyState = state;
  6978. }
  6979. if (ceErpTradeResponsible.ID > 0)
  6980. {
  6981. ceErpTradeResponsible.Update();
  6982. }
  6983. else
  6984. {
  6985. ceErpTradeResponsible.Create();
  6986. }
  6987. if (isDesign)
  6988. {
  6989. responsibleId = ceErpTradeResponsible.ID;
  6990. }
  6991. responsibleIds.Add(ceErpTradeResponsible.ID);
  6992. }
  6993. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  6994. CeErpTradeResponsible.NumByTid(backNum, eid);
  6995. }
  6996. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6997. if (ceErpTradeCellExtend != null)
  6998. {
  6999. ceErpTradeCellExtend.returnVisit = 0;
  7000. ceErpTradeCellExtend.Update();
  7001. }
  7002. if (entity.HandleTime != null)
  7003. {
  7004. if (entity.AfterSaleState == 1)
  7005. {
  7006. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7007. }
  7008. else
  7009. {
  7010. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7011. }
  7012. }
  7013. else
  7014. {
  7015. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7016. entity.HandleTime = DateTime.Now;
  7017. }
  7018. bool isCompale = false;
  7019. if (entity.AfterSaleState == 5)
  7020. {
  7021. isCompale = true;
  7022. entity.AfterSaleState = 3;
  7023. }
  7024. entity.AfterSaleSupplierState = 0;
  7025. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7026. {
  7027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7028. }
  7029. string sImgs = GetPostString("img");
  7030. entity.AfterSaleSupplierImg = sImgs;
  7031. entity.supRefundType = GetPostString("supRefundType");
  7032. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7033. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7034. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7035. entity.AfterSaleMemoType = GetPostString("MemoType");
  7036. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7037. {
  7038. //entity.AfterSaleSupplierState = 2;
  7039. }
  7040. string df = GetPostString("DeductFee");
  7041. if (df == "")
  7042. {
  7043. df = "0";
  7044. }
  7045. string rf = GetPostString("RefundFee");
  7046. if (rf == "")
  7047. {
  7048. rf = "0";
  7049. }
  7050. string pm = GetPostString("AfterSalePayment");
  7051. if (pm == "")
  7052. {
  7053. pm = "0";
  7054. }
  7055. entity.AfterSalePayment = Convert.ToDouble(pm);
  7056. entity.DeductFee = Convert.ToDouble(df);
  7057. entity.RefundFee = Convert.ToDouble(rf);
  7058. entity.UpdateTime = DateTime.Now;
  7059. entity.Update();
  7060. string toState = GetPostString("ToState");
  7061. string original = GetPostString("isOriginal");
  7062. ApiVo apiVo = new ApiVo();
  7063. apiVo.orderNumber = entity.ctid;
  7064. apiVo.actionName = "afterDesign";
  7065. apiVo.orderRemarks = entity.AfterSaleMethod;
  7066. apiVo.reasonRemarks = entity.AfterSaleReason;
  7067. apiVo.isDesign = isDesign;
  7068. apiVo.designFree = designFree;
  7069. apiVo.responsibleId = responsibleId;
  7070. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7071. if (toState == "设计师")
  7072. {
  7073. apiVo.isOriginal = Convert.ToBoolean(original);
  7074. }
  7075. designHelper.API_WorkCore(apiVo);//afterDesign
  7076. CeErpMethod methodSql = new CeErpMethod();
  7077. methodSql.con = entity.AfterSaleMethod;
  7078. methodSql.addTime = DateTime.Now;
  7079. methodSql.Create();
  7080. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7081. CeErpMethod.ExecuteNonQuery(delsql);
  7082. if (isCompale)
  7083. {
  7084. aftersale_data_change(entity.ctid);
  7085. }
  7086. returnSuccessMsg("操作成功!");
  7087. return;
  7088. }
  7089. returnErrorMsg("找不到订单记录");
  7090. }
  7091. }
  7092. public void ins_erp_toresponsible()
  7093. {
  7094. if (UrlPostParmsCheck("ctid"))
  7095. {
  7096. string eid = GetPostString("ctid");
  7097. CeErpTradeCell entity = null;
  7098. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7099. if (entity != null)
  7100. {
  7101. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7102. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7103. {
  7104. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7105. return;
  7106. }
  7107. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7108. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7109. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7110. if (entity.AfterSalePreTime == null)
  7111. {
  7112. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7113. {
  7114. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7115. }
  7116. }
  7117. entity.AfterSalePreTime = DateTime.Now;
  7118. //预完成给售后主管审核客户问题直接完成
  7119. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7120. {
  7121. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7122. {
  7123. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7124. }
  7125. }
  7126. ceErpTradeAfterSaleExtend.Update();
  7127. entity.AfterSaleState = 2;
  7128. entity.UpdateTime = DateTime.Now;
  7129. entity.Update();
  7130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7131. aftersale_data_change(entity.ctid);
  7132. returnSuccessMsg("操作成功!");
  7133. return;
  7134. }
  7135. returnErrorMsg("找不到订单记录");
  7136. }
  7137. }
  7138. public void cancel_erp_aftersaleanddelnew()
  7139. {
  7140. if (UrlPostParmsCheck("ctid"))
  7141. {
  7142. string eid = GetPostString("ctid");
  7143. CeErpTradeCell entity = null;
  7144. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7145. if (entity != null)
  7146. {
  7147. entity.AfterSaleState = 0;
  7148. entity.AfterSaleReason = "";
  7149. entity.AfterSaleMethod = "";
  7150. entity.AfterSaleMemo = "";
  7151. entity.AfterSaleResponsible = "";
  7152. entity.ResponsibleUserId = "";
  7153. entity.DeductFee = 0;
  7154. entity.RefundFee = 0;
  7155. entity.IsArbitrate = 0;
  7156. CeErpTradeResponsible.DelByTid(eid, -1);
  7157. entity.Update();
  7158. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7159. if (after != null)
  7160. {
  7161. if (after.OrderState < 5)
  7162. CeErpTradeCell.DelByCtid("S_" + eid);
  7163. }
  7164. returnSuccessMsg("操作成功!");
  7165. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7166. return;
  7167. }
  7168. returnErrorMsg("找不到订单记录");
  7169. }
  7170. }
  7171. public void get_erp_aftersale_pregather()
  7172. {
  7173. List<string> lw = new List<string>();
  7174. int st = GetInt("st");
  7175. string tid = GetPostString("ctid");
  7176. if (tid.Length > 0)
  7177. {
  7178. string select_tid = getTidByCtid(tid);
  7179. lw.Add(string.Format("tid='{0}'", select_tid));
  7180. }
  7181. string shopname = GetPostString("shopname");
  7182. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7183. string buyernick = GetPostString("buyer_nick");
  7184. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7185. string sellermemo = GetPostString("seller_memo");
  7186. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7187. string orderState = GetPostString("orderState");
  7188. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7189. string reason = GetPostString("reason");
  7190. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7191. string method = GetPostString("method");
  7192. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7193. string handler = GetPostString("handler");
  7194. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7195. string handledate1 = GetPostString("handledate1");
  7196. string handledate2 = GetPostString("handledate2");
  7197. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7198. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7199. string supplier = GetPostString("supplier");
  7200. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7201. string responsible = GetPostString("responsibleman");
  7202. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7203. string customer = GetPostString("customer");
  7204. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7205. string design = GetPostString("design");
  7206. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7207. string afterMemoType = GetPostString("aftermemotype");
  7208. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7209. string afterSaleMemo = GetPostString("afterSaleMemo");
  7210. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7211. string afterresult = GetPostString("afterresult");
  7212. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7213. string poscode = CurrentUser.UserPost.Post.Code;
  7214. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7215. {
  7216. string shopid = CurrentUser.User.pemShop;
  7217. lw.Add(string.Format("shopId in ({0})", shopid));
  7218. }
  7219. var mainwhere = string.Join(" and ", lw.ToArray());
  7220. string ro_json = "";
  7221. string type = GetPostString("gather_type");
  7222. int number = 0;
  7223. if (poscode == "AfterSale")
  7224. {
  7225. //处理中
  7226. if (type == "Handling")
  7227. {
  7228. 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) : ""));
  7229. DataTable dt = null;
  7230. try
  7231. {
  7232. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7233. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7234. }
  7235. catch (Exception e)
  7236. {
  7237. dt = new DataTable();
  7238. }
  7239. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7240. return;
  7241. }
  7242. if (type == "Wait")
  7243. {
  7244. //待处理
  7245. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7246. DataTable dt1 = null;
  7247. try
  7248. {
  7249. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7250. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7251. }
  7252. catch (Exception e)
  7253. {
  7254. dt1 = new DataTable();
  7255. }
  7256. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7257. return;
  7258. }
  7259. if (type == "back")
  7260. {
  7261. //打回
  7262. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7263. DataTable dt2 = null;
  7264. try
  7265. {
  7266. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7267. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7268. }
  7269. catch (Exception e)
  7270. {
  7271. dt2 = new DataTable();
  7272. }
  7273. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7274. return;
  7275. }
  7276. if (type == "preCompletion")
  7277. {
  7278. //预完成
  7279. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7280. DataTable dt3 = null;
  7281. try
  7282. {
  7283. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7284. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7285. }
  7286. catch (Exception e)
  7287. {
  7288. dt3 = new DataTable();
  7289. }
  7290. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7291. return;
  7292. }
  7293. if (type == "documentary")
  7294. {
  7295. //跟单中
  7296. 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) : ""));
  7297. DataTable dt4 = null;
  7298. try
  7299. {
  7300. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7301. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7302. }
  7303. catch (Exception e)
  7304. {
  7305. dt4 = new DataTable();
  7306. }
  7307. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7308. return;
  7309. }
  7310. if (type == "reBack")
  7311. {
  7312. //被打回
  7313. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7314. DataTable dt1 = null;
  7315. try
  7316. {
  7317. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7318. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7319. }
  7320. catch (Exception e)
  7321. {
  7322. dt1 = new DataTable();
  7323. }
  7324. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7325. return;
  7326. }
  7327. }
  7328. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7329. {
  7330. if (type == "puBack")
  7331. {
  7332. //退回
  7333. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7334. DataTable dt = null;
  7335. try
  7336. {
  7337. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7338. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7339. }
  7340. catch (Exception e)
  7341. {
  7342. dt = new DataTable();
  7343. }
  7344. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7345. return;
  7346. }
  7347. if (type == "reBack")
  7348. {
  7349. //打回
  7350. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7351. DataTable dt1 = null;
  7352. try
  7353. {
  7354. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7355. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7356. }
  7357. catch (Exception e)
  7358. {
  7359. dt1 = new DataTable();
  7360. }
  7361. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7362. return;
  7363. }
  7364. if (type == "examEd")
  7365. {
  7366. //已审核
  7367. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7368. DataTable dt2 = null;
  7369. try
  7370. {
  7371. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7372. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7373. }
  7374. catch (Exception e)
  7375. {
  7376. dt2 = new DataTable();
  7377. }
  7378. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7379. return;
  7380. }
  7381. if (type == "waitExam")
  7382. {
  7383. //待审核
  7384. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7385. DataTable dt3 = null;
  7386. try
  7387. {
  7388. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7389. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7390. }
  7391. catch (Exception e)
  7392. {
  7393. dt3 = new DataTable();
  7394. }
  7395. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7396. return;
  7397. }
  7398. if (type == "Handling")
  7399. {
  7400. //处理中
  7401. 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) : ""));
  7402. DataTable dt4 = null;
  7403. try
  7404. {
  7405. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7406. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7407. }
  7408. catch (Exception e)
  7409. {
  7410. dt4 = new DataTable();
  7411. }
  7412. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7413. return;
  7414. }
  7415. if (type == "Wait")
  7416. {
  7417. //待处理
  7418. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7419. DataTable dt5 = null;
  7420. try
  7421. {
  7422. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7423. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7424. }
  7425. catch (Exception e)
  7426. {
  7427. dt5 = new DataTable();
  7428. }
  7429. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7430. return;
  7431. }
  7432. if (type == "documentary")
  7433. {
  7434. //跟单中
  7435. 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) : ""));
  7436. DataTable dt6 = null;
  7437. try
  7438. {
  7439. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7440. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7441. }
  7442. catch (Exception e)
  7443. {
  7444. dt6 = new DataTable();
  7445. }
  7446. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7447. return;
  7448. }
  7449. }
  7450. returnSuccess(ro_json);
  7451. }
  7452. public void end_erp_aftersale()
  7453. {
  7454. if (UrlPostParmsCheck("ctid"))
  7455. {
  7456. string eid = GetPostString("ctid");
  7457. CeErpTradeCell entity = null;
  7458. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7459. if (entity != null)
  7460. {
  7461. string stype = GetPostString("stype");
  7462. string typeStr = stype;
  7463. entity.AfterSaleState = 4;
  7464. entity.FinishAfterSaleTime = DateTime.Now;
  7465. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7466. entity.Update();
  7467. ApiVo apiVo = new ApiVo();
  7468. apiVo.orderNumber = entity.ctid;
  7469. apiVo.actionName = "afterOver";
  7470. designHelper.API_WorkCore(apiVo); //afterOver
  7471. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7472. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7473. CeErpSukuraData.createInfo(entity.ctid, 8);
  7474. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7475. returnSuccessMsg("操作成功!");
  7476. return;
  7477. }
  7478. returnErrorMsg("找不到订单记录");
  7479. }
  7480. }
  7481. public void ins_erp_finishaftersale()
  7482. {
  7483. if (UrlPostParmsCheck("id"))
  7484. {
  7485. string eid = GetPostString("id");
  7486. CeErpTradeResponsible entity = null;
  7487. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7488. if (entity != null)
  7489. {
  7490. entity.VerifyState = 1;
  7491. entity.VerifyTime = DateTime.Now;
  7492. entity.Update();
  7493. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7494. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7495. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7496. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7497. if (dt.Rows.Count <= 0)
  7498. {
  7499. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7500. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7501. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7502. CeErpSukuraData.createInfo(entity.tid, 8);
  7503. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7504. {
  7505. CeErpDesignerBill.Del(entity.tid);
  7506. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7507. }
  7508. }
  7509. returnSuccessMsg("操作成功!");
  7510. return;
  7511. }
  7512. returnErrorMsg("找不到订单记录");
  7513. }
  7514. }
  7515. public void upd_erp_arbitrateaftersale()
  7516. {
  7517. if (UrlPostParmsCheck("id"))
  7518. {
  7519. string eid = GetPostString("id");
  7520. CeErpTradeResponsible entity = null;
  7521. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7522. if (entity != null)
  7523. {
  7524. entity.IsArbitrate = 1;
  7525. entity.ArbitradeMemo = GetPostString("reason");
  7526. entity.VerifyState = 2;
  7527. entity.Update();
  7528. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7529. if (tradecell != null)
  7530. {
  7531. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7532. tradecell.IsArbitrate = 1;
  7533. tradecell.Update();
  7534. }
  7535. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7536. returnSuccessMsg("操作成功!");
  7537. return;
  7538. }
  7539. returnErrorMsg("找不到订单记录");
  7540. }
  7541. }
  7542. public void upd_erp_backaftersale()
  7543. {
  7544. if (UrlPostParmsCheck("tid"))
  7545. {
  7546. string eid = GetPostString("tid");
  7547. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7548. int backNum = 0;
  7549. if (number != null)
  7550. {
  7551. backNum = number.BackNum;
  7552. }
  7553. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7554. CeErpTradeCell entity = null;
  7555. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7556. if (entity != null)
  7557. {
  7558. entity.AfterSaleBackReason = GetPostString("backreason");
  7559. entity.AfterSaleState = 1;
  7560. entity.AfterSaleSupplierState = 0;
  7561. entity.UpdateTime = DateTime.Now;
  7562. entity.Update();
  7563. returnSuccessMsg("操作成功!");
  7564. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7565. return;
  7566. }
  7567. returnErrorMsg("找不到订单记录");
  7568. }
  7569. }
  7570. public void get_erp_supplieraftersalelist()
  7571. {
  7572. DataStruct dStruct = GetPostStruct();
  7573. List<string> lw = new List<string>();
  7574. string tid = GetPostString("ctid");
  7575. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7576. string shopname = GetPostString("shopname");
  7577. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7578. string buyernick = GetPostString("buyer_nick");
  7579. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7580. string sellermemo = GetPostString("seller_memo");
  7581. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7582. string orderState = GetPostString("orderState");
  7583. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7584. string afterState = GetPostString("afterstate");
  7585. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7586. string date1 = GetPostString("date1");
  7587. string date2 = GetPostString("date2");
  7588. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7589. if (dw.Length > 0) lw.Add(dw);
  7590. string price1 = GetPostString("price1");
  7591. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7592. string price2 = GetPostString("price2");
  7593. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7594. string reason = GetPostString("reason");
  7595. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7596. string method = GetPostString("method");
  7597. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7598. string handledate1 = GetPostString("handledate1");
  7599. string handledate2 = GetPostString("handledate2");
  7600. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7601. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7602. string handler = GetPostString("handler");
  7603. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7604. string afterdate1 = GetPostString("afterdate1");
  7605. string afterdate2 = GetPostString("afterdate2");
  7606. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7607. if (afterDate.Length > 0) lw.Add(afterDate);
  7608. string customer = GetPostString("customer");
  7609. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7610. string design = GetPostString("design");
  7611. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7612. string afterMemoType = GetPostString("aftermemotype");
  7613. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7614. string vstate = GetPostString("vstate");
  7615. if (vstate.Length > 0)
  7616. {
  7617. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7618. }
  7619. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7620. string supplier = GetPostString("supplier");
  7621. int supid = commonHelper.getSupplierIDByName(supplier);
  7622. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7623. string posCode = CurrentUser.UserPost.Post.Code;
  7624. if (posCode == "Supplier")
  7625. {
  7626. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7627. }
  7628. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7629. {
  7630. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7631. }
  7632. else
  7633. {
  7634. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7635. }
  7636. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7637. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7638. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7639. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7640. writeGridDataTableJson(dStruct.TotalCount, dt);
  7641. }
  7642. public void upd_erp_supverifyaftersale()
  7643. {
  7644. if (UrlPostParmsCheck("id"))
  7645. {
  7646. string id = GetPostString("id");
  7647. int st = GetPostInt("afterstate");
  7648. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7649. CeErpTradeCell entity = null;
  7650. if (ceErpTradeResponsible != null)
  7651. {
  7652. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7653. }
  7654. string afmemo = GetPostString("supmemo");
  7655. string image = GetPostString("image");
  7656. if (entity != null)
  7657. {
  7658. entity.AfterSaleSupplierState = st;
  7659. entity.AfterSaleSupplierMemo = afmemo;
  7660. if (st == 1)
  7661. {
  7662. ceErpTradeResponsible.VerifyState = 1;
  7663. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7664. ceErpTradeResponsible.Update();
  7665. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7666. if (isAll)
  7667. {
  7668. entity.AfterSaleState = 4;
  7669. entity.FinishAfterSaleTime = DateTime.Now;
  7670. }
  7671. }
  7672. else
  7673. {
  7674. CeErpTradeResponsible.dateByTid(entity.ctid);
  7675. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7676. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7677. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7678. if (num <= 1)
  7679. {
  7680. entity.AfterSaleState = 1;
  7681. }
  7682. else
  7683. {
  7684. entity.AfterSaleState = 5;
  7685. }
  7686. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7687. if (ceErpTradeAfterSaleExtend != null)
  7688. {
  7689. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7690. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7691. ceErpTradeAfterSaleExtend.Update();
  7692. }
  7693. else
  7694. {
  7695. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7696. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7697. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7698. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7699. ceErpTradeAfterSaleExtend.Create();
  7700. }
  7701. }
  7702. if (entity.AfterSaleState == 4)
  7703. {
  7704. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7705. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7706. {
  7707. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7708. }
  7709. ApiVo apiVo = new ApiVo();
  7710. apiVo.orderNumber = entity.ctid;
  7711. apiVo.actionName = "afterOver";
  7712. designHelper.API_WorkCore(apiVo); //afterOver
  7713. }
  7714. entity.UpdateTime = DateTime.Now;
  7715. entity.Update();
  7716. returnSuccessMsg("操作成功!");
  7717. CeErpSukuraData.createInfo(entity.ctid, 8);
  7718. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7719. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7720. return;
  7721. }
  7722. returnErrorMsg("找不到订单记录");
  7723. }
  7724. }
  7725. public void upd_erp_masteraftersale()
  7726. {
  7727. if (UrlPostParmsCheck("id"))
  7728. {
  7729. string id = GetPostString("id");
  7730. int st = GetPostInt("afterstate");
  7731. string afmemo = GetPostString("supmemo");
  7732. string image = GetPostString("image");
  7733. string textResult = GetPostString("textResult");
  7734. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7735. if (ceErpTradeResponsible != null)
  7736. {
  7737. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7738. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7739. ceErpTradeResponsible.Update();
  7740. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7741. if (entity != null)
  7742. {
  7743. entity.AfterSaleSupplierState = st;
  7744. entity.AfterSaleSupplierMemo = afmemo;
  7745. if (st == 1)
  7746. {
  7747. }
  7748. else
  7749. {
  7750. CeErpTradeResponsible.dateByTid(entity.ctid);
  7751. //退回到售后
  7752. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7753. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7754. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7755. if (num <= 1)
  7756. {
  7757. entity.AfterSaleState = 1;
  7758. }
  7759. else
  7760. {
  7761. entity.AfterSaleState = 5;
  7762. }
  7763. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7764. if (ceErpTradeAfterSaleExtend != null)
  7765. {
  7766. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7767. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7768. ceErpTradeAfterSaleExtend.Update();
  7769. }
  7770. else
  7771. {
  7772. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7773. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7774. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7775. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7776. ceErpTradeAfterSaleExtend.Create();
  7777. }
  7778. }
  7779. entity.UpdateTime = DateTime.Now;
  7780. entity.Update();
  7781. returnSuccessMsg("操作成功!");
  7782. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7783. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7784. return;
  7785. }
  7786. }
  7787. returnErrorMsg("找不到订单记录");
  7788. }
  7789. }
  7790. public void upd_erp_personaftersale()
  7791. {
  7792. if (UrlPostParmsCheck("id"))
  7793. {
  7794. //林小连
  7795. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7796. {
  7797. upd_erp_masteraftersale();
  7798. return;
  7799. }
  7800. string id = GetPostString("id");
  7801. int st = GetPostInt("afterstate");
  7802. string afmemo = GetPostString("supmemo");
  7803. string image = GetPostString("image");
  7804. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7805. if (ceErpTradeResponsible != null)
  7806. {
  7807. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7808. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7809. ceErpTradeResponsible.Update();
  7810. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7811. if (entity != null)
  7812. {
  7813. entity.AfterSaleSupplierMemo = afmemo;
  7814. entity.AfterSaleSupplierState = st;
  7815. if (st == 1)
  7816. {
  7817. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7818. if (isAll)
  7819. {
  7820. entity.AfterSaleState = 4;
  7821. entity.FinishAfterSaleTime = DateTime.Now;
  7822. }
  7823. }
  7824. else
  7825. {
  7826. CeErpTradeResponsible.dateByTid(entity.ctid);
  7827. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7828. if (ceErpTradeAfterSaleExtend != null)
  7829. {
  7830. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7831. ceErpTradeAfterSaleExtend.Update();
  7832. }
  7833. else
  7834. {
  7835. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7836. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7837. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7838. ceErpTradeAfterSaleExtend.Create();
  7839. }
  7840. //退回到主管
  7841. //entity.AfterSaleState = 2;
  7842. }
  7843. if (entity.AfterSaleState == 4)
  7844. {
  7845. ApiVo apiVo = new ApiVo();
  7846. apiVo.orderNumber = entity.ctid;
  7847. apiVo.actionName = "afterOver";
  7848. designHelper.API_WorkCore(apiVo); //afterOver
  7849. }
  7850. entity.UpdateTime = DateTime.Now;
  7851. entity.Update();
  7852. returnSuccessMsg("操作成功!");
  7853. CeErpSukuraData.createInfo(entity.ctid, 8);
  7854. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7855. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7856. return;
  7857. }
  7858. }
  7859. returnErrorMsg("找不到订单记录");
  7860. }
  7861. }
  7862. public void set_erp_supplierrefundtag()
  7863. {
  7864. if (UrlPostParmsCheck("ctid"))
  7865. {
  7866. string eid = GetPostString("ctid");
  7867. CeErpTradeCell entity = null;
  7868. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7869. if (entity != null)
  7870. {
  7871. entity.IsSupplierRefund = GetPostInt("tag");
  7872. entity.Update();
  7873. returnSuccessMsg("操作成功!");
  7874. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7875. return;
  7876. }
  7877. returnErrorMsg("找不到订单记录");
  7878. }
  7879. }
  7880. public void get_erp_refundlist()
  7881. {
  7882. DataStruct dStruct = GetPostStruct();
  7883. List<string> lw = new List<string>();
  7884. string tid = GetPostString("tid");
  7885. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7886. //string rid = GetPostString("refund_id");
  7887. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7888. string shopname = GetPostString("shopname");
  7889. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7890. string buyernick = GetPostString("buyer_nick");
  7891. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7892. string customer = GetPostString("customer");
  7893. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7894. string design = GetPostString("design");
  7895. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7896. string sellermemo = GetPostString("seller_memo");
  7897. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7898. //string date1 = GetPostString("date1");
  7899. //string date2 = GetPostString("date2");
  7900. //string dateType = GetPostString("dateType");
  7901. //if (dateType.Length > 0)
  7902. //{
  7903. // if (dateType == "1001") dateType = "0";
  7904. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7905. // if (searchDT.Count == 2)
  7906. // {
  7907. // date1 = searchDT[0].ToString();
  7908. // date2 = searchDT[1].ToString();
  7909. // }
  7910. //}
  7911. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7912. //if (dw.Length > 0) lw.Add(dw);
  7913. string redate1 = GetPostString("refunddate1");
  7914. string redate2 = GetPostString("refunddate2");
  7915. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7916. if (dwdate.Length > 0) lw.Add(dwdate);
  7917. string price1 = GetPostString("price1");
  7918. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7919. string price2 = GetPostString("price2");
  7920. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7921. string ispartrefund = GetPostString("ispartrefund");
  7922. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7923. string refundState = GetPostString("refundvstate");
  7924. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7925. int st = GetInt("st");
  7926. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7927. {
  7928. string responsible = GetPostString("responsibleman");
  7929. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7930. lw.Add(string.Format("RefundState>={0}", st));
  7931. string code = CurrentUser.UserPost.Post.Code;
  7932. if (code == "CustomerService")
  7933. {
  7934. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7935. }
  7936. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7937. {
  7938. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7939. }
  7940. else if (code == "Place" || code == "PlaceMr")
  7941. {
  7942. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7943. }
  7944. dStruct.Order = "RefundState asc,created desc";
  7945. }
  7946. else if (st == 10)
  7947. {
  7948. string responsible = GetPostString("responsibleman");
  7949. if (responsible == "空白")
  7950. {
  7951. lw.Add(string.Format("ResponsibleUserName = ''"));
  7952. }
  7953. else if (responsible.Length > 0)
  7954. {
  7955. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7956. }
  7957. lw.Add(string.Format("RefundState>=0"));
  7958. dStruct.Order = "created desc";
  7959. }
  7960. else
  7961. {
  7962. string responsible = GetPostString("responsibleman");
  7963. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7964. lw.Add(string.Format("RefundState={0}", st));
  7965. dStruct.Order = "created desc";
  7966. }
  7967. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7968. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7969. dt.Columns.Add("refund_fees");
  7970. foreach (DataRow dr in dt.Rows)
  7971. {
  7972. String status = dr["status"].ToString();
  7973. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7974. {
  7975. dr["refund_fees"] = dr["refund_fee"];
  7976. }
  7977. else
  7978. {
  7979. dr["refund_fees"] = "0.0";
  7980. }
  7981. }
  7982. writeGridDataTableJson(dStruct.TotalCount, dt);
  7983. }
  7984. public void get_erp_refunddesignlist()
  7985. {
  7986. DataStruct dStruct = GetPostStruct();
  7987. List<string> lw = new List<string>();
  7988. string tid = GetPostString("tid");
  7989. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7990. string shopname = GetPostString("shopname");
  7991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7992. string buyernick = GetPostString("buyer_nick");
  7993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7994. string customer = GetPostString("customer");
  7995. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7996. string design = GetPostString("design");
  7997. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7998. string sellermemo = GetPostString("seller_memo");
  7999. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8000. string redate1 = GetPostString("refunddate1");
  8001. string redate2 = GetPostString("refunddate2");
  8002. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8003. if (dwdate.Length > 0) lw.Add(dwdate);
  8004. string price1 = GetPostString("price1");
  8005. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8006. string price2 = GetPostString("price2");
  8007. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8008. string ispartrefund = GetPostString("ispartrefund");
  8009. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8010. string designerorg = GetPostString("designerorg");
  8011. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8012. string refundState = GetPostString("refundState");
  8013. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8014. int myOrgid = CurrentUser.UserPost.OrgID;
  8015. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8016. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8017. {
  8018. if (CurrentUser.User.TeamIds.Length > 0)
  8019. {
  8020. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8021. }
  8022. else
  8023. {
  8024. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8025. }
  8026. }
  8027. else if ("SysAdmin".Equals(myOrgCode))
  8028. {
  8029. }
  8030. else
  8031. {
  8032. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8033. {
  8034. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8035. }
  8036. else
  8037. {
  8038. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8039. }
  8040. }
  8041. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8042. dStruct.Order = "created desc";
  8043. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8044. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8045. dt.Columns.Add("refund_fees");
  8046. foreach (DataRow dr in dt.Rows)
  8047. {
  8048. String status = dr["status"].ToString();
  8049. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8050. {
  8051. dr["refund_fees"] = dr["refund_fee"];
  8052. }
  8053. else
  8054. {
  8055. dr["refund_fees"] = "0.0";
  8056. }
  8057. }
  8058. writeGridDataTableJson(dStruct.TotalCount, dt);
  8059. }
  8060. public void handle_erp_refundtag()
  8061. {
  8062. if (UrlPostParmsCheck("refund_id"))
  8063. {
  8064. string eid = GetPostString("refund_id");
  8065. string respMan = GetPostString("ResponsibleName");
  8066. if (respMan.Length <= 0)
  8067. {
  8068. returnErrorMsg("责任人不能为空");
  8069. return;
  8070. }
  8071. CeErpTradeRefund entity = null;
  8072. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8073. if (entity != null)
  8074. {
  8075. entity.ResponsibleUserName = respMan;
  8076. string userid = GetPostString("ResponsibleUserId");
  8077. if (userid.Length > 0)
  8078. {
  8079. entity.ResponsibleUserId = userid;
  8080. }
  8081. entity.Memo = GetPostString("Memo");
  8082. if (respMan.IndexOf("客服") != -1 ||
  8083. respMan.IndexOf("设计师") != -1 ||
  8084. respMan.IndexOf("下单员") != -1)
  8085. {
  8086. entity.RefundState = 2;
  8087. }
  8088. else
  8089. {
  8090. entity.RefundState = 3;
  8091. }
  8092. entity.modified = DateTime.Now;
  8093. entity.Update();
  8094. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8095. returnSuccessMsg("操作成功!");
  8096. return;
  8097. }
  8098. returnErrorMsg("找不到订单记录");
  8099. }
  8100. }
  8101. public void handle_erp_designrefundtag()
  8102. {
  8103. if (UrlPostParmsCheck("refund_id"))
  8104. {
  8105. string eid = GetPostString("refund_id");
  8106. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8107. if (ceErpTradeCellExtend == null)
  8108. {
  8109. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8110. ceErpTradeCellExtend.ctid = eid;
  8111. }
  8112. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8113. if (ceErpTradeCellExtend.ID > 0)
  8114. {
  8115. ceErpTradeCellExtend.Update();
  8116. }
  8117. else
  8118. {
  8119. ceErpTradeCellExtend.Create();
  8120. }
  8121. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8122. returnSuccessMsg("操作成功!");
  8123. return;
  8124. }
  8125. returnErrorMsg("找不到订单记录");
  8126. }
  8127. public void upd_erp_refundverify()
  8128. {
  8129. if (UrlPostParmsCheck("refund_id"))
  8130. {
  8131. string eid = GetPostString("refund_id");
  8132. CeErpTradeRefund entity = null;
  8133. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8134. if (entity != null)
  8135. {
  8136. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8137. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8138. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8139. {
  8140. entity.RefundState = 2;
  8141. }
  8142. else
  8143. {
  8144. entity.RefundState = 3;
  8145. }
  8146. entity.Update();
  8147. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8148. returnSuccessMsg("操作成功!");
  8149. return;
  8150. }
  8151. returnErrorMsg("找不到订单记录");
  8152. }
  8153. }
  8154. public void upd_erp_refundapprove()
  8155. {
  8156. if (UrlPostParmsCheck("refund_id"))
  8157. {
  8158. string eid = GetPostString("refund_id");
  8159. CeErpTradeRefund entity = null;
  8160. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8161. if (entity != null)
  8162. {
  8163. int apr = GetPostInt("approve");
  8164. if (apr == 0)
  8165. {
  8166. entity.RefundState = 1;
  8167. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8168. }
  8169. else if (apr == 1)
  8170. {
  8171. entity.RefundState = 3;
  8172. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8173. }
  8174. entity.modified = DateTime.Now;
  8175. entity.Update();
  8176. returnSuccessMsg("操作成功!");
  8177. return;
  8178. }
  8179. returnErrorMsg("找不到订单记录");
  8180. }
  8181. }
  8182. public void get_erp_billlist()
  8183. {
  8184. DataStruct dStruct = GetPostStruct();
  8185. List<string> lw = new List<string>();
  8186. string title = GetPostString("title");
  8187. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8188. string tid = GetPostString("tid");
  8189. string tids = GetPostString("tids");
  8190. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8191. if (tids.Length > 0)
  8192. {
  8193. tids = "'" + tids + "'";
  8194. tids = tids.Replace(",", "','");
  8195. lw.Add(string.Format("tid in ({0})", tids));
  8196. }
  8197. string shopname = GetPostString("shopname");
  8198. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8199. string buyernick = GetPostString("buyer_nick");
  8200. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8201. string customer = GetPostString("customer");
  8202. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8203. string date1 = GetPostString("date1");
  8204. string date2 = GetPostString("date2");
  8205. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8206. if (dw.Length > 0) lw.Add(dw);
  8207. string price1 = GetPostString("price1");
  8208. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8209. string price2 = GetPostString("price2");
  8210. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8211. string returndate1 = GetPostString("returndate1");
  8212. string returndate2 = GetPostString("returndate2");
  8213. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8214. if (dw1.Length > 0) lw.Add(dw1);
  8215. string billtype = GetPostString("billtype");
  8216. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8217. string billstate = GetPostString("billstate");
  8218. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8219. string usershop = CurrentUser.User.pemShop;
  8220. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8221. dStruct.Order = "createTime desc";
  8222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8223. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8224. //foreach (DataRow dr in dt.Rows)
  8225. //{
  8226. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8227. //}
  8228. writeGridDataTableJson(dStruct.TotalCount, dt);
  8229. }
  8230. public void modify_erp_billinfo()
  8231. {
  8232. if (UrlPostParmsCheck("ID"))
  8233. {
  8234. string eid = GetPostString("ID");
  8235. CeErpBill bill_entity = null;
  8236. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8237. if (bill_entity != null)
  8238. {
  8239. bill_entity.tid = GetPostString("tid");
  8240. bill_entity.title = GetPostString("title");
  8241. bill_entity.tax = GetPostString("tax");
  8242. bill_entity.bank = GetPostString("bank");
  8243. bill_entity.bankac = GetPostString("bankac");
  8244. bill_entity.address = GetPostString("address");
  8245. bill_entity.phone = GetPostString("phone");
  8246. bill_entity.price = GetPostString("price");
  8247. bill_entity.productId = GetPostInt("ProductName");
  8248. bill_entity.num = GetPostInt("num");
  8249. bill_entity.unit = GetPostString("unit");
  8250. bill_entity.type = GetPostString("type");
  8251. bill_entity.sendType = GetPostString("SendType");
  8252. bill_entity.email = GetPostString("email");
  8253. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8254. bill_entity.shopName = GetPostString("ShopName");
  8255. bill_entity.applymemo = GetPostString("applymemo");
  8256. bill_entity.modifyTime = DateTime.Now;
  8257. bill_entity.createTime = DateTime.Now;
  8258. bill_entity.state = 0;
  8259. bill_entity.Update();
  8260. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8261. returnSuccessMsg("发票修改成功!");
  8262. return;
  8263. }
  8264. returnErrorMsg("找不到对应记录");
  8265. }
  8266. }
  8267. public void set_erp_invoicing()
  8268. {
  8269. if (UrlPostParmsCheck("id"))
  8270. {
  8271. try
  8272. {
  8273. string eid = GetPostString("id");
  8274. CeErpBill bill_entity = null;
  8275. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8276. if (bill_entity != null)
  8277. {
  8278. int ComId = GetPostInt("ComId");
  8279. //string memo = GetPostString("Memo");
  8280. int allInfo = GetPostInt("allinfo");
  8281. string clert = CurrentUser.User.Name;
  8282. //string detailValue = GetPostString("detailvalue");
  8283. string billId = bill_entity.billOrderId;
  8284. string[] billIdList = billId.Split(',');
  8285. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8286. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8287. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8288. {
  8289. billCount += 1;
  8290. }
  8291. if (billId.Length <= 0 || billIdList.Length != billCount)
  8292. {
  8293. bill_entity.billOrderId = "";
  8294. string prebill = "ltb";
  8295. for (int idx = 1; idx <= billCount; idx++)
  8296. {
  8297. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8298. string billoid = prebill + idx + dtstr;
  8299. bill_entity.billOrderId += billoid;
  8300. if (idx < billCount)
  8301. {
  8302. bill_entity.billOrderId += ",";
  8303. }
  8304. }
  8305. }
  8306. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8307. if (bill_entity.state == 5)
  8308. {
  8309. string errMsg = bill_entity.failerror;
  8310. string[] errlist = errMsg.Split('|');
  8311. string[] errTags = new string[errlist.Length];
  8312. for (int itag = 0; itag < errlist.Length; itag++)
  8313. {
  8314. if (errlist[itag].Length <= 0) continue;
  8315. errTags[itag] = errlist[itag].Split('&')[0];
  8316. }
  8317. for (int iii = 0; iii < errTags.Length; iii++)
  8318. {
  8319. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8320. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8321. if (billOrderList.Length >= erroBillOrderTag)
  8322. {
  8323. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8324. if (needModifyBillId.Length <= 19)
  8325. {
  8326. needModifyBillId = needModifyBillId + "1";
  8327. }
  8328. else
  8329. {
  8330. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8331. last = last + 1;
  8332. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8333. }
  8334. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8335. }
  8336. }
  8337. }
  8338. bool isHaveBillSucces = false;
  8339. string totalRes = "";
  8340. bill_entity.failerror = "";
  8341. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8342. {
  8343. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8344. totalRes += res;
  8345. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8346. {
  8347. isHaveBillSucces = true;
  8348. bill_entity.comId = ComId;
  8349. bill_entity.state = 1;
  8350. bill_entity.executeTime = DateTime.Now;
  8351. bill_entity.executeUser = clert;
  8352. }
  8353. else
  8354. {
  8355. bill_entity.state = 5;
  8356. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8357. }
  8358. }
  8359. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8360. bill_entity.Update();
  8361. if (isHaveBillSucces)
  8362. {
  8363. StringBuilder sql = new StringBuilder();
  8364. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8365. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8366. }
  8367. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8368. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8369. {
  8370. returnErrorMsg("开票失败");
  8371. }
  8372. else
  8373. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8374. return;
  8375. }
  8376. returnErrorMsg("找不到对应记录");
  8377. }
  8378. catch (Exception ex)
  8379. {
  8380. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8381. returnErrorMsg("操作失败");
  8382. }
  8383. }
  8384. }
  8385. public void get_erp_invoicing_back()
  8386. {
  8387. if (UrlPostParmsCheck("id"))
  8388. {
  8389. try
  8390. {
  8391. string id = GetPostString("id");
  8392. CeErpBill entiy = CeErpBill.Get(id);
  8393. if (entiy != null)
  8394. {
  8395. if (entiy.state == 0)
  8396. {
  8397. returnErrorMsg("发票还未开具");
  8398. return;
  8399. }
  8400. string[] billOrderList = entiy.billOrderId.Split(',');
  8401. int iTag = 0;
  8402. entiy.fplsh = "";
  8403. entiy.fpdm = "";
  8404. entiy.fphm = "";
  8405. foreach (string billOrderId in billOrderList)
  8406. {
  8407. iTag++;
  8408. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8409. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8410. {
  8411. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8412. try
  8413. {
  8414. Invoicing_get_response_Obj iObj = null;
  8415. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8416. if (iObj != null)
  8417. {
  8418. entiy.state = 2;
  8419. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8420. entiy.fpdm += iObj.list[0].c_fpdm;
  8421. entiy.fphm += iObj.list[0].c_fphm;
  8422. if (iTag < billOrderList.Length)
  8423. {
  8424. entiy.fplsh += ",";
  8425. entiy.fpdm += ",";
  8426. entiy.fphm += ",";
  8427. }
  8428. entiy.Update();
  8429. }
  8430. StringBuilder sql = new StringBuilder();
  8431. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8432. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8433. returnSuccessMsg("开票成功");
  8434. }
  8435. catch (Exception ex)
  8436. {
  8437. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8438. }
  8439. return;
  8440. }
  8441. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8442. {
  8443. var res_obj = new
  8444. {
  8445. data = "开票中"
  8446. };
  8447. string ro_json = JsonConvert.SerializeObject(res_obj);
  8448. returnSuccess(ro_json);
  8449. return;
  8450. }
  8451. else
  8452. {
  8453. int eidx = res.IndexOf("c_resultmsg");
  8454. int lidx = res.IndexOf("c_status");
  8455. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8456. entiy.state = 5;
  8457. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8458. entiy.Update();
  8459. returnErrorMsg("开票失败");
  8460. return;
  8461. }
  8462. }
  8463. }
  8464. }
  8465. catch (Exception ex)
  8466. {
  8467. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8468. }
  8469. return;
  8470. }
  8471. }
  8472. public void get_erp_invoicing()
  8473. {
  8474. if (UrlPostParmsCheck("id"))
  8475. {
  8476. try
  8477. {
  8478. string id = GetPostString("id");
  8479. CeErpBill entiy = CeErpBill.Get(id);
  8480. if (entiy != null)
  8481. {
  8482. if (entiy.state == 0)
  8483. {
  8484. returnErrorMsg("发票还未开具");
  8485. return;
  8486. }
  8487. if (entiy.sendType == "纸质发票")
  8488. {
  8489. if (entiy.img.Length <= 0)
  8490. {
  8491. returnErrorMsg("查无纸质发票");
  8492. return;
  8493. }
  8494. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8495. returnSuccess(returnres);
  8496. return;
  8497. }
  8498. string[] billOrderList = entiy.billOrderId.Split(',');
  8499. int iTag = 0;
  8500. string fpUrl = "";
  8501. entiy.fplsh = "";
  8502. entiy.fpdm = "";
  8503. entiy.fphm = "";
  8504. foreach (string billOrderId in billOrderList)
  8505. {
  8506. iTag++;
  8507. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8508. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8509. {
  8510. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8511. Invoicing_get_response_Obj iObj = null;
  8512. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8513. if (iObj != null)
  8514. {
  8515. //entiy.state = 2;
  8516. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8517. entiy.fpdm += iObj.list[0].c_fpdm;
  8518. entiy.fphm += iObj.list[0].c_fphm;
  8519. if (iTag < billOrderList.Length)
  8520. {
  8521. entiy.fplsh += ",";
  8522. entiy.fpdm += ",";
  8523. entiy.fphm += ",";
  8524. }
  8525. entiy.Update();
  8526. fpUrl += iObj.list[0].c_url + ",";
  8527. }
  8528. //returnSuccess(res);
  8529. StringBuilder sql = new StringBuilder();
  8530. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8531. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8532. }
  8533. else
  8534. {
  8535. int eidx = res.IndexOf("c_resultmsg");
  8536. //int lidx = res.IndexOf("c_status");
  8537. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8538. //开票失败
  8539. entiy.state = 5;
  8540. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8541. entiy.Update();
  8542. returnErrorMsg("开票失败");
  8543. return;
  8544. }
  8545. }
  8546. var returnObj = new
  8547. {
  8548. data = fpUrl
  8549. };
  8550. string ro_json = JsonConvert.SerializeObject(returnObj);
  8551. returnSuccess(ro_json);
  8552. }
  8553. }
  8554. catch (Exception ex)
  8555. {
  8556. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8557. }
  8558. return;
  8559. }
  8560. }
  8561. public void save_erp_billimg()
  8562. {
  8563. if (UrlPostParmsCheck("id"))
  8564. {
  8565. string eid = GetPostString("id");
  8566. CeErpBill bill_entity = null;
  8567. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8568. if (bill_entity != null)
  8569. {
  8570. bill_entity.img = GetPostString("img");
  8571. bill_entity.executeTime = DateTime.Now;
  8572. bill_entity.state = 2;
  8573. bill_entity.Update();
  8574. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8575. returnSuccessMsg("保存成功");
  8576. }
  8577. return;
  8578. }
  8579. }
  8580. public void upd_erp_billreturnback()
  8581. {
  8582. if (UrlPostParmsCheck("id"))
  8583. {
  8584. int eid = GetPostInt("id");
  8585. CeErpBill bill_entity = null;
  8586. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8587. if (bill_entity != null)
  8588. {
  8589. bill_entity.state = 3;
  8590. bill_entity.returnReason = GetPostString("reason");
  8591. bill_entity.Update();
  8592. returnSuccessMsg("驳回成功!");
  8593. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8594. }
  8595. return;
  8596. }
  8597. }
  8598. public void cancel_erp_bill()
  8599. {
  8600. if (UrlPostParmsCheck("id"))
  8601. {
  8602. int eid = GetPostInt("id");
  8603. int detailValue = GetPostInt("detailvalue");
  8604. CeErpBill bill_entity = null;
  8605. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8606. string cres = "";
  8607. string gres = "";
  8608. if (bill_entity != null)
  8609. {
  8610. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8611. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8612. {
  8613. int iTag = 0;
  8614. bill_entity.fplsh = "";
  8615. bill_entity.fpdm = "";
  8616. bill_entity.fphm = "";
  8617. foreach (string billOrderId in billOrderList)
  8618. {
  8619. iTag++;
  8620. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8621. if (gres.IndexOf("success") != -1)
  8622. {
  8623. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8624. Invoicing_get_response_Obj iObj = null;
  8625. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8626. if (iObj != null)
  8627. {
  8628. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8629. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8630. bill_entity.fphm += iObj.list[0].c_fphm;
  8631. if (iTag < billOrderList.Length)
  8632. {
  8633. bill_entity.fplsh += ",";
  8634. bill_entity.fpdm += ",";
  8635. bill_entity.fphm += ",";
  8636. }
  8637. bill_entity.Update();
  8638. }
  8639. }
  8640. else
  8641. {
  8642. returnErrorMsg(gres);
  8643. return;
  8644. }
  8645. }
  8646. }
  8647. if (bill_entity.sendType == "纸质发票")
  8648. {
  8649. //作废
  8650. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8651. //if (DateTime.Now.Month == extime.Month)
  8652. //{
  8653. //cres = taobaoHelper.cancel_invoicing(eid);
  8654. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8655. //{
  8656. bill_entity.state = 4;//已作废
  8657. bill_entity.Update();
  8658. returnSuccessMsg("发票已作废");
  8659. return;
  8660. //}
  8661. //else
  8662. //{
  8663. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8664. // bill_entity.Update();
  8665. // returnErrorMsg(cres);
  8666. // return;
  8667. //}
  8668. //}
  8669. //else
  8670. //{
  8671. // returnErrorMsg("纸质发票只能作废本月的发票");
  8672. // return;
  8673. //}
  8674. }
  8675. //红冲
  8676. int redTag = 0;
  8677. string[] fpdmList = bill_entity.fpdm.Split(',');
  8678. string[] fphmList = bill_entity.fphm.Split(',');
  8679. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8680. {
  8681. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8682. return;
  8683. }
  8684. foreach (string billOrderId in billOrderList)
  8685. {
  8686. redTag++;
  8687. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8688. cres += onecres;
  8689. cres += ",";
  8690. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8691. {
  8692. bill_entity.state = 4;//已作废
  8693. //bill_entity.Update();
  8694. //returnSuccessMsg("发票已红冲");
  8695. }
  8696. else if (onecres.IndexOf("重复冲红") != -1)
  8697. {
  8698. bill_entity.state = 4;//已作废
  8699. //bill_entity.Update();
  8700. //returnSuccessMsg("发票已红冲");
  8701. }
  8702. else
  8703. {
  8704. string errmsg = commonHelper.KeepChinese(onecres);
  8705. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8706. }
  8707. }
  8708. bill_entity.Update();
  8709. if (cres.IndexOf("失败") != -1)
  8710. returnErrorMsg("红冲失败");
  8711. else
  8712. returnSuccessMsg("发票已红冲");
  8713. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8714. return;
  8715. }
  8716. return;
  8717. }
  8718. }
  8719. public void del_erp_billorder()
  8720. {
  8721. if (UrlPostParmsCheck("id"))
  8722. {
  8723. string eid = GetPostString("id");
  8724. CeErpBill.Del(eid);
  8725. CeErpBill bill = CeErpBill.Get(eid);
  8726. if (bill != null)
  8727. {
  8728. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8729. }
  8730. returnSuccessMsg("删除成功");
  8731. }
  8732. }
  8733. public void finish_erp_bill()
  8734. {
  8735. if (UrlPostParmsCheck("ids"))
  8736. {
  8737. string eids = GetPostString("ids");
  8738. string[] list = eids.Split(',');
  8739. foreach (string eid in list)
  8740. {
  8741. CeErpBill bill = CeErpBill.Get(eid);
  8742. if (bill != null)
  8743. {
  8744. bill.state = 2;
  8745. bill.Update();
  8746. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8747. }
  8748. }
  8749. returnSuccessMsg("操作成功");
  8750. }
  8751. }
  8752. public void get_erp_returncash()
  8753. {
  8754. DataStruct dStruct = GetPostStruct();
  8755. List<string> lw = new List<string>();
  8756. string tid = GetPostString("tid");
  8757. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8758. string shopname = GetPostString("shopname");
  8759. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8760. string buyernick = GetPostString("buyer_nick");
  8761. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8762. string customer = GetPostString("customer");
  8763. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8764. string returndate1 = GetPostString("returndate1");
  8765. string returndate2 = GetPostString("returndate2");
  8766. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8767. if (dw.Length > 0) lw.Add(dw);
  8768. string finishDate1 = GetPostString("finishdate1");
  8769. string finishDate2 = GetPostString("finishdate2");
  8770. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8771. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8772. string returntype = GetPostString("returntype");
  8773. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8774. string returnvstate = GetPostString("returnvstate");
  8775. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8776. dStruct.Order = "created desc";
  8777. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8778. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8779. writeGridDataTableJson(dStruct.TotalCount, dt);
  8780. }
  8781. public void get_erp_staygoods()
  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("shop_name like '%{0}%'", shopname));
  8789. string wangwang = GetPostString("wangwang");
  8790. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8791. string customer = GetPostString("customer");
  8792. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8793. string returndate1 = GetPostString("returndate1");
  8794. string returndate2 = GetPostString("returndate2");
  8795. string dw = GetDateMinuteWhere("creata_time", 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("audit_time", finishDate1, finishDate2);
  8800. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8801. string returnvstate = GetPostString("returnvstate");
  8802. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8803. string persuadetype = GetPostString("persuadetype");
  8804. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8805. string customerOrg = GetPostString("customerOrg");
  8806. if (customerOrg.Length > 0)
  8807. {
  8808. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8809. }
  8810. dStruct.Order = "creata_time desc";
  8811. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8812. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8813. writeGridDataTableJson(dStruct.TotalCount, dt);
  8814. }
  8815. public void upd_erp_staygoods()
  8816. {
  8817. if (UrlPostParmsCheck("id"))
  8818. {
  8819. int eid = GetPostInt("id");
  8820. CeErpStayGoods entity = null;
  8821. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8822. if (entity != null)
  8823. {
  8824. entity.audit_type = 1;
  8825. entity.audit_time = DateTime.Now;
  8826. entity.audit_u_id = CurrentUser.UserID;
  8827. entity.audit_u_name = CurrentUser.UserName;
  8828. entity.Update();
  8829. returnSuccessMsg("审核成功!");
  8830. return;
  8831. }
  8832. returnErrorMsg("找不到订单记录");
  8833. }
  8834. }
  8835. public void upd_erp_stayGoodsback()
  8836. {
  8837. if (UrlPostParmsCheck("id"))
  8838. {
  8839. int eid = GetPostInt("id");
  8840. CeErpStayGoods entity = null;
  8841. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8842. if (entity != null)
  8843. {
  8844. entity.audit_text = GetPostString("reason");
  8845. entity.audit_type = 2;
  8846. entity.audit_time = DateTime.Now;
  8847. entity.audit_u_id = CurrentUser.UserID;
  8848. entity.audit_u_name = CurrentUser.UserName;
  8849. entity.Update();
  8850. returnSuccessMsg("退回成功!");
  8851. return;
  8852. }
  8853. returnErrorMsg("找不到订单记录");
  8854. }
  8855. }
  8856. public void upd_erp_returncashverify()
  8857. {
  8858. if (UrlPostParmsCheck("ID"))
  8859. {
  8860. int eid = GetPostInt("ID");
  8861. CeErpReturnCash entity = null;
  8862. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8863. if (entity != null)
  8864. {
  8865. entity.cashstate = 1;
  8866. entity.verifytime = DateTime.Now;
  8867. entity.verifyuserid = CurrentUser.UserID;
  8868. entity.Update();
  8869. returnSuccessMsg("审核成功!");
  8870. return;
  8871. }
  8872. returnErrorMsg("找不到订单记录");
  8873. }
  8874. }
  8875. public void upd_all_erp_returncashverify()
  8876. {
  8877. if (UrlPostParmsCheck("ID"))
  8878. {
  8879. String[] list = GetPostString("ID").Split(',');
  8880. CeErpReturnCash entity = null;
  8881. for (int i = 0; i < list.Length; i++)
  8882. {
  8883. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8884. if (entity != null)
  8885. {
  8886. if (entity.cashstate == 1)
  8887. {
  8888. returnErrorMsg("已审核过的订单不需要在审核!");
  8889. return;
  8890. }
  8891. entity.cashstate = 1;
  8892. entity.verifytime = DateTime.Now;
  8893. entity.verifyuserid = CurrentUser.UserID;
  8894. entity.Update();
  8895. }
  8896. }
  8897. returnSuccessMsg("审核成功!");
  8898. return;
  8899. }
  8900. }
  8901. public void upd_erp_returncashback()
  8902. {
  8903. if (UrlPostParmsCheck("ID"))
  8904. {
  8905. int eid = GetPostInt("ID");
  8906. CeErpReturnCash entity = null;
  8907. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8908. if (entity != null)
  8909. {
  8910. entity.backreason = GetPostString("reason");
  8911. entity.cashstate = 2;
  8912. entity.verifytime = DateTime.Now;
  8913. entity.verifyuserid = CurrentUser.UserID;
  8914. entity.Update();
  8915. returnSuccessMsg("退回成功!");
  8916. return;
  8917. }
  8918. returnErrorMsg("找不到订单记录");
  8919. }
  8920. }
  8921. public void upd_erp_returnprice()
  8922. {
  8923. if (UrlPostParmsCheck("ID"))
  8924. {
  8925. int eid = GetPostInt("ID");
  8926. CeErpReturnCash entity = null;
  8927. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8928. if (entity != null)
  8929. {
  8930. if (entity.cashstate == 1)
  8931. {
  8932. returnErrorMsg("审核通过了不能改");
  8933. return;
  8934. }
  8935. entity.returnprice = GetPostDouble("returnprice");
  8936. entity.Update();
  8937. returnSuccessMsg("修改成功!");
  8938. return;
  8939. }
  8940. returnErrorMsg("找不到订单记录");
  8941. }
  8942. }
  8943. public void del_erp_returncash()
  8944. {
  8945. if (UrlPostParmsCheck("ID"))
  8946. {
  8947. int eid = GetPostInt("ID");
  8948. CeErpReturnCash.Del(eid);
  8949. returnSuccessMsg("操作成功");
  8950. return;
  8951. }
  8952. }
  8953. public void test_for_do_sql()
  8954. {
  8955. string sql = GetPostString("sqlstr");
  8956. if (sql.Length > 0)
  8957. {
  8958. try
  8959. {
  8960. DbHelper.DbConn.ExecuteNonQuery(sql);
  8961. var res_obj = new
  8962. {
  8963. data = "成功",
  8964. };
  8965. string ro_json = JsonConvert.SerializeObject(res_obj);
  8966. returnSuccess(ro_json);
  8967. }
  8968. catch (Exception ex)
  8969. {
  8970. var res_obj = new
  8971. {
  8972. data = ex.Message,
  8973. };
  8974. string ro_json = JsonConvert.SerializeObject(res_obj);
  8975. returnSuccess(ro_json);
  8976. }
  8977. }
  8978. }
  8979. public void get_user_info()
  8980. {
  8981. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8982. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8983. }
  8984. public void get_total_data()
  8985. {
  8986. int userId = CurrentUser.UserID;
  8987. string sql = "";
  8988. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8989. {
  8990. 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);
  8991. }
  8992. else
  8993. {
  8994. 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 " +
  8995. "(select ID from CE_ErpUser where ID = {0}) d " +
  8996. "left join " +
  8997. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8998. ") a on d.ID = a.id left join " +
  8999. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9000. ") b on a.id = b.id1 left join" +
  9001. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9002. ") c on a.id = c.id2;", userId);
  9003. }
  9004. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9005. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9006. }
  9007. public void get_date_area_total_data2()
  9008. {
  9009. int userId = CurrentUser.UserID;
  9010. string date_type = GetPostString("timetype");
  9011. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9012. string sql = "";
  9013. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9014. {
  9015. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9016. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9017. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9018. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9019. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9020. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9021. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9022. ") a on e.ID = a.id left join " +
  9023. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9024. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9025. ") b on a.id = b.id1 " +
  9026. "left join " +
  9027. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9028. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9029. ") c on a.id = c.id2 " +
  9030. "left join " +
  9031. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9032. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9033. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9034. }
  9035. else
  9036. {
  9037. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9038. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9039. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9040. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9041. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9042. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9043. ") a on e.ID = a.id left join " +
  9044. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9045. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9046. ") c on a.id = c.id2 " +
  9047. "left join " +
  9048. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9049. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9050. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9051. }
  9052. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9053. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9054. }
  9055. public void get_date_area_total_data()
  9056. {
  9057. int userId = CurrentUser.UserID;
  9058. string date_type = GetPostString("timetype");
  9059. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9060. string date1 = searchDT[0].ToString();
  9061. string date2 = searchDT[1].ToString();
  9062. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9063. {
  9064. SqlParameter[] sqlParameter ={
  9065. new SqlParameter("@userId", SqlDbType.Int,4),
  9066. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9067. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9068. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9069. };
  9070. sqlParameter[0].Value = userId;
  9071. sqlParameter[1].Value = date1;
  9072. sqlParameter[2].Value = date2;
  9073. sqlParameter[3].Direction = ParameterDirection.Output;
  9074. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9075. string res = sqlParameter[3].Value.ToString();
  9076. var res_obj = new
  9077. {
  9078. data = res
  9079. };
  9080. string ro_json = JsonConvert.SerializeObject(res_obj);
  9081. returnSuccess(ro_json);
  9082. }
  9083. else
  9084. {
  9085. SqlParameter[] sqlParameter ={
  9086. new SqlParameter("@userId", SqlDbType.Int,4),
  9087. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9088. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9089. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9090. };
  9091. sqlParameter[0].Value = userId;
  9092. sqlParameter[1].Value = date1;
  9093. sqlParameter[2].Value = date2;
  9094. sqlParameter[3].Direction = ParameterDirection.Output;
  9095. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9096. string res = sqlParameter[3].Value.ToString();
  9097. var res_obj = new
  9098. {
  9099. data = res
  9100. };
  9101. string ro_json = JsonConvert.SerializeObject(res_obj);
  9102. returnSuccess(ro_json);
  9103. }
  9104. //writeGridDataViewJson(dt.Rows.Count, dv);
  9105. }
  9106. public void get_order_list()
  9107. {
  9108. string strFields = GetPostString("paraFields");
  9109. string strOrder = GetPostString("paraOrder");
  9110. string strWhere = GetPostString("paraWhere");
  9111. string strPageSize = GetPostString("paraPageSize");
  9112. DataStruct dStruct = GetPostStruct();
  9113. dStruct.PageSize = int.Parse(strPageSize);
  9114. dStruct.Fileds = strFields;
  9115. dStruct.Order = strOrder;
  9116. dStruct.MainWhere = strWhere;
  9117. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9118. writeGridDataTableJson(dStruct.TotalCount, dt);
  9119. }
  9120. ////获取待开始订单列表
  9121. //public void get_wait_design_order_list()
  9122. //{
  9123. // string date_type = GetPostString("date_type");
  9124. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9125. // DataStruct dStruct = GetPostStruct();
  9126. // dStruct.PageSize = 1000;
  9127. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9128. // List<string> lw = new List<string>();
  9129. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9130. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9131. // dStruct.Order = "WaitDesignTime asc";
  9132. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9133. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9134. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9135. //}
  9136. //获取完成单量排名
  9137. public void get_finish_order_count_ranking()
  9138. {
  9139. /* string date_type = GetPostString("date_type");
  9140. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9141. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9142. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9143. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9144. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9145. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9146. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9147. writeGridDataTableJson(0, new DataTable());
  9148. }
  9149. public void get_finish_order_amount_ranking()
  9150. {
  9151. /*string date_type = GetPostString("date_type");
  9152. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9153. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9154. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9155. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9156. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9157. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9158. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9159. writeGridDataTableJson(0, new DataTable());
  9160. }
  9161. public void get_finish_refund_count_ranking()
  9162. {
  9163. string date_type = GetPostString("date_type");
  9164. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9165. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9166. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9167. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9168. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9169. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9170. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9171. writeGridDataTableJson(dt.Rows.Count, dt);
  9172. }
  9173. public void get_finish_refund_amount_ranking()
  9174. {
  9175. string date_type = GetPostString("date_type");
  9176. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9177. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9178. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9179. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9180. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9181. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9182. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9183. writeGridDataTableJson(dt.Rows.Count, dt);
  9184. }
  9185. public void set_erp_finishorder_director()
  9186. {
  9187. if (UrlPostParmsCheck("ctid"))
  9188. {
  9189. string eid = GetPostString("ctid");
  9190. CeErpTradeCell entity = null;
  9191. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9192. if (entity != null)
  9193. {
  9194. entity.OrderState = 8;
  9195. entity.Update();
  9196. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9197. returnSuccessMsg("操作成功!");
  9198. return;
  9199. }
  9200. returnErrorMsg("找不到记录");
  9201. }
  9202. }
  9203. public void get_erp_placeregistlist()
  9204. {
  9205. DataStruct dStruct = GetPostStruct();
  9206. List<string> lw = new List<string>();
  9207. string outsid = GetPostString("outsid");
  9208. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9209. string memo = GetPostString("memo");
  9210. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9211. string filename = GetPostString("filename");
  9212. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9213. string islate = GetPostString("islate");
  9214. if (islate.Length > 0)
  9215. {
  9216. if (islate == "1")
  9217. lw.Add(string.Format("OutLate>0"));
  9218. else
  9219. lw.Add(string.Format("OutLate=0"));
  9220. }
  9221. string placedate1 = GetPostString("placedate1");
  9222. string placedate2 = GetPostString("placedate2");
  9223. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9224. if (dw.Length > 0) lw.Add(dw);
  9225. string deliveryDate1 = GetPostString("deliverydate1");
  9226. string deliveryDate2 = GetPostString("deliverydate2");
  9227. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9228. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9229. dStruct.Order = "ID desc";
  9230. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9231. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9232. writeGridDataTableJson(dStruct.TotalCount, dt);
  9233. }
  9234. public void ins_erp_placeregist()
  9235. {
  9236. if (UrlPostParmsCheck("id"))
  9237. {
  9238. string eid = GetPostString("id");
  9239. CeErpPlaceRegister entity = null;
  9240. if (eid == "0")//新增
  9241. {
  9242. entity = new CeErpPlaceRegister();
  9243. string xdTime = GetPostString("placeTime");
  9244. if (xdTime.Length > 0)
  9245. {
  9246. entity.PlactTime = Convert.ToDateTime(xdTime);
  9247. }
  9248. string fhTime = GetPostString("deliveryTime");
  9249. if (fhTime.Length > 0)
  9250. {
  9251. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9252. }
  9253. string preTime = GetPostString("preOutTime");
  9254. if (preTime.Length > 0)
  9255. {
  9256. entity.PreOutTime = Convert.ToDateTime(preTime);
  9257. }
  9258. entity.DeliveryCount = GetPostInt("deliveryCount");
  9259. entity.ReceiveCount = GetPostInt("receiveCount");
  9260. entity.OutSid = GetPostString("outSid");
  9261. entity.FileName = GetPostString("fileName");
  9262. entity.Memo = GetPostString("memo");
  9263. entity.AddUserId = CurrentUser.UserID;
  9264. entity.CreateTime = DateTime.Now;
  9265. entity.Img = GetPostString("img");
  9266. entity.Supplier = GetPostInt("supplier");
  9267. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9268. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9269. {
  9270. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9271. DateTime dt2 = (DateTime)entity.PreOutTime;
  9272. TimeSpan span = dt1.Subtract(dt2);
  9273. if (span.Days > 0)
  9274. {
  9275. entity.OutLate = span.Days;
  9276. }
  9277. }
  9278. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9279. entity.Create();
  9280. returnSuccessMsg("添加成功!");
  9281. return;
  9282. }
  9283. else //修改
  9284. {
  9285. entity = CeErpPlaceRegister.Get(eid);
  9286. if (entity != null)
  9287. {
  9288. string xdTime = GetPostString("placeTime");
  9289. if (xdTime.Length > 0)
  9290. {
  9291. entity.PlactTime = Convert.ToDateTime(xdTime);
  9292. }
  9293. string fhTime = GetPostString("deliveryTime");
  9294. if (fhTime.Length > 0)
  9295. {
  9296. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9297. }
  9298. string preTime = GetPostString("preOutTime");
  9299. if (preTime.Length > 0)
  9300. {
  9301. entity.PreOutTime = Convert.ToDateTime(preTime);
  9302. }
  9303. entity.DeliveryCount = GetPostInt("deliveryCount");
  9304. entity.ReceiveCount = GetPostInt("receiveCount");
  9305. if (entity.DeliveryCount == entity.ReceiveCount)
  9306. {
  9307. entity.CurState = "已完成";
  9308. }
  9309. else
  9310. {
  9311. entity.CurState = "未完成";
  9312. }
  9313. entity.OutSid = GetPostString("outSid");
  9314. entity.FileName = GetPostString("fileName");
  9315. entity.Memo = GetPostString("memo");
  9316. entity.Img = GetPostString("img");
  9317. entity.Supplier = GetPostInt("supplier");
  9318. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9319. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9320. {
  9321. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9322. DateTime dt2 = (DateTime)entity.PreOutTime;
  9323. TimeSpan span = dt1.Subtract(dt2);
  9324. if (span.Days > 0)
  9325. {
  9326. entity.OutLate = span.Days;
  9327. }
  9328. }
  9329. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9330. entity.Update();
  9331. returnSuccessMsg("修改成功");
  9332. return;
  9333. }
  9334. returnErrorMsg("找不到对应的记录");
  9335. return;
  9336. }
  9337. }
  9338. returnErrorMsg("缺少必要参数");
  9339. }
  9340. public void del_erp_placeregist()
  9341. {
  9342. string eid = GetPostString("id");
  9343. CeErpPlaceRegister.Del(eid);
  9344. returnSuccessMsg("删除成功!");
  9345. return;
  9346. }
  9347. public void ins_erp_placeregistbyorder()
  9348. {
  9349. string ctid = GetPostString("ctid");
  9350. if (ctid.Length > 0)
  9351. {
  9352. StringBuilder sql = new StringBuilder();
  9353. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9354. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9355. if (dt.Rows.Count > 0)
  9356. {
  9357. foreach (DataRow dr in dt.Rows)
  9358. {
  9359. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9360. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9361. entity.AddUserId = CurrentUser.UserID;
  9362. entity.tid = dr["tid"].ToString();
  9363. entity.Did = Convert.ToString(dr["ctid"]);
  9364. entity.splitTag = dr["SplitTag"].ToString();
  9365. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9366. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9367. if (pre_ctid.Length > 0)
  9368. {
  9369. sellmemo = sellmemo.Replace(pre_ctid, "");
  9370. }
  9371. sellmemo = sellmemo.Replace("[", "");
  9372. sellmemo = sellmemo.Replace("]", "");
  9373. entity.FileName = sellmemo;
  9374. string count = dr["ProductCount"].ToString();
  9375. int usecount = commonHelper.getIntCountFromString(count);
  9376. entity.DeliveryCount = usecount;
  9377. entity.CurState = "未完成";
  9378. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9379. {
  9380. entity.Supplier = 24;//dl手提袋定制
  9381. }
  9382. else
  9383. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9384. entity.CreateTime = DateTime.Now;
  9385. entity.Create();
  9386. }
  9387. returnSuccessMsg("操作成功");
  9388. return;
  9389. }
  9390. returnErrorMsg("没有找到对应订单");
  9391. return;
  9392. }
  9393. returnErrorMsg("缺少订单编号");
  9394. return;
  9395. }
  9396. public void get_erp_persuadelist()
  9397. {
  9398. DataStruct dStruct = GetPostStruct();
  9399. List<string> lw = new List<string>();
  9400. string ctid = GetPostString("ctid");
  9401. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9402. string shopname = GetPostString("shopname");
  9403. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9404. string buyernick = GetPostString("buyer_nick");
  9405. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9406. string customer = GetPostString("customer");
  9407. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9408. string returndate1 = GetPostString("returndate1");
  9409. string returndate2 = GetPostString("returndate2");
  9410. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9411. if (dw.Length > 0) lw.Add(dw);
  9412. string finishDate1 = GetPostString("finishdate1");
  9413. string finishDate2 = GetPostString("finishdate2");
  9414. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9415. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9416. string persuadetype = GetPostString("persuadetype");
  9417. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9418. string returnvstate = GetPostString("returnvstate");
  9419. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9420. dStruct.Order = "created desc";
  9421. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9422. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9423. writeGridDataTableJson(dStruct.TotalCount, dt);
  9424. }
  9425. public void upd_erp_returnpersuadeback()
  9426. {
  9427. if (UrlPostParmsCheck("ID"))
  9428. {
  9429. int eid = GetPostInt("ID");
  9430. CeErpPersuade entity = null;
  9431. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9432. if (entity != null)
  9433. {
  9434. entity.backreason = GetPostString("reason");
  9435. entity.pstate = 2;
  9436. entity.verifytime = DateTime.Now;
  9437. entity.verifyuserid = CurrentUser.UserID;
  9438. entity.Update();
  9439. returnSuccessMsg("退回成功!");
  9440. return;
  9441. }
  9442. returnErrorMsg("找不到订单记录");
  9443. }
  9444. }
  9445. public void upd_erp_returnpersuadeverify()
  9446. {
  9447. if (UrlPostParmsCheck("ID"))
  9448. {
  9449. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9450. {
  9451. returnErrorMsg("暂无权限审核");
  9452. return;
  9453. }
  9454. int eid = GetPostInt("ID");
  9455. CeErpPersuade entity = null;
  9456. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9457. if (entity != null)
  9458. {
  9459. entity.pstate = 1;
  9460. entity.verifytime = DateTime.Now;
  9461. entity.verifyuserid = CurrentUser.UserID;
  9462. entity.Update();
  9463. returnSuccessMsg("审核成功!");
  9464. return;
  9465. }
  9466. returnErrorMsg("找不到订单记录");
  9467. }
  9468. }
  9469. public void del_erp_persuade()
  9470. {
  9471. if (UrlPostParmsCheck("ID"))
  9472. {
  9473. int eid = GetPostInt("ID");
  9474. CeErpPersuade.Del(eid);
  9475. returnSuccessMsg("操作成功");
  9476. return;
  9477. }
  9478. }
  9479. public void get_erp_oldcustoupload()
  9480. {
  9481. DataStruct dStruct = GetPostStruct();
  9482. List<string> lw = new List<string>();
  9483. string buyernick = GetPostString("buyer_nick");
  9484. if (buyernick.Length > 0)
  9485. {
  9486. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9487. }
  9488. else
  9489. return;
  9490. dStruct.Order = "pay_time desc";
  9491. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9492. DataTable dt = null;
  9493. dt = WebCache.GetData("view_erptradecell", dStruct);
  9494. writeGridDataTableJson(dStruct.TotalCount, dt);
  9495. }
  9496. public void get_erp_checkorderlist()
  9497. {
  9498. DataStruct dStruct = GetPostStruct();
  9499. List<string> lw = new List<string>();
  9500. string tid = GetPostString("ctid");
  9501. if (tid.Length > 0)
  9502. {
  9503. string select_tid = getTidByCtid(tid);
  9504. lw.Add(string.Format("tid='{0}'", select_tid));
  9505. }
  9506. string shopname = GetPostString("shopname");
  9507. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9508. string buyernick = GetPostString("buyer_nick");
  9509. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9510. string customer = GetPostString("customer");
  9511. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9512. string design = GetPostString("design");
  9513. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9514. string orderState = GetPostString("orderState");
  9515. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9516. string address = GetPostString("address");
  9517. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9518. string sellermemo = GetPostString("seller_memo");
  9519. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9520. string supplier = GetPostString("supplier");
  9521. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9522. {
  9523. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9524. }
  9525. else
  9526. {
  9527. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9528. }
  9529. string date1 = GetPostString("date1");
  9530. string date2 = GetPostString("date2");
  9531. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9532. if (dw.Length > 0) lw.Add(dw);
  9533. string placedate1 = GetPostString("placedate1");
  9534. string placedate2 = GetPostString("placedate2");
  9535. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9536. if (fdw.Length > 0) lw.Add(fdw);
  9537. string price1 = GetPostString("price1");
  9538. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9539. string price2 = GetPostString("price2");
  9540. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9541. string checkst = GetPostString("checkstate");
  9542. if (checkst.Length > 0 && "10".Equals(checkst))
  9543. {
  9544. lw.Add(string.Format("CheckOut>0"));
  9545. }
  9546. else
  9547. {
  9548. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9549. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9550. }
  9551. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9552. {
  9553. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9554. }
  9555. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9556. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9557. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9558. writeGridDataTableJson(dStruct.TotalCount, dt);
  9559. }
  9560. public void ins_erp_startCheck()
  9561. {
  9562. if (UrlPostParmsCheck("ctid"))
  9563. {
  9564. string eid = GetPostString("ctid");
  9565. CeErpTradeCell entity = null;
  9566. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9567. if (entity != null)
  9568. {
  9569. entity.MemoOpt = 4;
  9570. entity.UpdateTime = DateTime.Now;
  9571. entity.Update();
  9572. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9573. CeErpSukuraData.createInfo(entity.ctid, 6);
  9574. returnSuccessMsg("操作成功!");
  9575. return;
  9576. }
  9577. returnErrorMsg("找不到记录");
  9578. }
  9579. }
  9580. public void upd_erp_sendXlw()
  9581. {
  9582. if (UrlPostParmsCheck("ctid"))
  9583. {
  9584. string eid = GetPostString("ctid");
  9585. CeErpTradeCell entity = null;
  9586. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9587. if (entity != null)
  9588. {
  9589. if (entity.IsSendGift == 1)
  9590. {
  9591. returnErrorMsg("请勿重复标记");
  9592. return;
  9593. }
  9594. entity.IsSendGift = 1;
  9595. entity.Update();
  9596. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9597. returnSuccessMsg("操作成功!");
  9598. return;
  9599. }
  9600. returnErrorMsg("找不到记录");
  9601. }
  9602. }
  9603. public void cancel_sendXlw()
  9604. {
  9605. if (UrlPostParmsCheck("ctid"))
  9606. {
  9607. string eid = GetPostString("ctid");
  9608. CeErpTradeCell entity = null;
  9609. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9610. if (entity != null)
  9611. {
  9612. if (entity.IsSendGift == 0)
  9613. {
  9614. returnErrorMsg("未标记小礼物");
  9615. return;
  9616. }
  9617. entity.IsSendGift = 0;
  9618. entity.Update();
  9619. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9620. returnSuccessMsg("操作成功!");
  9621. return;
  9622. }
  9623. returnErrorMsg("找不到记录");
  9624. }
  9625. }
  9626. public void get_erp_designbill()
  9627. {
  9628. DataStruct dStruct = GetPostStruct();
  9629. List<string> lw = new List<string>();
  9630. int isMy = GetInt("my");
  9631. if (isMy == 1)
  9632. {
  9633. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9634. }
  9635. string tid = GetPostString("tid");
  9636. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9637. string userName = GetPostString("design");
  9638. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9639. string price1 = GetPostString("price1");
  9640. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9641. string price2 = GetPostString("price2");
  9642. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9643. string rePrice1 = GetPostString("rePrice1");
  9644. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9645. string rePrice2 = GetPostString("rePrice2");
  9646. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9647. string designerType = GetPostString("designerType");
  9648. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9649. string orderState = GetPostString("orderState");
  9650. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9651. string endTime1 = GetPostString("endTime1");
  9652. string endTime2 = GetPostString("endTime2");
  9653. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9654. if (dw.Length > 0) lw.Add(dw);
  9655. string isDk = GetPostString("isDk");
  9656. if (isDk == "1")
  9657. {
  9658. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9659. }
  9660. else if (isDk == "0")
  9661. {
  9662. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9663. }
  9664. dStruct.Order = "oid, create_time desc";
  9665. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9666. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9667. writeGridDataTableJson(dStruct.TotalCount, dt);
  9668. }
  9669. public void upd_erp_designerbill()
  9670. {
  9671. if (UrlPostParmsCheck("ID"))
  9672. {
  9673. string eid = GetPostString("ID");
  9674. CeErpDesignerBill entity = null;
  9675. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9676. if (entity != null)
  9677. {
  9678. if (GetPostDouble("designerpirce") > 0)
  9679. {
  9680. entity.realPrice = GetPostDouble("designerpirce");
  9681. entity.update_time = DateTime.Now;
  9682. entity.update_u_id = CurrentUser.UserID;
  9683. entity.update_u_name = CurrentUser.UserName;
  9684. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9685. entity.Update();
  9686. returnSuccessMsg("操作成功!");
  9687. return;
  9688. }
  9689. else
  9690. {
  9691. entity.price = GetPostDouble("price");
  9692. entity.update_time = DateTime.Now;
  9693. entity.update_u_id = CurrentUser.UserID;
  9694. entity.update_u_name = CurrentUser.UserName;
  9695. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9696. entity.Update();
  9697. returnSuccessMsg("操作成功!");
  9698. return;
  9699. }
  9700. }
  9701. returnErrorMsg("找不到记录");
  9702. }
  9703. }
  9704. public void audit_erp_designerbill()
  9705. {
  9706. if (UrlPostParmsCheck("ID"))
  9707. {
  9708. string eid = GetPostString("ID");
  9709. CeErpDesignerBill entity = null;
  9710. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9711. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9712. if (entity != null)
  9713. {
  9714. entity.realPrice = GetPostDouble("designerpirce");
  9715. entity.update_time = DateTime.Now;
  9716. entity.update_u_id = CurrentUser.UserID;
  9717. entity.update_u_name = CurrentUser.UserName;
  9718. entity.isAudit = 1;
  9719. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9720. entity.Update();
  9721. if (orderEntity != null)
  9722. {
  9723. orderEntity.IsReadTag = 3;
  9724. orderEntity.Update();
  9725. }
  9726. returnSuccessMsg("操作成功!");
  9727. return;
  9728. }
  9729. returnErrorMsg("找不到记录");
  9730. }
  9731. }
  9732. public void all_audit_erp_designerbill()
  9733. {
  9734. if (UrlPostParmsCheck("idList"))
  9735. {
  9736. string[] list = GetPostString("idList").Split(',');
  9737. CeErpDesignerBill entity = null;
  9738. for (int i = 0; i < list.Length; i++)
  9739. {
  9740. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9741. if (entity == null) return;
  9742. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9743. if (orderEntity == null) return;
  9744. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9745. entity.update_time = DateTime.Now;
  9746. entity.update_u_id = CurrentUser.UserID;
  9747. entity.update_u_name = CurrentUser.UserName;
  9748. entity.isAudit = 1;
  9749. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9750. entity.Update();
  9751. orderEntity.IsReadTag = 3;
  9752. orderEntity.Update();
  9753. }
  9754. returnSuccessMsg("操作成功!");
  9755. return;
  9756. }
  9757. }
  9758. public void get_erp_sameorders()
  9759. {
  9760. if (UrlPostParmsCheck("ctid"))
  9761. {
  9762. string eid = GetPostString("ctid");
  9763. CeErpTradeCell entity = null;
  9764. entity = CeErpTradeCell.GetByCtid(eid);
  9765. if (entity != null)
  9766. {
  9767. StringBuilder sql = new StringBuilder();
  9768. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9769. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9770. var res = new
  9771. {
  9772. data = dt.Rows.Count
  9773. };
  9774. string ro_jsond = JsonConvert.SerializeObject(res);
  9775. returnSuccess(ro_jsond);
  9776. return;
  9777. }
  9778. returnErrorMsg("未找到订单");
  9779. return;
  9780. }
  9781. returnErrorMsg("缺少必要的参数");
  9782. }
  9783. public void get_erp_islasthavesameorder()
  9784. {
  9785. if (UrlPostParmsCheck("ctid"))
  9786. {
  9787. string eid = GetPostString("ctid");
  9788. string[] ctidList = eid.Split(',');
  9789. StringBuilder sql = new StringBuilder();
  9790. string tisCtid = "";
  9791. foreach (string ctid in ctidList)
  9792. {
  9793. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9794. if (entity != null)
  9795. {
  9796. sql = new StringBuilder();
  9797. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9798. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9799. if (dth.Rows.Count > 0)
  9800. {
  9801. tisCtid += entity.ctid;
  9802. tisCtid += ",";
  9803. }
  9804. }
  9805. }
  9806. if (tisCtid.Length > 0)
  9807. {
  9808. var res = new
  9809. {
  9810. data = tisCtid
  9811. };
  9812. string ro_jsond = JsonConvert.SerializeObject(res);
  9813. returnSuccess(ro_jsond);
  9814. }
  9815. else
  9816. {
  9817. var res = new
  9818. {
  9819. data = ""
  9820. };
  9821. string ro_jsond = JsonConvert.SerializeObject(res);
  9822. returnSuccess(ro_jsond);
  9823. }
  9824. return;
  9825. }
  9826. returnErrorMsg("缺少必要的参数");
  9827. }
  9828. public void file_client_down_url()
  9829. {
  9830. if (!UrlPostParmsCheck("userId"))
  9831. {
  9832. returnErrorMsg("缺少必要的参数");
  9833. }
  9834. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9835. }
  9836. public void checkout_form_data()
  9837. {
  9838. if (!UrlPostParmsCheck("tid"))
  9839. {
  9840. returnErrorMsg("缺少必要的参数");
  9841. }
  9842. string tid = GetPostString("tid");
  9843. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9844. if (ceErpOrderFormData != null)
  9845. {
  9846. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9847. returnSuccess(ro_jsond);
  9848. return;
  9849. }
  9850. returnErrorMsg("尚未有文件!");
  9851. }
  9852. public void back_supplier_audit()
  9853. {
  9854. int userId = CurrentUser.UserID;
  9855. StringBuilder sql = new StringBuilder();
  9856. 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);
  9857. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9858. if (dt.Rows.Count > 0)
  9859. {
  9860. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9861. }
  9862. else
  9863. {
  9864. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9865. }
  9866. }
  9867. public void back_supplier_query()
  9868. {
  9869. string eid = GetPostString("ctid");
  9870. if (eid != "")
  9871. {
  9872. StringBuilder sql = new StringBuilder();
  9873. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9874. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9875. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9876. }
  9877. else
  9878. {
  9879. returnErrorMsg("找不到订单记录");
  9880. return;
  9881. }
  9882. }
  9883. public void verified_to_order()
  9884. {
  9885. int userId = CurrentUser.UserID;
  9886. StringBuilder sql = new StringBuilder();
  9887. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9889. if (dt.Rows.Count > 0)
  9890. {
  9891. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9892. }
  9893. else
  9894. {
  9895. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9896. }
  9897. }
  9898. public void upd_supplier_audit()
  9899. {
  9900. if (UrlPostParmsCheck("ctid"))
  9901. {
  9902. string eid = GetPostString("ctid");
  9903. string reason = GetPostString("returnreason");
  9904. CeErpTradeCell entity = null;
  9905. CeWithdraw withdraw = null;
  9906. withdraw = CeWithdraw.GetByTid(eid);
  9907. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9908. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9909. {
  9910. if (withdraw != null)
  9911. {
  9912. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9913. {
  9914. returnSuccessMsg("您没有权限操作!");
  9915. return;
  9916. }
  9917. else
  9918. {
  9919. if (reason.Equals("1"))
  9920. {
  9921. if (entity.OrderState == -1)
  9922. {
  9923. if (entity.FinishPlaceTime == null)
  9924. {
  9925. entity.OrderState = 2;
  9926. }
  9927. else
  9928. {
  9929. entity.OrderState = 6;
  9930. }
  9931. }
  9932. entity.Update();
  9933. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9934. if (withdraw != null)
  9935. {
  9936. withdraw.status = int.Parse(reason);
  9937. withdraw.Update();
  9938. }
  9939. returnSuccessMsg("操作成功!");
  9940. return;
  9941. }
  9942. else
  9943. {
  9944. withdraw.status = int.Parse(reason);
  9945. withdraw.acknowledgingtime = DateTime.Now;
  9946. withdraw.Update();
  9947. returnSuccessMsg("查看详细请点击线下订单查询");
  9948. return;
  9949. }
  9950. }
  9951. }
  9952. // 第一个字符是 'N'
  9953. }
  9954. if (eid[0] != 'N')
  9955. {
  9956. }
  9957. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9958. {
  9959. entity.IsVerifyToSupplier = false;
  9960. entity.IsReturn = 1;
  9961. entity.ReturnTime = DateTime.Now;
  9962. entity.ReturnReason = reason;
  9963. if (entity.OrderState == 6)
  9964. {
  9965. entity.OrderState = 5;
  9966. }
  9967. entity.Update();
  9968. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9969. if (withdraw != null)
  9970. {
  9971. withdraw.status = int.Parse(reason);
  9972. withdraw.Update();
  9973. }
  9974. returnSuccessMsg("操作成功!");
  9975. return;
  9976. }
  9977. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9978. {
  9979. ;
  9980. if (withdraw != null)
  9981. {
  9982. withdraw.status = int.Parse(reason);
  9983. withdraw.acknowledgingtime = DateTime.Now;
  9984. withdraw.Update();
  9985. returnSuccessMsg("供应商取消撤回!");
  9986. return;
  9987. }
  9988. }
  9989. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9990. {
  9991. if (entity.OrderState == -1)
  9992. {
  9993. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9994. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9995. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9996. {
  9997. returnErrorMsg("台湾客户需填写身份证!");
  9998. return;
  9999. }
  10000. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10001. {
  10002. returnErrorMsg("偏远地区需要填写物流费!");
  10003. return;
  10004. }
  10005. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10006. {
  10007. returnErrorMsg("订单spu没有确认无法通过审核!");
  10008. return;
  10009. }
  10010. if (entity.FinishPlaceTime == null)
  10011. {
  10012. entity.OrderState = 2;
  10013. }
  10014. else
  10015. {
  10016. entity.OrderState = 3;
  10017. }
  10018. commonHelper.getCytPrice(entity);
  10019. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10020. {
  10021. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10022. }
  10023. }
  10024. entity.Update();
  10025. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10026. if (withdraw != null)
  10027. {
  10028. withdraw.status = int.Parse(reason);
  10029. withdraw.Update();
  10030. }
  10031. returnSuccessMsg("操作成功!");
  10032. return;
  10033. }
  10034. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10035. {
  10036. if (withdraw == null)
  10037. {
  10038. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10039. return;
  10040. }
  10041. }
  10042. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10043. {
  10044. if (withdraw != null)
  10045. {
  10046. withdraw.status = int.Parse(reason);
  10047. withdraw.acknowledgingtime = DateTime.Now;
  10048. withdraw.Update();
  10049. returnSuccessMsg("查看详细请点击线下订单查询");
  10050. return;
  10051. }
  10052. }
  10053. return;
  10054. }
  10055. }
  10056. //校验报价
  10057. public void refund_order_tip()
  10058. {
  10059. int userid = CurrentUser.UserID;
  10060. int sectionId = CurrentUser.UserPost.OrgID;
  10061. StringBuilder sql = new StringBuilder();
  10062. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10063. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10064. List<string> ids = new List<string>();
  10065. if (dth.Rows.Count > 0)
  10066. {
  10067. foreach (DataRow dr in dth.Rows)
  10068. {
  10069. ids.Add(dr["ID"].ToString());
  10070. }
  10071. try
  10072. {
  10073. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10074. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10075. }
  10076. catch (Exception ex)
  10077. {
  10078. }
  10079. }
  10080. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10081. }
  10082. public void refund_order_Design()
  10083. {
  10084. int userid = CurrentUser.UserID;
  10085. int sectionId = CurrentUser.UserPost.OrgID;
  10086. StringBuilder sql = new StringBuilder();
  10087. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10088. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10089. List<string> ids = new List<string>();
  10090. if (dth.Rows.Count > 0)
  10091. {
  10092. foreach (DataRow dr in dth.Rows)
  10093. {
  10094. ids.Add(dr["ID"].ToString());
  10095. }
  10096. try
  10097. {
  10098. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10099. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10100. }
  10101. catch (Exception ex)
  10102. {
  10103. }
  10104. }
  10105. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10106. }
  10107. public void change_order_info()
  10108. {
  10109. int userid = CurrentUser.UserID;
  10110. StringBuilder sql = new StringBuilder();
  10111. 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);
  10112. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10113. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10114. }
  10115. public void change_win_mome()
  10116. {
  10117. if (UrlPostParmsCheck("id,ctid"))
  10118. {
  10119. string id = GetPostString("id");
  10120. string ctid = GetPostString("ctid");
  10121. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10122. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10123. if (ce == null || ceErpMessageTip == null)
  10124. {
  10125. returnSuccessMsg("未找到对应的订单!");
  10126. return;
  10127. }
  10128. if (ce.OrderState >= 5)
  10129. {
  10130. ceErpMessageTip.isVisit = true;
  10131. ceErpMessageTip.Update();
  10132. returnSuccessMsg("已上传文件无法修改!");
  10133. return;
  10134. }
  10135. int type = GetPostInt("type");
  10136. string content = GetPostString("content");
  10137. if (type == 0)
  10138. {
  10139. content = content.Replace("(", "(");
  10140. content = content.Replace(")", ")");
  10141. string check = MidStrEx(content, "(", ")").Trim();
  10142. if (string.IsNullOrEmpty(check))
  10143. {
  10144. returnSuccessMsg("文件名格式不正确");
  10145. return;
  10146. }
  10147. }
  10148. ce.seller_memo = content;
  10149. ce.Update();
  10150. ceErpMessageTip.isVisit = true;
  10151. ceErpMessageTip.Update();
  10152. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10153. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10154. ApiVo apiVo = new ApiVo();
  10155. apiVo.orderNumber = ce.ctid;
  10156. apiVo.actionName = "demandDesign";
  10157. apiVo.orderRemarks = content;
  10158. apiVo.demandExamine = type + 1;
  10159. designHelper.API_WorkCore(apiVo);//demandDesign
  10160. returnSuccessMsg("修改成功!");
  10161. }
  10162. }
  10163. public static string MidStrEx(string sourse, string startstr, string endstr)
  10164. {
  10165. string result = string.Empty;
  10166. int startindex, endindex;
  10167. try
  10168. {
  10169. startindex = sourse.IndexOf(startstr);
  10170. if (startindex == -1)
  10171. return result;
  10172. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10173. endindex = tmpstr.IndexOf(endstr);
  10174. if (endindex == -1)
  10175. return result;
  10176. result = tmpstr.Remove(endindex);
  10177. }
  10178. catch (Exception ex)
  10179. {
  10180. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10181. }
  10182. return result;
  10183. }
  10184. public void refund_order_list()
  10185. {
  10186. int userid = CurrentUser.UserID;
  10187. int sectionId = CurrentUser.UserPost.OrgID;
  10188. StringBuilder sql = new StringBuilder();
  10189. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10190. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10191. DataStruct dStruct = GetPostStruct();
  10192. DataTable dt = null;
  10193. List<string> ids = new List<string>();
  10194. List<string> tids = new List<string>();
  10195. if (dth.Rows.Count > 0)
  10196. {
  10197. foreach (DataRow dr in dth.Rows)
  10198. {
  10199. tids.Add("'" + dr["tid"].ToString() + "'");
  10200. ids.Add(dr["id"].ToString());
  10201. }
  10202. try
  10203. {
  10204. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10205. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10206. List<string> lw = new List<string>();
  10207. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10208. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10209. dt = WebCache.GetData("view_orderlist", dStruct);
  10210. }
  10211. catch (Exception ex)
  10212. {
  10213. }
  10214. }
  10215. writeGridDataTableJson(dStruct.TotalCount, dt);
  10216. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10217. }
  10218. //新增
  10219. public void order_batch_downloads()
  10220. {
  10221. string ceid = GetPostString("tid");
  10222. String[] tid = ceid.Split(',');
  10223. order_batch_caiyingtong(tid);
  10224. /* (string success, string errors) = UploadFiles(tid);
  10225. returnSuccessMsg(success + errors);*/
  10226. return;
  10227. }
  10228. //报价接口
  10229. public void Get_To_Quote()
  10230. {
  10231. string ceid = GetPostString("ctid");
  10232. if (ceid != null)
  10233. {
  10234. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10235. if (entity != null)
  10236. {
  10237. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10238. {
  10239. return;
  10240. }
  10241. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10242. double price = 0;
  10243. if (cp == null)
  10244. {
  10245. JObject jsonObject12 = new JObject
  10246. {
  10247. { "UserId", "77886" },
  10248. { "Pwd", "lt666888" },
  10249. { "Filename", entity.seller_memo }
  10250. };
  10251. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10252. JObject jsonObjects1 = JObject.Parse(response1);
  10253. string ms1g = (string)jsonObjects1["msg"];
  10254. if (ms1g == "报价成功")
  10255. {
  10256. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10257. string data = (string)jsonObject1["price"];
  10258. 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 + "');";
  10259. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10260. returnSuccessMsg("获取报价成功:" + data);
  10261. price = Convert.ToDouble(data);
  10262. }
  10263. else
  10264. {
  10265. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10266. return;
  10267. }
  10268. }
  10269. String[] beizhu = entity.seller_memo.Split('-');
  10270. String chanp = "";
  10271. if (beizhu.Length > 0)
  10272. {
  10273. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10274. }
  10275. else
  10276. {
  10277. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10278. }
  10279. JObject jsonObject = new JObject
  10280. {
  10281. { "UserId", "77886" },
  10282. { "Pwd", "lt666888" },
  10283. { "Filename", chanp }
  10284. };
  10285. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10286. JObject jsonObjects = JObject.Parse(response);
  10287. string msg = (string)jsonObjects["msg"];
  10288. if (msg == "报价成功")
  10289. {
  10290. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10291. string data = (string)jsonObject1["price"];
  10292. 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 + "');";
  10293. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10294. returnSuccessMsg("获取报价成功:" + data);
  10295. price = Convert.ToDouble(data);
  10296. }
  10297. else
  10298. {
  10299. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10300. return;
  10301. }
  10302. if (price > 0)
  10303. {
  10304. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10305. if (ceErpTradeCellExtend == null)
  10306. {
  10307. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10308. ceErpTradeCellExtend.ctid = entity.ctid;
  10309. ceErpTradeCellExtend.payment_cyt = price;
  10310. ceErpTradeCellExtend.Create();
  10311. }
  10312. else
  10313. {
  10314. ceErpTradeCellExtend.payment_cyt = price;
  10315. ceErpTradeCellExtend.Update();
  10316. }
  10317. }
  10318. return;
  10319. }
  10320. }
  10321. else
  10322. {
  10323. returnErrorMsg("请至少选择一条数据");
  10324. return;
  10325. }
  10326. }
  10327. //新增
  10328. public void order_To_Supplier()
  10329. {
  10330. string ceid = GetPostString("tid");
  10331. String[] tid = ceid.Split(',');
  10332. if (tid.Length > 0)
  10333. {
  10334. try
  10335. {
  10336. for (int i = 0; i < tid.Length; i++)
  10337. {
  10338. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10339. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10340. entity.SupplierId = suid;
  10341. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10342. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10343. entity.Update();
  10344. }
  10345. }
  10346. catch (Exception ex)
  10347. {
  10348. returnErrorMsg("自动匹配供应商失败");
  10349. return;
  10350. }
  10351. }
  10352. else
  10353. {
  10354. returnErrorMsg("请至少选择一条数据");
  10355. return;
  10356. }
  10357. returnSuccessMsg("自动匹配供应商成功");
  10358. return;
  10359. }
  10360. public (string, string) UploadFiles(string[] urls)
  10361. {
  10362. string success = "";
  10363. string errors = "";
  10364. int userid = CurrentUser.UserID;
  10365. foreach (string url in urls)
  10366. {
  10367. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10368. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10369. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10370. {
  10371. JObject jsonObject = new JObject
  10372. {
  10373. { "Userid", "77886" },
  10374. { "pwd", "cyt86435015" },
  10375. { "content", base64FileContent },
  10376. { "ext", Path.GetExtension(fileName) }
  10377. };
  10378. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10379. JObject jsonObjects = JObject.Parse(response);
  10380. string msg = (string)jsonObjects["msg"];
  10381. if (msg.Equals("上传成功"))
  10382. {
  10383. success += url + " 上传成功";
  10384. }
  10385. else
  10386. {
  10387. errors += url + " 上传失败";
  10388. }
  10389. }
  10390. else
  10391. {
  10392. errors += url + " 格式出现问题";
  10393. }
  10394. }
  10395. if (urls.Length == 0)
  10396. {
  10397. return (success, errors);
  10398. }
  10399. return (success, errors);
  10400. }
  10401. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10402. {
  10403. return true; //总是接受
  10404. }
  10405. public static string HttpPost(string url, string param = null)
  10406. {
  10407. HttpWebRequest request;
  10408. //如果是发送HTTPS请求
  10409. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10410. {
  10411. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10412. request = WebRequest.Create(url) as HttpWebRequest;
  10413. request.ProtocolVersion = HttpVersion.Version10;
  10414. }
  10415. else
  10416. {
  10417. request = WebRequest.Create(url) as HttpWebRequest;
  10418. }
  10419. request.Method = "POST";
  10420. request.ContentType = "application/json";
  10421. request.Accept = "*/*";
  10422. request.Timeout = 120000;
  10423. request.AllowAutoRedirect = false;
  10424. StreamWriter requestStream = null;
  10425. WebResponse response = null;
  10426. string responseStr = null;
  10427. try
  10428. {
  10429. requestStream = new StreamWriter(request.GetRequestStream());
  10430. requestStream.Write(param);
  10431. requestStream.Close();
  10432. response = request.GetResponse();
  10433. if (response != null)
  10434. {
  10435. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10436. responseStr = reader.ReadToEnd();
  10437. reader.Close();
  10438. }
  10439. }
  10440. catch (Exception ex)
  10441. {
  10442. return ex.Message;
  10443. }
  10444. finally
  10445. {
  10446. request = null;
  10447. requestStream = null;
  10448. response = null;
  10449. }
  10450. return responseStr;
  10451. }
  10452. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10453. {
  10454. string base64FileContent;
  10455. string fileName;
  10456. using (WebClient webClient = new WebClient())
  10457. {
  10458. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10459. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10460. {
  10461. using (Stream stream = response.GetResponseStream())
  10462. {
  10463. using (MemoryStream memoryStream = new MemoryStream())
  10464. {
  10465. stream.CopyTo(memoryStream);
  10466. byte[] fileBytes = memoryStream.ToArray();
  10467. base64FileContent = Convert.ToBase64String(fileBytes);
  10468. fileName = response.Headers["Content-Disposition"];
  10469. if (!string.IsNullOrEmpty(fileName))
  10470. {
  10471. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10472. if (index >= 0)
  10473. {
  10474. fileName = fileName.Substring(index + 9).Trim('\"');
  10475. }
  10476. }
  10477. else
  10478. {
  10479. fileName = Path.GetFileName(downloadUrl);
  10480. }
  10481. }
  10482. }
  10483. }
  10484. }
  10485. return (fileName, base64FileContent);
  10486. }
  10487. //新增
  10488. public void order_batch_caiyingtong(string[] downloadUrls)
  10489. {
  10490. try
  10491. {
  10492. //遍历文件
  10493. DataStruct dStruct = GetPostStruct();
  10494. DataTable dt = null;
  10495. int userid = CurrentUser.UserID;
  10496. List<string> ids = new List<string>();//失败组
  10497. List<string> tids = new List<string>();
  10498. using (WebClient webClient = new WebClient())
  10499. {
  10500. foreach (var url in downloadUrls)
  10501. {
  10502. try
  10503. {
  10504. tids.Add("'" + url + "'");
  10505. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10506. if (entity != null)
  10507. {
  10508. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10509. if (cp == null)
  10510. {
  10511. JObject jsonObject = new JObject
  10512. {
  10513. { "Userid", "77886" },
  10514. { "pwd", "lt666888" },
  10515. { "Filename",entity.seller_memo }
  10516. };
  10517. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10518. JObject jsonObjects = JObject.Parse(response);
  10519. string msg = (string)jsonObjects["msg"];
  10520. if (msg == "报价成功")
  10521. {
  10522. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10523. DownloadAndConvertToBase64(url1);
  10524. }
  10525. else
  10526. {
  10527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10528. }
  10529. }
  10530. else
  10531. {
  10532. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10533. JObject jsonObject = new JObject
  10534. {
  10535. { "Userid", "77886" },
  10536. { "pwd", "lt666888" },
  10537. { "Filename",chanp }
  10538. };
  10539. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10540. JObject jsonObjects = JObject.Parse(response);
  10541. string msg = (string)jsonObjects["msg"];
  10542. if (msg == "报价成功")
  10543. {
  10544. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10545. DownloadAndConvertToBase64(url1);
  10546. }
  10547. else
  10548. {
  10549. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10550. }
  10551. }
  10552. }
  10553. // 上传文件到FTP
  10554. }
  10555. catch (Exception ex)
  10556. {
  10557. Console.WriteLine($"An error occurred: {ex.Message}");
  10558. }
  10559. }
  10560. List<string> lw = new List<string>();
  10561. lw.Add(string.Format("( OrderState < 6 )"));
  10562. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10563. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10564. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10565. if (dt.Rows.Count > 0)
  10566. {
  10567. foreach (DataRow dr in dt.Rows)
  10568. {
  10569. ids.Add(dr["ctid"].ToString());
  10570. }
  10571. }
  10572. String ErrorMsgs = "";
  10573. foreach (String id in ids)
  10574. {
  10575. ErrorMsgs += id + ",";
  10576. }
  10577. if (ErrorMsgs.Length > 1)
  10578. {
  10579. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10580. }
  10581. if (ErrorMsgs.Length < 1)
  10582. {
  10583. ErrorMsgs = "上传成功";
  10584. returnSuccessMsg(ErrorMsgs);
  10585. }
  10586. else
  10587. {
  10588. returnErrorMsg("以下订单" + ErrorMsgs);
  10589. }
  10590. }
  10591. // 删除文件夹及其内容
  10592. /* Directory.Delete(localDirectory, true);*/
  10593. }
  10594. catch { }
  10595. }
  10596. public void get_center_data()
  10597. {
  10598. int userId = CurrentUser.UserID;
  10599. string postCode = CurrentUser.UserPost.Post.Code;
  10600. List<string> lw = new List<string>();
  10601. List<string> ww = new List<string>();
  10602. DateTime currentTime = DateTime.Now;
  10603. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10604. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10605. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10606. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10607. string sql = " SELECT ";
  10608. string startTime = "2023-10-01 11:22:31";
  10609. //设计
  10610. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10611. {
  10612. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10613. 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));
  10614. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10615. 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));
  10616. }
  10617. //客服
  10618. else if (postCode == "CustomerService" || postCode == "Director")
  10619. {
  10620. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10621. 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));
  10622. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10623. 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));
  10624. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10625. 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));
  10626. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10627. 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));
  10628. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10629. 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));
  10630. }
  10631. //售后
  10632. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10633. {
  10634. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10635. 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));
  10636. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10637. 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));
  10638. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10639. 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));
  10640. }
  10641. //下单部
  10642. else if (postCode == "Place" || postCode == "PlaceMr")
  10643. {
  10644. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10645. 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));
  10646. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10647. 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));
  10648. }
  10649. //车间
  10650. else if (postCode == "Supplier")
  10651. {
  10652. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10653. 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));
  10654. }
  10655. DataTable dt = new DataTable();
  10656. if (lw.Count > 0)
  10657. {
  10658. sql += string.Join(" , ", lw);
  10659. sql += " FROM ";
  10660. sql += string.Join(" , ", ww);
  10661. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10662. }
  10663. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10664. }
  10665. public void get_center_data_list()
  10666. {
  10667. int userId = CurrentUser.UserID;
  10668. string postCode = CurrentUser.UserPost.Post.Code;
  10669. string shopIds = CurrentUser.User.pemShop;
  10670. DataStruct dStruct = GetPostStruct();
  10671. List<string> lw = new List<string>();
  10672. DateTime currentTime = DateTime.Now;
  10673. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10674. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10675. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10676. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10677. string startTime = "2023-10-01 11:22:31";
  10678. int order_type = GetPostInt("order_type");
  10679. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10680. {
  10681. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10682. if (order_type == 0)
  10683. {
  10684. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10685. }
  10686. else if (order_type == 3)
  10687. {
  10688. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10689. }
  10690. else
  10691. {
  10692. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10693. }
  10694. }
  10695. //客服
  10696. if (postCode == "CustomerService" || postCode == "Director")
  10697. {
  10698. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10699. if (order_type == 0)
  10700. {
  10701. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10702. }
  10703. else if (order_type == 1)
  10704. {
  10705. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10706. }
  10707. else if (order_type == 2)
  10708. {
  10709. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10710. }
  10711. else if (order_type == 3)
  10712. {
  10713. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10714. }
  10715. else if (order_type == 4)
  10716. {
  10717. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10718. }
  10719. else
  10720. {
  10721. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10722. }
  10723. }
  10724. //售后
  10725. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10726. {
  10727. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10728. if (shopIds != "")
  10729. {
  10730. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10731. }
  10732. if (order_type == 2)
  10733. {
  10734. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10735. }
  10736. else if (order_type == 4)
  10737. {
  10738. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10739. }
  10740. else if (order_type == 5)
  10741. {
  10742. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10743. }
  10744. else
  10745. {
  10746. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10747. }
  10748. }
  10749. //下单部
  10750. if (postCode == "Place" || postCode == "PlaceMr")
  10751. {
  10752. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10753. if (shopIds != "")
  10754. {
  10755. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10756. }
  10757. else if (order_type == 1)
  10758. {
  10759. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10760. }
  10761. else if (order_type == 2)
  10762. {
  10763. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10764. }
  10765. else
  10766. {
  10767. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10768. }
  10769. }
  10770. //车间
  10771. if (postCode == "Supplier")
  10772. {
  10773. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10774. if (order_type == 5)
  10775. {
  10776. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10777. }
  10778. else
  10779. {
  10780. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10781. }
  10782. }
  10783. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10784. dStruct.Fileds = "tid,ctid";
  10785. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10786. writeGridDataTableJson(dStruct.TotalCount, dt);
  10787. }
  10788. public void aftersale_audit_master()
  10789. {
  10790. if (UrlPostParmsCheck("ctid"))
  10791. {
  10792. string ctid = GetPostString("ctid");
  10793. if (ctid.Length > 0)
  10794. {
  10795. bool result = aftersale_data_change(ctid);
  10796. if (result)
  10797. {
  10798. returnSuccessMsg("修改成功!");
  10799. return;
  10800. }
  10801. }
  10802. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10803. }
  10804. }
  10805. public void aftersale_batch_audit_master()
  10806. {
  10807. if (UrlPostParmsCheck("ctids"))
  10808. {
  10809. string ctids = GetPostString("ctids");
  10810. if (ctids.Length > 0)
  10811. {
  10812. List<string> list = new List<string>();
  10813. string[] ctid_list = ctids.Split(',');
  10814. foreach (var item in ctid_list)
  10815. {
  10816. bool result = aftersale_data_change(item);
  10817. if (!result)
  10818. {
  10819. list.Add(item);
  10820. }
  10821. }
  10822. if (list.Count > 0)
  10823. {
  10824. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10825. return;
  10826. }
  10827. returnSuccessMsg("修改成功!");
  10828. return;
  10829. }
  10830. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10831. }
  10832. }
  10833. public bool aftersale_data_change(string ctid)
  10834. {
  10835. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10836. if (ceErpTradeCell != null)
  10837. {
  10838. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10839. ceErpTradeCell.AfterSaleSupplierState = 0;
  10840. StringBuilder sql = new StringBuilder();
  10841. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10842. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10843. CeErpTradeResponsible.DelByTid(ctid, 0);
  10844. 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 == "不理赔")
  10845. {
  10846. CeErpTradeResponsible.DelByTid(ctid, 1);
  10847. ceErpTradeCell.AfterSaleSupplierState = 1;
  10848. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10849. ceErpTradeCell.AfterSaleState = 4;
  10850. }
  10851. else
  10852. {
  10853. ceErpTradeCell.AfterSaleState = 3;
  10854. }
  10855. bool needCyt = false;
  10856. if (dt != null)
  10857. {
  10858. if (dt.Rows.Count == 1)
  10859. {
  10860. bool isEnd = false;
  10861. foreach (DataRow dr in dt.Rows)
  10862. {
  10863. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10864. {
  10865. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10866. isEnd = true;
  10867. }
  10868. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10869. {
  10870. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10871. isEnd = true;
  10872. }
  10873. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10874. {
  10875. needCyt = true;
  10876. }
  10877. }
  10878. if (isEnd)
  10879. {
  10880. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10881. ceErpTradeCell.AfterSaleState = 4;
  10882. ceErpTradeCell.AfterSaleSupplierState = 1;
  10883. }
  10884. }
  10885. else
  10886. {
  10887. bool isAll = true;
  10888. foreach (DataRow dr in dt.Rows)
  10889. {
  10890. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10891. {
  10892. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10893. continue;
  10894. }
  10895. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10896. {
  10897. string path = "";
  10898. int OrgID = 0;
  10899. if (!Convert.IsDBNull(dr["OrgPath"]))
  10900. {
  10901. path = dr["OrgPath"].ToString();
  10902. }
  10903. if (!Convert.IsDBNull(dr["OrgID"]))
  10904. {
  10905. OrgID = Convert.ToInt32(dr["OrgID"]);
  10906. }
  10907. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10908. {
  10909. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10910. continue;
  10911. }
  10912. }
  10913. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10914. {
  10915. needCyt = true;
  10916. }
  10917. isAll = false;
  10918. }
  10919. if (isAll)
  10920. {
  10921. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10922. ceErpTradeCell.AfterSaleState = 4;
  10923. ceErpTradeCell.AfterSaleSupplierState = 1;
  10924. }
  10925. }
  10926. }
  10927. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10928. {
  10929. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10930. }
  10931. if (ceErpTradeCell.AfterSaleState == 4)
  10932. {
  10933. ApiVo apiVo = new ApiVo();
  10934. apiVo.orderNumber = ceErpTradeCell.ctid;
  10935. apiVo.actionName = "afterOver";
  10936. designHelper.API_WorkCore(apiVo); //afterOver
  10937. }
  10938. ceErpTradeCell.Update();
  10939. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10940. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10941. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10942. return true;
  10943. }
  10944. return false;
  10945. }
  10946. public void get_erp_wechatorder()
  10947. {
  10948. DataStruct dStruct = GetPostStruct();
  10949. List<string> lw = new List<string>();
  10950. string tid = GetPostString("tid");
  10951. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10952. string shopname = GetPostString("shopname");
  10953. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10954. string buyernick = GetPostString("buyer_nick");
  10955. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10956. string customer = GetPostString("customer");
  10957. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10958. string returndate1 = GetPostString("returndate1");
  10959. string returndate2 = GetPostString("returndate2");
  10960. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10961. if (dw.Length > 0) lw.Add(dw);
  10962. string finishDate1 = GetPostString("finishdate1");
  10963. string finishDate2 = GetPostString("finishdate2");
  10964. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10965. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10966. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10967. dStruct.Order = "created desc";
  10968. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10969. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10970. writeGridDataTableJson(dStruct.TotalCount, dt);
  10971. }
  10972. public void get_erp_wechatlist_sumprice()
  10973. {
  10974. DataStruct dStruct = GetPostStruct();
  10975. List<string> lw = new List<string>();
  10976. string tid = GetPostString("tid");
  10977. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10978. string shopname = GetPostString("shopname");
  10979. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10980. string buyernick = GetPostString("buyer_nick");
  10981. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10982. string customer = GetPostString("customer");
  10983. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10984. string returndate1 = GetPostString("returndate1");
  10985. string returndate2 = GetPostString("returndate2");
  10986. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10987. if (dw.Length > 0) lw.Add(dw);
  10988. string finishDate1 = GetPostString("finishdate1");
  10989. string finishDate2 = GetPostString("finishdate2");
  10990. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10991. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10992. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10993. string mainWhere = string.Join(" and ", lw.ToArray());
  10994. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10995. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10996. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10997. decimal total = 0;
  10998. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10999. {
  11000. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11001. }
  11002. var res = new
  11003. {
  11004. data = total
  11005. };
  11006. string ro_jsond = JsonConvert.SerializeObject(res);
  11007. returnSuccess(ro_jsond);
  11008. return;
  11009. }
  11010. public void get_erp_qr_waitdeliverylist()
  11011. {
  11012. DataStruct dStruct = GetPostStruct();
  11013. List<string> lw = new List<string>();
  11014. string tid = GetPostString("ctid");
  11015. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11016. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11017. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11018. var res_objz = new
  11019. {
  11020. restype = 1,
  11021. data = dt
  11022. };
  11023. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11024. returnSuccess(ro_jsonz);
  11025. }
  11026. public void get_erp_yield_list()
  11027. {
  11028. DataStruct dStruct = GetPostStruct();
  11029. List<string> lw = new List<string>();
  11030. string tid = GetPostString("ctid");
  11031. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11032. string shopname = GetPostString("shopname");
  11033. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11034. string buyernick = GetPostString("buyer_nick");
  11035. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11036. //if (tid.Length == 0 && buyernick.Length == 0)
  11037. //{
  11038. // lw.Add(string.Format("IsRefund<={0}", 1));
  11039. //}
  11040. string customer = GetPostString("customer");
  11041. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11042. string design = GetPostString("design");
  11043. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11044. string orderState = GetPostString("orderState");
  11045. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11046. string address = GetPostString("address");
  11047. 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));
  11048. string sellermemo = GetPostString("seller_memo");
  11049. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11050. string supplier = GetPostString("supplier");
  11051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11052. string OrderArea = GetPostString("order_area");
  11053. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11054. string placedate1 = GetPostString("placedate1");
  11055. string placedate2 = GetPostString("placedate2");
  11056. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11057. if (fdw.Length > 0) lw.Add(fdw);
  11058. string price1 = GetPostString("price1");
  11059. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11060. string price2 = GetPostString("price2");
  11061. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11062. string unusualCon = GetPostString("unusualcon");
  11063. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11064. string posTag = CurrentUser.UserPost.Post.Code;
  11065. if (posTag == "Supplier")
  11066. {
  11067. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11068. }
  11069. lw.Add(string.Format("OrderState = 6 "));
  11070. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11071. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11073. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11074. writeGridDataTableJson(dStruct.TotalCount, dt);
  11075. }
  11076. public void change_erp_sup_state()
  11077. {
  11078. if (UrlPostParmsCheck("ctid"))
  11079. {
  11080. string ctid = GetPostString("ctid");
  11081. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11082. if (ceErpTradeCell != null)
  11083. {
  11084. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11085. if (ceErpTradeCellExtend == null)
  11086. {
  11087. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11088. ceErpTradeCellExtend.ctid = ctid;
  11089. ceErpTradeCellExtend.SupState = 1;
  11090. ceErpTradeCellExtend.Create();
  11091. }
  11092. else
  11093. {
  11094. ceErpTradeCellExtend.SupState = 1;
  11095. ceErpTradeCellExtend.Update();
  11096. }
  11097. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11098. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11099. return;
  11100. }
  11101. returnErrorMsg("找不到订单");
  11102. }
  11103. }
  11104. public void supplier_all_downs()
  11105. {
  11106. if (UrlPostParmsCheck("tids"))
  11107. {
  11108. string tids = GetPostString("tids");
  11109. if (tids != null && tids.Length > 0)
  11110. {
  11111. StringBuilder sql = new StringBuilder();
  11112. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11113. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11114. sql = new StringBuilder();
  11115. 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, "下载设计文件");
  11116. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11117. string[] list = tids.Split(',');
  11118. foreach (string ctid in list)
  11119. {
  11120. CeErpSukuraData.createInfo(ctid, 3);
  11121. }
  11122. designHelper.api_approveDesign(tids); //approveDesign
  11123. returnSuccessMsg("下载成功!");
  11124. return;
  11125. }
  11126. returnErrorMsg("下载订单更新失败");
  11127. }
  11128. }
  11129. public void uploaderFileSuccess()
  11130. {
  11131. if (UrlPostParmsCheck("fileName"))
  11132. {
  11133. string fileName = GetPostString("fileName");
  11134. ApiVo apiVo = new ApiVo();
  11135. apiVo.orderNumber = fileName;
  11136. apiVo.actionName = "finishDesign";
  11137. designHelper.API_WorkCore(apiVo);//finishDesign
  11138. returnSuccessMsg("");
  11139. }
  11140. }
  11141. public void get_sample2_order()
  11142. {
  11143. if (UrlPostParmsCheck("ctid"))
  11144. {
  11145. string ctid = GetPostString("ctid");
  11146. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11147. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11148. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11149. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11150. double total = 0.0;
  11151. double order_price = 0.0;
  11152. if (dt_bu.Rows.Count > 0)
  11153. {
  11154. foreach (DataRow dr in dt_bu.Rows)
  11155. {
  11156. total += Convert.ToDouble(dr["payment"]);
  11157. }
  11158. }
  11159. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11160. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11161. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11162. string tid = ctid.Replace("S_", "");
  11163. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11164. double paymant = 0.0;
  11165. if (entity != null)
  11166. {
  11167. paymant = entity.payment;
  11168. }
  11169. string return_reason = "";
  11170. if (dt_after != null && dt_after.Rows.Count > 0)
  11171. {
  11172. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11173. }
  11174. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11175. }
  11176. }
  11177. public void get_erp_design_status()
  11178. {
  11179. string designName = GetPostString("designName");
  11180. DataStruct dStruct = GetPostStruct();
  11181. if (designName.Length > 0)
  11182. {
  11183. 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";
  11184. sql_user += " and Name like '%" + designName + "%'";
  11185. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11186. List<string> ids_list = new List<string>();
  11187. if (user_table.Rows.Count > 0)
  11188. {
  11189. foreach (DataRow item in user_table.Rows)
  11190. {
  11191. ids_list.Add(item["id"].ToString());
  11192. string ids_s = item["TeamIds"].ToString();
  11193. if (ids_s.Length > 0)
  11194. {
  11195. ids_list.AddRange(ids_s.Split(','));
  11196. }
  11197. }
  11198. }
  11199. HashSet<string> set = new HashSet<string>(ids_list);
  11200. ids_list = set.ToList();
  11201. if (ids_list.Count > 0)
  11202. {
  11203. 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));
  11204. dStruct.MainWhere = sql;
  11205. DataTable dt = null;
  11206. dt = WebCache.GetData("view_ErpUser", dStruct);
  11207. writeGridDataTableJson(dStruct.TotalCount, dt);
  11208. }
  11209. }
  11210. }
  11211. public void change_erp_order_price()
  11212. {
  11213. string ctid = GetPostString("ctid");
  11214. double price = GetPostDouble("price");
  11215. if (ctid.Length > 0)
  11216. {
  11217. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11218. if (ceErpTradeCellExtend == null)
  11219. {
  11220. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11221. ceErpTradeCellExtend.ctid = ctid;
  11222. ceErpTradeCellExtend.payment_cyt = price;
  11223. ceErpTradeCellExtend.Create();
  11224. }
  11225. else
  11226. {
  11227. ceErpTradeCellExtend.payment_cyt = price;
  11228. ceErpTradeCellExtend.Update();
  11229. }
  11230. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11231. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11232. {
  11233. ceErpDataSendOrderInfo.isSync = false;
  11234. ceErpDataSendOrderInfo.Update();
  11235. }
  11236. if (ceErpDataSendOrderInfo == null)
  11237. {
  11238. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11239. ceErpDataSendOrderInfo.isSync = false;
  11240. ceErpDataSendOrderInfo.ctid = ctid;
  11241. ceErpDataSendOrderInfo.Create();
  11242. }
  11243. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11244. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11245. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11246. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11247. {
  11248. dataSendOrderBean dataSendOrderBean = null;
  11249. foreach (DataRow item in dth.Rows)
  11250. {
  11251. try
  11252. {
  11253. dataSendOrderBean = new dataSendOrderBean();
  11254. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11255. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11256. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11257. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11258. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11259. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11260. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11261. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11262. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11263. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11264. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11265. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11266. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11267. if (result != null)
  11268. {
  11269. if ("0".Equals(result.errcode))
  11270. {
  11271. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11272. }
  11273. else
  11274. {
  11275. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11276. }
  11277. }
  11278. }
  11279. catch (Exception ex)
  11280. {
  11281. }
  11282. }
  11283. }
  11284. returnSuccessMsg("修改成功!");
  11285. return;
  11286. }
  11287. returnErrorMsg("找不到订单");
  11288. }
  11289. public void find_he_together()
  11290. {
  11291. string ctid = GetPostString("ctid");
  11292. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11293. List<string> list = new List<string>();
  11294. if (ceErpTradeCell != null)
  11295. {
  11296. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11297. {
  11298. 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);
  11299. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11300. if (table != null && table.Rows.Count > 0)
  11301. {
  11302. foreach (TableRow row in table.Rows)
  11303. {
  11304. }
  11305. }
  11306. }
  11307. }
  11308. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11309. }
  11310. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11311. {
  11312. //chy----19
  11313. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11314. //GD-CYT-----64
  11315. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11316. //ZHX----3
  11317. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11318. //JK----97
  11319. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11320. //ZT----70
  11321. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11322. //LHCY-----98
  11323. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11324. //XD-----90
  11325. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11326. //CYCY-----14
  11327. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11328. };
  11329. //其他改名
  11330. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11331. {
  11332. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11333. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11334. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11335. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11336. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11337. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11338. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11339. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11340. };
  11341. //不统计
  11342. List<int> no_suppliers = new List<int>()
  11343. {
  11344. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11345. };
  11346. //配件单
  11347. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11348. {
  11349. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11350. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11351. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11352. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11353. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11354. {"旗杆",new List<string>(){ "班旗" } },
  11355. {"牙签",new List<string>(){ "不干胶" } }
  11356. };
  11357. public void get_place_order_data()
  11358. {
  11359. string date1 = GetPostString("date1");
  11360. string date2 = GetPostString("date2");
  11361. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11362. DateTime start = DateTime.Parse(starttime);
  11363. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11364. DateTime end = DateTime.Parse(endtime);
  11365. if (date1 != null && date1.Length > 0)
  11366. {
  11367. DateTime dateTime = DateTime.Parse(date1);
  11368. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11369. start = DateTime.Parse(starttime);
  11370. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11371. end = DateTime.Parse(endtime);
  11372. }
  11373. if (date2 != null && date2.Length > 0)
  11374. {
  11375. DateTime dateTime = DateTime.Parse(date2);
  11376. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11377. end = DateTime.Parse(endtime);
  11378. }
  11379. 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);
  11380. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11381. //不干胶-----1,卡片-----29
  11382. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11383. foreach (DataRow row in data.Rows)
  11384. {
  11385. int productId = Convert.ToInt32(row["ProductId"]);
  11386. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11387. if (no_suppliers.Contains(supplierId))
  11388. {
  11389. continue;
  11390. }
  11391. string seller_memo = row["seller_memo"].ToString();
  11392. bool ispj = false;//是否配件单
  11393. bool isfirst = true;//第一个配
  11394. maps.Keys.ForEach(key =>
  11395. {
  11396. //备注包含配件
  11397. if (seller_memo.Contains(key) && isfirst)
  11398. {
  11399. List<string> list = maps[key];
  11400. ispj = true;
  11401. isfirst = false;
  11402. for (int i = 0; i < list.Count; i++)
  11403. {
  11404. if (seller_memo.Contains(list[i]))
  11405. {
  11406. ispj = false;
  11407. break;
  11408. }
  11409. }
  11410. }
  11411. });
  11412. if (ispj)
  11413. {
  11414. continue;
  11415. }
  11416. seller_memo = seller_memo.Replace("UV", "uv");
  11417. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11418. //吊牌归到卡片
  11419. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11420. seller_memo = seller_memo.Replace("卡套", "卡片");
  11421. seller_memo = seller_memo.Replace("封套", "卡片");
  11422. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11423. seller_memo = seller_memo.Replace("腰封", "卡片");
  11424. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11425. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11426. seller_memo = seller_memo.Replace("横幅", "条幅");
  11427. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11428. string map_key = "";
  11429. string type = "";
  11430. if (supplierMap.ContainsKey(supplierId))
  11431. {
  11432. foreach (var kvp in supplierMap[supplierId])
  11433. {
  11434. if (seller_memo.Contains(kvp.Key))
  11435. {
  11436. map_key = kvp.Value;
  11437. type = kvp.Value;
  11438. break;
  11439. }
  11440. }
  11441. }
  11442. if (map_key == "")
  11443. {
  11444. type = "其他";
  11445. map_key = "其他";
  11446. }
  11447. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11448. {
  11449. map_key = suppliers[supplierId];
  11450. }
  11451. if (supplierId == 70)
  11452. {
  11453. supplierId = 70;
  11454. }
  11455. map_key += "_" + row["SupplierName"].ToString();
  11456. Dictionary<string, int> map = null;
  11457. if (other_map.ContainsKey(map_key))
  11458. {
  11459. other_map.TryGetValue(map_key, out map);
  11460. }
  11461. else
  11462. {
  11463. map = new Dictionary<string, int>();
  11464. map.Add("dayDev", 0);//当天出货
  11465. map.Add("dayTotal", 0);//下单总数
  11466. map.Add("payTotal", 0);//500以上
  11467. map.Add("today", 0);//当天出货数量
  11468. map.Add("unusua", 0);//异常数
  11469. other_map.Add(map_key, map);
  11470. other_map.TryGetValue(map_key, out map);
  11471. }
  11472. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11473. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11474. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11475. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11476. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11477. {
  11478. map["dayTotal"]++;
  11479. if (supplierId == 97)
  11480. {
  11481. supplierId = 97;
  11482. }
  11483. }
  11484. if (Convert.ToDecimal(row["payment"]) >= 500)
  11485. {
  11486. map["payTotal"]++;
  11487. }
  11488. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11489. {
  11490. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11491. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11492. {
  11493. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11494. {
  11495. map["today"]++;
  11496. }
  11497. }
  11498. else
  11499. {
  11500. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11501. {
  11502. map["today"]++;
  11503. }
  11504. else
  11505. {
  11506. if (supplierId == 119)
  11507. {
  11508. Debug.WriteLine(row["seller_memo"].ToString());
  11509. }
  11510. }
  11511. }
  11512. }
  11513. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11514. {
  11515. map["unusua"]++;
  11516. }
  11517. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11518. //GD-CYT-----64
  11519. DateTime two = palceTimeStart.AddHours(14);
  11520. DateTime three = palceTimeStart.AddHours(15);
  11521. DateTime four = palceTimeStart.AddHours(16);
  11522. DateTime six = palceTimeStart.AddHours(18);
  11523. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11524. {
  11525. //下午四点前 500-1000
  11526. string count = row["ProductCount"].ToString();
  11527. if (count != null && count.Length > 0)
  11528. {
  11529. int productCount = commonHelper.getPlaceProductCount(count);
  11530. if (productCount >= 500 && productCount <= 1000)
  11531. {
  11532. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11533. {
  11534. map["dayDev"]++;
  11535. }
  11536. }
  11537. }
  11538. }
  11539. //UV
  11540. else if ("uv".Equals(type))
  11541. {
  11542. //ZT----70
  11543. //ZHX----3
  11544. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11545. {
  11546. map["dayDev"]++;
  11547. }
  11548. //JK----97
  11549. //HZX----105
  11550. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11551. {
  11552. map["dayDev"]++;
  11553. }
  11554. }
  11555. //帆布---52|条幅---27
  11556. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11557. {
  11558. //LHCY-----98
  11559. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11560. {
  11561. map["dayDev"]++;
  11562. }
  11563. }
  11564. //条幅
  11565. else if ("条幅".Equals(type))
  11566. {
  11567. //XD-----90
  11568. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11569. {
  11570. map["dayDev"]++;
  11571. }
  11572. }
  11573. //桌布
  11574. else if ("桌布".Equals(type))
  11575. {
  11576. //XD-----90
  11577. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11578. {
  11579. map["dayDev"]++;
  11580. }
  11581. }
  11582. //DL---10
  11583. //AYTW---119
  11584. //FS-CYT-DY ----80
  11585. //JK----97
  11586. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11587. {
  11588. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11589. {
  11590. map["dayDev"]++;
  11591. }
  11592. }
  11593. // QC---121
  11594. else if (supplierId == 121)
  11595. {
  11596. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11597. {
  11598. map["dayDev"]++;
  11599. }
  11600. }
  11601. }
  11602. DataTable dt = new DataTable();
  11603. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11604. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11605. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11606. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11607. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11608. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11609. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11610. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11611. other_map.Keys.ForEach(key =>
  11612. {
  11613. DataRow dr = dt.NewRow();
  11614. Dictionary<string, int> map = other_map[key];
  11615. string[] key_list = key.Split('_');
  11616. dr[0] = key_list[0];
  11617. dr[1] = key_list[1];
  11618. if (key_list.Length > 2)
  11619. {
  11620. dr[1] += "(" + key_list[2] + ")";
  11621. }
  11622. dr[2] = map["dayTotal"];
  11623. dr[3] = map["payTotal"];
  11624. dr[4] = map["today"];
  11625. dr[5] = map["unusua"];
  11626. dr[6] = map["dayDev"];
  11627. double rate = 0.00;
  11628. if (map["dayDev"] > 0)
  11629. {
  11630. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11631. }
  11632. dr[7] = rate.ToString();
  11633. dt.Rows.Add(dr);
  11634. });
  11635. DataView dv = new DataView(dt);
  11636. dv.Sort = "SupplierName";
  11637. //dv.Sort = "AllOrder desc";
  11638. DataTable dtNew = dv.ToTable();
  11639. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11640. }
  11641. public void check_order_desing_info()
  11642. {
  11643. string ctid = GetPostString("ctid");
  11644. if (!string.IsNullOrEmpty(ctid))
  11645. {
  11646. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11647. if (ceErpTradeCell != null)
  11648. {
  11649. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11650. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11651. return;
  11652. }
  11653. returnErrorMsg("找不到订单");
  11654. return;
  11655. }
  11656. returnErrorMsg("找不到订单");
  11657. }
  11658. public void get_timeout_detail()
  11659. {
  11660. string poscode = CurrentUser.UserPost.Post.Code;
  11661. DataStruct dStruct = GetPostStruct();
  11662. List<string> lw = new List<string>();
  11663. string id = GetPostString("id");
  11664. string pay_date1 = GetPostString("pay_date1");
  11665. string pay_date2 = GetPostString("pay_date2");
  11666. int type = GetPostInt("type");
  11667. if (type == 0)
  11668. {
  11669. if (pay_date1.Length > 0)
  11670. {
  11671. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11672. }
  11673. if (pay_date2.Length > 0)
  11674. {
  11675. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11676. }
  11677. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11678. }
  11679. if (type == 1)
  11680. {
  11681. if (pay_date1.Length > 0)
  11682. {
  11683. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11684. }
  11685. if (pay_date2.Length > 0)
  11686. {
  11687. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11688. }
  11689. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11690. }
  11691. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11692. DataTable dt = null;
  11693. dt = WebCache.GetData("view_orderlist", dStruct);
  11694. writeGridDataTableJson(dStruct.TotalCount, dt);
  11695. }
  11696. public void saveUrgentChargePrice()
  11697. {
  11698. string ctid = GetPostString("ctid");
  11699. if (!string.IsNullOrEmpty(ctid))
  11700. {
  11701. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11702. if (ceErpTradeCell != null)
  11703. {
  11704. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11705. if (prices <= 100)
  11706. {
  11707. returnErrorMsg("此订单金额不足100元,无法加急。");
  11708. return;
  11709. }
  11710. double price = GetPostDouble("price");
  11711. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11712. if (ceErpTradeCellExtend == null)
  11713. {
  11714. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11715. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11716. }
  11717. ceErpTradeCellExtend.urgentCharge = price;
  11718. if (ceErpTradeCellExtend.ID > 0)
  11719. {
  11720. ceErpTradeCellExtend.Update();
  11721. }
  11722. else
  11723. {
  11724. ceErpTradeCellExtend.Save();
  11725. }
  11726. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11727. returnSuccessMsg("修改成功!");
  11728. return;
  11729. }
  11730. returnErrorMsg("找不到订单");
  11731. return;
  11732. }
  11733. returnErrorMsg("找不到订单");
  11734. }
  11735. public void finish_erp_order()
  11736. {
  11737. string ctid = GetPostString("ctid");
  11738. if (!string.IsNullOrEmpty(ctid))
  11739. {
  11740. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11741. {
  11742. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11743. if (ceErpTradeCell != null)
  11744. {
  11745. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11746. ceErpTradeCell.Update();
  11747. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11748. returnSuccessMsg("修改成功!");
  11749. return;
  11750. }
  11751. }
  11752. }
  11753. returnErrorMsg("找不到订单");
  11754. }
  11755. public void get_trade_order_list()
  11756. {
  11757. string tid = GetPostString("tid");
  11758. if (!string.IsNullOrEmpty(tid))
  11759. {
  11760. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11761. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11762. writeGridDataTableJson(data.Rows.Count, data);
  11763. return;
  11764. }
  11765. returnErrorMsg("找不到订单");
  11766. }
  11767. public void save_cell_spu()
  11768. {
  11769. string ctid = GetPostString("ctid");
  11770. string spu_id = GetPostString("spu_id");
  11771. if (!string.IsNullOrEmpty(ctid))
  11772. {
  11773. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11774. if (ceErpTradeCellExtend == null)
  11775. {
  11776. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11777. ceErpTradeCellExtend.ctid = ctid;
  11778. }
  11779. ceErpTradeCellExtend.spu_id = spu_id;
  11780. if (!string.IsNullOrEmpty(spu_id))
  11781. {
  11782. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11783. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11784. }
  11785. if (ceErpTradeCellExtend.ID == 0)
  11786. {
  11787. ceErpTradeCellExtend.Create();
  11788. }
  11789. else
  11790. {
  11791. ceErpTradeCellExtend.Update();
  11792. }
  11793. returnSuccessMsg("修改成功!");
  11794. return;
  11795. }
  11796. returnErrorMsg("找不到订单");
  11797. }
  11798. public void change_express_info()
  11799. {
  11800. string ctid = GetPostString("ctid");
  11801. string transNo = GetPostString("transNo");
  11802. string transCom = GetPostString("transCom");
  11803. if (!string.IsNullOrEmpty(ctid))
  11804. {
  11805. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11806. if (ceErpTradeCellExtend == null)
  11807. {
  11808. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11809. ceErpTradeCellExtend.ctid = ctid;
  11810. }
  11811. ceErpTradeCellExtend.modExpressNo = transNo;
  11812. ceErpTradeCellExtend.modExpressCom = transCom;
  11813. ceErpTradeCellExtend.readMod = 2;
  11814. if (ceErpTradeCellExtend.ID == 0)
  11815. {
  11816. ceErpTradeCellExtend.Create();
  11817. }
  11818. else
  11819. {
  11820. ceErpTradeCellExtend.Update();
  11821. }
  11822. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11823. returnSuccessMsg("修改成功!");
  11824. return;
  11825. }
  11826. returnErrorMsg("找不到订单");
  11827. }
  11828. public void get_change_express_list()
  11829. {
  11830. DataStruct dStruct = GetPostStruct();
  11831. List<string> lw = new List<string>();
  11832. int st = 2;
  11833. string tid = GetPostString("ctid");
  11834. if (tid.Length > 0)
  11835. {
  11836. string select_tid = getTidByCtid(tid);
  11837. lw.Add(string.Format("tid='{0}'", select_tid));
  11838. }
  11839. string shopname = GetPostString("shopname");
  11840. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11841. string buyernick = GetPostString("buyer_nick");
  11842. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11843. string sellermemo = GetPostString("seller_memo");
  11844. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11845. string supplier = GetPostString("supplier");
  11846. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11847. string customer = GetPostString("customer");
  11848. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11849. string design = GetPostString("design");
  11850. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11851. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11852. string poscode = CurrentUser.UserPost.Post.Code;
  11853. if (poscode != "SysAdmin")
  11854. {
  11855. string shopid = CurrentUser.User.pemShop;
  11856. lw.Add(string.Format("shopId in ({0})", shopid));
  11857. }
  11858. lw.Add("readMod = 2");
  11859. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11860. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11861. writeGridDataTableJson(dStruct.TotalCount, dt);
  11862. }
  11863. public void deal_express_complete()
  11864. {
  11865. string ctid = GetPostString("ctid");
  11866. if (!string.IsNullOrEmpty(ctid))
  11867. {
  11868. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11869. if (ceErpTradeCellExtend == null)
  11870. {
  11871. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11872. ceErpTradeCellExtend.ctid = ctid;
  11873. }
  11874. ceErpTradeCellExtend.readMod = 1;
  11875. if (ceErpTradeCellExtend.ID == 0)
  11876. {
  11877. ceErpTradeCellExtend.Create();
  11878. }
  11879. else
  11880. {
  11881. ceErpTradeCellExtend.Update();
  11882. }
  11883. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11884. returnSuccessMsg("修改成功!");
  11885. return;
  11886. }
  11887. returnErrorMsg("找不到订单");
  11888. }
  11889. public void aftersale_return_visit()
  11890. {
  11891. string ctid = GetPostString("ctid");
  11892. if (!string.IsNullOrEmpty(ctid))
  11893. {
  11894. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11895. if (ceErpTradeCellExtend == null)
  11896. {
  11897. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11898. ceErpTradeCellExtend.ctid = ctid;
  11899. }
  11900. ceErpTradeCellExtend.returnVisit = 1;
  11901. if (ceErpTradeCellExtend.ID == 0)
  11902. {
  11903. ceErpTradeCellExtend.Create();
  11904. }
  11905. else
  11906. {
  11907. ceErpTradeCellExtend.Update();
  11908. }
  11909. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11910. if (ceErpTradeAfterSaleExtend != null)
  11911. {
  11912. ceErpTradeAfterSaleExtend.TextResult = "";
  11913. ceErpTradeAfterSaleExtend.Update();
  11914. }
  11915. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11916. returnSuccessMsg("修改成功!");
  11917. return;
  11918. }
  11919. returnErrorMsg("找不到订单");
  11920. }
  11921. public void orderPlaceInfo()
  11922. {
  11923. string ctids = GetPostString("ctids");
  11924. string[] list = ctids.Split(',');
  11925. foreach (string ctid in list)
  11926. {
  11927. CeErpSukuraData.createInfo(ctid, 3);
  11928. }
  11929. StringBuilder sql = new StringBuilder();
  11930. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11931. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11932. designHelper.api_approveDesign(ctids); //approveDesign
  11933. returnSuccessMsg("");
  11934. }
  11935. public void get_issue_list()
  11936. {
  11937. DataStruct dStruct = GetPostStruct();
  11938. List<string> lw = new List<string>();
  11939. int st = 2;
  11940. string tid = GetPostString("ctid");
  11941. if (tid.Length > 0)
  11942. {
  11943. string select_tid = getTidByCtid(tid);
  11944. lw.Add(string.Format("tid='{0}'", select_tid));
  11945. }
  11946. string shopname = GetPostString("shopname");
  11947. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11948. string buyernick = GetPostString("buyer_nick");
  11949. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11950. string sellermemo = GetPostString("seller_memo");
  11951. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11952. string supplier = GetPostString("supplier");
  11953. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11954. string customer = GetPostString("customer");
  11955. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11956. string design = GetPostString("design");
  11957. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11958. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11959. string poscode = CurrentUser.UserPost.Post.Code;
  11960. if (poscode != "SysAdmin")
  11961. {
  11962. string shopid = CurrentUser.User.pemShop;
  11963. lw.Add(string.Format("shopId in ({0})", shopid));
  11964. }
  11965. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11966. {
  11967. lw.Add("IssueState = 1");
  11968. }
  11969. else
  11970. {
  11971. string iisstate = GetPostString("iisstate");
  11972. if ("1".Equals(iisstate))
  11973. {
  11974. lw.Add("IssueState =1");
  11975. }
  11976. else if ("2".Equals(iisstate))
  11977. {
  11978. lw.Add("IssueState = 2");
  11979. }
  11980. else
  11981. {
  11982. lw.Add("IssueState > 0");
  11983. }
  11984. }
  11985. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11986. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11987. writeGridDataTableJson(dStruct.TotalCount, dt);
  11988. }
  11989. public void saveIssueContent()
  11990. {
  11991. string ctid = GetPostString("ctid");
  11992. if (!string.IsNullOrEmpty(ctid))
  11993. {
  11994. string content = GetPostString("content");
  11995. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11996. if (ceErpTradeAfterSaleExtend == null)
  11997. {
  11998. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11999. ceErpTradeAfterSaleExtend.tid = ctid;
  12000. }
  12001. ceErpTradeAfterSaleExtend.IssueContent = content;
  12002. ceErpTradeAfterSaleExtend.IssueState = 1;
  12003. if (ceErpTradeAfterSaleExtend.ID > 0)
  12004. {
  12005. ceErpTradeAfterSaleExtend.Update();
  12006. }
  12007. else
  12008. {
  12009. ceErpTradeAfterSaleExtend.Create();
  12010. }
  12011. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12012. returnSuccessMsg("添加成功!");
  12013. return;
  12014. }
  12015. returnErrorMsg("找不到订单");
  12016. }
  12017. public void dealIssueContent()
  12018. {
  12019. string ctid = GetPostString("ctid");
  12020. if (!string.IsNullOrEmpty(ctid))
  12021. {
  12022. string content = GetPostString("content");
  12023. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12024. if (ceErpTradeAfterSaleExtend != null)
  12025. {
  12026. ceErpTradeAfterSaleExtend.IssueState = 2;
  12027. ceErpTradeAfterSaleExtend.Update();
  12028. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12029. returnSuccessMsg("修改完成!");
  12030. return;
  12031. }
  12032. }
  12033. returnErrorMsg("找不到订单");
  12034. }
  12035. public void set_tid_attachments()
  12036. {
  12037. string tid = GetPostString("tid");
  12038. string atta = GetPostString("atta");
  12039. if (!string.IsNullOrEmpty(tid))
  12040. {
  12041. if (string.IsNullOrEmpty(atta))
  12042. {
  12043. returnErrorMsg("文件地址为空");
  12044. return;
  12045. }
  12046. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12047. if (ceErpTradeCell != null)
  12048. {
  12049. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12050. if (ceErpTrade == null)
  12051. {
  12052. returnErrorMsg("找不到订单");
  12053. return;
  12054. }
  12055. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12056. bool isSend = false;
  12057. if (dt != null && dt.Rows.Count > 0)
  12058. {
  12059. foreach (DataRow row in dt.Rows)
  12060. {
  12061. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12062. {
  12063. isSend = true;
  12064. }
  12065. }
  12066. if (isSend)
  12067. {
  12068. returnErrorMsg("已发货无法修改");
  12069. return;
  12070. }
  12071. ceErpTrade.Attachments = atta;
  12072. ceErpTrade.Update();
  12073. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12074. returnSuccessMsg("上传成功!");
  12075. return;
  12076. }
  12077. }
  12078. }
  12079. returnErrorMsg("找不到订单");
  12080. }
  12081. public void get_tid_attachments()
  12082. {
  12083. string tid = GetPostString("tid");
  12084. if (!string.IsNullOrEmpty(tid))
  12085. {
  12086. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12087. if (ceErpTradeCell != null)
  12088. {
  12089. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12090. if (ceErpTrade == null)
  12091. {
  12092. returnErrorMsg("找不到订单");
  12093. return;
  12094. }
  12095. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12096. return;
  12097. }
  12098. }
  12099. returnErrorMsg("找不到订单");
  12100. }
  12101. public void check_erp_sameorders()
  12102. {
  12103. if (UrlPostParmsCheck("ctid"))
  12104. {
  12105. string eid = GetPostString("ctid");
  12106. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12107. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12108. if (entity != null && ceErpTrade != null)
  12109. {
  12110. if (entity.OrderState > 6)
  12111. {
  12112. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12113. return;
  12114. }
  12115. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12116. List<string> ids = new List<string>();
  12117. if (dt != null && dt.Rows.Count > 1)
  12118. {
  12119. bool needhe = true;
  12120. foreach (DataRow dr in dt.Rows)
  12121. {
  12122. ids.Add("'" + dr["ctid"] + "'");
  12123. /* //备注有合包
  12124. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12125. {
  12126. needhe = true;
  12127. }
  12128. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12129. {
  12130. needhe = true;
  12131. }
  12132. //顺丰快递
  12133. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12134. {
  12135. needhe = true;
  12136. }*/
  12137. }
  12138. if (!needhe)
  12139. {
  12140. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12141. return;
  12142. }
  12143. StringBuilder sql = new StringBuilder();
  12144. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12145. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12146. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12147. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12148. foreach (DataRow dr in dt.Rows)
  12149. {
  12150. dr["dstate"] = 0;
  12151. dr["dnumber"] = 0;
  12152. foreach (DataRow row in dt1.Rows)
  12153. {
  12154. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12155. {
  12156. dr["dstate"] = 2;
  12157. dr["default"] = 1;
  12158. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12159. }
  12160. }
  12161. if (eid.Equals(dr["ctid"].ToString()))
  12162. {
  12163. dr["dstate"] = 1;
  12164. dr["default"] = 1;
  12165. }
  12166. }
  12167. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12168. return;
  12169. }
  12170. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12171. return;
  12172. }
  12173. returnErrorMsg("未找到订单");
  12174. return;
  12175. }
  12176. returnErrorMsg("缺少必要的参数");
  12177. }
  12178. public void get_mark_number()
  12179. {
  12180. string eid = GetPostString("ctid");
  12181. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12182. if (entity != null)
  12183. {
  12184. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12185. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12186. int current = 1;
  12187. if (ceErpDeliverMark == null)
  12188. {
  12189. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12190. List<string> ids = new List<string>();
  12191. if (dt != null && dt.Rows.Count > 1)
  12192. {
  12193. foreach (DataRow dr in dt.Rows)
  12194. {
  12195. ids.Add("'" + dr["ctid"] + "'");
  12196. }
  12197. //查询已有的编号
  12198. StringBuilder sql = new StringBuilder();
  12199. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12200. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12201. if (dt1 == null || dt1.Rows.Count == 0)
  12202. {
  12203. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12204. List<int> list_number = new List<int>();
  12205. foreach (DataRow row in numbers.Rows)
  12206. {
  12207. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12208. }
  12209. //查询空余编号
  12210. for (int i = 0; i < list_number.Count + 2; i++)
  12211. {
  12212. if (!list_number.Contains(current))
  12213. {
  12214. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12215. //防止查询过程中有新数据生成
  12216. if (ceErpDeliverMark1 == null)
  12217. {
  12218. break;
  12219. }
  12220. }
  12221. current++;
  12222. }
  12223. }
  12224. else
  12225. {
  12226. foreach (DataRow row in dt1.Rows)
  12227. {
  12228. current = Convert.ToInt32(row["markNumber"]);
  12229. }
  12230. }
  12231. ceErpDeliverMark = new CeErpDeliverMark();
  12232. ceErpDeliverMark.ctid = eid;
  12233. ceErpDeliverMark.createtime = DateTime.Now;
  12234. if (ceErpTrade != null)
  12235. {
  12236. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12237. }
  12238. ceErpDeliverMark.markNumber = current;
  12239. ceErpDeliverMark.Create();
  12240. }
  12241. }
  12242. else
  12243. {
  12244. current = ceErpDeliverMark.markNumber;
  12245. }
  12246. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12247. return;
  12248. }
  12249. }
  12250. public void aftersaleCytSend()
  12251. {
  12252. string ctid = GetPostString("ctid");
  12253. if (!string.IsNullOrEmpty(ctid))
  12254. {
  12255. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12256. if (ceErpTradeCell != null)
  12257. {
  12258. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12259. }
  12260. returnSuccessMsg("推送成功");
  12261. return;
  12262. }
  12263. returnErrorMsg("缺少必要的参数");
  12264. }
  12265. public void packOrderInfo()
  12266. {
  12267. string ctids = GetPostString("ctids");
  12268. if (!string.IsNullOrEmpty(ctids))
  12269. {
  12270. string[] ctid_list = ctids.Split(',');
  12271. if (ctid_list.Length > 20)
  12272. {
  12273. returnErrorMsg("单次下载次数不能超过20个");
  12274. return;
  12275. }
  12276. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12277. StringBuilder sql = new StringBuilder();
  12278. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12279. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12280. int supplierId = 0;
  12281. StringBuilder insterSql = new StringBuilder();
  12282. for (int i = 0; i < dt.Rows.Count; i++)
  12283. {
  12284. DataRow row = dt.Rows[i];
  12285. if (i == 0)
  12286. {
  12287. supplierId = Convert.ToInt32(row["SupplierId"]);
  12288. }
  12289. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12290. {
  12291. returnErrorMsg("同车间的订单才能一起打包");
  12292. return;
  12293. }
  12294. int orderState = Convert.ToInt32(row["OrderState"]);
  12295. if (orderState != 5)
  12296. {
  12297. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12298. return;
  12299. }
  12300. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12301. }
  12302. CeErpPackData ceErpPackData = new CeErpPackData();
  12303. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12304. ceErpPackData.supplierId = supplierId;
  12305. ceErpPackData.createtime = DateTime.Now;
  12306. ceErpPackData.createBy = CurrentUser.UserID;
  12307. ceErpPackData.createName = CurrentUser.UserName;
  12308. ceErpPackData.Create();
  12309. if (ceErpPackData.ID > 0)
  12310. {
  12311. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12312. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12313. }
  12314. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12315. returnSuccessMsg("打包成功");
  12316. return;
  12317. }
  12318. returnErrorMsg("缺少必要的参数");
  12319. }
  12320. public void rePackOrderInfo()
  12321. {
  12322. string id = GetPostString("id");
  12323. if (!string.IsNullOrEmpty(id))
  12324. {
  12325. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12326. if (ceErpPackData == null)
  12327. {
  12328. returnSuccessMsg("查无数据");
  12329. return;
  12330. }
  12331. ceErpPackData.upStatus = 0;
  12332. ceErpPackData.message = "";
  12333. ceErpPackData.Update();
  12334. returnSuccessMsg("打包成功");
  12335. return;
  12336. }
  12337. returnErrorMsg("缺少必要的参数");
  12338. }
  12339. public void backPackOrderInfo()
  12340. {
  12341. string id = GetPostString("id");
  12342. if (!string.IsNullOrEmpty(id))
  12343. {
  12344. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12345. if (ceErpPackData == null)
  12346. {
  12347. returnSuccessMsg("查无数据");
  12348. return;
  12349. }
  12350. ceErpPackData.upStatus = 4;
  12351. ceErpPackData.Update();
  12352. List<string> list = new List<string>();
  12353. StringBuilder sql = new StringBuilder();
  12354. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12355. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12356. for (int i = 0; i < dt.Rows.Count; i++)
  12357. {
  12358. DataRow row = dt.Rows[i];
  12359. list.Add("'" + row["ctid"].ToString() + "'");
  12360. }
  12361. string textCtids = string.Join(",", list);
  12362. 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));
  12363. 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, "无法打包退回"));
  12364. returnSuccessMsg("退回成功");
  12365. return;
  12366. }
  12367. returnErrorMsg("缺少必要的参数");
  12368. }
  12369. public void addPackDownNum()
  12370. {
  12371. string id = GetPostString("id");
  12372. if (!string.IsNullOrEmpty(id))
  12373. {
  12374. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12375. returnSuccessMsg("下载成功");
  12376. return;
  12377. }
  12378. returnErrorMsg("缺少必要的参数");
  12379. }
  12380. public void get_pack_list()
  12381. {
  12382. DataStruct dStruct = GetPostStruct();
  12383. List<string> lw = new List<string>();
  12384. string supplier = GetPostString("supplier");
  12385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12386. string posTag = CurrentUser.UserPost.Post.Code;
  12387. if (posTag == "Supplier")
  12388. {
  12389. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12390. }
  12391. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12392. dStruct.Order = "createtime desc";
  12393. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12394. writeGridDataTableJson(dStruct.TotalCount, dt);
  12395. }
  12396. public void get_pack_order_list()
  12397. {
  12398. string packId = GetPostString("packId");
  12399. if (string.IsNullOrEmpty(packId))
  12400. {
  12401. returnErrorMsg("缺少必要的参数");
  12402. return;
  12403. }
  12404. StringBuilder sql = new StringBuilder();
  12405. 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);
  12406. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12407. if (dt == null || dt.Rows.Count == 0)
  12408. {
  12409. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12410. return;
  12411. }
  12412. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12413. return;
  12414. }
  12415. public void get_supplier_product_time_list()
  12416. {
  12417. DataStruct dStruct = GetPostStruct();
  12418. List<string> lw = new List<string>();
  12419. string supplier = GetPostString("supplier");
  12420. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12421. string posTag = CurrentUser.UserPost.Post.Code;
  12422. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12423. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12424. writeGridDataTableJson(dStruct.TotalCount, dt);
  12425. }
  12426. public void saveSupplierProductTime()
  12427. {
  12428. string productId = GetPostString("productId");
  12429. if (string.IsNullOrEmpty(productId))
  12430. {
  12431. returnErrorMsg("缺少必要的参数");
  12432. return;
  12433. }
  12434. string productName = GetPostString("productName");
  12435. int supplierId = GetPostInt("supplierId");
  12436. if (supplierId == 0)
  12437. {
  12438. returnErrorMsg("缺少必要的参数");
  12439. return;
  12440. }
  12441. int quantity = GetPostInt("quantity");
  12442. int sendDay = GetPostInt("sendTime");
  12443. string supplierName = GetPostString("supplierName");
  12444. string craft = GetPostString("craft");
  12445. string deadLine = GetPostString("deadLine");
  12446. string dayDeadLine = GetPostString("dayDeadLine");
  12447. try
  12448. {
  12449. int eid = GetPostInt("eid");
  12450. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12451. if (ceErpSupplierProductTime == null)
  12452. {
  12453. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12454. }
  12455. ceErpSupplierProductTime.productId = productId;
  12456. ceErpSupplierProductTime.productName = productName;
  12457. ceErpSupplierProductTime.supplierId = supplierId;
  12458. ceErpSupplierProductTime.supplierName = supplierName;
  12459. ceErpSupplierProductTime.craft = craft;
  12460. ceErpSupplierProductTime.sendDay = sendDay;
  12461. ceErpSupplierProductTime.quantity = quantity;
  12462. if (!string.IsNullOrEmpty(deadLine))
  12463. {
  12464. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12465. }
  12466. if (!string.IsNullOrEmpty(dayDeadLine))
  12467. {
  12468. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12469. }
  12470. if (ceErpSupplierProductTime.ID == 0)
  12471. {
  12472. ceErpSupplierProductTime.Save();
  12473. }
  12474. else
  12475. {
  12476. ceErpSupplierProductTime.Update();
  12477. }
  12478. }
  12479. catch (Exception e)
  12480. {
  12481. }
  12482. returnSuccessMsg("保存成功");
  12483. return;
  12484. }
  12485. public void delSupplierProductTime()
  12486. {
  12487. int eid = GetPostInt("eid");
  12488. if (eid > 0)
  12489. {
  12490. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12491. if (ceErpSupplierProductTime == null)
  12492. {
  12493. returnErrorMsg("查无数据");
  12494. return;
  12495. }
  12496. ceErpSupplierProductTime.Delete();
  12497. returnSuccessMsg("保存成功");
  12498. return;
  12499. }
  12500. returnErrorMsg("缺少必要的参数");
  12501. }
  12502. public void getExpressInfo()
  12503. {
  12504. string ctid = GetPostString("ctid");
  12505. if (!string.IsNullOrEmpty(ctid))
  12506. {
  12507. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12508. if (ceErpTradeCell != null)
  12509. {
  12510. string outSid = ceErpTradeCell.OutSid;
  12511. if (outSid.Length > 0)
  12512. {
  12513. 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);
  12514. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12515. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12516. return;
  12517. }
  12518. }
  12519. returnErrorMsg("查无记录");
  12520. return;
  12521. }
  12522. returnErrorMsg("缺少必要的参数");
  12523. }
  12524. public void getExpressPostData()
  12525. {
  12526. string express = GetPostString("express");
  12527. if (!string.IsNullOrEmpty(express))
  12528. {
  12529. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12530. if (ceErpExpressInfo != null)
  12531. {
  12532. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12533. return;
  12534. }
  12535. }
  12536. returnErrorMsg("缺少必要的参数");
  12537. }
  12538. public void checkSupplierOrder()
  12539. {
  12540. string ctids = GetPostString("ctids");
  12541. if (ctids != null)
  12542. {
  12543. List<string> list = new List<string>();
  12544. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12545. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12546. for (int i = 0; i < dt.Rows.Count; i++)
  12547. {
  12548. DataRow row = dt.Rows[i];
  12549. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12550. {
  12551. continue;
  12552. }
  12553. list.Add(row["seller_memo"].ToString());
  12554. }
  12555. if (list.Count > 0)
  12556. {
  12557. 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, "点击下载按钮"));
  12558. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12559. return;
  12560. }
  12561. }
  12562. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12563. return;
  12564. }
  12565. public void addPersonId()
  12566. {
  12567. string tid = GetPostString("tid");
  12568. string personId = GetPostString("personId");
  12569. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12570. if (ceErpTrade != null)
  12571. {
  12572. ceErpTrade.receiver_zip = personId;
  12573. ceErpTrade.Update();
  12574. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12575. returnSuccessMsg("保存成功");
  12576. return;
  12577. }
  12578. returnErrorMsg("缺少必要的参数");
  12579. }
  12580. public void addDeliveryPaymant()
  12581. {
  12582. string tid = GetPostString("tid");
  12583. string paymant = GetPostString("paymant");
  12584. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12585. if (ceErpTrade != null)
  12586. {
  12587. if (!string.IsNullOrEmpty(paymant))
  12588. {
  12589. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12590. }
  12591. ceErpTrade.Update();
  12592. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12593. returnSuccessMsg("保存成功");
  12594. return;
  12595. }
  12596. returnErrorMsg("缺少必要的参数");
  12597. }
  12598. public void saveCellFile()
  12599. {
  12600. string tid = GetPostString("tid");
  12601. string ctid = GetPostString("ctid");
  12602. string urls = GetPostString("urls");
  12603. string type = GetPostString("type");
  12604. string del = GetPostString("del");
  12605. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12606. {
  12607. if ("1".Equals(del))
  12608. {
  12609. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12610. }
  12611. string[] list = urls.Split(',');
  12612. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12613. {
  12614. foreach (string item in list)
  12615. {
  12616. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12617. ceErpTradeCellFile.Create();
  12618. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12619. }
  12620. }
  12621. returnSuccessMsg("保存成功");
  12622. return;
  12623. }
  12624. returnErrorMsg("缺少必要的参数");
  12625. }
  12626. public void getCellFile()
  12627. {
  12628. string tid = GetPostString("tid");
  12629. string ctid = GetPostString("ctid");
  12630. string type = GetPostString("type");
  12631. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12632. {
  12633. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12634. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12635. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12636. return;
  12637. }
  12638. returnErrorMsg("缺少必要的参数");
  12639. }
  12640. public void delCellFile()
  12641. {
  12642. string id = GetPostString("id");
  12643. if (string.IsNullOrEmpty(id))
  12644. {
  12645. returnErrorMsg("缺少必要的参数");
  12646. return;
  12647. }
  12648. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12649. CeErpTradeCellFile.delByID(id);
  12650. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12651. returnSuccessMsg("保存成功");
  12652. }
  12653. }
  12654. }