| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305 |
- using BizCom;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using NHibernate.Linq;
- using NHibernate.Mapping;
- using NPOI.OpenXmlFormats.Dml.Diagram;
- using NPOI.OpenXmlFormats.Shared;
- using NPOI.SS.Formula.Eval;
- using NPOI.SS.Formula.Functions;
- using NPOI.SS.Formula.Udf;
- using SiteCore.Redis;
- using SiteCore.taobao;
- using SiteCore.taoObj;
- using SQLData;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel.Design;
- using System.Data;
- using System.Data.SqlClient;
- using System.Data.SqlTypes;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Security;
- using System.Reflection.Emit;
- using System.Security.Cryptography;
- using System.Security.Cryptography.X509Certificates;
- using System.Security.Policy;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Web.UI.WebControls;
- using Utils;
- using Utils.Serialization;
- using static NHibernate.Linq.Visitors.LeftJoinDetector;
- using static SiteCore.taoObj.Api_waybill_code_response_Obj;
- using static SiteCore.taoObj.work_core_vo;
- using static System.Net.Mime.MediaTypeNames;
- namespace SiteCore.Handler
- {
- public partial class sync
- {
- public void get_erp_orderlist()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- //apiHelper.Api_SyncOrderByTime("598825");
- //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
- //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
- //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
- //banniuApiHelper.sendLogisticsInfo(null);
- //commonHelper.setOrderDummyDelivery("4055992920657411904");
- //commonHelper.checkOrderListDesignInfo("4042031616863358615");
- //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
- //int sid = commonHelper.autoDistributeToSupplier(entity);
- // string a = apiHelper.API_GetPrintData("YT8951457355085");
- //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1740972223000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1741145016000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2208932202028/O1CN01SQkhPk1QqsBIMPegn_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"2484480075794418199\",\"refSkuId\":\"0\",\"refSpuId\":\"787248116865\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"饰品售后卡片定制珠宝项链购后感谢卡硬卡设计金银保养留言卡纸制作电商包裹贺卡高级明信片首饰好平小卡印刷\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1740995566000,\"openBuyerId\":\"AAFoRHraABkUZRPgSx0XdWH-\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"麦郁旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1740972209000,\"payTime\":1740972216000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"maiyu\",\"posId\":598808,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"湖州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴兴区\",\"receiverId\":\"82b7afe37a7abf32c5a68285642bc6c7$\",\"receiverState\":\"浙江省\",\"receiverTown\":\"织里镇\",\"refOid\":\"2484480075794418199\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-卡片-300克铜版纸-tb90589912-小元-2,寄样-卡片-300克雅柔纸-tb90589912-小元-2,寄样-卡片-300克蛋壳纸-tb90589912-小元-2,寄样-卡片-300克刚古水纹纸-tb90589912-小元-2,寄样-卡片-300克荷兰白卡纸-tb90589912-小元-2\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
- //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}}");
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- int paramsCount = 0;
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string date2 = GetPostString("date2");
- string buyernick = GetPostString("buyer_nick");
- if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
- {
- if (tid.Length <= 0 && buyernick.Length <= 0)
- {
- return;
- }
- }
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
- }
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- }
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0)
- {
- lw.Add(dw);
- }
- if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- }
- }
- else
- {
- if (ex_psize == 0)
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- if (PKey != "admin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- paramsCount++;
- }
- }
- string uploaddate1 = GetPostString("uploaddate1");
- string uploaddate2 = GetPostString("uploaddate2");
- string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
- if (update.Length > 0) lw.Add(update);
- string deliverydate1 = GetPostString("deliverydate1");
- string deliverydate2 = GetPostString("deliverydate2");
- string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
- if (deliverydate.Length > 0)
- {
- lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
- };
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string addwechat = GetPostString("addwechat");
- if (addwechat.Length > 0)
- {
- int addWt = Convert.ToInt32(addwechat);
- if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
- else lw.Add(string.Format("IsAddWechat={0}", addWt));
- }
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string backReason = GetPostString("backReason");
- if (backReason.Length > 0)
- {
- lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- string finishdate1 = GetPostString("finishdate1");
- string finishdate2 = GetPostString("finishdate2");
- string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
- bool isFinish = false;
- if (finishdate.Length > 0)
- {
- lw.Add(finishdate);
- isFinish = true;
- paramsCount++;
- }
- if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (ex_psize > 0)
- {
- int UserID = CurrentUser.UserID;
- if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
- UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
- }
- dStruct.Order = "pay_time desc";
- }
- string isNew = GetPostString("isNew");
- if (isNew == "true")
- {
- lw.Add(string.Format("IsNew = {0}", 1));
- }
- string overtime = GetPostString("overtime");
- if (overtime == "1")
- {
- lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
- }
- String usePost = CurrentUser.UserPost.Post.Code;
- if (usePost.Equals("Operation") == true)
- {
- dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- else
- {
- dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- //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";
- if (dStruct.PageSize == 100000)
- {
- dStruct.Order = "";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- string tablename = "view_orderlist";
- if (isFinish)
- {
- tablename = "view_orderlist_end";
- }
- dt = WebCache.GetData(tablename, dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- if (dr["refund_fees"] != null)
- {
- decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
- decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
- decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
- if (payment == refund_fees)
- {
- dr["refund_fees"] = Math.Round(refund_fees, 2);
- continue; // 跳过当前迭代
- }
- else if (refund_fees == total_fee)
- {
- dr["refund_fees"] = payment;
- continue; // 跳过当前迭代
- }
- else
- {
- decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
- decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
- dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
- }
- }
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- dr["refund_fees"] = "0.00";
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_orderlist_sumprice()
- {
- returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
- return;
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (PKey != "admin")
- {
- string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- //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";
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_CustomerServiceGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string customer = GetPostString("customer");
- if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
- ") as b on a.ID = b.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as d on a.ID = d.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as e on a.ID = e.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'CustomerService'",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- //writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //设计汇总
- public void get_erp_DesignerGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string Designer = GetPostString("designer");
- int org = GetPostInt("org");
- if (Designer.Length > 0)
- {
- userWhere = string.Format(" where Name like '%{0}%'", Designer);
- if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
- }
- else if (org > 0)
- {
- userWhere = string.Format(" where OrgID ={0}", org);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string state = GetPostString("state");
- if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string UpDate1 = GetPostString("UpDate1");
- string UpDate2 = GetPostString("UpDate2");
- dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 (" +
- "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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
- ") as b on a.ID = b.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as d on a.ID = d.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as e on a.ID = e.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as g on a.ID = g.DesignUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'Designer') as z",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //删除tradecell的订单
- public void del_erp_cellorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell.DelByCtid(eid);
- LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
- returnSuccessMsg("删除成功");
- }
- }
- public void clear_erp_refundstate()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] ctidList = eids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsRefund = 0;
- entity.Update();
- LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
- }
- else
- continue;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("缺少必要参数");
- }
- public void set_erp_urgency()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string utime = GetPostString("urgencytime");
- if (utime.Length > 0)
- {
- entity.UrgencyTime = Convert.ToDateTime(utime);
- }
- else
- {
- returnErrorMsg("请选择加急时间");
- return;
- }
- if (entity.OrderState <= 4)
- {
- //entity.seller_memo = entity.seller_memo + "-加急";
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- DateTime urgtime = Convert.ToDateTime(utime);
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
- }
- else
- {
- newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- entity.IsUrgency = true;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "changeDesign";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.remarkSign = 3;
- designHelper.API_WorkCore(apiVo); //changeDesign
- CeErpSukuraData.createInfo(entity.ctid, 7);
- LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
- returnSuccessMsg("设置成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_reset()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
- {
- if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
- {
- returnErrorMsg("财务要求已下单已发货无法重置");
- return;
- }
- }
- entity.IsUrgency = false;
- entity.seller_memo = "";
- entity.OtherMemo = "";
- entity.OrderState = 0;
- entity.IsReturn = 0;
- //entity.IsRefund = 0;
- entity.MemoOpt = 0;
- entity.AfterSaleState = 0;
- entity.AfterSaleResponsible = "";
- entity.AfterSaleUserId = 0;
- entity.IsNeedBill = 0;
- entity.CustomerUserId = 0;
- entity.DesignUserId = 0;
- entity.SupplierId = 0;
- entity.PlaceUserId = 0;
- entity.ptid = "";
- entity.IsSample = 0;
- entity.IsXianHuo = 0;
- entity.isDianziOrder = 0;
- entity.DispatchSort = 0;
- entity.FinishPlaceTime = null;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- trade.seller_memo = "";
- trade.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
- returnSuccessMsg("重置成功!");
- CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
- if (desginBill != null)
- {
- desginBill.isDel = 1;
- desginBill.Update();
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "resetDesign";
- designHelper.API_WorkCore(apiVo);//resetDesign
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_sellermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string memo = GetPostString("seller_memo");
- memo = memo.Replace(" ", "");
- if (memo.Contains("补差"))
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- if (entity.seller_memo != memo)
- {
- if (entity.IsSample == 2)
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- if (CurrentUser.UserPost.Post.Code != "SysAdmin")
- {
- if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
- {
- returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
- return;
- }
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
- }
- commonHelper.getCytPrice(entity);
- int memoopt = GetPostInt("MemoOpt");
- Boolean ismemoopt = false;
- if (memoopt > 0)
- {
- string stropt = "";
- if (memoopt == 1)
- {
- stropt = "“改稿”";
- ismemoopt = true;
- }
- else if (memoopt == 2)
- {
- stropt = "“定稿”";
- }
- else if (memoopt == 3)
- {
- stropt = "“查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- entity.MemoOpt = Convert.ToInt32(memoopt);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
- }
- if (entity.OrderState < 5)
- {
- memo = memo.Replace("(", "(");
- memo = memo.Replace(")", ")");
- }
- entity.seller_memo = memo;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
- apiVo.orderRemarks = memo;
- apiVo.remarkSign = memoopt;
- designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_checkorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (entity.OrderState < 6)
- {
- returnErrorMsg("下单完成后才可查货");
- return;
- }
- /*if (entity.OrderState > 6)
- {
- returnErrorMsg("订单已发货");
- return;
- }*/
- if (entity.FinishPlaceTime != null)
- {
- if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
- {
- returnErrorMsg("下单时间不足,无法查货");
- return;
- }
- }
- entity.MemoOpt = 3;
- entity.CheckOrderTime = DateTime.Now;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 6);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_othermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OtherMemo = GetPostString("otherMemo");
- if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
- {
- //品类一直
- entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
- CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
- if (ceErpSampleCustomer == null)
- {
- ceErpSampleCustomer = new CeErpSampleCustomer();
- ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
- ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
- ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
- ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
- ceErpSampleCustomer.shopId = entity.ShopId;
- }
- ceErpSampleCustomer.lastbuy_time = entity.pay_time;
- ceErpSampleCustomer.lastTid = entity.tid;
- if (ceErpSampleCustomer.ID > 0)
- {
- ceErpSampleCustomer.Update();
- }
- else
- {
- ceErpSampleCustomer.Create();
- }
- }
- }
- }
- }
- //if (entity.IsOldCustomer == 1)
- //{
- //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
- //{
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
- //}
- //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
- //{
- // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
- // {
- // if (entity.OtherMemo.IndexOf("改稿") > -1)
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
- // }
- // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
- // {
- // entity.OrderState = 2;
- // entity.DesignUserId = 0;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
- // }
- // else
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
- // }
- // }
- //}
- //}
- entity.Update();
- returnSuccessMsg("保存成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_customermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.CustomerMemo = GetPostString("CustomerMemo");
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "followRemarks";
- apiVo.orderRemarks = entity.CustomerMemo;
- designHelper.API_WorkCore(apiVo);//followRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addmemotag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string sfTagstr = GetPostString("memotag");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState == 0)
- {
- returnErrorMsg("请先领单");
- return;
- }
- //撤销顺丰
- if (sfTagstr == "撤销顺丰")
- {
- entity.IsSF = 0;
- string reMsg = "";
- string oldmemo = entity.seller_memo;
- if (entity.OrderState < 5)
- {
- oldmemo = oldmemo.Replace("顺丰到付", "");
- oldmemo = oldmemo.Replace("顺丰寄付", "");
- entity.seller_memo = oldmemo;
- }
- else
- {
- if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
- {
- reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
- }
- }
- entity.Update();
- work_core_vo.ApiVo api = new work_core_vo.ApiVo();
- api.orderNumber = entity.ctid;
- api.actionName = "followRemarks";
- api.orderRemarks = entity.seller_memo;
- api.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(api);//followRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
- returnSuccessMsg("撤销成功!" + reMsg);
- return;
- }
- if (entity.OrderState < 5 || entity.IsXianHuo == 1)
- {
- //string oldmemo = entity.seller_memo;
- //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
- string sfStr = GetPostString("memotag");
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(" + sfStr + "." + useLastmemo;
- }
- else
- {
- newlastmemo = "(" + sfStr + ")-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- string sfTagMSg = "";
- if (sfTagstr == "顺丰寄付")
- {
- entity.IsSF = 1;
- sfTagMSg = "顺丰寄付";
- }
- else if (sfTagstr == "顺丰到付")
- {
- entity.IsSF = 2;
- sfTagMSg = "顺丰到付";
- }
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "orderRemarks";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(apiVo);//orderRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int tag = GetPostInt("wechattag");
- //if(tag==4 && entity.IsSample == 2)
- //{
- // returnErrorMsg("补差价单不能标记微信单");
- // return;
- //}
- entity.wechatTag = tag;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (tag == 1)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "微信返现";
- cash.returnprice = 0;
- cash.created = DateTime.Now;
- cash.con = "订单标记微信单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 2)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "推购返现";
- cash.returnprice = 5;
- cash.created = DateTime.Now;
- cash.con = "订单标记推购单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 3)
- {
- CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
- if (pers == null)
- {
- pers = new CeErpPersuade();
- pers.ctid = entity.ctid;
- pers.pstate = 0;
- pers.created = DateTime.Now;
- pers.applyuserid = CurrentUser.UserID;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
- }
- else
- {
- pers.pstate = 0;
- pers.Update();
- }
- }
- else if (tag == 4 || tag == 5)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
- if (pers == null)
- {
- pers = new CeErpStayGoods();
- pers.t_id = entity.tid;
- pers.status = "待审核";
- pers.audit_type = 0;
- if (tag == 4)
- {
- pers.stay_type = "微信推购";
- }
- else
- {
- pers.stay_type = "旺旺推购";
- }
- if (entity.IsXianHuo == 0)
- {
- pers.product_id = entity.ProductId;
- }
- pers.wangwang = main.buyer_nick;
- pers.shop_name = main.seller_nick;
- pers.creata_time = DateTime.Now;
- pers.create_u_id = CurrentUser.UserID;
- pers.create_u_name = CurrentUser.UserName;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
- }
- else
- {
- pers.audit_type = 0;
- pers.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 10);
- }
- //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag_cancel()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.wechatTag = 0;
- entity.Update();
- CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
- if (pers != null)
- {
- pers.status = "取消推购";
- pers.audit_type = 3;
- pers.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addweichattag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsAddWechat > 0)
- {
- returnErrorMsg("此单已经标记过了");
- return;
- }
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- entity.IsAddWechat = 2;
- }
- else
- {
- entity.IsAddWechat = 1;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_getmyorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.ctid.IndexOf("C") != -1)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- decimal total = 0;
- foreach (DataRow dr in dt.Rows)
- {
- total += Convert.ToDecimal(dr["payment"]);
- }
- decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
- if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
- {
- returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
- return;
- }
- }
- }
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void getmyorder_from_init()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string sellerMemo = GetPostString("sellerMemo");
- if (sellerMemo.Length > 0)
- {
- entity.seller_memo = sellerMemo;
- }
- string oterhMemo = GetPostString("otherMemo");
- if (oterhMemo.Length > 0)
- {
- entity.OtherMemo = oterhMemo;
- }
- int urg = GetPostInt("urgency");
- entity.IsUrgency = (urg == 1 ? true : false);
- int wechat = GetPostInt("wechat");
- int command = GetPostInt("command");
- if (wechat == 1)
- {
- entity.wechatTag = 1;
- }
- if (command == 1)
- {
- entity.wechatTag = 2;
- }
- string pPro = GetPostString("pprofession");
- if (pPro.Length > 0)
- {
- entity.ParentProfessionId = Convert.ToInt32(pPro);
- string spro = GetPostString("profession");
- if (spro.Length > 0)
- {
- entity.ProfessionId = Convert.ToInt32(spro);
- }
- }
- string proId = GetPostString("productId");
- if (proId.Length > 0)
- {
- entity.ProductId = Convert.ToInt32(proId);
- }
- entity.Material = GetPostString("material");
- entity.Craft = GetPostString("craft");
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_setrelationorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string ftid = GetPostString("ftid");
- CeErpTradeCell entity = null;
- CeErpTradeCell fentity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
- if (fentity == null)
- {
- returnErrorMsg("找不到关联的主订单");
- return;
- }
- if (entity != null)
- {
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("本单已经设计完成无法关联");
- return;
- }
- if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
- {
- returnErrorMsg("线下单续审核后才能关联!");
- return;
- }
- entity.ptid = ftid;
- entity.OrderState = fentity.OrderState;
- //entity.status = fentity.status;
- entity.CustomerUserId = fentity.CustomerUserId;
- entity.DesignUserId = fentity.DesignUserId;
- entity.seller_memo = "补差价单:" + ftid;
- entity.IsSample = 2;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ftid;
- apiVo.payment = entity.payment;
- apiVo.actionName = "repairDesign";
- designHelper.API_WorkCore(apiVo);//repairDesign
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
- returnSuccessMsg("关联成功!");
- return;
- }
- else
- returnErrorMsg("找不到记录");
- }
- }
- public void download_erp_neworder()
- {
- string seller = GetPostString("seller_nick");
- string tid = GetPostString("tid");
- if (seller.Length <= 0 || tid.Length <= 0)
- {
- returnErrorMsg("数据错误");
- }
- //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
- //{
- // returnErrorMsg("找不到店铺Sessionkey");
- //}
- //string sessionkey = taobaoHelper.ShopKeyDics[seller];
- //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
- string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
- if (res.IndexOf("refOid") == -1)
- {
- returnErrorMsg("下载订单数据失败");
- return;
- }
- tmcHelper.Api_Tmc_CreateNewOrder(res);
- returnSuccessMsg("下载完成");
- //tmcHelper.createNewOrder(res);
- //CeErpTrade entr = null;
- //entr = CeErpTrade.Get(tid);
- //if (entr != null)
- //{
- // returnSuccess("下载成功");
- // //下载成功之后,Cell表生成对应的订单;
- // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
- //}
- //else
- //{
- // returnErrorMsg("下载失败或者创建订单失败");
- //}
- }
- public void set_erp_atersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("AfterSaleReason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
- {
- returnErrorMsg("此订单已经在售后");
- return;
- }
- entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
- //entity.AfterSaleReason = reason;
- entity.AfterSaleTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
- returnSuccessMsg("转售后成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_withdraw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- try
- {
- string eid = GetPostString("ctid");//商品id
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
- CeWithdraw ceWithdrawSelect = null;
- ceWithdrawSelect = CeWithdraw.GetByTid(eid);
- if (ceWithdrawSelect != null)
- {
- if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
- {
- ceWithdrawSelect.status = -1;
- ceWithdrawSelect.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("重新发起审核成功");
- return;
- }
- else
- {
- returnSuccessMsg("请勿重复申请!");
- return;
- }
- }
- else
- {
- string CustomerUserId = GetPostString("CustomerUserId");//供应商id
- if (string.IsNullOrEmpty(CustomerUserId))
- {
- CustomerUserId = "-1";
- }
- int Userid = CurrentUser.UserID;//用户id
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = eid;
- ceWithdraw.userid = Userid;
- ceWithdraw.providerid = CustomerUserId;
- ceWithdraw.status = 3;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.Create();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("申请撤回订单成功,待车间确认");
- return;
- }
- }
- catch
- {
- returnErrorMsg("申请撤回订单失败");
- return;
- }
- }
- }
- public void ins_erp_billinfo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpBill bill = CeErpBill.GetByTid(eid);
- bool isHave = false;
- if (bill != null)
- {
- isHave = true;
- if (bill.state != 4)
- {
- returnErrorMsg("此单已经申请过发票了");
- return;
- }
- }
- if (entity.IsNeedBill == 0)
- {
- entity.IsNeedBill = 1;
- }
- entity.Update();
- string errjson = "";
- try
- {
- CeErpBill bill_entity = new CeErpBill();
- bill_entity.tid = entity.tid;
- bill_entity.title = GetPostString("title");
- string taxstr = GetPostString("tax");
- taxstr = taxstr.Replace(" ", "");
- bill_entity.tax = taxstr;
- bill_entity.bank = GetPostString("bank");
- string bankacstr = GetPostString("bankac");
- bankacstr = bankacstr.Replace(" ", "");
- bill_entity.bankac = bankacstr;
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
- if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
- {
- billCount += 1;
- }
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applyMemo");
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.userId = CurrentUser.UserID;
- errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
- bill_entity.Create();
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
- returnErrorMsg("创建发票出错!");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
- returnSuccessMsg("发票申请成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_neworder()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- CeErpTrade entity = new CeErpTrade();
- string plat_form = GetPostString("platform");
- string preStr = "N_";
- if (plat_form == "拼多多")
- {
- preStr = "P_";
- }
- else if (plat_form == "阿里巴巴")
- {
- preStr = "A_";
- }
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = GetPostString("seller_nick");
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- if (shopId != 34 && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- entitycell.tid = entity.tid;
- entitycell.ShopId = shopId;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- entitycell.OrderState = 0;
- entitycell.pay_time = entity.pay_time;
- entitycell.IsOffLineOrder = 1;
- entitycell.Create();
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
- return;
- }
- }
- public void ins_erp_neworder2()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- //string plat_form = GetPostString("platform");
- string preStr = "X_";
- string memo = GetPostString("memo");
- string productId = GetPostString("productId");
- string primg = GetPostString("proofimg");
- string sellerNick = GetPostString("seller_nick");
- string addFrom = GetPostString("addfrom");
- if (addFrom == "1")
- {
- preStr = "N_";
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- else
- {
- returnErrorMsg("找不到对应店铺");
- return;
- }
- if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
- {
- returnErrorMsg("必须上传付款凭证");
- return;
- }
- CeErpTrade entity = new CeErpTrade();
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = sellerNick;
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- entity.seller_memo = memo;
- entity.orderFrom = 20;
- entity.orderType = 15;
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- string toWhere = GetPostString("towhere");
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- //唯一标识
- entitycell.OrderSn = entity.tid;
- //string orderSn = dataHelper.getSaleOrderSn();
- //if (orderSn != "")
- // {
- // entitycell.OrderSn = orderSn;
- // }
- entitycell.tid = entity.tid;
- //if (preStr == "X_")
- //{
- entitycell.IsOffLineOrder = 1;
- //}
- entitycell.CustomerUserId = CurrentUser.UserID;
- entitycell.PayProofImg = primg;
- entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
- entitycell.ProductId = Convert.ToInt32(productId);
- entitycell.ShopId = shopId;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
- {
- entitycell.IsXianHuo = 1;
- }
- entitycell.pay_time = entity.pay_time;
- if (toWhere == "1")
- {
- entitycell.OrderState = 2;
- }
- else
- {
- entitycell.OrderState = 6;
- entitycell.FinishPlaceTime = entitycell.pay_time;
- }
- if (shopId == 94)
- {
- entitycell.OrderState = 4;
- entitycell.WaitDesignTime = entitycell.pay_time;
- entitycell.StartDesignTime = entitycell.pay_time;
- entitycell.DesignUserId = 218;
- }
- if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
- {
- entitycell.OrderState = -1;//修改12-5
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = entity.tid;
- ceWithdraw.providerid = "-1";
- ceWithdraw.status = -1;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.userid = 1337;
- ceWithdraw.Create();
- }
- entitycell.Create();
- CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
- if (shopId == 34 && entity.buyer_nick == "现货手提袋")
- {
- addPlaceRegist(entitycell, CurrentUser.UserID);
- }
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
- return;
- }
- }
- public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = tradecell.pay_time;
- entity.AddUserId = userid;
- entity.FileName = tradecell.seller_memo;
- entity.Supplier = 24;
- entity.CreateTime = DateTime.Now;
- entity.Did = tradecell.ctid;
- entity.tid = tradecell.tid;
- entity.splitTag = tradecell.SplitTag;
- entity.CurState = "未完成";
- entity.Create();
- }
- public void get_erp_offlinelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //if (PKey != "admin")
- //{
- // string usershop = CurrentUser.User.pemShop;
- // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- //}
- //if (ex_psize > 0)
- //{
- dStruct.Order = "pay_time desc";
- //}
- //else
- // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
- lw.Add(string.Format("IsOffLineOrder=1"));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_returncashrecord()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("tid like '%{0}%'", tid));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
- //writeGridDataTableJson(dStruct.TotalCount, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- return;
- }
- returnErrorMsg("id数据错误!");
- }
- public void ins_erp_returncashrecord()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string tid = GetPostString("tid");
- string retype = GetPostString("type");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnErrorMsg("相同返现类型记录已存在");
- return;
- }
- CeErpReturnCash entity = new CeErpReturnCash();
- entity.tid = tid;
- entity.seller_nick = GetPostString("seller_nick");
- string pment = GetPostString("payment");
- if (pment.Length > 0)
- {
- entity.payment = Convert.ToDouble(pment);
- }
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.cashstate = 0;
- entity.rtype = retype;
- string rPrice = GetPostString("returnprice");
- if (rPrice.Length > 0)
- {
- entity.returnprice = Convert.ToDouble(rPrice);
- }
- entity.created = DateTime.Now;
- entity.con = GetPostString("con");
- entity.img = GetPostString("img");
- entity.applyuserid = CurrentUser.UserID;
- entity.Create();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void set_erp_predelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
- //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
- //{
- // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
- // return;
- //}
- entity.IsPreDelivery = 1;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- returnSuccessMsg("预发货成功!");
- return;
- //string shop = GetPostString("seller_nick");
- ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
- //string comName = GetPostString("comName");
- //string comCode = GetPostString("comCode");
- //string outSid = GetPostString("outSid");//运单号
- //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
- //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
- ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
- //string apires = "";
- //if (deliveryType == "虚拟发货")
- //{
- // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
- //}
- //else
- //{
- // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
- //}
- ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
- ////{
- //if (apires.IndexOf("发货成功") != -1)
- //{
- // if (deliveryType != "虚拟发货")
- // {
- // //还要插入快递信息到 快递信息表
- // CeErpExpressInfo exinfo = new CeErpExpressInfo();
- // exinfo.tid = eid;
- // exinfo.out_sid = outSid;
- // exinfo.company_code = comCode;
- // exinfo.company_name = comName;
- // exinfo.delivery_memo = deliveryMemo;
- // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- // exinfo.deliveryType = deliveryType;
- // exinfo.Create();
- // }
- // returnSuccessMsg("发货成功!");
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- //}
- //else
- //{
- // returnErrorMsg("淘宝发货失败!!");
- //}
- //return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_unusuallist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag > 0"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_unusualtonomal()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.UnusualTag = -1;
- entity.Update();
- returnSuccessMsg("忽略成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_unusualreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.UnusualCon = GetPostString("con");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- //查货是否超时
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- }
- if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
- {
- ceErpTradeCellExtend.CheckOut += 1;
- }
- ceErpTradeCellExtend.CheckTime = DateTime.Now;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sampleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] eArr = eid.Split(',');
- if (eArr.Length > 1)
- {
- List<string> eLst = new List<string>();
- for (int i = 0; i < eArr.Length; i++)
- {
- eLst.Add("'" + eArr[i] + "'");
- }
- eid = string.Join(",", eLst.ToArray());
- }
- else
- {
- eid = "'" + eid + "'";
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
- if (dt.Rows.Count > 0)
- {
- string errmsg = "";
- foreach (DataRow dr in dt.Rows)
- {
- StringBuilder sqlsb = new StringBuilder();
- sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
- sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
- string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
- if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
- {
- continue;
- }
- else
- {
- string emsg = commonHelper.KeepChinese(apires);
- errmsg += emsg;
- }
- }
- if (errmsg.Length > 0)
- {
- returnErrorMsg(errmsg);
- return;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transcustomer()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("CustomerUserId");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //string[] mlist = entity.seller_memo.Split('-');
- //string sql = "select * from view_erpuser where id=" + userid;
- //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //if (dt != null && dt.Rows.Count > 0)
- //{
- // string nmemo = "";
- // for(int i = 0; i < mlist.Length - 1; i++)
- // {
- // nmemo += mlist[i];
- // nmemo += "-";
- // }
- // nmemo+= dt.Rows[0]["Tb"].ToString();
- // entity.seller_memo = nmemo;
- //}
- entity.CustomerUserId = userid;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transdesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctidList = eids.Split(',');
- int userid = GetPostInt("DesignUserId");
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- entitys = CeErpDesignerBill.GetByTid(ctid);
- if (entity != null)
- {
- if (entity.OrderState > 4)
- {
- continue;
- }
- //存在退款不能流转
- if (entity.IsRefund > 0)
- {
- continue;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- }
- }
- public void upd_erp_distributedesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("DesignUserId");
- string[] idlist = eid.Split(',');
- if (idlist.Length <= 0)
- {
- returnErrorMsg("订单不能为空");
- return;
- }
- foreach (string ctid in idlist)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- else continue;
- if (entity != null)
- {
- if (userid == 2125 || userid == 3542)
- { }
- if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
- {
- returnErrorMsg("金额错误的订单无法指派");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成无法指派");
- return;
- }
- if (entity.OrderState == -1)
- {
- returnErrorMsg("审核中的订单无法指派");
- return;
- }
- if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
- {
- returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
- return;
- }
- if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
- {
- returnErrorMsg("指派设计共创无法再次指派!");
- return;
- }
- entity.OrderState = 3;
- CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
- if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- if (userid == 2125 && entity.seller_memo != "")
- {
- apiDesign.API_GetPrintData_CreateOrder(entity);
- }
- if (userid == 3542 && entity.seller_memo != "")
- {
- designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
- LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
- if (response.msg != "设计共创:成功")
- {
- returnErrorMsg(response.msg);
- return;
- }
- entity.DispatchSort = 2;
- entity.OrderState = 3;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.Update();
- string name = commonHelper.getUserNameById(userid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_myorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string urgency = GetPostString("urgency");
- if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
- string after = GetPostString("after");
- if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myreturnorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
- {
- lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
- }
- else
- {
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- }
- lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myorderlist_pregather()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- int userId = CurrentUser.UserID; //客服id
- string orderWhere = "";
- List<string> lw = new List<string>();
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("CustomerUserId={0}", userId));
- lw.Add(string.Format("OrderState<9"));
- orderWhere = string.Join(" and ", lw.ToArray());
- string orderWhere2 = "";
- List<string> lw2 = new List<string>();
- string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw2.Length > 0) lw2.Add(dw2);
- lw2.Add(string.Format("CustomerUserId={0}", userId));
- orderWhere2 = string.Join(" and ", lw2.ToArray());
- string sql = string.Format("select *" +
- "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
- "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 " +
- "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 " +
- "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");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //writeGridDataTableJson(dt.Rows.Count, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void upd_erp_publishorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 0; //发布后,变为待抢单
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
- returnSuccessMsg("发布成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_my_tiporder()
- {
- StringBuilder sql = new StringBuilder();
- int userId = 0;
- if (CurrentUser != null) userId = CurrentUser.UserID;
- string posCode = CurrentUser.UserPost.Post.Code;
- string isTipedAfterSaleVerify = GetPostString("af");
- DataTable dt = new DataTable();
- if (posCode != "Supplier")
- {
- if (posCode == "CustomerService" || posCode == "Director")
- {
- sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
- }
- else
- {
- string teamIds = CurrentUser.User.TeamIds;
- if (teamIds == "")
- {
- teamIds = "0";
- }
- 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);
- }
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (dt.Rows.Count <= 0)
- {
- string key = "aftersale_order_" + userId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 4;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (posCode == "Supplier")
- {
- string ids = CurrentUser.User.pemVend;
- if (ids != null && ids.Length > 0)
- {
- string[] ids_list = ids.Split(',');
- foreach (var item in ids_list)
- {
- string key = "return_order_" + item;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 1;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- 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);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void reset_erp_tiporder()
- {
- string ids = GetPostString("ids");
- string[] ctidList = ids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
- if (enty != null)
- {
- enty.IsReadTag = 0;
- enty.Update();
- }
- }
- returnSuccessMsg("成功!");
- return;
- }
- public void get_erp_designlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- lw.Add(string.Format("OrderState<6"));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string designTime = GetPostString("designtime");
- if (designTime.Length > 0)
- {
- lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
- }
- string usershop = CurrentUser.User.pemShop;
- if (usershop.Length > 0)
- {
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if (myOrgCode.IndexOf("Designer") != -1)
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- else
- {
- string orgId = GetPostString("designerhd");
- if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
- }
- if (tid.Length > 0 || buyernick.Length > 0)
- {
- lw.Add(string.Format("OrderState >= 3"));
- }
- else
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_mydesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- //lw.Add(string.Format("OrderState<6"));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string olddownload = GetPostString("olddown");
- if (olddownload == "1")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
- }
- else if (olddownload == "2")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
- }
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
- lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
- else
- lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- if (tid.Length <= 0)
- {
- lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
- }
- lw.Add(string.Format("IsReturn!=3"));
- dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string teamids = CurrentUser.User.TeamIds.ToString();
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_startdesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState != 3)
- {
- returnErrorMsg("请刷新,订单已经设计了");
- return;
- }
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- //entity.MakeSupplier = suname;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designselfmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string con = GetPostString("con");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.DesignSelfMemo = con;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designprice()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int uid = CurrentUser.UserID;
- string userName = CurrentUser.UserName;
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entitys == null)
- {
- entitys = new CeErpDesignerBill();
- }
- if (entity != null)
- {
- entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
- //entity.Number = Convert.ToInt32(GetPostString("number"));
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- string suname = "";
- if (entity.SupplierId == 0)
- {
- int sid = commonHelper.autoDistributeToSupplier(entity);
- entity.SupplierId = sid;
- suname = commonHelper.getSupplierNameById(entity.SupplierId);
- }
- entity.Update();
- CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
- if (ceErpUserPost != null)
- {
- CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
- if (ceErpPost != null)
- {
- if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
- {
- entitys.tid = entity.ctid;
- entitys.oid = entity.tid;
- entitys.uid = uid;
- entitys.userName = userName;
- entitys.designerType = 1;
- entitys.designerTypeText = "内部设计师";
- entitys.price = Convert.ToDouble(GetPostString("price"));
- entitys.designNum = GetPostInt("designNum");
- entitys.modifyNum = GetPostInt("modifyNum");
- entitys.designSize = GetPostString("designSize");
- entitys.modifySize = GetPostString("modifySize");
- if (CeErpDesignerBill.GetByTid("ctid") == null)
- {
- entitys.create_time = DateTime.Now;
- entitys.create_u_id = uid;
- entitys.create_u_name = userName;
- entitys.Save();
- }
- else
- {
- entitys.update_time = DateTime.Now;
- entitys.update_u_id = uid;
- entitys.update_u_name = userName;
- entitys.Update();
- }
- }
- }
- }
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
- if (suname != "")
- {
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upload_erp_filecomplete()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 5; //设计完成
- entity.Update();
- returnSuccessMsg(eid + "上传成功,设计完成!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_designovertimelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "WaitDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //设计管理 获取抢单大厅列表
- public void get_erp_grabinglist()
- {
- int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
- DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
- bool oldOrder = false;
- if (org != null)
- {
- oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
- }
- string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
- sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
- //先处理订单数据
- if (dt.Rows.Count > 0)
- {
- Dictionary<string, int> design = null;
- int count = 0;
- foreach (DataRow row in dt.Rows)
- {
- if (map.ContainsKey(row["ShopId"].ToString()))
- {
- map.TryGetValue(row["ShopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, int>();
- }
- if (design.ContainsKey(row["ProductId"].ToString()))
- {
- design.TryGetValue(row["ProductId"].ToString(), out count);
- }
- count++;
- design[row["ProductId"].ToString()] = count;
- map[row["ShopId"].ToString()] = design;
- }
- }
- sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
- DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //把店铺排序和技能排序分类
- Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
- Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
- if (design_dt.Rows.Count > 0)
- {
- Dictionary<string, string> design = null;
- List<string> shopIds = null;
- foreach (DataRow row in design_dt.Rows)
- {
- if ("0".Equals(row["designId"].ToString()))
- {
- if (shop_orders.ContainsKey(row["orders"].ToString()))
- {
- shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
- }
- else
- {
- shopIds = new List<string>();
- }
- shopIds.Add(row["shopId"].ToString());
- shop_orders[row["orders"].ToString()] = shopIds;
- }
- else
- {
- if (design_orders.ContainsKey(row["shopId"].ToString()))
- {
- design_orders.TryGetValue(row["shopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, string>();
- }
- design[row["orders"].ToString()] = row["designId"].ToString();
- design_orders[row["shopId"].ToString()] = design;
- }
- }
- //处理成key value后根据key排序
- shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- foreach (List<string> val in shop_orders.Values)
- {
- if (val != null)
- {
- foreach (string key in val)
- {
- if (design_orders.ContainsKey(key.ToString()))
- {
- design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- }
- }
- }
- }
- }
- //校验哪个优先级有订单
- Dictionary<string, string> designIds = new Dictionary<string, string>();
- foreach (string key in shop_orders.Keys)
- {
- List<string> ids = null;
- shop_orders.TryGetValue(key, out ids);
- //id为shopid
- foreach (string id in ids)
- {
- Dictionary<string, int> list = null;
- Dictionary<string, string> desing = null;
- map.TryGetValue(id, out list);
- design_orders.TryGetValue(id, out desing);
- if (list != null && desing != null)
- {
- foreach (var item in desing)
- {
- int count = 0;
- if (list.ContainsKey(item.Value))
- {
- list.TryGetValue(item.Value, out count);
- if (count > 0)
- {
- designIds[id] = item.Value;
- break;
- }
- }
- }
- }
- }
- if (designIds.Count > 0)
- {
- break;
- }
- }
- DataTable table = new DataTable();
- table.Columns.Add("tid", typeof(string));
- table.Columns.Add("ctid", typeof(string));
- table.Columns.Add("seller_nick", typeof(string));
- table.Columns.Add("productName", typeof(string));
- table.Columns.Add("pay_time", typeof(string));
- table.Columns.Add("seller_memo", typeof(string));
- if (designIds.Count > 0)
- {
- string shopId = "";
- string productId = "";
- foreach (var designInfo in designIds)
- {
- shopId = designInfo.Key;
- productId = designInfo.Value;
- CeErpShop ceErpShop = CeErpShop.Get(shopId);
- CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
- {
- DataRow data = table.NewRow();
- data["ctid"] = row["ctid"].ToString();
- data["tid"] = row["tid"].ToString();
- data["seller_nick"] = ceErpShop.ShopName;
- data["pay_time"] = row["pay_time"].ToString();
- data["seller_memo"] = row["seller_memo"].ToString();
- data["productName"] = ceErpProduct.PType;
- table.Rows.Add(data);
- }
- }
- }
- }
- }
- writeGridDataTableJson(table.Rows.Count, table);
- }
- private object rushLockObject = new object();
- public void set_erp_grabingorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- int total = CurrentUser.User.Person.Total;
- int userId = CurrentUser.User.ID;
- int noFinish = CurrentUser.User.Person.NoFinish;
- int finalization = CurrentUser.User.Person.Finalization;
- string eids = GetPostString("ctid");
- string key = "RushKey_" + userId;
- int count = 0;
- if (erpRedis.RedisHelper.KeyExists(key))
- {
- string redisCount = erpRedis.RedisHelper.StringGet(key);
- if (redisCount != null)
- {
- count = Convert.ToInt32(redisCount);
- }
- }
- if (count >= total)
- {
- returnErrorMsg("半小时内已经抢" + total + "单");
- return;
- }
- string[] ctidlist = eids.Split(',');
- if (count + ctidlist.Length > total)
- {
- returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
- return;
- }
- int itag = 0;
- lock (rushLockObject)
- {
- if (ctidlist.Length > 0)
- {
- string[] dtList = new string[ctidlist.Length];
- for (int i = 0; i < ctidlist.Length; i++)
- {
- dtList[i] = "'" + ctidlist[i] + "'";
- }
- 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"));
- DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- if (dt_user.Rows.Count > 0)
- {
- int doing = 0;//未定稿
- int finish = 0;//已完成
- foreach (DataRow dr in dt_user.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
- {
- doing++;
- }
- else
- {
- finish++;
- }
- }
- if (doing >= noFinish)
- {
- returnErrorMsg(doing + "未定稿数量,无法继续抢单");
- return;
- }
- if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
- {
- returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
- return;
- }
- }
- //校验选择单子状态
- string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- List<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) != 2)
- {
- list.Add(dr["ctid"].ToString());
- }
- }
- if (list.Count > 0)
- {
- returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
- return;
- }
- }
- foreach (string ctid in ctidlist)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.DesignUserId = CurrentUser.UserID;
- entity.WaitDesignTime = DateTime.Now;
- entity.StartDesignTime = DateTime.Now;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
- itag++;
- }
- }
- }
- }
- count += ctidlist.Length;
- erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
- if (itag == 0)
- returnErrorMsg("没有找到相关订单");
- else
- returnSuccessMsg("抢单成功!");
- return;
- }
- }
- public void get_erp_waitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string address = GetPostString("address");
- 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));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string pagesize = GetPostString("pagesize");
- if (pagesize != null)
- {
- dStruct.PageSize = 200;
- }
- DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_supplierwaitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsVerifyToSupplier=1"));
- if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- string supplier = GetPostString("supplier");
- if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
- {
- lw.Add(string.Format("SupplierName = '{0}'", supplier));
- }
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_verifytosupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- CeErpTradeCell entity = null;
- string[] eidsList = eids.Split(',');
- if (eidsList.Length <= 0)
- {
- returnErrorMsg("订单号不能空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctidstr in eidsList)
- {
- tLst.Add("'" + ctidstr + "'");
- CeErpDataSendOrderInfo.createObject(ctidstr);
- }
- string needtids = string.Join(",", tLst.ToArray());
- StringBuilder sql = new StringBuilder();
- //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
- sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
- sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("操作成功!");
- return;
- /**foreach (string ctidstr in eidsList)
- {
- entity = CeErpTradeCell.GetByCtid(ctidstr);
- if (entity != null)
- {
- if (entity.SupplierId == 0)
- {
- continue;
- }
- entity.IsVerifyToSupplier = true;
- if (entity.IsReturn == 1) //1是供应商打回
- {
- entity.IsReturn = 0;
- }
- entity.FinishPlaceTime = DateTime.Now;
- entity.PlaceUserId = CurrentUser.UserID;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;**/
- }
- }
- public void upd_erp_supplierback()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
- {
- string key = "return_order_" + entity.SupplierId;
- List<string> list = new List<string>();
- if (RedisHelper.HasKey(key))
- {
- object data = RedisHelper.StringGet(key);
- list = Convert.ToString(data).Split(',').ToList();
- }
- list.Add(eid);
- RedisHelper.StringSet(key, string.Join(",", list));
- }
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_toaftersaleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.isAfterSaleOrder != 1)
- {
- returnErrorMsg("带S的售后单才能打回给售后");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成了不能打回给售后");
- return;
- }
- entity.OrderState = 0;
- entity.IsReturn = 3;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_aftersaletodesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.IsReturn = 0;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void assign_erp_supplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- int sid = GetPostInt("SupplierName");
- string fromTag = GetPostString("tag");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- string errMsg = "";
- string suname = commonHelper.getSupplierNameById(sid);
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (fromTag == "waitingorder" && entity.OrderState >= 6)
- {
- errMsg += (ctid + "指派失败!!!");
- continue;
- }
- entity.SupplierId = sid;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
- if (entity.OrderState >= 6)
- {
- //if (entity.MakeSupplier.IndexOf(",") != -1)
- //{
- // string msl = entity.MakeSupplier;
- // string[] mslist = msl.Split(',');
- // 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);
- // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- //else
- //{
- StringBuilder sql = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- }
- }
- else
- {
- continue;
- }
- }
- if (errMsg.Length > 0)
- {
- returnErrorMsg(errMsg);
- return;
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void assign_erp_makesupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string sname = GetPostString("SupplierName");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.MakeSupplier = sname;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
- tLst.Add("'" + ctid + "'");
- }
- else
- {
- continue;
- }
- }
- string ctids = string.Join(",", tLst.ToArray());
- StringBuilder sql2 = new StringBuilder();
- sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void ins_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- bool isPlace = false;
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- if (entity.OrderState == 6)
- {
- isPlace = true;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- int toType = GetPostInt("totype");
- string fromType = "3";
- if (entity.OrderState < 5)
- {
- fromType = "3";
- }
- else
- {
- fromType = "4";
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- string clearman = GetPostString("clearman");
- if (!string.IsNullOrEmpty(clearman))
- {
- entity.DesignUserId = 0;
- }
- }
- else
- {
- entity.OrderState = 3;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- if (entity.IsXianHuo == 1)
- {
- entity.OrderState = 5;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 3)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isPlace)
- {
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth != null && dth.Rows.Count > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cyt_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "Pwd", "lt666888" },
- { "LTOrderId",eid }
- };
- string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg != "取消成功")
- {
- returnErrorMsg(msg);
- return;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- int toType = GetPostInt("totype");
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- }
- else
- {
- entity.OrderState = 4;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_xianhuoreturntag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctids = eids.Split(',');
- foreach (string ctid in ctids)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsReturn = 0;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("type != 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pddderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jdderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_demoorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("IsSample={0}", 3));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_erp_checkmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.CheckMemo = GetPostString("CheckMemo");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_returnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn>0"));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("IsReturn!=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_today_sumreturn()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string bdate1 = GetPostString("returnTimeS");
- string bdate2 = GetPostString("returnTimeE");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- lw.Add(string.Format("IsReturn=0"));
- lw.Add(string.Format("IsXianHuo=0"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "";
- if (dw_back.Length > 0)
- {
- sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
- }
- else
- {
- 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 + "'";
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- decimal total = 0, today_finish = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["total"]);
- }
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
- {
- today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
- }
- var res = new
- {
- data = total,
- data1 = today_finish,
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_allreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("ReturnTime != ''"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_aftersalereturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- dStruct.Order = "ReturnTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_xianhuoreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState=6 "));
- lw.Add(string.Format("IsXianHuo=1 "));
- lw.Add(string.Format("IsReturn>0 "));
- lw.Add(string.Format("IsReturn!=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_orderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState >= 7)
- {
- returnErrorMsg("此单已发货,无需重复发货");
- return;
- }
- if (entity.OrderState != 6)
- {
- returnErrorMsg("此单状态为非【下单完成】,无法发货");
- return;
- }
- string shop = GetPostString("seller_nick");
- //string sessionkey = taobaoHelper.ShopKeyDics[shop];
- string comName = GetPostString("comName");
- string comCode = GetPostString("comCode");
- string outSid = GetPostString("outSid");
- string deliveryType = GetPostString("deliveryType");
- string deliveryMemo = GetPostString("deliveryMemo");
- outSid = outSid.Trim();
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- if (mainEn == null)
- {
- returnErrorMsg("找不到原始订单记录");
- return;
- }
- bool isInitOrderDeliv = false;
- if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
- {
- isInitOrderDeliv = true;
- }
- string apires = "";
- string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
- 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)
- {
- apires = "发货成功true";
- }
- else
- {
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- }
- if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
- {
- entity.OrderState = 7;//发货后订单已发货
- entity.OutSid = outSid;
- entity.MemoOpt = 0;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, comName, outSid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = eid;
- exinfo.out_sid = outSid;
- exinfo.company_code = comCode;
- exinfo.company_name = comName;
- exinfo.delivery_memo = deliveryMemo;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = deliveryType;
- exinfo.Create();
- returnSuccessMsg("发货操作成功!");
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(apires);
- returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
- XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
- }
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_multidelivery()
- {
- string eids = GetPostString("tids");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("发货不能为空");
- return;
- }
- foreach (string ctid in eidList)
- {
- if (ctid.Length <= 0) continue;
- CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
- if (expInfo != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
- {
- expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
- expInfo.state = "异常";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- continue;
- }
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
- {
- expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
- expInfo.state = "异常";
- expInfo.Update();
- continue;
- }
- //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
- bool isInitOrderDeliv = false;
- if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
- {
- isInitOrderDeliv = true;
- expInfo.isMultiDelivery = 1;
- }
- if (ctid.IndexOf("N") != -1)
- {
- StringBuilder sqlbucha = new StringBuilder();
- sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
- CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- commonHelper.UpdateRelationOrder(ctid);
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- }
- else
- {
- string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
- string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
- {
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- commonHelper.UpdateRelationOrder(ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- }
- else
- {
- expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
- expInfo.state = "异常";
- expInfo.Update();
- }
- }
- }
- }
- }
- returnSuccessMsg("操作完成");
- }
- public void reset_erp_memoopt()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stropt = "";
- if (entity.MemoOpt == 1)
- {
- stropt = "“改稿”";
- }
- else if (entity.MemoOpt == 2)
- {
- stropt = "“定稿”";
- }
- else if (entity.MemoOpt == 3)
- {
- stropt = "“完成查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
- entity.MemoOpt = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_deliveryunusual()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6"));
- lw.Add(string.Format("UnusualTag = 5"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_deliveryedlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pdddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_allplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- }
- else
- {
- if (ex_psize <= 0) //非导出的时候 显示3个月数据
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("isDianziOrder = 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_financeallplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("isDianziOrder = 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_expresslist()
- {
- int listtype = GetInt("ltype");
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string outsid = GetPostString("out_sid");
- if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
- string importer = GetPostString("ImportUserName");
- if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
- string file = GetPostString("import_file");
- if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
- string printman = GetPostString("printman");
- if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string fdate1 = GetPostString("finishdate1");
- string fdate2 = GetPostString("finishdate2");
- string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
- if (fdw.Length > 0) lw.Add(fdw);
- if (listtype == 1)
- {
- lw.Add(string.Format("importUserId !=0"));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- if (dStruct.PageSize != 100000)
- {
- dStruct.Order = "isMultiDelivery asc, import_time desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_buchaorderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSample != 2)
- {
- returnErrorMsg("补差价单才能标记为已发货");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
- entity.OrderState = 7;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_stdtemplates()
- {
- //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
- //string res = taobaoHelper.test();
- string res = apiHelper.API_PrintTemplate();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
- {
- int sidx = res.IndexOf("error_code");
- int eidx = res.IndexOf("success");
- string msg = res.Substring(sidx, eidx - sidx);
- returnErrorMsg(msg);
- return;
- }
- if (res.Length <= 0)
- {
- returnErrorMsg("模板数据为空!");
- return;
- }
- ReturnSuccess(res);
- }
- public void cancel_print_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string res = "";
- string code = entity.LastBillWaybillCode;
- if (code == "")
- {
- code = entity.OutSid;
- }
- res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
- XLog.SaveLog(0, "取消面单" + res);
- }
- }
- }
- public void set_erp_printwaybill()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
- string cpName = GetPostString("cpname");
- string isTogether = GetPostString("together");
- //var res_obj = new
- //{
- // restype = 1,
- // 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\"}"
- //};
- //string ro_json = JsonConvert.SerializeObject(res_obj);
- //ReturnSuccess(ro_json);
- //return;
- bool isUseLastWayBillCode = false;
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
- {
- isUseLastWayBillCode = true;
- }
- if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
- {
- returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
- return;
- }
- }
- string res = "";
- Api_waybill_code_response_Obj fullObj = null;
- string pData_str = "";
- string curUseWayBillCode = "";
- if (isUseLastWayBillCode == false)
- {
- res = apiHelper.API_GetWaybill(cpCode, ctid);
- //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
- if (res.IndexOf("failure") != -1)
- {
- //int idx = res.IndexOf("sub_message");
- //int idx2 = res.IndexOf("flag");
- //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objd = new
- {
- restype = 0,
- data = "获取面单失败" + errMsgNeed
- };
- string ro_jsond = JsonConvert.SerializeObject(res_objd);
- returnSuccess(ro_jsond);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- }
- //returnErrorMsg("获取面单失败,"+emsg);
- XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
- return;
- }
- else if (res.IndexOf("errorMsg") != -1)
- {
- //int idx = res.IndexOf("errorMsg");
- //int idx2 = res.IndexOf("}]}");
- //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objf = new
- {
- restype = 0,
- data = "获取面单失败2" + errMsgNeed
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- }
- returnSuccess(ro_jsonf);
- //returnErrorMsg("获取面单失败," + emsg);
- XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
- return;
- }
- try
- {
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- //res = res.Replace(" ", "");
- fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "生成fullObj" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj发生错误" + ex.Message
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- if (fullObj.response.data.content.Count > 0)
- {
- ContentItem codeObj = fullObj.response.data.content[0];
- if (cpCode.IndexOf("SFFQ-") != -1)
- {
- pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
- curUseWayBillCode = codeObj.waybillCode;
- }
- else
- {
- XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj找不到快递单号waybillCode"
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- }
- else
- {
- //使用上次打印的快递单号
- if (cpCode == "SFFQ-LY")
- {
- pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
- curUseWayBillCode = entity.LastBillWaybillCode;
- }
- if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
- {
- var res_obje = new
- {
- restype = 0,
- data = "获取加密打印数据失败"
- };
- string ro_jsone = JsonConvert.SerializeObject(res_obje);
- returnSuccess(ro_jsone);
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
- //returnErrorMsg("获取加密打印数据失败");
- return;
- }
- //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
- //string msg = "{\"data\":\""+pageUrl+"\"}";
- string btnType = "";
- if (entity != null)
- {
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- //cpcode是 YTO-CAINIAO
- //string comCode = cpCode.Split('-')[0].ToString();
- string apires = "";
- if (ctid.IndexOf("N") != -1)
- {
- apires = "发货成功";
- }
- else
- {
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- }
- //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
- //打单后发货
- if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
- {
- try
- {
- btnType = "待发货";
- entity.OutSid = curUseWayBillCode;
- entity.OrderState = 7;
- entity.IsUrgency = false;
- entity.LastBillCpCode = "";
- entity.LastBillWaybillCode = "";
- entity.FinishDeliveryTime = DateTime.Now;
- entity.IsReturn = 0;
- entity.MemoOpt = 0;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = entity.OutSid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- if (isTogether == "1")
- {
- StringBuilder sqlsb = new StringBuilder();
- sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
- }
- }
- else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
- {
- entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
- if (entity.OrderState == 6)
- {
- entity.OrderState = 7;
- }
- entity.FinishDeliveryTime = DateTime.Now;
- btnType = "已发货";
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = entity.OutSid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- if (isTogether == "1")
- {
- StringBuilder sqlsb = new StringBuilder();
- sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- }
- //不处理
- }
- else
- {
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- string errmsg = commonHelper.KeepChinese(apires);
- var res_objz = new
- {
- restype = 0,
- data = "打单后发货失败"
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
- XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
- return;
- }
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
- var res_obj = new
- {
- restype = 1,
- data = pData_str
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ReturnSuccess(ro_json);
- return;
- }
- }
- private string GetUTF8String(byte[] vs)
- {
- throw new NotImplementedException();
- }
- public void set_erp_printwaybill_cn()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode");
- string cpName = GetPostString("cpname");
- string tempUrl = GetPostString("tempurl");
- //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
- //string res = taobaoHelper.test();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
- {
- int sidx = res.IndexOf("errorMsg");
- int eidx = res.IndexOf("}");
- string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
- var res_objzxx = new
- {
- restype = 0,
- data = msg
- };
- string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
- returnSuccess(ro_jsonzxx);
- //returnErrorMsg(msg);
- return;
- }
- int idx = res.IndexOf("waybillCode");
- int idx2 = res.IndexOf("printData");
- string outsid = res.Substring(idx + 14, idx2 - idx - 17);
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string osid = entity.OutSid;
- entity.OutSid = osid + "," + outsid;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.OrderState = 7;
- entity.IsReturn = 0;
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = outsid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
- var res_objz = new
- {
- restype = 1,
- data = res
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //ReturnSuccess(res);
- }
- }
- ////打单,打印面单 获取面单号
- //public void set_erp_printwaybill()
- //{
- // if (UrlPostParmsCheck("ctid"))
- // {
- // string ctid = GetPostString("ctid");
- // string cpCode = GetPostString("cpcode");
- // string tempUrl = GetPostString("tempurl");
- // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- // //string res = taobaoHelper.test();
- // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- // if (res.IndexOf("error_response") != -1)
- // {
- // int sidx = res.IndexOf("sub_msg");
- // int eidx = res.IndexOf("request_id");
- // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
- // returnErrorMsg(msg);
- // return;
- // }
- // int idx = res.IndexOf("waybill_code");
- // int idx2 = res.IndexOf("}]}");
- // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
- // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
- // ReturnSuccess(res);
- // }
- //}
- public void cancel_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //有过处理的售后,取消也不能删除 售 字,保留
- if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
- {
- entity.AfterSaleState = 4;
- }
- else
- entity.AfterSaleState = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (st == 3)
- {
- if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
- }
- else
- {
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string posCode = CurrentUser.UserPost.Post.Code;
- //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
- //{
- // string vstate = GetPostString("vstate");
- // if (vstate.Length > 0)
- // {
- // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- // }
- // if (posCode == "Supplier")
- // {
- // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- // }
- // else
- // {
- // lw.Add(string.Format("AfterSaleState = {0}", st));
- // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
- // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
- // {
- // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
- // {
- // int orgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "Director")
- // {
- // string shopid = CurrentUser.User.pemShop;
- // lw.Add(string.Format("shopId in ({0})", shopid));
- // }
- // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- // //{
- // // int org_id = CurrentUser.UserPost.OrgID;
- // // lw.Add(string.Format("OrgID={0}", org_id));
- // //}
- // dStruct.Order = "IsArbitrate desc, createdTime desc";
- // }
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- if (st == 5)
- {
- if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
- {
- if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
- {
- int mrOrgid = CurrentUser.UserPost.OrgID;
- lw.Add(string.Format("DesOrgID={0}", mrOrgid));
- lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
- }
- //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
- //{
- // int mrOrgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
- //}
- else
- {
- string userIdStr = "";
- if (posCode == "CustomerService")
- {
- userIdStr = CurrentUser.UserID + "_k";
- }
- else if (posCode == "Designer" || posCode == "wxDesigner")
- {
- userIdStr = CurrentUser.UserID + "_s";
- }
- else if (posCode == "Place")
- {
- userIdStr = CurrentUser.UserID + "_x";
- }
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
- }
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dwplace.Length > 0) lw.Add(dwplace);
- string supState = GetPostString("supState");
- if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
- string searchType = GetPostString("searchType");
- if (searchType.Length > 0 && "moreBack".Equals(searchType))
- {
- lw.Add(string.Format("BackNum>1"));
- }
- lw.Add(string.Format("AfterSaleState>0"));
- if (ex_psize > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Finance")
- dStruct.Order = "pay_time desc";
- else
- dStruct.Order = "HandleTime desc";
- }
- else
- dStruct.Order = "HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_test", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
- //{
- // lw.Add(string.Format("AfterSaleState=4"));
- // string code = CurrentUser.UserPost.Post.Code;
- // if (code == "CustomerService")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- // }
- // else if (code == "Designer" || code == "DesignerMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- // }
- // else if (code == "Place" || code == "PlaceMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- // }
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //else //处理中的售后,待处理和处理中合并
- //{
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- }
- public void get_erp_disagreeftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string backdate1 = GetPostString("backdate1");
- string backdate2 = GetPostString("backdate2");
- string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
- if (backDate.Length > 0) lw.Add(backDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string aftersakereason = GetPostString("aftersakereason");
- if (aftersakereason.Length > 0)
- {
- if (aftersakereason == "1")
- {
- lw.Add(string.Format("AfterSaleResSupId > 0"));
- }
- if (aftersakereason == "2")
- {
- lw.Add(string.Format("AfterSaleResSupId = 0"));
- }
- }
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null "));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (searchType == "moreBack")
- {
- lw.Add(string.Format("backNum > 1"));
- }
- lw.Add(string.Format("(AfterSaleState=5)"));
- dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_handlingaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "documentary")
- {
- lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (afterState.Length <= 0)
- {
- lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- }
- dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
- //public void get_erp_back_handlingaftersalelist()
- //{
- // DataStruct dStruct = GetPostStruct();
- // List<string> lw = new List<string>();
- // string tid = GetPostString("ctid");
- // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- // string shopname = GetPostString("shopname");
- // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- // string buyernick = GetPostString("buyer_nick");
- // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- // string sellermemo = GetPostString("seller_memo");
- // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- // string orderState = GetPostString("orderState");
- // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- // string afterState = GetPostString("afterstate");
- // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- // string date1 = GetPostString("date1");
- // string date2 = GetPostString("date2");
- // string dw = GetDateMinuteWhere("pay_time", date1, date2);
- // if (dw.Length > 0) lw.Add(dw);
- // string price1 = GetPostString("price1");
- // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- // string price2 = GetPostString("price2");
- // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- // //lw.Add(string.Format("IsRefund!={0}", 1));
- // string reason = GetPostString("reason");
- // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- // string method = GetPostString("method");
- // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- // string handler = GetPostString("handler");
- // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- // string handledate1 = GetPostString("handledate1");
- // string handledate2 = GetPostString("handledate2");
- // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- // string afterdate1 = GetPostString("afterdate1");
- // string afterdate2 = GetPostString("afterdate2");
- // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- // if (afterDate.Length > 0) lw.Add(afterDate);
- // string supplier = GetPostString("supplier");
- // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- // string responsible = GetPostString("responsibleman");
- // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- // string customer = GetPostString("customer");
- // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- // string design = GetPostString("design");
- // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- // string afterMemoType = GetPostString("aftermemotype");
- // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- public void get_erp_aftersaleverifylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string posCode = CurrentUser.UserPost.Post.Code;
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 1");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else if (posCode == "logistics")
- {
- lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 2");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else
- {
- lw.Add(string.Format("(AfterSaleState = 3)"));
- string reasonState = GetPostString("reasonState");
- lw.Add("type = 0");
- if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
- || posCode == "Summarize" || posCode == "Finance")
- {
- if (reasonState == "2")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "1")
- {
- lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- lw.Add("VerifyState in (0,3)");
- }
- //不加条件,可以看全部
- }
- 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")
- {
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgId = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgId))
- {
- lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
- }
- if (reasonState == "1")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "2")
- {
- lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- }
- }
- else
- {
- lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
- }
- //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- //{
- // int org_id = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("OrgID={0}", org_id));
- //}
- dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- public void get_erp_finishaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 4;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- if ("3".Equals(vstate))
- {
- lw.Add(string.Format("IsTem=1"));
- }
- else
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- }
- lw.Add(string.Format("AfterSaleState=4"));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
- {
- //不加条件,可以看全部
- }
- else if (code == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- else if (code == "logistics")
- {
- lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add("type = 2");
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- 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")
- {
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgIds = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgIds))
- {
- lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
- }
- }
- else
- {
- lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
- }
- dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string responStr = GetPostString("AfterSaleResponsible");
- if (responStr.Length <= 0)
- {
- returnErrorMsg("售后责任人不能为空");
- return;
- }
- bool isDesign = false;
- double designFree = 0.00;
- int responsibleId = 0;
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int isNeedNewOrder = GetPostInt("IsNewOrder");
- string afterMethod = GetPostString("AfterSaleMethod");
- if (isNeedNewOrder == 1)
- {
- CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
- bool ishav = true;
- if (newentity == null)
- {
- newentity = entity.Clone() as CeErpTradeCell;
- ishav = false;
- newentity.ctid = "S_" + entity.ctid;
- newentity.OrderState = 0;
- }
- //唯一标识
- newentity.OrderSn = newentity.ctid;
- /* string orderSn = dataHelper.getSaleOrderSn();
- if (orderSn != "")
- {
- newentity.OrderSn = orderSn;
- }*/
- newentity.AfterSaleState = 0;
- newentity.AfterSaleMethod = afterMethod;
- if (!ishav)
- {
- string memo_str = newentity.seller_memo;
- memo_str = memo_str.Replace("(", "(");
- memo_str = memo_str.Replace(")", ")");
- int sIndex = memo_str.IndexOf("(");
- int eIndex = memo_str.IndexOf(")");
- if (sIndex == -1 || eIndex == -1)
- {
- returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
- return;
- }
- string first = memo_str.Substring(0, sIndex + 1);
- string memoCtid = newentity.OrderSn;
- //if (memoCtid.IndexOf("C") != -1)
- //{
- //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
- //if (CIdx.IndexOf("+") != -1)
- //{
- //CIdx = "C" + CIdx.Split('+')[1];
- //}
- //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
- //}
- string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
- //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
- string newMemo = first + memoCtid + last;
- newentity.seller_memo = newMemo;
- newentity.FinishPlaceTime = null;
- newentity.UnusualTag = 0;
- newentity.UnusualCon = "";
- newentity.UnusualTime = null;
- newentity.AfterSaleMemo = "";
- newentity.AfterSaleMethod = afterMethod;
- newentity.AfterSalePreTime = null;
- newentity.AfterSaleReason = "";
- newentity.AfterSaleResponsible = "";
- newentity.AfterSaleState = 0;
- newentity.AfterSaleTime = null;
- newentity.AfterSaleUserId = 0;
- newentity.AfterSaleSupplierState = 0;
- newentity.LastBillWaybillCode = "";
- newentity.LastBillCpCode = "";
- newentity.FinishAfterSaleTime = null;
- newentity.HandleTime = null;
- newentity.IsSF = 0;
- newentity.IsOldCustomer = 0;
- newentity.UrgencyTime = null;
- newentity.ResponsibleUserId = "";
- newentity.IsVerifyToSupplier = false;
- newentity.payment = 0;
- newentity.CheckMemo = "";
- newentity.OutSid = "";
- newentity.CheckOrderTime = null;
- LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
- }
- newentity.isAfterSaleOrder = 1;
- newentity.IsRefund = 0;
- string receiveMobile = GetPostString("receiver_mobile");
- if (receiveMobile.Length > 0)
- {
- CeErpTrade trade = CeErpTrade.Get(newentity.tid);
- if (trade != null)
- {
- trade.receiver_name = GetPostString("receiver_name");
- trade.receiver_mobile = receiveMobile;
- trade.receiver_state = GetPostString("receiver_state");
- trade.receiver_city = GetPostString("receiver_city");
- trade.receiver_district = GetPostString("receiver_district");
- trade.receiver_address = GetPostString("receiver_address");
- newentity.IsOffLineOrder = 1;
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
- }
- }
- string st = GetPostString("ToState");
- if (st.Length > 0)
- {
- if (newentity.OrderState <= 3)
- {
- newentity.WaitDesignTime = DateTime.Now;
- newentity.StartDesignTime = null;
- newentity.FinishDesignTime = null;
- newentity.OrderState = 3;
- if (st == "下单员")
- {
- newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
- if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
- {
- newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
- }
- }
- else
- {
- newentity.WaitDesignTime = DateTime.Now;
- string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
- DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
- {
- DataRow user = dt1.Rows[0];
- //找主管
- string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
- newentity.DesignUserId = designMr;
- string key = "aftersale_order_" + designMr;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- //账号正常
- if (user["State"].ToString() == "0")
- {
- newentity.DesignUserId = entity.DesignUserId;
- string key = "aftersale_order_" + entity.DesignUserId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- }
- }
- }
- if (entity.IsXianHuo == 1)
- {
- newentity.OrderState = 6;
- entity.FinishPlaceTime = DateTime.Now;
- }
- }
- if (ishav)
- {
- newentity.Update();
- }
- else
- {
- newentity.Create();
- CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
- newCellExtend.ctid = newentity.ctid;
- newCellExtend.orderFrom = 20;
- newCellExtend.orderType = 30;
- if (st == "下单员")
- {
- }
- else
- {
- newCellExtend.ReprintTime = DateTime.Now;
- }
- newCellExtend.Create();
- }
- if (st != "下单员")
- {
- designHelper.API_GetPrintData_CreateOrder(newentity);
- }
- }
- //处理售后扩展
- string resIdStr = GetPostString("ResponsibleUserId");
- string refundFees = GetPostString("refundFrees");
- int IsComplain = GetPostInt("isComplain");
- int IsBad = GetPostInt("isBad");
- string IsOriginal = GetPostString("isOriginal");
- double diffResultPrice = GetPostDouble("diffResultPrice");
- string textResult = GetPostString("textResult");
- string supplierResponsible = GetPostString("supplierResponsible");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
- if (ceErpTradeAfterSaleExtend == null)
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = eid;
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.Create();
- }
- else
- {
- if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
- {
- ceErpTradeAfterSaleExtend.ChangeNum += 1;
- }
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.Update();
- }
- int gysid = GetPostInt("ResponsibleSupId");
- if (entity.AfterSaleUserId == 0)
- {
- entity.AfterSaleUserId = CurrentUser.UserID;
- }
- entity.ResponsibleUserId = resIdStr;
- entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
- entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
- if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
- {
- CeErpTradeResponsible.DelByTid(eid, -1);
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- char[] separator = { ',' };
- string[] sArray = resIdStr.Split(separator);
- string[] refundFreeList = { };
- if (refundFees.Length > 0)
- {
- refundFreeList = refundFees.Split(separator);
- }
- int index = -1;
- foreach (string i in sArray)
- {
- index++;
- if (i.Length <= 0) continue;
- char[] separator2 = { '_' };
- string idstr = i.Split(separator2)[0];
- string idtype = i.Split(separator2)[1];
- double refudFree = 0;
- if (refundFreeList.Length > 0)
- {
- refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
- }
- if (idtype == "s")
- {
- isDesign = true;
- designFree = refudFree;
- }
- int userId = Convert.ToInt32(idstr);
- int type = 0;
- if (idtype == "g")
- {
- type = 1;
- }
- if (idtype == "w")
- {
- type = 2;
- }
- if (idtype == "t")
- {
- type = 3;
- }
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
- if (ceErpTradeResponsible == null)
- {
- ceErpTradeResponsible = new CeErpTradeResponsible();
- ceErpTradeResponsible.tid = eid;
- ceErpTradeResponsible.UserId = userId;
- ceErpTradeResponsible.createdTime = DateTime.Now;
- ceErpTradeResponsible.type = type;
- if (type == 1)
- {
- ceErpTradeResponsible.IsSup = 1;
- }
- if (type == 2)
- {
- ceErpTradeResponsible.IsFlow = 1;
- }
- }
- ceErpTradeResponsible.RefundFee = refudFree;
- ceErpTradeResponsible.VerifyState = 0;
- if (userId == 2125 || idtype == "w")
- {
- ceErpTradeResponsible.VerifyState = 1;
- }
- if (idtype == "w" && userId == 101)
- {
- ceErpTradeResponsible.VerifyState = 0;
- }
- if (ceErpTradeResponsible.ID > 0)
- {
- ceErpTradeResponsible.Update();
- }
- else
- {
- ceErpTradeResponsible.Create();
- }
- if (isDesign)
- {
- responsibleId = ceErpTradeResponsible.ID;
- }
- }
- CeErpTradeResponsible.NumByTid(backNum, eid);
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null)
- {
- ceErpTradeCellExtend.returnVisit = 0;
- ceErpTradeCellExtend.Update();
- }
- if (entity.HandleTime != null)
- {
- if (entity.AfterSaleState == 1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
- }
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
- entity.HandleTime = DateTime.Now;
- }
- bool isCompale = false;
- if (entity.AfterSaleState == 5)
- {
- isCompale = true;
- entity.AfterSaleState = 3;
- }
- entity.AfterSaleSupplierState = 0;
- if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
- }
- string sImgs = GetPostString("img");
- entity.AfterSaleSupplierImg = sImgs;
- entity.supRefundType = GetPostString("supRefundType");
- entity.AfterSaleReason = GetPostString("AfterSaleReason");
- entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
- entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
- entity.AfterSaleMemoType = GetPostString("MemoType");
- if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
- {
- //entity.AfterSaleSupplierState = 2;
- }
- string df = GetPostString("DeductFee");
- if (df == "")
- {
- df = "0";
- }
- string rf = GetPostString("RefundFee");
- if (rf == "")
- {
- rf = "0";
- }
- string pm = GetPostString("AfterSalePayment");
- if (pm == "")
- {
- pm = "0";
- }
- entity.AfterSalePayment = Convert.ToDouble(pm);
- entity.DeductFee = Convert.ToDouble(df);
- entity.RefundFee = Convert.ToDouble(rf);
- entity.Update();
- string toState = GetPostString("ToState");
- string original = GetPostString("isOriginal");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterDesign";
- apiVo.orderRemarks = entity.AfterSaleMethod;
- apiVo.reasonRemarks = entity.AfterSaleReason;
- apiVo.isDesign = isDesign;
- apiVo.designFree = designFree;
- apiVo.responsibleId = responsibleId;
- apiVo.afterFiles = entity.AfterSaleSupplierImg;
- if (toState == "设计师")
- {
- apiVo.isOriginal = Convert.ToBoolean(original);
- }
- designHelper.API_WorkCore(apiVo);//afterDesign
- CeErpMethod methodSql = new CeErpMethod();
- methodSql.con = entity.AfterSaleMethod;
- methodSql.addTime = DateTime.Now;
- methodSql.Create();
- string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
- CeErpMethod.ExecuteNonQuery(delsql);
- if (isCompale)
- {
- aftersale_data_change(entity.ctid);
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_toresponsible()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
- {
- returnErrorMsg("客户售后结果不能为空或不能为待处理!");
- return;
- }
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (entity.AfterSalePreTime == null)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.PreTimeOut += 1;
- }
- }
- entity.AfterSalePreTime = DateTime.Now;
- //预完成给售后主管审核客户问题直接完成
- if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
- }
- }
- ceErpTradeAfterSaleExtend.Update();
- entity.AfterSaleState = 2;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
- aftersale_data_change(entity.ctid);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cancel_erp_aftersaleanddelnew()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleState = 0;
- entity.AfterSaleReason = "";
- entity.AfterSaleMethod = "";
- entity.AfterSaleMemo = "";
- entity.AfterSaleResponsible = "";
- entity.ResponsibleUserId = "";
- entity.DeductFee = 0;
- entity.RefundFee = 0;
- entity.IsArbitrate = 0;
- CeErpTradeResponsible.DelByTid(eid, -1);
- entity.Update();
- CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
- if (after != null)
- {
- if (after.OrderState < 5)
- CeErpTradeCell.DelByCtid("S_" + eid);
- }
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersale_pregather()
- {
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- var mainwhere = string.Join(" and ", lw.ToArray());
- string ro_json = "";
- string type = GetPostString("gather_type");
- if (poscode == "AfterSale")
- {
- //处理中
- if (type == "Handling")
- {
- 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) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
- return;
- }
- if (type == "back")
- {
- //打回
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
- return;
- }
- if (type == "preCompletion")
- {
- //预完成
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
- return;
- }
- if (type == "reBack")
- {
- //被打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
- return;
- }
- }
- if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
- {
- if (type == "puBack")
- {
- //退回
- string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
- return;
- }
- if (type == "reBack")
- {
- //打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
- return;
- }
- if (type == "examEd")
- {
- //已审核
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
- return;
- }
- if (type == "waitExam")
- {
- //待审核
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
- return;
- }
- if (type == "Handling")
- {
- //处理中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt5 = null;
- try
- {
- dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
- }
- catch (Exception e)
- {
- dt5 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt6 = null;
- try
- {
- dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
- }
- catch (Exception e)
- {
- dt6 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
- return;
- }
- }
- returnSuccess(ro_json);
- }
- public void end_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stype = GetPostString("stype");
- string typeStr = stype;
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_finishaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.VerifyState = 1;
- entity.VerifyTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
- string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
- if (dt.Rows.Count <= 0)
- {
- string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- CeErpSukuraData.createInfo(entity.tid, 8);
- if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
- {
- CeErpDesignerBill.Del(entity.tid);
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_arbitrateaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.IsArbitrate = 1;
- entity.ArbitradeMemo = GetPostString("reason");
- entity.VerifyState = 2;
- entity.Update();
- CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
- if (tradecell != null)
- {
- tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
- tradecell.IsArbitrate = 1;
- tradecell.Update();
- }
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_backaftersale()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string eid = GetPostString("tid");
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- CeErpTradeResponsible.NumByTid(backNum + 1, eid);
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleBackReason = GetPostString("backreason");
- entity.AfterSaleState = 1;
- entity.AfterSaleSupplierState = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_supplieraftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- lw.Add(string.Format("AfterSaleState>={0}", 2));
- string supplier = GetPostString("supplier");
- int supid = commonHelper.getSupplierIDByName(supplier);
- if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
- string posCode = CurrentUser.UserPost.Post.Code;
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("AfterSaleResSupId != 0"));
- }
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_supverifyaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- CeErpTradeCell entity = null;
- if (ceErpTradeResponsible != null)
- {
- entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- }
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- ceErpTradeResponsible.VerifyState = 1;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- if (entity.AfterSaleState == 4)
- {
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
- {
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_masteraftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- string textResult = GetPostString("textResult");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- //退回到售后
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_personaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierMemo = afmemo;
- entity.AfterSaleSupplierState = st;
- if (st == 1)
- {
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Create();
- }
- //退回到主管
- //entity.AfterSaleState = 2;
- }
- if (entity.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_supplierrefundtag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.IsSupplierRefund = GetPostInt("tag");
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_refundlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- //string rid = GetPostString("refund_id");
- //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- //string date1 = GetPostString("date1");
- //string date2 = GetPostString("date2");
- //string dateType = GetPostString("dateType");
- //if (dateType.Length > 0)
- //{
- // if (dateType == "1001") dateType = "0";
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
- // if (searchDT.Count == 2)
- // {
- // date1 = searchDT[0].ToString();
- // date2 = searchDT[1].ToString();
- // }
- //}
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string refundState = GetPostString("refundvstate");
- if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
- int st = GetInt("st");
- if (st == 2) //待确认列表中,把state=3已确认的也显示
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState>={0}", st));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "CustomerService")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- }
- else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- }
- else if (code == "Place" || code == "PlaceMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- }
- dStruct.Order = "RefundState asc,created desc";
- }
- else if (st == 10)
- {
- string responsible = GetPostString("responsibleman");
- if (responsible == "空白")
- {
- lw.Add(string.Format("ResponsibleUserName = ''"));
- }
- else if (responsible.Length > 0)
- {
- lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- }
- lw.Add(string.Format("RefundState>=0"));
- dStruct.Order = "created desc";
- }
- else
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState={0}", st));
- dStruct.Order = "created desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_refunddesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string designerorg = GetPostString("designerorg");
- if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
- string refundState = GetPostString("refundState");
- if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if ("Designer".Equals(myOrgCode))//设计师能看到的
- {
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- }
- else if ("SysAdmin".Equals(myOrgCode))
- {
- }
- else
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_refundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- string respMan = GetPostString("ResponsibleName");
- if (respMan.Length <= 0)
- {
- returnErrorMsg("责任人不能为空");
- return;
- }
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- entity.ResponsibleUserName = respMan;
- string userid = GetPostString("ResponsibleUserId");
- if (userid.Length > 0)
- {
- entity.ResponsibleUserId = userid;
- }
- entity.Memo = GetPostString("Memo");
- if (respMan.IndexOf("客服") != -1 ||
- respMan.IndexOf("设计师") != -1 ||
- respMan.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.modified = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void handle_erp_designrefundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = eid;
- }
- ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- public void upd_erp_refundverify()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
- entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
- entity.ResponsibleUserName.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_refundapprove()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- int apr = GetPostInt("approve");
- if (apr == 0)
- {
- entity.RefundState = 1;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
- }
- else if (apr == 1)
- {
- entity.RefundState = 3;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
- }
- entity.modified = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_billlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string title = GetPostString("title");
- if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
- string tid = GetPostString("tid");
- string tids = GetPostString("tids");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- if (tids.Length > 0)
- {
- tids = "'" + tids + "'";
- tids = tids.Replace(",", "','");
- lw.Add(string.Format("tid in ({0})", tids));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
- if (dw1.Length > 0) lw.Add(dw1);
- string billtype = GetPostString("billtype");
- if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
- string billstate = GetPostString("billstate");
- if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- dStruct.Order = "createTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
- //foreach (DataRow dr in dt.Rows)
- //{
- // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
- //}
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void modify_erp_billinfo()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpBill bill_entity = null;
- if (eid != "") bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.tid = GetPostString("tid");
- bill_entity.title = GetPostString("title");
- bill_entity.tax = GetPostString("tax");
- bill_entity.bank = GetPostString("bank");
- bill_entity.bankac = GetPostString("bankac");
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applymemo");
- bill_entity.modifyTime = DateTime.Now;
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
- returnSuccessMsg("发票修改成功!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- }
- public void set_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- int ComId = GetPostInt("ComId");
- //string memo = GetPostString("Memo");
- int allInfo = GetPostInt("allinfo");
- string clert = CurrentUser.User.Name;
- //string detailValue = GetPostString("detailvalue");
- string billId = bill_entity.billOrderId;
- string[] billIdList = billId.Split(',');
- CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
- if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
- {
- billCount += 1;
- }
- if (billId.Length <= 0 || billIdList.Length != billCount)
- {
- bill_entity.billOrderId = "";
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- }
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.state == 5)
- {
- string errMsg = bill_entity.failerror;
- string[] errlist = errMsg.Split('|');
- string[] errTags = new string[errlist.Length];
- for (int itag = 0; itag < errlist.Length; itag++)
- {
- if (errlist[itag].Length <= 0) continue;
- errTags[itag] = errlist[itag].Split('&')[0];
- }
- for (int iii = 0; iii < errTags.Length; iii++)
- {
- if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
- int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
- if (billOrderList.Length >= erroBillOrderTag)
- {
- string needModifyBillId = billOrderList[erroBillOrderTag - 1];
- if (needModifyBillId.Length <= 19)
- {
- needModifyBillId = needModifyBillId + "1";
- }
- else
- {
- int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
- last = last + 1;
- needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
- }
- billOrderList[erroBillOrderTag - 1] = needModifyBillId;
- }
- }
- }
- bool isHaveBillSucces = false;
- string totalRes = "";
- bill_entity.failerror = "";
- for (int ii = 1; ii <= billOrderList.Length; ii++)
- {
- string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
- totalRes += res;
- if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
- {
- isHaveBillSucces = true;
- bill_entity.comId = ComId;
- bill_entity.state = 1;
- bill_entity.executeTime = DateTime.Now;
- bill_entity.executeUser = clert;
- }
- else
- {
- bill_entity.state = 5;
- bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
- }
- }
- bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
- bill_entity.Update();
- if (isHaveBillSucces)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
- if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
- {
- returnErrorMsg("开票失败");
- }
- else
- returnSuccessMsg("发票开具中,稍后刷新查看!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
- returnErrorMsg("操作失败");
- }
- }
- }
- public void get_erp_invoicing_back()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- try
- {
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("开票成功");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
- }
- return;
- }
- else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
- {
- var res_obj = new
- {
- data = "开票中"
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- return;
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void get_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- if (entiy.sendType == "纸质发票")
- {
- if (entiy.img.Length <= 0)
- {
- returnErrorMsg("查无纸质发票");
- return;
- }
- string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
- returnSuccess(returnres);
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- string fpUrl = "";
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- //entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- fpUrl += iObj.list[0].c_url + ",";
- }
- //returnSuccess(res);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- //int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
- //开票失败
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- var returnObj = new
- {
- data = fpUrl
- };
- string ro_json = JsonConvert.SerializeObject(returnObj);
- returnSuccess(ro_json);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void save_erp_billimg()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.img = GetPostString("img");
- bill_entity.executeTime = DateTime.Now;
- bill_entity.state = 2;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
- returnSuccessMsg("保存成功");
- }
- return;
- }
- }
- public void upd_erp_billreturnback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.state = 3;
- bill_entity.returnReason = GetPostString("reason");
- bill_entity.Update();
- returnSuccessMsg("驳回成功!");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
- }
- return;
- }
- }
- public void cancel_erp_bill()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- int detailValue = GetPostInt("detailvalue");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- string cres = "";
- string gres = "";
- if (bill_entity != null)
- {
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
- {
- int iTag = 0;
- bill_entity.fplsh = "";
- bill_entity.fpdm = "";
- bill_entity.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
- if (gres.IndexOf("success") != -1)
- {
- //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
- if (iObj != null)
- {
- bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
- bill_entity.fpdm += iObj.list[0].c_fpdm;
- bill_entity.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- bill_entity.fplsh += ",";
- bill_entity.fpdm += ",";
- bill_entity.fphm += ",";
- }
- bill_entity.Update();
- }
- }
- else
- {
- returnErrorMsg(gres);
- return;
- }
- }
- }
- if (bill_entity.sendType == "纸质发票")
- {
- //作废
- //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
- //if (DateTime.Now.Month == extime.Month)
- //{
- //cres = taobaoHelper.cancel_invoicing(eid);
- //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
- //{
- bill_entity.state = 4;//已作废
- bill_entity.Update();
- returnSuccessMsg("发票已作废");
- return;
- //}
- //else
- //{
- // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
- // bill_entity.Update();
- // returnErrorMsg(cres);
- // return;
- //}
- //}
- //else
- //{
- // returnErrorMsg("纸质发票只能作废本月的发票");
- // return;
- //}
- }
- //红冲
- int redTag = 0;
- string[] fpdmList = bill_entity.fpdm.Split(',');
- string[] fphmList = bill_entity.fphm.Split(',');
- if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
- {
- returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
- return;
- }
- foreach (string billOrderId in billOrderList)
- {
- redTag++;
- string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
- cres += onecres;
- cres += ",";
- if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else if (onecres.IndexOf("重复冲红") != -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(onecres);
- bill_entity.failerror += redTag + "&" + errmsg + "|";
- }
- }
- bill_entity.Update();
- if (cres.IndexOf("失败") != -1)
- returnErrorMsg("红冲失败");
- else
- returnSuccessMsg("发票已红冲");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
- return;
- }
- return;
- }
- }
- public void del_erp_billorder()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill.Del(eid);
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
- }
- returnSuccessMsg("删除成功");
- }
- }
- public void finish_erp_bill()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] list = eids.Split(',');
- foreach (string eid in list)
- {
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- bill.state = 2;
- bill.Update();
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
- }
- }
- returnSuccessMsg("操作成功");
- }
- }
- public void get_erp_returncash()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returntype = GetPostString("returntype");
- if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_staygoods()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
- string wangwang = GetPostString("wangwang");
- if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
- string customerOrg = GetPostString("customerOrg");
- if (customerOrg.Length > 0)
- {
- lw.Add(string.Format("OrgID = {0}", customerOrg));
- }
- dStruct.Order = "creata_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_staygoods()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_type = 1;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_stayGoodsback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_text = GetPostString("reason");
- entity.audit_type = 2;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_all_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- String[] list = GetPostString("ID").Split(',');
- CeErpReturnCash entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("已审核过的订单不需要在审核!");
- return;
- }
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- }
- }
- returnSuccessMsg("审核成功!");
- return;
- }
- }
- public void upd_erp_returncashback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.cashstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnprice()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("审核通过了不能改");
- return;
- }
- entity.returnprice = GetPostDouble("returnprice");
- entity.Update();
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_returncash()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void test_for_do_sql()
- {
- string sql = GetPostString("sqlstr");
- if (sql.Length > 0)
- {
- try
- {
- DbHelper.DbConn.ExecuteNonQuery(sql);
- var res_obj = new
- {
- data = "成功",
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- catch (Exception ex)
- {
- var res_obj = new
- {
- data = ex.Message,
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- }
- }
- public void get_user_info()
- {
- DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
- }
- public void get_total_data()
- {
- int userId = CurrentUser.UserID;
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- 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);
- }
- else
- {
- 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 " +
- "(select ID from CE_ErpUser where ID = {0}) d " +
- "left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
- ") a on d.ID = a.id left join " +
- "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
- ") b on a.id = b.id1 left join" +
- "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
- ") c on a.id = c.id2;", userId);
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data2()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
- "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
- " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") a on e.ID = a.id left join " +
- "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
- " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") b on a.id = b.id1 " +
- "left join " +
- "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- else
- {
- sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
- " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
- ") a on e.ID = a.id left join " +
- "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string date1 = searchDT[0].ToString();
- string date2 = searchDT[1].ToString();
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- else
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- //writeGridDataViewJson(dt.Rows.Count, dv);
- }
- public void get_order_list()
- {
- string strFields = GetPostString("paraFields");
- string strOrder = GetPostString("paraOrder");
- string strWhere = GetPostString("paraWhere");
- string strPageSize = GetPostString("paraPageSize");
- DataStruct dStruct = GetPostStruct();
- dStruct.PageSize = int.Parse(strPageSize);
- dStruct.Fileds = strFields;
- dStruct.Order = strOrder;
- dStruct.MainWhere = strWhere;
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- ////获取待开始订单列表
- //public void get_wait_design_order_list()
- //{
- // string date_type = GetPostString("date_type");
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- // DataStruct dStruct = GetPostStruct();
- // dStruct.PageSize = 1000;
- // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
- // List<string> lw = new List<string>();
- // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
- // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
- // dStruct.Order = "WaitDesignTime asc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //获取完成单量排名
- public void get_finish_order_count_ranking()
- {
- /* string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_order_amount_ranking()
- {
- /*string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_refund_count_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void get_finish_refund_amount_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void set_erp_finishorder_director()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 8;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_placeregistlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string outsid = GetPostString("outsid");
- if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
- string memo = GetPostString("memo");
- if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
- string filename = GetPostString("filename");
- if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
- string islate = GetPostString("islate");
- if (islate.Length > 0)
- {
- if (islate == "1")
- lw.Add(string.Format("OutLate>0"));
- else
- lw.Add(string.Format("OutLate=0"));
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
- if (dw.Length > 0) lw.Add(dw);
- string deliveryDate1 = GetPostString("deliverydate1");
- string deliveryDate2 = GetPostString("deliverydate2");
- string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
- if (dw_deli.Length > 0) lw.Add(dw_deli);
- dStruct.Order = "ID desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_placeregist()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister entity = null;
- if (eid == "0")//新增
- {
- entity = new CeErpPlaceRegister();
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.AddUserId = CurrentUser.UserID;
- entity.CreateTime = DateTime.Now;
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Create();
- returnSuccessMsg("添加成功!");
- return;
- }
- else //修改
- {
- entity = CeErpPlaceRegister.Get(eid);
- if (entity != null)
- {
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- if (entity.DeliveryCount == entity.ReceiveCount)
- {
- entity.CurState = "已完成";
- }
- else
- {
- entity.CurState = "未完成";
- }
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到对应的记录");
- return;
- }
- }
- returnErrorMsg("缺少必要参数");
- }
- public void del_erp_placeregist()
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister.Del(eid);
- returnSuccessMsg("删除成功!");
- return;
- }
- public void ins_erp_placeregistbyorder()
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
- entity.AddUserId = CurrentUser.UserID;
- entity.tid = dr["tid"].ToString();
- entity.Did = Convert.ToString(dr["ctid"]);
- entity.splitTag = dr["SplitTag"].ToString();
- string sellmemo = Convert.ToString(dr["seller_memo"]);
- string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
- if (pre_ctid.Length > 0)
- {
- sellmemo = sellmemo.Replace(pre_ctid, "");
- }
- sellmemo = sellmemo.Replace("[", "");
- sellmemo = sellmemo.Replace("]", "");
- entity.FileName = sellmemo;
- string count = dr["ProductCount"].ToString();
- int usecount = commonHelper.getIntCountFromString(count);
- entity.DeliveryCount = usecount;
- entity.CurState = "未完成";
- if (Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- entity.Supplier = 24;//dl手提袋定制
- }
- else
- entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
- entity.CreateTime = DateTime.Now;
- entity.Create();
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("没有找到对应订单");
- return;
- }
- returnErrorMsg("缺少订单编号");
- return;
- }
- public void get_erp_persuadelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_returnpersuadeback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.pstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnpersuadeverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- if (CurrentUser.UserPost.Post.Code != "Summarize")
- {
- returnErrorMsg("暂无权限审核");
- return;
- }
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.pstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_persuade()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void get_erp_oldcustoupload()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- }
- else
- return;
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_checkorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (CurrentUser.UserPost.Post.Code == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string checkst = GetPostString("checkstate");
- if (checkst.Length > 0 && "10".Equals(checkst))
- {
- lw.Add(string.Format("CheckOut>0"));
- }
- else
- {
- if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
- lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
- }
- dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_startCheck()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
- CeErpSukuraData.createInfo(entity.ctid, 6);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 1)
- {
- returnErrorMsg("请勿重复标记");
- return;
- }
- entity.IsSendGift = 1;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void cancel_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 0)
- {
- returnErrorMsg("未标记小礼物");
- return;
- }
- entity.IsSendGift = 0;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_designbill()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int isMy = GetInt("my");
- if (isMy == 1)
- {
- lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
- }
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string userName = GetPostString("design");
- if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
- string rePrice1 = GetPostString("rePrice1");
- if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
- string rePrice2 = GetPostString("rePrice2");
- if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
- string designerType = GetPostString("designerType");
- if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string endTime1 = GetPostString("endTime1");
- string endTime2 = GetPostString("endTime2");
- string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
- if (dw.Length > 0) lw.Add(dw);
- string isDk = GetPostString("isDk");
- if (isDk == "1")
- {
- lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
- }
- else if (isDk == "0")
- {
- lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
- }
- dStruct.Order = "oid, create_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- if (entity != null)
- {
- if (GetPostDouble("designerpirce") > 0)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- entity.price = GetPostDouble("price");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- if (orderEntity != null)
- {
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void all_audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("idList"))
- {
- string[] list = GetPostString("idList").Split(',');
- CeErpDesignerBill entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
- if (entity == null) return;
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
- if (orderEntity == null) return;
- if (entity.realPrice == 0) entity.realPrice = entity.price;
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_sameorders()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- var res = new
- {
- data = dt.Rows.Count
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("未找到订单");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void get_erp_islasthavesameorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] ctidList = eid.Split(',');
- StringBuilder sql = new StringBuilder();
- string tisCtid = "";
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth.Rows.Count > 0)
- {
- tisCtid += entity.ctid;
- tisCtid += ",";
- }
- }
- }
- if (tisCtid.Length > 0)
- {
- var res = new
- {
- data = tisCtid
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- else
- {
- var res = new
- {
- data = ""
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void file_client_down_url()
- {
- if (!UrlPostParmsCheck("userId"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
- }
- public void checkout_form_data()
- {
- if (!UrlPostParmsCheck("tid"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- string tid = GetPostString("tid");
- CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
- if (ceErpOrderFormData != null)
- {
- string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("尚未有文件!");
- }
- public void back_supplier_audit()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void back_supplier_query()
- {
- string eid = GetPostString("ctid");
- if (eid != "")
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnErrorMsg("找不到订单记录");
- return;
- }
- }
- public void verified_to_order()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void upd_supplier_audit()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- CeWithdraw withdraw = null;
- withdraw = CeWithdraw.GetByTid(eid);
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
- {
- if (withdraw != null)
- {
- if (!withdraw.userid.Equals(CurrentUser.UserID))
- {
- returnSuccessMsg("您没有权限操作!");
- return;
- }
- else
- {
- if (reason.Equals("1"))
- {
- if (entity.OrderState == -1)
- {
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 6;
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- }
- // 第一个字符是 'N'
- }
- if (eid[0] != 'N')
- {
- }
- if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
- {
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState > 2)
- {
- ;
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("供应商取消撤回!");
- return;
- }
- }
- else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
- {
- if (entity.OrderState == -1)
- {
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 3;
- }
- commonHelper.getCytPrice(entity);
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState < 0)
- {
- if (withdraw == null)
- {
- returnSuccessMsg("驳回操作成功!可重新发起审核!");
- return;
- }
- }
- else if (int.Parse(reason) == 4 && entity.OrderState < 0)
- {
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- return;
- }
- }
- //校验报价
- public void refund_order_tip()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void refund_order_Design()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_order_info()
- {
- int userid = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_win_mome()
- {
- if (UrlPostParmsCheck("id,ctid"))
- {
- string id = GetPostString("id");
- string ctid = GetPostString("ctid");
- CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
- CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
- if (ce == null || ceErpMessageTip == null)
- {
- returnSuccessMsg("未找到对应的订单!");
- return;
- }
- int type = GetPostInt("type");
- string content = GetPostString("content");
- if (type == 0)
- {
- content = content.Replace("(", "(");
- content = content.Replace(")", ")");
- string check = MidStrEx(content, "(", ")").Trim();
- if (string.IsNullOrEmpty(check))
- {
- returnSuccessMsg("文件名格式不正确");
- return;
- }
- }
- ce.seller_memo = content;
- ce.Update();
- ceErpMessageTip.isVisit = true;
- ceErpMessageTip.Update();
- string text = type == 0 ? "同意修改:" + content : "不同意修改";
- LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ce.ctid;
- apiVo.actionName = "demandDesign";
- apiVo.orderRemarks = content;
- apiVo.demandExamine = type + 1;
- designHelper.API_WorkCore(apiVo);//demandDesign
- returnSuccessMsg("修改成功!");
- }
- }
- public static string MidStrEx(string sourse, string startstr, string endstr)
- {
- string result = string.Empty;
- int startindex, endindex;
- try
- {
- startindex = sourse.IndexOf(startstr);
- if (startindex == -1)
- return result;
- string tmpstr = sourse.Substring(startindex + startstr.Length);
- endindex = tmpstr.IndexOf(endstr);
- if (endindex == -1)
- return result;
- result = tmpstr.Remove(endindex);
- }
- catch (Exception ex)
- {
- Console.WriteLine("MidStrEx Err:" + ex.Message);
- }
- return result;
- }
- public void refund_order_list()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- List<string> ids = new List<string>();
- List<string> tids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- tids.Add("'" + dr["tid"].ToString() + "'");
- ids.Add(dr["id"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- List<string> lw = new List<string>();
- lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_orderlist", dStruct);
- }
- catch (Exception ex)
- {
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
- }
- //新增
- public void order_batch_downloads()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- order_batch_caiyingtong(tid);
- /* (string success, string errors) = UploadFiles(tid);
- returnSuccessMsg(success + errors);*/
- return;
- }
- //报价接口
- public void Get_To_Quote()
- {
- string ceid = GetPostString("ctid");
- if (ceid != null)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
- if (entity != null)
- {
- if (entity.seller_memo.IndexOf("种子纸") > -1)
- {
- return;
- }
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- double price = 0;
- if (cp == null)
- {
- JObject jsonObject12 = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", entity.seller_memo }
- };
- string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
- JObject jsonObjects1 = JObject.Parse(response1);
- string ms1g = (string)jsonObjects1["msg"];
- if (ms1g == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects1["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
- return;
- }
- }
- String[] beizhu = entity.seller_memo.Split('-');
- String chanp = "";
- if (beizhu.Length > 0)
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
- }
- else
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- }
- JObject jsonObject = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + msg);
- return;
- }
- if (price > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- }
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- }
- //新增
- public void order_To_Supplier()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- if (tid.Length > 0)
- {
- try
- {
- for (int i = 0; i < tid.Length; i++)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- catch (Exception ex)
- {
- returnErrorMsg("自动匹配供应商失败");
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- returnSuccessMsg("自动匹配供应商成功");
- return;
- }
- public (string, string) UploadFiles(string[] urls)
- {
- string success = "";
- string errors = "";
- int userid = CurrentUser.UserID;
- foreach (string url in urls)
- {
- String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
- (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
- if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "cyt86435015" },
- { "content", base64FileContent },
- { "ext", Path.GetExtension(fileName) }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg.Equals("上传成功"))
- {
- success += url + " 上传成功";
- }
- else
- {
- errors += url + " 上传失败";
- }
- }
- else
- {
- errors += url + " 格式出现问题";
- }
- }
- if (urls.Length == 0)
- {
- return (success, errors);
- }
- return (success, errors);
- }
- private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
- {
- return true; //总是接受
- }
- public static string HttpPost(string url, string param = null)
- {
- HttpWebRequest request;
- //如果是发送HTTPS请求
- if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
- {
- ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
- request = WebRequest.Create(url) as HttpWebRequest;
- request.ProtocolVersion = HttpVersion.Version10;
- }
- else
- {
- request = WebRequest.Create(url) as HttpWebRequest;
- }
- request.Method = "POST";
- request.ContentType = "application/json";
- request.Accept = "*/*";
- request.Timeout = 120000;
- request.AllowAutoRedirect = false;
- StreamWriter requestStream = null;
- WebResponse response = null;
- string responseStr = null;
- try
- {
- requestStream = new StreamWriter(request.GetRequestStream());
- requestStream.Write(param);
- requestStream.Close();
- response = request.GetResponse();
- if (response != null)
- {
- StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
- responseStr = reader.ReadToEnd();
- reader.Close();
- }
- }
- catch (Exception ex)
- {
- return ex.Message;
- }
- finally
- {
- request = null;
- requestStream = null;
- response = null;
- }
- return responseStr;
- }
- public (string, string) DownloadAndConvertToBase64(string downloadUrl)
- {
- string base64FileContent;
- string fileName;
- using (WebClient webClient = new WebClient())
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
- using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
- {
- using (Stream stream = response.GetResponseStream())
- {
- using (MemoryStream memoryStream = new MemoryStream())
- {
- stream.CopyTo(memoryStream);
- byte[] fileBytes = memoryStream.ToArray();
- base64FileContent = Convert.ToBase64String(fileBytes);
- fileName = response.Headers["Content-Disposition"];
- if (!string.IsNullOrEmpty(fileName))
- {
- int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
- if (index >= 0)
- {
- fileName = fileName.Substring(index + 9).Trim('\"');
- }
- }
- else
- {
- fileName = Path.GetFileName(downloadUrl);
- }
- }
- }
- }
- }
- return (fileName, base64FileContent);
- }
- //新增
- public void order_batch_caiyingtong(string[] downloadUrls)
- {
- try
- {
- //遍历文件
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- int userid = CurrentUser.UserID;
- List<string> ids = new List<string>();//失败组
- List<string> tids = new List<string>();
- using (WebClient webClient = new WebClient())
- {
- foreach (var url in downloadUrls)
- {
- try
- {
- tids.Add("'" + url + "'");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
- if (entity != null)
- {
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- if (cp == null)
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",entity.seller_memo }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- else
- {
- String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- }
- // 上传文件到FTP
- }
- catch (Exception ex)
- {
- Console.WriteLine($"An error occurred: {ex.Message}");
- }
- }
- List<string> lw = new List<string>();
- lw.Add(string.Format("( OrderState < 6 )"));
- lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- ids.Add(dr["ctid"].ToString());
- }
- }
- String ErrorMsgs = "";
- foreach (String id in ids)
- {
- ErrorMsgs += id + ",";
- }
- if (ErrorMsgs.Length > 1)
- {
- ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
- }
- if (ErrorMsgs.Length < 1)
- {
- ErrorMsgs = "上传成功";
- returnSuccessMsg(ErrorMsgs);
- }
- else
- {
- returnErrorMsg("以下订单" + ErrorMsgs);
- }
- }
- // 删除文件夹及其内容
- /* Directory.Delete(localDirectory, true);*/
- }
- catch { }
- }
- public void get_center_data()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- List<string> lw = new List<string>();
- List<string> ww = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string sql = " SELECT ";
- string startTime = "2023-10-01 11:22:31";
- //设计
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- }
- //客服
- else if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- }
- //售后
- else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- //下单部
- else if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- }
- //车间
- else if (postCode == "Supplier")
- {
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- DataTable dt = new DataTable();
- if (lw.Count > 0)
- {
- sql += string.Join(" , ", lw);
- sql += " FROM ";
- sql += string.Join(" , ", ww);
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_center_data_list()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- string shopIds = CurrentUser.User.pemShop;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string startTime = "2023-10-01 11:22:31";
- int order_type = GetPostInt("order_type");
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //客服
- if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //售后
- if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //下单部
- if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //车间
- if (postCode == "Supplier")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Fileds = "tid,ctid";
- DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void aftersale_audit_master()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- bool result = aftersale_data_change(ctid);
- if (result)
- {
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public void aftersale_batch_audit_master()
- {
- if (UrlPostParmsCheck("ctids"))
- {
- string ctids = GetPostString("ctids");
- if (ctids.Length > 0)
- {
- List<string> list = new List<string>();
- string[] ctid_list = ctids.Split(',');
- foreach (var item in ctid_list)
- {
- bool result = aftersale_data_change(item);
- if (!result)
- {
- list.Add(item);
- }
- }
- if (list.Count > 0)
- {
- returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
- return;
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public bool aftersale_data_change(string ctid)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
- ceErpTradeCell.AfterSaleSupplierState = 0;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- CeErpTradeResponsible.DelByTid(ctid, 0);
- 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 == "不理赔")
- {
- CeErpTradeResponsible.DelByTid(ctid, 1);
- ceErpTradeCell.AfterSaleSupplierState = 1;
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- }
- else
- {
- ceErpTradeCell.AfterSaleState = 3;
- }
- bool needCyt = false;
- if (dt != null)
- {
- if (dt.Rows.Count == 1)
- {
- bool isEnd = false;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
- {
- needCyt = true;
- }
- }
- if (isEnd)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- else
- {
- bool isAll = true;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
- {
- string path = "";
- int OrgID = 0;
- if (!Convert.IsDBNull(dr["OrgPath"]))
- {
- path = dr["OrgPath"].ToString();
- }
- if (!Convert.IsDBNull(dr["OrgID"]))
- {
- OrgID = Convert.ToInt32(dr["OrgID"]);
- }
- if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
- {
- needCyt = true;
- }
- isAll = false;
- }
- if (isAll)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- }
- if (needCyt && ceErpTradeCell.AfterSaleState != 4)
- {
- commonHelper.sendCytAfterSale(ceErpTradeCell);
- }
- if (ceErpTradeCell.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ceErpTradeCell.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- ceErpTradeCell.Update();
- CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
- CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
- return true;
- }
- return false;
- }
- public void get_erp_wechatorder()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_wechatlist_sumprice()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_qr_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- var res_objz = new
- {
- restype = 1,
- data = dt
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- }
- public void get_erp_yield_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_supYield", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void change_erp_sup_state()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
- returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
- return;
- }
- returnErrorMsg("找不到订单");
- }
- }
- public void supplier_all_downs()
- {
- if (UrlPostParmsCheck("tids"))
- {
- string tids = GetPostString("tids");
- if (tids != null && tids.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- sql = new StringBuilder();
- 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, "下载设计文件");
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- string[] list = tids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- designHelper.api_approveDesign(tids); //approveDesign
- returnSuccessMsg("下载成功!");
- return;
- }
- returnErrorMsg("下载订单更新失败");
- }
- }
- public void uploaderFileSuccess()
- {
- if (UrlPostParmsCheck("fileName"))
- {
- string fileName = GetPostString("fileName");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = fileName;
- apiVo.actionName = "finishDesign";
- designHelper.API_WorkCore(apiVo);//finishDesign
- returnSuccessMsg("");
- }
- }
- public void get_sample2_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
- DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
- double total = 0.0;
- double order_price = 0.0;
- if (dt_bu.Rows.Count > 0)
- {
- foreach (DataRow dr in dt_bu.Rows)
- {
- total += Convert.ToDouble(dr["payment"]);
- }
- }
- order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
- string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
- DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
- string tid = ctid.Replace("S_", "");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
- double paymant = 0.0;
- if (entity != null)
- {
- paymant = entity.payment;
- }
- string return_reason = "";
- if (dt_after != null && dt_after.Rows.Count > 0)
- {
- return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
- }
- returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
- }
- }
- public void get_erp_design_status()
- {
- string designName = GetPostString("designName");
- DataStruct dStruct = GetPostStruct();
- if (designName.Length > 0)
- {
- 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";
- sql_user += " and Name like '%" + designName + "%'";
- DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- List<string> ids_list = new List<string>();
- if (user_table.Rows.Count > 0)
- {
- foreach (DataRow item in user_table.Rows)
- {
- ids_list.Add(item["id"].ToString());
- string ids_s = item["TeamIds"].ToString();
- if (ids_s.Length > 0)
- {
- ids_list.AddRange(ids_s.Split(','));
- }
- }
- }
- HashSet<string> set = new HashSet<string>(ids_list);
- ids_list = set.ToList();
- if (ids_list.Count > 0)
- {
- 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));
- dStruct.MainWhere = sql;
- DataTable dt = null;
- dt = WebCache.GetData("view_ErpUser", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- }
- public void change_erp_order_price()
- {
- string ctid = GetPostString("ctid");
- double price = GetPostDouble("price");
- if (ctid.Length > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
- if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
- {
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.Update();
- }
- if (ceErpDataSendOrderInfo == null)
- {
- ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.ctid = ctid;
- ceErpDataSendOrderInfo.Create();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dth != null && dth.Rows.Count > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void find_he_together()
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- List<string> list = new List<string>();
- if (ceErpTradeCell != null)
- {
- if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
- {
- 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);
- DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (table != null && table.Rows.Count > 0)
- {
- foreach (TableRow row in table.Rows)
- {
- }
- }
- }
- }
- returnSuccess(JsonConvert.SerializeObject(new { list }));
- }
- Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
- {
- //chy----19
- {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
- //GD-CYT-----64
- {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
- //ZHX----3
- {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
- //JK----97
- {97, new Dictionary<string, string> {{"uv", "uv"}}},
- //ZT----70
- {70, new Dictionary<string, string> {{"uv", "uv"}}},
- //LHCY-----98
- {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
- //XD-----90
- {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
- //CYCY-----14
- {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
- };
- //其他改名
- Dictionary<int, string> suppliers = new Dictionary<int, string>()
- {
- {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
- {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
- {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
- {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
- {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
- {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
- {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
- {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
- };
- //不统计
- List<int> no_suppliers = new List<int>()
- {
- 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
- };
- //配件单
- Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
- {
- {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
- {"棉绳",new List<string>(){ "卡片", "吊牌" } },
- {"别针",new List<string>(){ "卡片", "吊牌" } },
- {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
- {"流苏",new List<string>(){ "卡片", "吊牌" } },
- {"旗杆",new List<string>(){ "班旗" } },
- {"牙签",new List<string>(){ "不干胶" } }
- };
- public void get_place_order_data()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
- DateTime start = DateTime.Parse(starttime);
- string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
- DateTime end = DateTime.Parse(endtime);
- if (date1 != null && date1.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date1);
- starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- start = DateTime.Parse(starttime);
- endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
- end = DateTime.Parse(endtime);
- }
- if (date2 != null && date2.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date2);
- endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- end = DateTime.Parse(endtime);
- }
- 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);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //不干胶-----1,卡片-----29
- Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
- foreach (DataRow row in data.Rows)
- {
- int productId = Convert.ToInt32(row["ProductId"]);
- int supplierId = Convert.ToInt32(row["SupplierId"]);
- if (no_suppliers.Contains(supplierId))
- {
- continue;
- }
- string seller_memo = row["seller_memo"].ToString();
- bool ispj = false;//是否配件单
- bool isfirst = true;//第一个配
- maps.Keys.ForEach(key =>
- {
- //备注包含配件
- if (seller_memo.Contains(key) && isfirst)
- {
- List<string> list = maps[key];
- ispj = true;
- isfirst = false;
- for (int i = 0; i < list.Count; i++)
- {
- if (seller_memo.Contains(list[i]))
- {
- ispj = false;
- break;
- }
- }
- }
- });
- if (ispj)
- {
- continue;
- }
- seller_memo = seller_memo.Replace("UV", "uv");
- seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
- //吊牌归到卡片
- seller_memo = seller_memo.Replace("吊牌", "卡片");
- seller_memo = seller_memo.Replace("卡套", "卡片");
- seller_memo = seller_memo.Replace("封套", "卡片");
- seller_memo = seller_memo.Replace("吸管套", "卡片");
- seller_memo = seller_memo.Replace("腰封", "卡片");
- seller_memo = seller_memo.Replace("旗帜布", "条幅");
- seller_memo = seller_memo.Replace("手拉旗", "条幅");
- seller_memo = seller_memo.Replace("横幅", "条幅");
- seller_memo = seller_memo.Replace("锦旗", "条幅");
- string map_key = "";
- string type = "";
- if (supplierMap.ContainsKey(supplierId))
- {
- foreach (var kvp in supplierMap[supplierId])
- {
- if (seller_memo.Contains(kvp.Key))
- {
- map_key = kvp.Value;
- type = kvp.Value;
- break;
- }
- }
- }
- if (map_key == "")
- {
- type = "其他";
- map_key = "其他";
- }
- if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
- {
- map_key = suppliers[supplierId];
- }
- if (supplierId == 70)
- {
- supplierId = 70;
- }
- map_key += "_" + row["SupplierName"].ToString();
- Dictionary<string, int> map = null;
- if (other_map.ContainsKey(map_key))
- {
- other_map.TryGetValue(map_key, out map);
- }
- else
- {
- map = new Dictionary<string, int>();
- map.Add("dayDev", 0);//当天出货
- map.Add("dayTotal", 0);//下单总数
- map.Add("payTotal", 0);//500以上
- map.Add("today", 0);//当天出货数量
- map.Add("unusua", 0);//异常数
- other_map.Add(map_key, map);
- other_map.TryGetValue(map_key, out map);
- }
- DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
- DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
- if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
- {
- map["dayTotal"]++;
- if (supplierId == 97)
- {
- supplierId = 97;
- }
- }
- if (Convert.ToDecimal(row["payment"]) >= 500)
- {
- map["payTotal"]++;
- }
- if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
- {
- DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
- if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
- {
- map["today"]++;
- }
- }
- if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
- {
- map["unusua"]++;
- }
- DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- //GD-CYT-----64
- DateTime two = palceTimeStart.AddHours(14);
- DateTime three = palceTimeStart.AddHours(15);
- DateTime four = palceTimeStart.AddHours(16);
- if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
- {
- //下午四点前 500-1000
- string count = row["ProductCount"].ToString();
- if (count != null && count.Length > 0)
- {
- int productCount = commonHelper.getPlaceProductCount(count);
- if (productCount >= 500 && productCount <= 1000)
- {
- if (DateTime.Compare(FinishPlaceTime, four) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- }
- //UV
- else if ("uv".Equals(type))
- {
- //ZT----70
- //ZHX----3
- if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
- {
- map["dayDev"]++;
- }
- //JK----97
- //HZX----105
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
- {
- map["dayDev"]++;
- if (supplierId == 97)
- {
- supplierId = 97;
- Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
- }
- }
- }
- //帆布---52|条幅---27
- else if ("帆布".Equals(type) || "条幅".Equals(type))
- {
- //LHCY-----98
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
- {
- map["dayDev"]++;
- }
- }
- //条幅
- else if ("条幅".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //桌布
- else if ("桌布".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //DL---10
- //AYTW---119
- //FS-CYT-DY ----80
- //JK----97
- else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
- {
- if (DateTime.Compare(FinishPlaceTime, three) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
- dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
- dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("today", typeof(string)));
- dt.Columns.Add(new DataColumn("unusua", typeof(string)));
- dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
- dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
- other_map.Keys.ForEach(key =>
- {
- DataRow dr = dt.NewRow();
- Dictionary<string, int> map = other_map[key];
- string[] key_list = key.Split('_');
- dr[0] = key_list[0];
- dr[1] = key_list[1];
- if (key_list.Length > 2)
- {
- dr[1] += "(" + key_list[2] + ")";
- }
- dr[2] = map["dayTotal"];
- dr[3] = map["payTotal"];
- dr[4] = map["today"];
- dr[5] = map["unusua"];
- dr[6] = map["dayDev"];
- double rate = 0.00;
- if (map["dayDev"] > 0)
- {
- rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
- }
- dr[7] = rate.ToString();
- dt.Rows.Add(dr);
- });
- DataView dv = new DataView(dt);
- dv.Sort = "SupplierName";
- //dv.Sort = "AllOrder desc";
- DataTable dtNew = dv.ToTable();
- writeGridDataTableJson(dtNew.Rows.Count, dtNew);
- }
- public void check_order_desing_info()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
- returnSuccess(JsonConvert.SerializeObject(new { response }));
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_timeout_detail()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string id = GetPostString("id");
- string pay_date1 = GetPostString("pay_date1");
- string pay_date2 = GetPostString("pay_date2");
- int type = GetPostInt("type");
- if (type == 0)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
- }
- if (type == 1)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_orderlist", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveUrgentChargePrice()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- double price = GetPostDouble("price");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
- }
- ceErpTradeCellExtend.urgentCharge = price;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Save();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void finish_erp_order()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
- ceErpTradeCell.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void get_trade_order_list()
- {
- string tid = GetPostString("tid");
- if (!string.IsNullOrEmpty(tid))
- {
- string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(data.Rows.Count, data);
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void save_cell_spu()
- {
- string ctid = GetPostString("ctid");
- string spu_id = GetPostString("spu_id");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.spu_id = spu_id;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void change_express_info()
- {
- string ctid = GetPostString("ctid");
- string transNo = GetPostString("transNo");
- string transCom = GetPostString("transCom");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.modExpressNo = transNo;
- ceErpTradeCellExtend.modExpressCom = transCom;
- ceErpTradeCellExtend.readMod = 2;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_change_express_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- lw.Add("readMod = 2");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void deal_express_complete()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.readMod = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void aftersale_return_visit()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.returnVisit = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.TextResult = "";
- ceErpTradeAfterSaleExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void orderPlaceInfo()
- {
- string ctids = GetPostString("ctids");
- string[] list = ctids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- designHelper.api_approveDesign(ctids); //approveDesign
- returnSuccessMsg("");
- }
- }
- }
|