sync.order.cs 632 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. namespace SiteCore.Handler
  48. {
  49. public partial class sync
  50. {
  51. public void get_erp_orderlist()
  52. {
  53. string poscode = CurrentUser.UserPost.Post.Code;
  54. DataStruct dStruct = GetPostStruct();
  55. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\即客4月无快递单号订单.xlsx");
  56. //apiHelper.Api_SyncOrderByTime("598825");
  57. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  58. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  59. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  60. //banniuApiHelper.sendLogisticsInfo(null);
  61. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  62. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  63. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  64. //int sid = commonHelper.autoDistributeToSupplier(entity);
  65. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  66. //tmcHelper.Api_TmcTradeMsg("{\r\n \"content\": {\r\n \"businessType\": \"GUARANTEE\",\r\n \"buyerMemo\": \"\",\r\n \"consolidateType\": \"\",\r\n \"createTime\": 1744882656361,\r\n \"deliveryType\": \"OFFLINE\",\r\n \"discountFee\": 0.0,\r\n \"flag\": \"NONE\",\r\n \"latestDeliveryTime\": 1744882656361,\r\n \"lines\": [\r\n {\r\n \"mark2\": [],\r\n \"num\": 4,\r\n \"outerId\": \"\",\r\n \"payment\": 60.0,\r\n \"picUrl\": \"https://img.alicdn.com/bao/uploaded/i4/2209226402185/O1CN011Zh53V1S0mQKgHJyF_!!4611686018427382153-0-item_pic.jpg\",\r\n \"platServiceFee\": 0.0,\r\n \"price\": 10.0,\r\n \"refOlId\": \"1111122222333338942\",\r\n \"refSkuId\": \"0\",\r\n \"refSpuId\": \"908453435193\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellPrice\": 10.0,\r\n \"singleFee\": 10.0,\r\n \"standards\": \"测试内部\",\r\n \"status\": \"NOT_SHIPPED\",\r\n \"title\": \"【老客户订单2】测试老客户订单内部\",\r\n \"totalFee\": 60.0,\r\n \"totalPrice\": 60.0,\r\n \"totalSellPrice\": 60.0\r\n }\r\n ],\r\n \"logisticsOrderNo\": \"\",\r\n \"mark2\": [],\r\n \"modifyTime\": 1744882656361,\r\n \"openBuyerId\": \"AAG1RHraABkUZRPgSx3g7Eam\",\r\n \"openBuyerNick\": \"0**\",\r\n \"openSellerNick\": \"海角七旗舰店\",\r\n \"orderSource\": \"SYNC\",\r\n \"orderTime\": 1744882656361,\r\n \"payTime\": 1744882656361,\r\n \"payment\": 100.0,\r\n \"platServiceFee\": 0.0,\r\n \"posCode\": \"HJQ\",\r\n \"posId\": 663281,\r\n \"postFee\": 0.0,\r\n \"props\": {\r\n \"payType\": \"ALI_PAY\",\r\n \"govSubsidyAmount\": 0\r\n },\r\n \"receivedPayment\": 0.0,\r\n \"receiverCity\": \"龙岩市\",\r\n \"receiverCountry\": \"中国\",\r\n \"receiverDistrict\": \"新罗区\",\r\n \"receiverId\": \"d1b65912ef886228ac4ada4b65055e52$\",\r\n \"receiverState\": \"福建省\",\r\n \"receiverTown\": \"西陂街道\",\r\n \"refOid\": \"1111122222333338942\",\r\n \"refType\": \"TB\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellerMemo\": \"\",\r\n \"serviceFee\": 0.0,\r\n \"status\": \"NOT_SHIPPED\",\r\n \"totalFee\": 100.0,\r\n \"totalPrice\": 100.0,\r\n \"totalSellPrice\": 100.0,\r\n \"type\": \"SALE\"\r\n }\r\n}");
  67. //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}}");
  68. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  69. List<string> lw = new List<string>();
  70. string tid = GetPostString("ctid");
  71. string date1 = GetPostString("date1");
  72. //12-1 修改
  73. string urgent = GetPostString("urgent");
  74. string back = GetPostString("back");
  75. string offlineSearch = GetPostString("offlineSearch");
  76. int paramsCount = 0;
  77. if (!string.IsNullOrWhiteSpace(urgent))
  78. {
  79. if (urgent.Equals("true"))
  80. {
  81. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  82. }
  83. }
  84. if (!string.IsNullOrWhiteSpace(back))
  85. {
  86. if (back.Equals("true"))
  87. {
  88. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  89. }
  90. }
  91. if (!string.IsNullOrWhiteSpace(offlineSearch))
  92. {
  93. if (offlineSearch.Equals("true"))
  94. {
  95. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  96. }
  97. }
  98. //end
  99. string date2 = GetPostString("date2");
  100. string buyernick = GetPostString("buyer_nick");
  101. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  102. {
  103. if (tid.Length <= 0 && buyernick.Length <= 0)
  104. {
  105. return;
  106. }
  107. }
  108. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  109. {
  110. if (tid.Length > 0)
  111. {
  112. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  113. if (ceErpTradeCell != null)
  114. {
  115. tid = ceErpTradeCell.tid;
  116. }
  117. List<string> select_tid = getTidByCtidMore(tid);
  118. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  119. }
  120. if (buyernick.Length > 0)
  121. {
  122. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  123. }
  124. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  125. if (dw.Length > 0)
  126. {
  127. lw.Add(dw);
  128. }
  129. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. }
  134. }
  135. else
  136. {
  137. if (ex_psize == 0)
  138. {
  139. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  140. }
  141. if (PKey != "admin")
  142. {
  143. string usershop = CurrentUser.User.pemShop;
  144. lw.Add(string.Format("ShopId in ({0})", usershop));
  145. paramsCount++;
  146. }
  147. }
  148. string uploaddate1 = GetPostString("uploaddate1");
  149. string uploaddate2 = GetPostString("uploaddate2");
  150. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  151. if (update.Length > 0) lw.Add(update);
  152. string deliverydate1 = GetPostString("deliverydate1");
  153. string deliverydate2 = GetPostString("deliverydate2");
  154. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  155. if (deliverydate.Length > 0)
  156. {
  157. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  158. };
  159. string shopname = GetPostString("shopname");
  160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  161. string addwechat = GetPostString("addwechat");
  162. if (addwechat.Length > 0)
  163. {
  164. int addWt = Convert.ToInt32(addwechat);
  165. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  166. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  167. }
  168. string customer = GetPostString("customer");
  169. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  170. string design = GetPostString("design");
  171. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  172. string orderState = GetPostString("orderState");
  173. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  174. string address = GetPostString("address");
  175. 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));
  176. string sellermemo = GetPostString("seller_memo");
  177. if (sellermemo.Length > 0)
  178. {
  179. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  180. }
  181. string backReason = GetPostString("backReason");
  182. if (backReason.Length > 0)
  183. {
  184. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  185. }
  186. string apdate1 = GetPostString("apdate1");
  187. string apdate2 = GetPostString("apdate2");
  188. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  189. if (dwap.Length > 0) lw.Add(dwap);
  190. string price1 = GetPostString("price1");
  191. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  192. string price2 = GetPostString("price2");
  193. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  194. string isoldcustomer = GetPostString("isoldcus");
  195. string spudata = GetPostString("spudata");
  196. if ("0".Equals(spudata))
  197. {
  198. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  199. }
  200. if ("1".Equals(spudata))
  201. {
  202. lw.Add(string.Format("spu_id <> ''"));
  203. }
  204. string finishdate1 = GetPostString("finishdate1");
  205. string finishdate2 = GetPostString("finishdate2");
  206. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  207. bool isFinish = false;
  208. if (finishdate.Length > 0)
  209. {
  210. lw.Add(finishdate);
  211. isFinish = true;
  212. paramsCount++;
  213. }
  214. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  215. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  216. if (ex_psize > 0)
  217. {
  218. int UserID = CurrentUser.UserID;
  219. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  220. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  221. {
  222. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  223. }
  224. dStruct.Order = "pay_time desc";
  225. }
  226. string isNew = GetPostString("isNew");
  227. if (isNew == "true")
  228. {
  229. lw.Add(string.Format("IsNew = {0}", 1));
  230. }
  231. string overtime = GetPostString("overtime");
  232. if (overtime == "1")
  233. {
  234. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  235. }
  236. String usePost = CurrentUser.UserPost.Post.Code;
  237. if (usePost.Equals("Operation") == true)
  238. {
  239. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  240. }
  241. else
  242. {
  243. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  244. }
  245. //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";
  246. if (dStruct.PageSize == 100000)
  247. {
  248. dStruct.Order = "";
  249. }
  250. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  251. DataTable dt = null;
  252. string tablename = "view_orderlist";
  253. if (isFinish)
  254. {
  255. tablename = "view_orderlist_end";
  256. }
  257. dt = WebCache.GetData(tablename, dStruct);
  258. if (dt != null && dt.Rows.Count > 0)
  259. {
  260. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  261. foreach (DataRow dr in dt.Rows)
  262. {
  263. try
  264. {
  265. if (dr["refund_fees"] != null)
  266. {
  267. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  268. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  269. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  270. if (payment == refund_fees)
  271. {
  272. dr["refund_fees"] = Math.Round(refund_fees, 2);
  273. }
  274. else if (refund_fees == total_fee)
  275. {
  276. dr["refund_fees"] = payment;
  277. }
  278. else
  279. {
  280. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  281. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  282. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  283. }
  284. }
  285. // 对象操作
  286. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  287. ceErpTradeCell.ctid = dr["ctid"].ToString();
  288. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  289. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  290. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  291. if (dStruct.PageSize != 100000)
  292. {
  293. if (dr["DispatchSort"].ToString() == "2")
  294. {
  295. dr["gongchuang"] = 200;
  296. }
  297. else if ("外协".Equals(dr["ToType"].ToString()))
  298. {
  299. dr["gongchuang"] = 200;
  300. }
  301. else if ("内部".Equals(dr["ToType"].ToString()))
  302. {
  303. dr["gongchuang"] = -1;
  304. }
  305. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  306. {
  307. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  308. dr["gongchuang"] = response.code;
  309. }
  310. }
  311. }
  312. catch (NullReferenceException ex)
  313. {
  314. // 处理空引用异常
  315. dr["refund_fees"] = "0.00";
  316. }
  317. }
  318. }
  319. writeGridDataTableJson(dStruct.TotalCount, dt);
  320. }
  321. public void get_erp_orderlist_sumprice()
  322. {
  323. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  324. return;
  325. List<string> lw = new List<string>();
  326. string tid = GetPostString("ctid");
  327. string date1 = GetPostString("date1");
  328. string date2 = GetPostString("date2");
  329. if (tid.Length > 0 || date1.Length > 0)
  330. {
  331. lw.Add(string.Format("ctid like '%{0}%'", tid));
  332. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  333. if (dw.Length > 0) lw.Add(dw);
  334. }
  335. else
  336. {
  337. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  338. }
  339. string shopname = GetPostString("shopname");
  340. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  341. string buyernick = GetPostString("buyer_nick");
  342. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  343. string customer = GetPostString("customer");
  344. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  345. string design = GetPostString("design");
  346. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  347. string orderState = GetPostString("orderState");
  348. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  349. string address = GetPostString("address");
  350. 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));
  351. string sellermemo = GetPostString("seller_memo");
  352. if (sellermemo.Length > 0)
  353. {
  354. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  355. }
  356. string apdate1 = GetPostString("apdate1");
  357. string apdate2 = GetPostString("apdate2");
  358. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  359. if (dwap.Length > 0) lw.Add(dwap);
  360. string price1 = GetPostString("price1");
  361. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  362. string price2 = GetPostString("price2");
  363. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  364. string isoldcustomer = GetPostString("isoldcus");
  365. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  366. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  367. if (PKey != "admin")
  368. {
  369. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  370. lw.Add(string.Format("shopId in ({0})", usershop));
  371. }
  372. //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";
  373. string mainWhere = string.Join(" and ", lw.ToArray());
  374. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  375. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  376. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  377. decimal total = 0;
  378. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  379. {
  380. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  381. }
  382. var res = new
  383. {
  384. data = total
  385. };
  386. string ro_jsond = JsonConvert.SerializeObject(res);
  387. returnSuccess(ro_jsond);
  388. return;
  389. }
  390. public void get_erp_CustomerServiceGather()
  391. {
  392. string userWhere = "", orderWhere = "";
  393. List<string> lw = new List<string>();
  394. string customer = GetPostString("customer");
  395. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  396. string shopname = GetPostString("shopname");
  397. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  398. string date1 = GetPostString("date1");
  399. string date2 = GetPostString("date2");
  400. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  401. if (dw.Length > 0) lw.Add(dw);
  402. orderWhere = string.Join(" and ", lw.ToArray());
  403. 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 " +
  404. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  405. "left join " +
  406. "( " +
  407. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  408. ") as b on a.ID = b.CustomerUserId " +
  409. "left join " +
  410. "( " +
  411. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  412. ") as d on a.ID = d.CustomerUserId " +
  413. "left join " +
  414. "( " +
  415. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  416. ") as e on a.ID = e.CustomerUserId " +
  417. "left join " +
  418. "( " +
  419. " select CustomerUserId, RefundCount, RefundSum from " +
  420. " ( " +
  421. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  422. " from CE_ErpTradeRefund a " +
  423. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  424. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  425. " group by CustomerUserId " +
  426. " ) as a " +
  427. ") as f on a.ID = f.CustomerUserId " +
  428. "where a.PostCode = 'CustomerService'",
  429. userWhere, orderWhere);
  430. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  431. writeGridDataTableJson(dt.Rows.Count, dt);
  432. //writeGridDataTableJson(dt.Rows.Count, dt);
  433. }
  434. //设计汇总
  435. public void get_erp_DesignerGather()
  436. {
  437. string userWhere = "", orderWhere = "";
  438. List<string> lw = new List<string>();
  439. string Designer = GetPostString("designer");
  440. int org = GetPostInt("org");
  441. if (Designer.Length > 0)
  442. {
  443. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  444. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  445. }
  446. else if (org > 0)
  447. {
  448. userWhere = string.Format(" where OrgID ={0}", org);
  449. }
  450. string shopname = GetPostString("shopname");
  451. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  452. string state = GetPostString("state");
  453. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  454. string OrderArea = GetPostString("order_area");
  455. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  456. string date1 = GetPostString("date1");
  457. string date2 = GetPostString("date2");
  458. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  459. if (dw.Length > 0) lw.Add(dw);
  460. string UpDate1 = GetPostString("UpDate1");
  461. string UpDate2 = GetPostString("UpDate2");
  462. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  463. if (dw.Length > 0) lw.Add(dw);
  464. orderWhere = string.Join(" and ", lw.ToArray());
  465. 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 (" +
  466. "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 " +
  467. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  468. "left join " +
  469. "( " +
  470. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  471. ") as b on a.ID = b.DesignUserId " +
  472. "left join " +
  473. "( " +
  474. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  475. ") as d on a.ID = d.DesignUserId " +
  476. "left join " +
  477. "( " +
  478. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  479. ") as e on a.ID = e.DesignUserId " +
  480. "left join " +
  481. "( " +
  482. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  483. ") as g on a.ID = g.DesignUserId " +
  484. "left join " +
  485. "( " +
  486. " select CustomerUserId, RefundCount, RefundSum from " +
  487. " ( " +
  488. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  489. " from CE_ErpTradeRefund a " +
  490. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  491. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  492. " group by CustomerUserId " +
  493. " ) as a " +
  494. ") as f on a.ID = f.CustomerUserId " +
  495. "where a.PostCode = 'Designer') as z",
  496. userWhere, orderWhere);
  497. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  498. writeGridDataTableJson(dt.Rows.Count, dt);
  499. }
  500. //删除tradecell的订单
  501. public void del_erp_cellorder()
  502. {
  503. if (UrlPostParmsCheck("ctid"))
  504. {
  505. string eid = GetPostString("ctid");
  506. CeErpTradeCell.DelByCtid(eid);
  507. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  508. returnSuccessMsg("删除成功");
  509. }
  510. }
  511. public void clear_erp_refundstate()
  512. {
  513. if (UrlPostParmsCheck("ids"))
  514. {
  515. string eids = GetPostString("ids");
  516. string[] ctidList = eids.Split(',');
  517. foreach (string ctid in ctidList)
  518. {
  519. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  520. if (entity != null)
  521. {
  522. entity.IsRefund = 0;
  523. entity.Update();
  524. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  525. }
  526. else
  527. continue;
  528. }
  529. returnSuccessMsg("操作成功");
  530. return;
  531. }
  532. returnErrorMsg("缺少必要参数");
  533. }
  534. public void set_erp_urgency()
  535. {
  536. if (UrlPostParmsCheck("ctid"))
  537. {
  538. string eid = GetPostString("ctid");
  539. CeErpTradeCell entity = null;
  540. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  541. if (entity != null)
  542. {
  543. double prices = commonHelper.calculationPrice(entity);
  544. if (prices <= 100)
  545. {
  546. returnErrorMsg("此订单金额不足100元,无法加急。");
  547. return;
  548. }
  549. string utime = GetPostString("urgencytime");
  550. if (utime.Length > 0)
  551. {
  552. entity.UrgencyTime = Convert.ToDateTime(utime);
  553. }
  554. else
  555. {
  556. returnErrorMsg("请选择加急时间");
  557. return;
  558. }
  559. if (entity.OrderState <= 4)
  560. {
  561. //entity.seller_memo = entity.seller_memo + "-加急";
  562. string smemo = entity.seller_memo;
  563. int kindex = smemo.IndexOf(")");
  564. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  565. if (lastoneStr != "-")
  566. {
  567. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  568. }
  569. string prememo = smemo.Substring(0, kindex + 2);
  570. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  571. int lastkindex = lastmemo.IndexOf("(");
  572. DateTime urgtime = Convert.ToDateTime(utime);
  573. string newlastmemo = "";
  574. if (lastkindex == 0)
  575. {
  576. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  577. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  578. }
  579. else
  580. {
  581. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  582. }
  583. entity.seller_memo = prememo + newlastmemo;
  584. }
  585. entity.IsUrgency = true;
  586. entity.UpdateTime = DateTime.Now;
  587. entity.Update();
  588. ApiVo apiVo = new ApiVo();
  589. apiVo.orderNumber = entity.ctid;
  590. apiVo.actionName = "changeDesign";
  591. apiVo.orderRemarks = entity.seller_memo;
  592. apiVo.remarkSign = 3;
  593. designHelper.API_WorkCore(apiVo); //changeDesign
  594. CeErpSukuraData.createInfo(entity.ctid, 7);
  595. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  596. returnSuccessMsg("设置成功!");
  597. return;
  598. }
  599. returnErrorMsg("找不到记录");
  600. }
  601. }
  602. public void set_erp_reset()
  603. {
  604. if (UrlPostParmsCheck("ctid"))
  605. {
  606. string eid = GetPostString("ctid");
  607. CeErpTradeCell entity = null;
  608. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  609. if (entity != null)
  610. {
  611. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  612. {
  613. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  614. {
  615. returnErrorMsg("财务要求已下单已发货无法重置");
  616. return;
  617. }
  618. }
  619. entity.IsUrgency = false;
  620. entity.seller_memo = "";
  621. entity.OtherMemo = "";
  622. entity.OrderState = 0;
  623. entity.IsReturn = 0;
  624. //entity.IsRefund = 0;
  625. entity.MemoOpt = 0;
  626. entity.AfterSaleState = 0;
  627. entity.AfterSaleResponsible = "";
  628. entity.AfterSaleUserId = 0;
  629. entity.IsNeedBill = 0;
  630. entity.CustomerUserId = 0;
  631. entity.DesignUserId = 0;
  632. entity.SupplierId = 0;
  633. entity.PlaceUserId = 0;
  634. entity.ptid = "";
  635. entity.IsSample = 0;
  636. entity.IsXianHuo = 0;
  637. entity.isDianziOrder = 0;
  638. entity.DispatchSort = 0;
  639. entity.FinishPlaceTime = null;
  640. entity.Update();
  641. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  642. if (trade != null)
  643. {
  644. trade.seller_memo = "";
  645. trade.Update();
  646. }
  647. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  648. returnSuccessMsg("重置成功!");
  649. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  650. if (desginBill != null)
  651. {
  652. desginBill.isDel = 1;
  653. desginBill.Update();
  654. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  655. }
  656. ApiVo apiVo = new ApiVo();
  657. apiVo.orderNumber = entity.ctid;
  658. apiVo.actionName = "resetDesign";
  659. designHelper.API_WorkCore(apiVo);//resetDesign
  660. return;
  661. }
  662. returnErrorMsg("找不到记录");
  663. }
  664. }
  665. public void save_erp_sellermemo()
  666. {
  667. if (UrlPostParmsCheck("ctid"))
  668. {
  669. string ctid = GetPostString("ctid");
  670. CeErpTradeCell entity = null;
  671. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  672. if (entity != null)
  673. {
  674. string memo = GetPostString("seller_memo");
  675. memo = memo.Replace(" ", "");
  676. if (memo.Contains("补差"))
  677. {
  678. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  679. return;
  680. }
  681. List<string> bitList = new List<string>
  682. {
  683. "\\","/",":","*","?", "\"","<" ,">","|"
  684. };
  685. bool isIn = false;
  686. foreach (string bit in bitList)
  687. {
  688. if (memo.Contains(bit))
  689. {
  690. isIn = true;
  691. }
  692. }
  693. if (isIn)
  694. {
  695. returnErrorMsg("不能使用 一些符合作为文件名");
  696. return;
  697. }
  698. if (entity.seller_memo != memo)
  699. {
  700. if (entity.IsSample == 2)
  701. {
  702. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  703. return;
  704. }
  705. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  706. {
  707. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  708. {
  709. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  710. return;
  711. }
  712. /*if (CurrentUser.UserPost.Post.Code != "Place")
  713. {
  714. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  715. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  716. {
  717. returnErrorMsg("售前系统订单无法再此修改!");
  718. return;
  719. }
  720. }*/
  721. }
  722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  723. }
  724. commonHelper.getCytPrice(entity);
  725. int memoopt = GetPostInt("MemoOpt");
  726. Boolean ismemoopt = false;
  727. if (memoopt > 0)
  728. {
  729. string stropt = "";
  730. if (memoopt == 1)
  731. {
  732. stropt = "“改稿”";
  733. ismemoopt = true;
  734. }
  735. else if (memoopt == 2)
  736. {
  737. stropt = "“定稿”";
  738. }
  739. else if (memoopt == 3)
  740. {
  741. stropt = "“查货”";
  742. CeErpSukuraData.createInfo(entity.ctid, 6);
  743. }
  744. entity.MemoOpt = Convert.ToInt32(memoopt);
  745. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  746. }
  747. if (entity.OrderState < 5)
  748. {
  749. memo = memo.Replace("(", "(");
  750. memo = memo.Replace(")", ")");
  751. }
  752. if (entity.OrderState < 3)
  753. {
  754. entity.DispatchSort = 0;
  755. }
  756. entity.seller_memo = memo;
  757. entity.UpdateTime = DateTime.Now;
  758. entity.Update();
  759. ApiVo apiVo = new ApiVo();
  760. apiVo.orderNumber = entity.ctid;
  761. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  762. apiVo.orderRemarks = memo;
  763. apiVo.remarkSign = memoopt;
  764. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  765. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  766. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  767. {
  768. dataHelper.api_orderBack(entity.ctid, "0", "");
  769. }
  770. if (entity.seller_memo.Contains("改稿"))
  771. {
  772. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  773. }
  774. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  775. returnSuccessMsg("保存成功!");
  776. return;
  777. }
  778. returnErrorMsg("找不到记录");
  779. }
  780. }
  781. public void ins_erp_checkorder()
  782. {
  783. if (UrlPostParmsCheck("ctid"))
  784. {
  785. string ctid = GetPostString("ctid");
  786. CeErpTradeCell entity = null;
  787. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  788. if (entity != null)
  789. {
  790. if (entity.OrderState < 6)
  791. {
  792. returnErrorMsg("下单完成后才可查货");
  793. return;
  794. }
  795. /*if (entity.OrderState > 6)
  796. {
  797. returnErrorMsg("订单已发货");
  798. return;
  799. }*/
  800. if (entity.FinishPlaceTime != null)
  801. {
  802. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  803. {
  804. returnErrorMsg("下单时间不足,无法查货");
  805. return;
  806. }
  807. }
  808. entity.MemoOpt = 3;
  809. entity.CheckOrderTime = DateTime.Now;
  810. entity.UpdateTime = DateTime.Now;
  811. entity.Update();
  812. CeErpSukuraData.createInfo(entity.ctid, 6);
  813. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  814. returnSuccessMsg("操作成功!");
  815. return;
  816. }
  817. returnErrorMsg("找不到记录");
  818. }
  819. }
  820. public void save_erp_othermemo()
  821. {
  822. if (UrlPostParmsCheck("ctid"))
  823. {
  824. string ctid = GetPostString("ctid");
  825. CeErpTradeCell entity = null;
  826. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  827. if (entity != null)
  828. {
  829. entity.OtherMemo = GetPostString("otherMemo");
  830. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  831. {
  832. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  833. StringBuilder sql = new StringBuilder();
  834. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  835. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  836. if (dt != null && dt.Rows.Count > 0)
  837. {
  838. foreach (DataRow dr in dt.Rows)
  839. {
  840. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  841. {
  842. //品类一直
  843. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  844. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  845. if (ceErpSampleCustomer == null)
  846. {
  847. ceErpSampleCustomer = new CeErpSampleCustomer();
  848. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  849. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  850. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  851. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  852. ceErpSampleCustomer.shopId = entity.ShopId;
  853. }
  854. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  855. ceErpSampleCustomer.lastTid = entity.tid;
  856. if (ceErpSampleCustomer.ID > 0)
  857. {
  858. ceErpSampleCustomer.Update();
  859. }
  860. else
  861. {
  862. ceErpSampleCustomer.Create();
  863. }
  864. }
  865. }
  866. }
  867. }
  868. //if (entity.IsOldCustomer == 1)
  869. //{
  870. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  871. //{
  872. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  873. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  874. //}
  875. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  876. //{
  877. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  878. // {
  879. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  880. // {
  881. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  882. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  883. // }
  884. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  885. // {
  886. // entity.OrderState = 2;
  887. // entity.DesignUserId = 0;
  888. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  889. // }
  890. // else
  891. // {
  892. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  893. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  894. // }
  895. // }
  896. //}
  897. //}
  898. entity.UpdateTime = DateTime.Now;
  899. entity.Update();
  900. returnSuccessMsg("保存成功!");
  901. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  902. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  903. if (entity.OtherMemo.Contains("改稿"))
  904. {
  905. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  906. }
  907. return;
  908. }
  909. returnErrorMsg("找不到记录");
  910. }
  911. }
  912. public void save_erp_customermemo()
  913. {
  914. if (UrlPostParmsCheck("ctid"))
  915. {
  916. string ctid = GetPostString("ctid");
  917. CeErpTradeCell entity = null;
  918. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  919. if (entity != null)
  920. {
  921. entity.UpdateTime = DateTime.Now;
  922. entity.CustomerMemo = GetPostString("CustomerMemo");
  923. entity.Update();
  924. ApiVo apiVo = new ApiVo();
  925. apiVo.orderNumber = entity.ctid;
  926. apiVo.actionName = "followRemarks";
  927. apiVo.orderRemarks = entity.CustomerMemo;
  928. designHelper.API_WorkCore(apiVo);//followRemarks
  929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  930. returnSuccessMsg("保存成功!");
  931. return;
  932. }
  933. returnErrorMsg("找不到记录");
  934. }
  935. }
  936. public void upd_erp_addmemotag()
  937. {
  938. if (UrlPostParmsCheck("ctid"))
  939. {
  940. ;
  941. string eid = GetPostString("ctid");
  942. string sfTagstr = GetPostString("memotag");
  943. CeErpTradeCell entity = null;
  944. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  945. if (entity != null)
  946. {
  947. ApiVo apiVo = new ApiVo();
  948. if (entity.OrderState == 0)
  949. {
  950. returnErrorMsg("请先领单");
  951. return;
  952. }
  953. //撤销顺丰
  954. if (sfTagstr == "撤销顺丰")
  955. {
  956. entity.IsSF = 0;
  957. string reMsg = "";
  958. string oldmemo = entity.seller_memo;
  959. if (entity.OrderState < 5)
  960. {
  961. oldmemo = oldmemo.Replace("顺丰到付", "");
  962. oldmemo = oldmemo.Replace("顺丰寄付", "");
  963. entity.seller_memo = oldmemo;
  964. }
  965. else
  966. {
  967. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  968. {
  969. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  970. }
  971. }
  972. entity.Update();
  973. apiVo.orderNumber = entity.ctid;
  974. apiVo.actionName = "orderRemarks";
  975. apiVo.orderRemarks = entity.seller_memo;
  976. apiVo.isSf = entity.IsSF.ToString();
  977. designHelper.API_WorkCore(apiVo);//orderRemarks
  978. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  979. returnSuccessMsg("撤销成功!" + reMsg);
  980. return;
  981. }
  982. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  983. {
  984. //string oldmemo = entity.seller_memo;
  985. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  986. string sfStr = GetPostString("memotag");
  987. string smemo = entity.seller_memo;
  988. int kindex = smemo.IndexOf(")");
  989. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  990. if (lastoneStr != "-")
  991. {
  992. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  993. }
  994. string prememo = smemo.Substring(0, kindex + 2);
  995. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  996. int lastkindex = lastmemo.IndexOf("(");
  997. string newlastmemo = "";
  998. if (lastkindex == 0)
  999. {
  1000. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1001. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1002. }
  1003. else
  1004. {
  1005. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1006. }
  1007. entity.seller_memo = prememo + newlastmemo;
  1008. }
  1009. string sfTagMSg = "";
  1010. if (sfTagstr == "顺丰寄付")
  1011. {
  1012. entity.IsSF = 1;
  1013. sfTagMSg = "顺丰寄付";
  1014. }
  1015. else if (sfTagstr == "顺丰到付")
  1016. {
  1017. entity.IsSF = 2;
  1018. sfTagMSg = "顺丰到付";
  1019. }
  1020. entity.Update();
  1021. apiVo = new ApiVo();
  1022. apiVo.orderNumber = entity.ctid;
  1023. apiVo.actionName = "orderRemarks";
  1024. apiVo.orderRemarks = entity.seller_memo;
  1025. apiVo.isSf = entity.IsSF.ToString();
  1026. designHelper.API_WorkCore(apiVo);//orderRemarks
  1027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1028. returnSuccessMsg("标记成功!");
  1029. return;
  1030. }
  1031. returnErrorMsg("找不到记录");
  1032. }
  1033. }
  1034. public void upd_erp_ordertag()
  1035. {
  1036. if (UrlPostParmsCheck("ctid"))
  1037. {
  1038. string eid = GetPostString("ctid");
  1039. CeErpTradeCell entity = null;
  1040. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1041. if (entity != null)
  1042. {
  1043. int tag = GetPostInt("wechattag");
  1044. //if(tag==4 && entity.IsSample == 2)
  1045. //{
  1046. // returnErrorMsg("补差价单不能标记微信单");
  1047. // return;
  1048. //}
  1049. entity.wechatTag = tag;
  1050. entity.Update();
  1051. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1052. if (tag == 1)
  1053. {
  1054. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1055. if (cash == null)
  1056. {
  1057. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1058. cash = new CeErpReturnCash();
  1059. cash.tid = entity.tid;
  1060. cash.seller_nick = main.seller_nick;
  1061. cash.payment = trade.payment;
  1062. cash.buyer_nick = main.buyer_nick;
  1063. cash.cashstate = 0;
  1064. cash.rtype = "微信返现";
  1065. cash.returnprice = 0;
  1066. cash.created = DateTime.Now;
  1067. cash.con = "订单标记微信单";
  1068. cash.img = "";
  1069. cash.applyuserid = CurrentUser.UserID;
  1070. cash.Create();
  1071. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1072. }
  1073. else
  1074. {
  1075. cash.cashstate = 0;
  1076. cash.Update();
  1077. }
  1078. CeErpSukuraData.createInfo(entity.ctid, 9);
  1079. }
  1080. else if (tag == 2)
  1081. {
  1082. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1083. if (cash == null)
  1084. {
  1085. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1086. cash = new CeErpReturnCash();
  1087. cash.tid = entity.tid;
  1088. cash.seller_nick = main.seller_nick;
  1089. cash.payment = trade.payment;
  1090. cash.buyer_nick = main.buyer_nick;
  1091. cash.cashstate = 0;
  1092. cash.rtype = "推购返现";
  1093. cash.returnprice = 5;
  1094. cash.created = DateTime.Now;
  1095. cash.con = "订单标记推购单";
  1096. cash.img = "";
  1097. cash.applyuserid = CurrentUser.UserID;
  1098. cash.Create();
  1099. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1100. }
  1101. else
  1102. {
  1103. cash.cashstate = 0;
  1104. cash.Update();
  1105. }
  1106. CeErpSukuraData.createInfo(entity.ctid, 9);
  1107. }
  1108. else if (tag == 3)
  1109. {
  1110. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1111. if (pers == null)
  1112. {
  1113. pers = new CeErpPersuade();
  1114. pers.ctid = entity.ctid;
  1115. pers.pstate = 0;
  1116. pers.created = DateTime.Now;
  1117. pers.applyuserid = CurrentUser.UserID;
  1118. pers.Create();
  1119. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1120. }
  1121. else
  1122. {
  1123. pers.pstate = 0;
  1124. pers.Update();
  1125. }
  1126. }
  1127. else if (tag == 4 || tag == 5)
  1128. {
  1129. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1130. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1131. if (pers == null)
  1132. {
  1133. pers = new CeErpStayGoods();
  1134. pers.t_id = entity.tid;
  1135. pers.status = "待审核";
  1136. pers.audit_type = 0;
  1137. if (tag == 4)
  1138. {
  1139. pers.stay_type = "微信推购";
  1140. }
  1141. else
  1142. {
  1143. pers.stay_type = "旺旺推购";
  1144. }
  1145. if (entity.IsXianHuo == 0)
  1146. {
  1147. pers.product_id = entity.ProductId;
  1148. }
  1149. pers.wangwang = main.buyer_nick;
  1150. pers.shop_name = main.seller_nick;
  1151. pers.creata_time = DateTime.Now;
  1152. pers.create_u_id = CurrentUser.UserID;
  1153. pers.create_u_name = CurrentUser.UserName;
  1154. pers.Create();
  1155. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1156. }
  1157. else
  1158. {
  1159. pers.audit_type = 0;
  1160. pers.Update();
  1161. }
  1162. CeErpSukuraData.createInfo(entity.ctid, 10);
  1163. }
  1164. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1165. returnSuccessMsg("标记成功!");
  1166. return;
  1167. }
  1168. returnErrorMsg("找不到记录");
  1169. }
  1170. }
  1171. public void upd_erp_ordertag_cancel()
  1172. {
  1173. if (UrlPostParmsCheck("ctid"))
  1174. {
  1175. string eid = GetPostString("ctid");
  1176. CeErpTradeCell entity = null;
  1177. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1178. if (entity != null)
  1179. {
  1180. entity.wechatTag = 0;
  1181. entity.Update();
  1182. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1183. if (pers != null)
  1184. {
  1185. pers.status = "取消推购";
  1186. pers.audit_type = 3;
  1187. pers.Update();
  1188. }
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1190. returnSuccessMsg("标记成功!");
  1191. return;
  1192. }
  1193. returnErrorMsg("找不到记录");
  1194. }
  1195. }
  1196. public void upd_erp_addweichattag()
  1197. {
  1198. if (UrlPostParmsCheck("ctid"))
  1199. {
  1200. ;
  1201. string eid = GetPostString("ctid");
  1202. CeErpTradeCell entity = null;
  1203. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1204. if (entity != null)
  1205. {
  1206. if (entity.IsAddWechat > 0)
  1207. {
  1208. returnErrorMsg("此单已经标记过了");
  1209. return;
  1210. }
  1211. 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);
  1212. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1213. if (dt.Rows.Count > 0)
  1214. {
  1215. entity.IsAddWechat = 2;
  1216. }
  1217. else
  1218. {
  1219. entity.IsAddWechat = 1;
  1220. }
  1221. entity.Update();
  1222. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1223. returnSuccessMsg("标记成功!");
  1224. return;
  1225. }
  1226. returnErrorMsg("找不到记录");
  1227. }
  1228. }
  1229. public void upd_erp_getmyorder()
  1230. {
  1231. if (UrlPostParmsCheck("ctid"))
  1232. {
  1233. ;
  1234. string eid = GetPostString("ctid");
  1235. CeErpTradeCell entity = null;
  1236. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1237. if (entity != null)
  1238. {
  1239. if (entity.ctid.IndexOf("C") != -1)
  1240. {
  1241. StringBuilder sql = new StringBuilder();
  1242. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1243. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1244. if (dt.Rows.Count > 0)
  1245. {
  1246. decimal total = 0;
  1247. foreach (DataRow dr in dt.Rows)
  1248. {
  1249. total += Convert.ToDecimal(dr["payment"]);
  1250. }
  1251. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1252. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1253. {
  1254. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1255. return;
  1256. }
  1257. }
  1258. }
  1259. if (entity.OrderState == -1)
  1260. {
  1261. returnErrorMsg("待审核订单无法领取!");
  1262. return;
  1263. }
  1264. entity.CustomerUserId = CurrentUser.UserID;
  1265. if (entity.OrderState < 2)
  1266. {
  1267. entity.OrderState = 2;
  1268. if (entity.ShopId != 0)
  1269. {
  1270. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1271. }
  1272. }
  1273. entity.UpdateTime = DateTime.Now;
  1274. entity.Update();
  1275. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1276. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1277. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1278. {
  1279. dataHelper.api_orderBack(entity.ctid, "0", "");
  1280. }
  1281. returnSuccessMsg("领单成功!");
  1282. return;
  1283. }
  1284. returnErrorMsg("找不到记录");
  1285. }
  1286. }
  1287. public void getmyorder_from_init()
  1288. {
  1289. if (UrlPostParmsCheck("ctid"))
  1290. {
  1291. string eid = GetPostString("ctid");
  1292. CeErpTradeCell entity = null;
  1293. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1294. if (entity != null)
  1295. {
  1296. string sellerMemo = GetPostString("sellerMemo");
  1297. if (sellerMemo.Length > 0)
  1298. {
  1299. entity.seller_memo = sellerMemo;
  1300. }
  1301. string oterhMemo = GetPostString("otherMemo");
  1302. if (oterhMemo.Length > 0)
  1303. {
  1304. entity.OtherMemo = oterhMemo;
  1305. }
  1306. int urg = GetPostInt("urgency");
  1307. entity.IsUrgency = (urg == 1 ? true : false);
  1308. int wechat = GetPostInt("wechat");
  1309. int command = GetPostInt("command");
  1310. if (wechat == 1)
  1311. {
  1312. entity.wechatTag = 1;
  1313. }
  1314. if (command == 1)
  1315. {
  1316. entity.wechatTag = 2;
  1317. }
  1318. string pPro = GetPostString("pprofession");
  1319. if (pPro.Length > 0)
  1320. {
  1321. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1322. string spro = GetPostString("profession");
  1323. if (spro.Length > 0)
  1324. {
  1325. entity.ProfessionId = Convert.ToInt32(spro);
  1326. }
  1327. }
  1328. string proId = GetPostString("productId");
  1329. if (proId.Length > 0)
  1330. {
  1331. entity.ProductId = Convert.ToInt32(proId);
  1332. }
  1333. entity.Material = GetPostString("material");
  1334. entity.Craft = GetPostString("craft");
  1335. entity.CustomerUserId = CurrentUser.UserID;
  1336. if (entity.OrderState < 2)
  1337. {
  1338. entity.OrderState = 2;
  1339. if (entity.ShopId != 0)
  1340. {
  1341. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1342. }
  1343. }
  1344. entity.Update();
  1345. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1346. returnSuccessMsg("领单成功!");
  1347. return;
  1348. }
  1349. returnErrorMsg("找不到记录");
  1350. }
  1351. }
  1352. public void upd_erp_setrelationorder()
  1353. {
  1354. if (UrlPostParmsCheck("ctid"))
  1355. {
  1356. ;
  1357. string eid = GetPostString("ctid");
  1358. string ftid = GetPostString("ftid");
  1359. CeErpTradeCell entity = null;
  1360. CeErpTradeCell fentity = null;
  1361. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1362. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1363. if (fentity == null)
  1364. {
  1365. returnErrorMsg("找不到关联的主订单");
  1366. return;
  1367. }
  1368. if (entity != null)
  1369. {
  1370. if (entity.OrderState >= 5)
  1371. {
  1372. returnErrorMsg("本单已经设计完成无法关联");
  1373. return;
  1374. }
  1375. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1376. {
  1377. returnErrorMsg("线下单续审核后才能关联!");
  1378. return;
  1379. }
  1380. entity.ptid = ftid;
  1381. entity.OrderState = fentity.OrderState;
  1382. //entity.status = fentity.status;
  1383. entity.CustomerUserId = fentity.CustomerUserId;
  1384. entity.DesignUserId = fentity.DesignUserId;
  1385. entity.seller_memo = "补差价单:" + ftid;
  1386. entity.IsSample = 2;
  1387. entity.Update();
  1388. ApiVo apiVo = new ApiVo();
  1389. apiVo.orderNumber = ftid;
  1390. apiVo.payment = entity.payment;
  1391. apiVo.actionName = "repairDesign";
  1392. designHelper.API_WorkCore(apiVo);//repairDesign
  1393. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1394. returnSuccessMsg("关联成功!");
  1395. return;
  1396. }
  1397. else
  1398. returnErrorMsg("找不到记录");
  1399. }
  1400. }
  1401. public void download_erp_neworder()
  1402. {
  1403. string seller = GetPostString("seller_nick");
  1404. string tid = GetPostString("tid");
  1405. if (seller.Length <= 0 || tid.Length <= 0)
  1406. {
  1407. returnErrorMsg("数据错误");
  1408. }
  1409. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1410. //{
  1411. // returnErrorMsg("找不到店铺Sessionkey");
  1412. //}
  1413. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1414. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1415. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1416. if (res.IndexOf("refOid") == -1)
  1417. {
  1418. returnErrorMsg("下载订单数据失败");
  1419. return;
  1420. }
  1421. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1422. returnSuccessMsg("下载完成");
  1423. //tmcHelper.createNewOrder(res);
  1424. //CeErpTrade entr = null;
  1425. //entr = CeErpTrade.Get(tid);
  1426. //if (entr != null)
  1427. //{
  1428. // returnSuccess("下载成功");
  1429. // //下载成功之后,Cell表生成对应的订单;
  1430. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1431. //}
  1432. //else
  1433. //{
  1434. // returnErrorMsg("下载失败或者创建订单失败");
  1435. //}
  1436. }
  1437. public void set_erp_atersale()
  1438. {
  1439. if (UrlPostParmsCheck("ctid"))
  1440. {
  1441. string eid = GetPostString("ctid");
  1442. string reason = GetPostString("AfterSaleReason");
  1443. CeErpTradeCell entity = null;
  1444. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1445. if (entity != null)
  1446. {
  1447. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1448. {
  1449. returnErrorMsg("此订单已经在售后");
  1450. return;
  1451. }
  1452. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1453. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1454. entity.AfterSaleTime = DateTime.Now;
  1455. entity.Update();
  1456. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1457. returnSuccessMsg("转售后成功!");
  1458. return;
  1459. }
  1460. returnErrorMsg("找不到记录");
  1461. }
  1462. }
  1463. public void set_erp_withdraw()
  1464. {
  1465. if (UrlPostParmsCheck("ctid"))
  1466. {
  1467. try
  1468. {
  1469. string eid = GetPostString("ctid");//商品id
  1470. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1471. CeWithdraw ceWithdrawSelect = null;
  1472. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1473. if (ceWithdrawSelect != null)
  1474. {
  1475. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1476. {
  1477. ceWithdrawSelect.status = -1;
  1478. ceWithdrawSelect.Update();
  1479. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1480. returnSuccessMsg("重新发起审核成功");
  1481. return;
  1482. }
  1483. else
  1484. {
  1485. returnSuccessMsg("请勿重复申请!");
  1486. return;
  1487. }
  1488. }
  1489. else
  1490. {
  1491. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1492. if (string.IsNullOrEmpty(CustomerUserId))
  1493. {
  1494. CustomerUserId = "-1";
  1495. }
  1496. int Userid = CurrentUser.UserID;//用户id
  1497. CeWithdraw ceWithdraw = new CeWithdraw();
  1498. ceWithdraw.tid = eid;
  1499. ceWithdraw.userid = Userid;
  1500. ceWithdraw.providerid = CustomerUserId;
  1501. ceWithdraw.status = 3;
  1502. ceWithdraw.creationtime = DateTime.Now;
  1503. ceWithdraw.Create();
  1504. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1505. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1506. return;
  1507. }
  1508. }
  1509. catch
  1510. {
  1511. returnErrorMsg("申请撤回订单失败");
  1512. return;
  1513. }
  1514. }
  1515. }
  1516. public void ins_erp_billinfo()
  1517. {
  1518. if (UrlPostParmsCheck("ctid"))
  1519. {
  1520. string eid = GetPostString("ctid");
  1521. CeErpTradeCell entity = null;
  1522. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1523. if (entity != null)
  1524. {
  1525. CeErpBill bill = CeErpBill.GetByTid(eid);
  1526. bool isHave = false;
  1527. if (bill != null)
  1528. {
  1529. isHave = true;
  1530. if (bill.state != 4)
  1531. {
  1532. returnErrorMsg("此单已经申请过发票了");
  1533. return;
  1534. }
  1535. }
  1536. if (entity.IsNeedBill == 0)
  1537. {
  1538. entity.IsNeedBill = 1;
  1539. }
  1540. entity.Update();
  1541. string errjson = "";
  1542. try
  1543. {
  1544. CeErpBill bill_entity = new CeErpBill();
  1545. bill_entity.tid = entity.tid;
  1546. bill_entity.title = GetPostString("title");
  1547. string taxstr = GetPostString("tax");
  1548. taxstr = taxstr.Replace(" ", "");
  1549. bill_entity.tax = taxstr;
  1550. bill_entity.bank = GetPostString("bank");
  1551. string bankacstr = GetPostString("bankac");
  1552. bankacstr = bankacstr.Replace(" ", "");
  1553. bill_entity.bankac = bankacstr;
  1554. bill_entity.address = GetPostString("address");
  1555. bill_entity.phone = GetPostString("phone");
  1556. bill_entity.price = GetPostString("price");
  1557. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1558. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1559. {
  1560. billCount += 1;
  1561. }
  1562. string prebill = "ltb";
  1563. for (int idx = 1; idx <= billCount; idx++)
  1564. {
  1565. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1566. string billoid = prebill + idx + dtstr;
  1567. bill_entity.billOrderId += billoid;
  1568. if (idx < billCount)
  1569. {
  1570. bill_entity.billOrderId += ",";
  1571. }
  1572. }
  1573. bill_entity.productId = GetPostInt("ProductName");
  1574. bill_entity.num = GetPostInt("num");
  1575. bill_entity.unit = GetPostString("unit");
  1576. bill_entity.type = GetPostString("type");
  1577. bill_entity.sendType = GetPostString("SendType");
  1578. bill_entity.email = GetPostString("email");
  1579. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1580. bill_entity.shopName = GetPostString("ShopName");
  1581. bill_entity.applymemo = GetPostString("applyMemo");
  1582. bill_entity.createTime = DateTime.Now;
  1583. bill_entity.state = 0;
  1584. bill_entity.userId = CurrentUser.UserID;
  1585. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1586. bill_entity.Create();
  1587. }
  1588. catch (Exception ex)
  1589. {
  1590. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1591. returnErrorMsg("创建发票出错!");
  1592. return;
  1593. }
  1594. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1595. returnSuccessMsg("发票申请成功!");
  1596. return;
  1597. }
  1598. returnErrorMsg("找不到记录");
  1599. }
  1600. }
  1601. public void ins_erp_neworder()
  1602. {
  1603. if (UrlPostParmsCheck("receiver_name"))
  1604. {
  1605. CeErpTrade entity = new CeErpTrade();
  1606. string plat_form = GetPostString("platform");
  1607. string preStr = "N_";
  1608. if (plat_form == "拼多多")
  1609. {
  1610. preStr = "P_";
  1611. }
  1612. else if (plat_form == "阿里巴巴")
  1613. {
  1614. preStr = "A_";
  1615. }
  1616. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1617. entity.seller_nick = GetPostString("seller_nick");
  1618. entity.buyer_nick = GetPostString("buyer_nick");
  1619. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1620. entity.total_fee = entity.payment;
  1621. entity.pay_time = DateTime.Now;
  1622. entity.status = "NOT_SHIPPED";
  1623. entity.receiver_name = GetPostString("receiver_name");
  1624. entity.receiver_mobile = GetPostString("receiver_mobile");
  1625. entity.receiver_state = GetPostString("receiver_state");
  1626. entity.receiver_city = GetPostString("receiver_city");
  1627. entity.receiver_district = GetPostString("receiver_district");
  1628. entity.receiver_address = GetPostString("receiver_address");
  1629. if (entity.receiver_state == "" || entity.receiver_city == "")
  1630. {
  1631. returnErrorMsg("收件地址不能为空");
  1632. return;
  1633. }
  1634. int shopId = 0;
  1635. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1636. if (nShop != null)
  1637. {
  1638. shopId = nShop.ID;
  1639. }
  1640. if (shopId != 34 && entity.payment == 0)
  1641. {
  1642. returnErrorMsg("公司自用的单金额才能为0");
  1643. return;
  1644. }
  1645. entity.Create();
  1646. CeErpTradeCell entitycell = new CeErpTradeCell();
  1647. entitycell.ctid = entity.tid;
  1648. entitycell.tid = entity.tid;
  1649. entitycell.ShopId = shopId;
  1650. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1651. entitycell.OrderState = 0;
  1652. entitycell.pay_time = entity.pay_time;
  1653. entitycell.IsOffLineOrder = 1;
  1654. entitycell.Create();
  1655. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1656. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1657. return;
  1658. }
  1659. }
  1660. public void ins_erp_neworder2()
  1661. {
  1662. if (UrlPostParmsCheck("receiver_name"))
  1663. {
  1664. //string plat_form = GetPostString("platform");
  1665. string preStr = "X_";
  1666. string memo = GetPostString("memo");
  1667. string productId = GetPostString("productId");
  1668. string primg = GetPostString("proofimg");
  1669. string sellerNick = GetPostString("seller_nick");
  1670. string addFrom = GetPostString("addfrom");
  1671. if (addFrom == "1")
  1672. {
  1673. preStr = "N_";
  1674. }
  1675. int shopId = 0;
  1676. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1677. if (nShop != null)
  1678. {
  1679. shopId = nShop.ID;
  1680. }
  1681. else
  1682. {
  1683. returnErrorMsg("找不到对应店铺");
  1684. return;
  1685. }
  1686. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1687. {
  1688. returnErrorMsg("必须上传付款凭证");
  1689. return;
  1690. }
  1691. CeErpTrade entity = new CeErpTrade();
  1692. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1693. entity.seller_nick = sellerNick;
  1694. entity.buyer_nick = GetPostString("buyer_nick");
  1695. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1696. entity.total_fee = entity.payment;
  1697. entity.pay_time = DateTime.Now;
  1698. entity.status = "NOT_SHIPPED";
  1699. entity.receiver_name = GetPostString("receiver_name");
  1700. entity.receiver_mobile = GetPostString("receiver_mobile");
  1701. entity.receiver_state = GetPostString("receiver_state");
  1702. entity.receiver_city = GetPostString("receiver_city");
  1703. entity.receiver_district = GetPostString("receiver_district");
  1704. entity.receiver_address = GetPostString("receiver_address");
  1705. entity.seller_memo = memo;
  1706. entity.orderFrom = 20;
  1707. entity.orderType = 15;
  1708. if (entity.receiver_state == "" || entity.receiver_city == "")
  1709. {
  1710. returnErrorMsg("收件地址不能为空");
  1711. return;
  1712. }
  1713. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1714. {
  1715. returnErrorMsg("公司自用的单金额才能为0");
  1716. return;
  1717. }
  1718. entity.Create();
  1719. string toWhere = GetPostString("towhere");
  1720. CeErpTradeCell entitycell = new CeErpTradeCell();
  1721. entitycell.ctid = entity.tid;
  1722. //唯一标识
  1723. entitycell.OrderSn = entity.tid;
  1724. string orderSn = dataHelper.getSaleOrderSn();
  1725. if (orderSn != "")
  1726. {
  1727. entitycell.OrderSn = orderSn;
  1728. }
  1729. entitycell.tid = entity.tid;
  1730. //if (preStr == "X_")
  1731. //{
  1732. entitycell.IsOffLineOrder = 1;
  1733. //}
  1734. entitycell.CustomerUserId = CurrentUser.UserID;
  1735. entitycell.PayProofImg = primg;
  1736. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1737. entitycell.ProductId = Convert.ToInt32(productId);
  1738. entitycell.ShopId = shopId;
  1739. entitycell.UpdateTime = DateTime.Now;
  1740. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1741. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1742. {
  1743. entitycell.IsXianHuo = 1;
  1744. }
  1745. entitycell.pay_time = entity.pay_time;
  1746. if (toWhere == "1")
  1747. {
  1748. entitycell.OrderState = 2;
  1749. }
  1750. else
  1751. {
  1752. entitycell.OrderState = 6;
  1753. entitycell.FinishPlaceTime = entitycell.pay_time;
  1754. }
  1755. if (shopId == 94)
  1756. {
  1757. entitycell.OrderState = 4;
  1758. entitycell.WaitDesignTime = entitycell.pay_time;
  1759. entitycell.StartDesignTime = entitycell.pay_time;
  1760. entitycell.DesignUserId = 218;
  1761. }
  1762. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1763. {
  1764. entitycell.OrderState = -1;//修改12-5
  1765. CeWithdraw ceWithdraw = new CeWithdraw();
  1766. ceWithdraw.tid = entity.tid;
  1767. ceWithdraw.providerid = "-1";
  1768. ceWithdraw.status = -1;
  1769. ceWithdraw.creationtime = DateTime.Now;
  1770. ceWithdraw.userid = 1337;
  1771. ceWithdraw.Create();
  1772. }
  1773. entitycell.Create();
  1774. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1775. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1776. {
  1777. addPlaceRegist(entitycell, CurrentUser.UserID);
  1778. }
  1779. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1780. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1781. return;
  1782. }
  1783. }
  1784. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1785. {
  1786. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1787. entity.PlactTime = tradecell.pay_time;
  1788. entity.AddUserId = userid;
  1789. entity.FileName = tradecell.seller_memo;
  1790. entity.Supplier = 24;
  1791. entity.CreateTime = DateTime.Now;
  1792. entity.Did = tradecell.ctid;
  1793. entity.tid = tradecell.tid;
  1794. entity.splitTag = tradecell.SplitTag;
  1795. entity.CurState = "未完成";
  1796. entity.Create();
  1797. }
  1798. public void get_erp_offlinelist()
  1799. {
  1800. DataStruct dStruct = GetPostStruct();
  1801. List<string> lw = new List<string>();
  1802. string tid = GetPostString("ctid");
  1803. string date1 = GetPostString("date1");
  1804. string date2 = GetPostString("date2");
  1805. if (tid.Length > 0 || date1.Length > 0)
  1806. {
  1807. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1808. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1809. if (dw.Length > 0) lw.Add(dw);
  1810. }
  1811. else
  1812. {
  1813. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1814. }
  1815. string shopname = GetPostString("shopname");
  1816. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1817. string buyernick = GetPostString("buyer_nick");
  1818. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1819. string customer = GetPostString("customer");
  1820. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1821. string design = GetPostString("design");
  1822. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1823. string orderState = GetPostString("orderState");
  1824. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1825. string address = GetPostString("address");
  1826. 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));
  1827. string sellermemo = GetPostString("seller_memo");
  1828. if (sellermemo.Length > 0)
  1829. {
  1830. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1831. }
  1832. string price1 = GetPostString("price1");
  1833. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1834. string price2 = GetPostString("price2");
  1835. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1836. //if (PKey != "admin")
  1837. //{
  1838. // string usershop = CurrentUser.User.pemShop;
  1839. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1840. //}
  1841. //if (ex_psize > 0)
  1842. //{
  1843. dStruct.Order = "pay_time desc";
  1844. //}
  1845. //else
  1846. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1847. lw.Add(string.Format("IsOffLineOrder=1"));
  1848. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1849. DataTable dt = null;
  1850. dt = WebCache.GetData("view_erptradecell", dStruct);
  1851. writeGridDataTableJson(dStruct.TotalCount, dt);
  1852. }
  1853. public void get_erp_returncashrecord()
  1854. {
  1855. DataStruct dStruct = GetPostStruct();
  1856. List<string> lw = new List<string>();
  1857. string tid = GetPostString("ctid");
  1858. if (tid.Length > 0)
  1859. {
  1860. lw.Add(string.Format("tid like '%{0}%'", tid));
  1861. dStruct.Order = "id desc";
  1862. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1863. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1864. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1865. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1866. return;
  1867. }
  1868. returnErrorMsg("id数据错误!");
  1869. }
  1870. public void ins_erp_returncashrecord()
  1871. {
  1872. if (UrlPostParmsCheck("tid"))
  1873. {
  1874. string tid = GetPostString("tid");
  1875. string retype = GetPostString("type");
  1876. StringBuilder sql = new StringBuilder();
  1877. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1878. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1879. if (dt.Rows.Count > 0)
  1880. {
  1881. returnErrorMsg("相同返现类型记录已存在");
  1882. return;
  1883. }
  1884. CeErpReturnCash entity = new CeErpReturnCash();
  1885. entity.tid = tid;
  1886. entity.seller_nick = GetPostString("seller_nick");
  1887. string pment = GetPostString("payment");
  1888. if (pment.Length > 0)
  1889. {
  1890. entity.payment = Convert.ToDouble(pment);
  1891. }
  1892. entity.buyer_nick = GetPostString("buyer_nick");
  1893. entity.cashstate = 0;
  1894. entity.rtype = retype;
  1895. string rPrice = GetPostString("returnprice");
  1896. if (rPrice.Length > 0)
  1897. {
  1898. entity.returnprice = Convert.ToDouble(rPrice);
  1899. }
  1900. entity.created = DateTime.Now;
  1901. entity.con = GetPostString("con");
  1902. entity.img = GetPostString("img");
  1903. entity.applyuserid = CurrentUser.UserID;
  1904. entity.Create();
  1905. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1906. returnSuccessMsg("操作成功!");
  1907. return;
  1908. }
  1909. }
  1910. public void set_erp_predelivery()
  1911. {
  1912. if (UrlPostParmsCheck("ctid"))
  1913. {
  1914. string eid = GetPostString("ctid");
  1915. CeErpTradeCell entity = null;
  1916. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1917. if (entity != null)
  1918. {
  1919. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1920. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1921. //{
  1922. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1923. // return;
  1924. //}
  1925. entity.IsPreDelivery = 1;
  1926. entity.Update();
  1927. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1928. returnSuccessMsg("预发货成功!");
  1929. return;
  1930. //string shop = GetPostString("seller_nick");
  1931. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1932. //string comName = GetPostString("comName");
  1933. //string comCode = GetPostString("comCode");
  1934. //string outSid = GetPostString("outSid");//运单号
  1935. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1936. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1937. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1938. //string apires = "";
  1939. //if (deliveryType == "虚拟发货")
  1940. //{
  1941. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1942. //}
  1943. //else
  1944. //{
  1945. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1946. //}
  1947. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1948. ////{
  1949. //if (apires.IndexOf("发货成功") != -1)
  1950. //{
  1951. // if (deliveryType != "虚拟发货")
  1952. // {
  1953. // //还要插入快递信息到 快递信息表
  1954. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1955. // exinfo.tid = eid;
  1956. // exinfo.out_sid = outSid;
  1957. // exinfo.company_code = comCode;
  1958. // exinfo.company_name = comName;
  1959. // exinfo.delivery_memo = deliveryMemo;
  1960. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1961. // exinfo.deliveryType = deliveryType;
  1962. // exinfo.Create();
  1963. // }
  1964. // returnSuccessMsg("发货成功!");
  1965. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1966. //}
  1967. //else
  1968. //{
  1969. // returnErrorMsg("淘宝发货失败!!");
  1970. //}
  1971. //return;
  1972. }
  1973. returnErrorMsg("找不到订单记录");
  1974. }
  1975. }
  1976. public void get_erp_unusuallist()
  1977. {
  1978. DataStruct dStruct = GetPostStruct();
  1979. List<string> lw = new List<string>();
  1980. string tid = GetPostString("ctid");
  1981. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1982. string shopname = GetPostString("shopname");
  1983. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1984. string buyernick = GetPostString("buyer_nick");
  1985. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1986. string ResponsibleMan = GetPostString("responsible");
  1987. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1988. string date1 = GetPostString("date1");
  1989. string date2 = GetPostString("date2");
  1990. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1991. if (dw.Length > 0) lw.Add(dw);
  1992. string price1 = GetPostString("price1");
  1993. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1994. string price2 = GetPostString("price2");
  1995. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1996. string orderState = GetPostString("orderState");
  1997. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1998. string sellermemo = GetPostString("seller_memo");
  1999. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2000. lw.Add(string.Format("UnusualTag > 0"));
  2001. lw.Add(string.Format("IsRefund<={0}", 1));
  2002. dStruct.Order = "pay_time desc";
  2003. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2004. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2005. writeGridDataTableJson(dStruct.TotalCount, dt);
  2006. }
  2007. public void set_erp_unusualtonomal()
  2008. {
  2009. if (UrlPostParmsCheck("ctid"))
  2010. {
  2011. string eid = GetPostString("ctid");
  2012. CeErpTradeCell entity = null;
  2013. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2014. if (entity != null)
  2015. {
  2016. entity.UnusualTag = -1;
  2017. entity.Update();
  2018. returnSuccessMsg("忽略成功!");
  2019. return;
  2020. }
  2021. returnErrorMsg("找不到记录");
  2022. }
  2023. }
  2024. public void ins_erp_unusualreason()
  2025. {
  2026. if (UrlPostParmsCheck("ctid"))
  2027. {
  2028. string eid = GetPostString("ctid");
  2029. CeErpTradeCell entity = null;
  2030. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2031. if (entity != null)
  2032. {
  2033. entity.MemoOpt = 4;
  2034. entity.UnusualCon = GetPostString("con");
  2035. entity.Update();
  2036. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2037. if (trade != null)
  2038. {
  2039. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2040. }
  2041. //查货是否超时
  2042. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2043. if (ceErpTradeCellExtend == null)
  2044. {
  2045. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2046. ceErpTradeCellExtend.ctid = entity.ctid;
  2047. }
  2048. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2049. {
  2050. ceErpTradeCellExtend.CheckOut += 1;
  2051. }
  2052. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2053. if (ceErpTradeCellExtend.ID > 0)
  2054. {
  2055. ceErpTradeCellExtend.Update();
  2056. }
  2057. else
  2058. {
  2059. ceErpTradeCellExtend.Create();
  2060. }
  2061. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2062. returnSuccessMsg("操作成功!");
  2063. return;
  2064. }
  2065. returnErrorMsg("找不到记录");
  2066. }
  2067. }
  2068. public void upd_erp_sampleorder()
  2069. {
  2070. if (UrlPostParmsCheck("ctid"))
  2071. {
  2072. string eid = GetPostString("ctid");
  2073. string[] eArr = eid.Split(',');
  2074. if (eArr.Length > 1)
  2075. {
  2076. List<string> eLst = new List<string>();
  2077. for (int i = 0; i < eArr.Length; i++)
  2078. {
  2079. eLst.Add("'" + eArr[i] + "'");
  2080. }
  2081. eid = string.Join(",", eLst.ToArray());
  2082. }
  2083. else
  2084. {
  2085. eid = "'" + eid + "'";
  2086. }
  2087. StringBuilder sql = new StringBuilder();
  2088. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2089. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2090. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2091. if (dt.Rows.Count > 0)
  2092. {
  2093. string errmsg = "";
  2094. foreach (DataRow dr in dt.Rows)
  2095. {
  2096. StringBuilder sqlsb = new StringBuilder();
  2097. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2098. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2099. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2100. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2101. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2102. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2103. {
  2104. continue;
  2105. }
  2106. else
  2107. {
  2108. string emsg = commonHelper.KeepChinese(apires);
  2109. errmsg += emsg;
  2110. }
  2111. }
  2112. if (errmsg.Length > 0)
  2113. {
  2114. returnErrorMsg(errmsg);
  2115. return;
  2116. }
  2117. returnSuccessMsg("操作成功");
  2118. return;
  2119. }
  2120. returnErrorMsg("找不到记录");
  2121. }
  2122. }
  2123. public void upd_erp_transcustomer()
  2124. {
  2125. if (UrlPostParmsCheck("ctid"))
  2126. {
  2127. string eid = GetPostString("ctid");
  2128. int userid = GetPostInt("CustomerUserId");
  2129. CeErpTradeCell entity = null;
  2130. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2131. if (entity != null)
  2132. {
  2133. //string[] mlist = entity.seller_memo.Split('-');
  2134. //string sql = "select * from view_erpuser where id=" + userid;
  2135. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2136. //if (dt != null && dt.Rows.Count > 0)
  2137. //{
  2138. // string nmemo = "";
  2139. // for(int i = 0; i < mlist.Length - 1; i++)
  2140. // {
  2141. // nmemo += mlist[i];
  2142. // nmemo += "-";
  2143. // }
  2144. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2145. // entity.seller_memo = nmemo;
  2146. //}
  2147. entity.CustomerUserId = userid;
  2148. entity.Update();
  2149. returnSuccessMsg("操作成功!");
  2150. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2151. return;
  2152. }
  2153. returnErrorMsg("找不到记录");
  2154. }
  2155. }
  2156. public void upd_erp_transdesigner()
  2157. {
  2158. if (UrlPostParmsCheck("ctid"))
  2159. {
  2160. string eids = GetPostString("ctid");
  2161. string[] ctidList = eids.Split(',');
  2162. int userid = GetPostInt("DesignUserId");
  2163. foreach (string ctid in ctidList)
  2164. {
  2165. CeErpTradeCell entity = null;
  2166. CeErpDesignerBill entitys = null;
  2167. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2168. entitys = CeErpDesignerBill.GetByTid(ctid);
  2169. if (entity != null)
  2170. {
  2171. if (entity.OrderState > 4)
  2172. {
  2173. continue;
  2174. }
  2175. //存在退款不能流转
  2176. if (entity.IsRefund > 0)
  2177. {
  2178. continue;
  2179. }
  2180. entity.DesignUserId = userid;
  2181. entity.WaitDesignTime = DateTime.Now;
  2182. entity.Update();
  2183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2184. }
  2185. }
  2186. returnSuccessMsg("操作成功!");
  2187. }
  2188. }
  2189. public void upd_erp_distributedesigner()
  2190. {
  2191. if (UrlPostParmsCheck("ctid"))
  2192. {
  2193. string eid = GetPostString("ctid");
  2194. int userid = GetPostInt("DesignUserId");
  2195. string[] idlist = eid.Split(',');
  2196. if (idlist.Length <= 0)
  2197. {
  2198. returnErrorMsg("订单不能为空");
  2199. return;
  2200. }
  2201. foreach (string ctid in idlist)
  2202. {
  2203. CeErpTradeCell entity = null;
  2204. CeErpDesignerBill entitys = null;
  2205. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2206. else continue;
  2207. if (entity != null)
  2208. {
  2209. if (userid == 2125 || userid == 3542)
  2210. { }
  2211. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2212. {
  2213. returnErrorMsg("金额错误的订单无法指派");
  2214. return;
  2215. }
  2216. if (entity.OrderState >= 5)
  2217. {
  2218. returnErrorMsg("已经设计完成无法指派");
  2219. return;
  2220. }
  2221. if (entity.OrderState == -1)
  2222. {
  2223. returnErrorMsg("审核中的订单无法指派");
  2224. return;
  2225. }
  2226. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2227. {
  2228. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2229. return;
  2230. }
  2231. //157赖橙帆 159林晨 73 静之颖
  2232. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2233. {
  2234. returnErrorMsg("指派设计共创无法再次指派!");
  2235. return;
  2236. }
  2237. entity.OrderState = 3;
  2238. if (entity.SupplierId == 0)
  2239. {
  2240. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2241. entity.SupplierId = suid;
  2242. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2243. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2244. }
  2245. if (userid == 2125 && entity.seller_memo != "")
  2246. {
  2247. apiDesign.API_GetPrintData_CreateOrder(entity);
  2248. }
  2249. if (userid == 3542 && entity.seller_memo != "")
  2250. {
  2251. string userPost = CurrentUser.UserPost.Post.Code;
  2252. if (CurrentUser.UserID == 73)
  2253. {
  2254. userPost = "SysAdmin";
  2255. }
  2256. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2257. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2258. if (response.msg != "设计共创:成功")
  2259. {
  2260. returnErrorMsg(response.msg);
  2261. return;
  2262. }
  2263. entity.DispatchSort = 2;
  2264. }
  2265. else
  2266. {
  2267. if (entity.DispatchSort == 2)
  2268. {
  2269. ApiVo apiVo = new ApiVo();
  2270. apiVo.actionName = "closeDesign";
  2271. apiVo.orderNumber = entity.ctid;
  2272. designHelper.API_WorkCore(apiVo);//closeDesign
  2273. }
  2274. entity.DispatchSort = 0;
  2275. }
  2276. entity.DesignUserId = userid;
  2277. entity.WaitDesignTime = DateTime.Now;
  2278. entity.UpdateTime = DateTime.Now;
  2279. entity.Update();
  2280. string name = commonHelper.getUserNameById(userid);
  2281. commonHelper.UpdateRelationOrder(entity.ctid);
  2282. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2283. }
  2284. }
  2285. returnSuccessMsg("操作成功!");
  2286. return;
  2287. }
  2288. }
  2289. public string getTidByCtid(string ctid)
  2290. {
  2291. string tid = "";
  2292. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2293. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2294. if (dataTable != null && dataTable.Rows.Count > 0)
  2295. {
  2296. tid = dataTable.Rows[0]["tid"].ToString();
  2297. }
  2298. return tid;
  2299. }
  2300. public List<string> getTidByCtidMore(string ctid)
  2301. {
  2302. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2303. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2304. List<string> list = new List<string>();
  2305. if (dataTable != null && dataTable.Rows.Count > 0)
  2306. {
  2307. foreach (DataRow item in dataTable.Rows)
  2308. {
  2309. list.Add("'" + item["tid"].ToString() + "'");
  2310. }
  2311. }
  2312. return list;
  2313. }
  2314. public List<string> getTidByCtidLike(string ctid)
  2315. {
  2316. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2317. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2318. List<string> list = new List<string>();
  2319. if (dataTable != null && dataTable.Rows.Count > 0)
  2320. {
  2321. foreach (DataRow item in dataTable.Rows)
  2322. {
  2323. list.Add("'" + item["tid"].ToString() + "'");
  2324. }
  2325. }
  2326. return list;
  2327. }
  2328. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2329. {
  2330. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2331. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2332. List<string> list = new List<string>();
  2333. if (dataTable != null && dataTable.Rows.Count > 0)
  2334. {
  2335. foreach (DataRow item in dataTable.Rows)
  2336. {
  2337. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2338. {
  2339. continue;
  2340. }
  2341. list.Add("'" + item["receiverId"].ToString() + "'");
  2342. }
  2343. }
  2344. return list;
  2345. }
  2346. public void get_erp_myorderlist()
  2347. {
  2348. DataStruct dStruct = GetPostStruct();
  2349. List<string> lw = new List<string>();
  2350. string tid = GetPostString("ctid");
  2351. if (tid.Length > 0)
  2352. {
  2353. string select_tid = getTidByCtid(tid);
  2354. lw.Add(string.Format("tid='{0}'", select_tid));
  2355. }
  2356. else
  2357. {
  2358. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2359. }
  2360. //12-1 修改
  2361. string urgent = GetPostString("urgent");
  2362. string back = GetPostString("back");
  2363. string offlineSearch = GetPostString("offlineSearch");
  2364. if (!string.IsNullOrWhiteSpace(urgent))
  2365. {
  2366. if (urgent.Equals("true"))
  2367. {
  2368. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2369. }
  2370. }
  2371. if (!string.IsNullOrWhiteSpace(back))
  2372. {
  2373. if (back.Equals("true"))
  2374. {
  2375. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2376. }
  2377. }
  2378. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2379. {
  2380. if (offlineSearch.Equals("true"))
  2381. {
  2382. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2383. }
  2384. }
  2385. //end
  2386. string shopname = GetPostString("shopname");
  2387. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2388. string buyernick = GetPostString("buyer_nick");
  2389. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2390. string design = GetPostString("design");
  2391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2392. string orderState = GetPostString("orderState");
  2393. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2394. string sellermemo = GetPostString("seller_memo");
  2395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2396. string date1 = GetPostString("date1");
  2397. string date2 = GetPostString("date2");
  2398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2399. if (dw.Length > 0) lw.Add(dw);
  2400. string price1 = GetPostString("price1");
  2401. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2402. string price2 = GetPostString("price2");
  2403. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2404. string urgency = GetPostString("urgency");
  2405. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2406. string after = GetPostString("after");
  2407. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2408. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2409. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2410. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2411. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2412. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2413. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2414. if (dt != null && dt.Rows.Count > 0)
  2415. {
  2416. foreach (DataRow dr in dt.Rows)
  2417. {
  2418. try
  2419. {
  2420. // 对象操作
  2421. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2422. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2423. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2424. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2425. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2426. if (dStruct.PageSize != 100000)
  2427. {
  2428. if (dr["DispatchSort"].ToString() == "2")
  2429. {
  2430. dr["gongchuang"] = 200;
  2431. }
  2432. else if ("外协".Equals(dr["ToType"].ToString()))
  2433. {
  2434. dr["gongchuang"] = 200;
  2435. }
  2436. else if ("内部".Equals(dr["ToType"].ToString()))
  2437. {
  2438. dr["gongchuang"] = -1;
  2439. }
  2440. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2441. {
  2442. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2443. dr["gongchuang"] = response.code;
  2444. }
  2445. }
  2446. }
  2447. catch (NullReferenceException ex)
  2448. {
  2449. }
  2450. }
  2451. }
  2452. writeGridDataTableJson(dStruct.TotalCount, dt);
  2453. }
  2454. public void get_erp_myreturnorderlist()
  2455. {
  2456. DataStruct dStruct = GetPostStruct();
  2457. List<string> lw = new List<string>();
  2458. string tid = GetPostString("ctid");
  2459. if (tid.Length > 0)
  2460. {
  2461. string select_tid = getTidByCtid(tid);
  2462. lw.Add(string.Format("tid='{0}'", select_tid));
  2463. }
  2464. else
  2465. {
  2466. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2467. }
  2468. string shopname = GetPostString("shopname");
  2469. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2470. string buyernick = GetPostString("buyer_nick");
  2471. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2472. string design = GetPostString("design");
  2473. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2474. string orderState = GetPostString("orderState");
  2475. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2476. string sellermemo = GetPostString("seller_memo");
  2477. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2478. string date1 = GetPostString("date1");
  2479. string date2 = GetPostString("date2");
  2480. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2481. if (dw.Length > 0) lw.Add(dw);
  2482. string price1 = GetPostString("price1");
  2483. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2484. string price2 = GetPostString("price2");
  2485. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2486. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2487. {
  2488. lw.Add(string.Format("CusOrgID = 94"));
  2489. }
  2490. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2491. {
  2492. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2493. }
  2494. else
  2495. {
  2496. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2497. }
  2498. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2499. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2500. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2501. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2502. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2503. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2504. if (dt != null && dt.Rows.Count > 0)
  2505. {
  2506. foreach (DataRow dr in dt.Rows)
  2507. {
  2508. try
  2509. {
  2510. // 对象操作
  2511. if (dStruct.PageSize != 100000)
  2512. {
  2513. if (dr["DispatchSort"].ToString() == "2")
  2514. {
  2515. dr["gongchuang"] = 200;
  2516. }
  2517. else if ("外协".Equals(dr["ToType"].ToString()))
  2518. {
  2519. dr["gongchuang"] = 200;
  2520. }
  2521. else if ("内部".Equals(dr["ToType"].ToString()))
  2522. {
  2523. dr["gongchuang"] = -1;
  2524. }
  2525. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2526. {
  2527. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2528. dr["gongchuang"] = response.code;
  2529. }
  2530. }
  2531. }
  2532. catch (NullReferenceException ex)
  2533. {
  2534. // 处理空引用异常
  2535. }
  2536. }
  2537. }
  2538. writeGridDataTableJson(dStruct.TotalCount, dt);
  2539. }
  2540. public void get_erp_myorderlist_pregather()
  2541. {
  2542. string date1 = GetPostString("date1");
  2543. string date2 = GetPostString("date2");
  2544. int userId = CurrentUser.UserID; //客服id
  2545. string orderWhere = "";
  2546. List<string> lw = new List<string>();
  2547. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2548. if (dw.Length > 0) lw.Add(dw);
  2549. lw.Add(string.Format("CustomerUserId={0}", userId));
  2550. lw.Add(string.Format("OrderState<9"));
  2551. orderWhere = string.Join(" and ", lw.ToArray());
  2552. string orderWhere2 = "";
  2553. List<string> lw2 = new List<string>();
  2554. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2555. if (dw2.Length > 0) lw2.Add(dw2);
  2556. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2557. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2558. string sql = string.Format("select *" +
  2559. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2560. "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 " +
  2561. "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 " +
  2562. "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");
  2563. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2564. //writeGridDataTableJson(dt.Rows.Count, dt);
  2565. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2566. }
  2567. public void upd_erp_publishorder()
  2568. {
  2569. if (UrlPostParmsCheck("ctid"))
  2570. {
  2571. string eid = GetPostString("ctid");
  2572. CeErpTradeCell entity = null;
  2573. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2574. if (entity != null)
  2575. {
  2576. entity.OrderState = 0; //发布后,变为待抢单
  2577. entity.Update();
  2578. commonHelper.UpdateRelationOrder(entity.ctid);
  2579. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2580. returnSuccessMsg("发布成功!");
  2581. return;
  2582. }
  2583. returnErrorMsg("找不到记录");
  2584. }
  2585. }
  2586. public void get_erp_my_tiporder()
  2587. {
  2588. StringBuilder sql = new StringBuilder();
  2589. int userId = 0;
  2590. if (CurrentUser != null) userId = CurrentUser.UserID;
  2591. string posCode = CurrentUser.UserPost.Post.Code;
  2592. string isTipedAfterSaleVerify = GetPostString("af");
  2593. DataTable dt = new DataTable();
  2594. if (posCode != "Supplier")
  2595. {
  2596. if (posCode == "CustomerService" || posCode == "Director")
  2597. {
  2598. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2599. }
  2600. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2601. {
  2602. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2603. }
  2604. else
  2605. {
  2606. string teamIds = CurrentUser.User.TeamIds;
  2607. if (teamIds == "")
  2608. {
  2609. teamIds = "0";
  2610. }
  2611. 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);
  2612. }
  2613. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2614. }
  2615. if (dt.Rows.Count <= 0)
  2616. {
  2617. string key = "aftersale_order_" + userId;
  2618. if (RedisHelper.HasKey(key))
  2619. {
  2620. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2621. dt.Columns.Add("ctid", typeof(string));
  2622. dt.Columns.Add("IsReadTag", typeof(int));
  2623. foreach (var i in list)
  2624. {
  2625. DataRow data = dt.NewRow();
  2626. data["ctid"] = i;
  2627. data["IsReadTag"] = 4;
  2628. dt.Rows.Add(data);
  2629. }
  2630. RedisHelper.StringDelete(key);
  2631. }
  2632. }
  2633. if (dt.Rows.Count <= 0)
  2634. {
  2635. sql = new StringBuilder();
  2636. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2637. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2638. }
  2639. if (posCode == "Supplier")
  2640. {
  2641. string ids = CurrentUser.User.pemVend;
  2642. if (ids != null && ids.Length > 0)
  2643. {
  2644. string[] ids_list = ids.Split(',');
  2645. foreach (var item in ids_list)
  2646. {
  2647. string key = "return_order_" + item;
  2648. if (RedisHelper.HasKey(key))
  2649. {
  2650. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2651. dt.Columns.Add("ctid", typeof(string));
  2652. dt.Columns.Add("IsReadTag", typeof(int));
  2653. foreach (var i in list)
  2654. {
  2655. DataRow data = dt.NewRow();
  2656. data["ctid"] = i;
  2657. data["IsReadTag"] = 1;
  2658. dt.Rows.Add(data);
  2659. }
  2660. RedisHelper.StringDelete(key);
  2661. }
  2662. }
  2663. }
  2664. if (dt.Rows.Count <= 0)
  2665. {
  2666. sql = new StringBuilder();
  2667. 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);
  2668. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2669. }
  2670. }
  2671. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2672. }
  2673. public void reset_erp_tiporder()
  2674. {
  2675. string ids = GetPostString("ids");
  2676. string[] ctidList = ids.Split(',');
  2677. foreach (string ctid in ctidList)
  2678. {
  2679. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2680. if (enty != null)
  2681. {
  2682. enty.IsReadTag = 0;
  2683. enty.Update();
  2684. }
  2685. }
  2686. returnSuccessMsg("成功!");
  2687. return;
  2688. }
  2689. public void get_erp_designlist()
  2690. {
  2691. DataStruct dStruct = GetPostStruct();
  2692. List<string> lw = new List<string>();
  2693. string tid = GetPostString("ctid");
  2694. if (tid.Length > 0)
  2695. {
  2696. string select_tid = getTidByCtid(tid);
  2697. lw.Add(string.Format("tid='{0}'", select_tid));
  2698. }
  2699. string shopname = GetPostString("shopname");
  2700. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2701. string buyernick = GetPostString("buyer_nick");
  2702. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2703. string customer = GetPostString("customer");
  2704. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2705. string design = GetPostString("design");
  2706. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2707. string orderState = GetPostString("orderState");
  2708. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2709. lw.Add(string.Format("OrderState<6"));
  2710. string address = GetPostString("address");
  2711. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2712. string sellermemo = GetPostString("seller_memo");
  2713. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2714. string date1 = GetPostString("date1");
  2715. string date2 = GetPostString("date2");
  2716. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2717. if (dw.Length > 0) lw.Add(dw);
  2718. string apdate1 = GetPostString("apdate1");
  2719. string apdate2 = GetPostString("apdate2");
  2720. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2721. if (dwap.Length > 0) lw.Add(dwap);
  2722. string price1 = GetPostString("price1");
  2723. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2724. string price2 = GetPostString("price2");
  2725. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2726. string designTime = GetPostString("designtime");
  2727. if (designTime.Length > 0)
  2728. {
  2729. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2730. }
  2731. string usershop = CurrentUser.User.pemShop;
  2732. if (usershop.Length > 0)
  2733. {
  2734. lw.Add(string.Format("shopId in ({0})", usershop));
  2735. }
  2736. int myOrgid = CurrentUser.UserPost.OrgID;
  2737. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2738. if (myOrgCode.IndexOf("Designer") != -1)
  2739. {
  2740. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2741. {
  2742. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2743. }
  2744. else
  2745. {
  2746. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2747. }
  2748. }
  2749. else
  2750. {
  2751. string orgId = GetPostString("designerhd");
  2752. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2753. }
  2754. if (tid.Length > 0 || buyernick.Length > 0)
  2755. {
  2756. lw.Add(string.Format("OrderState >= 3"));
  2757. }
  2758. else
  2759. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2760. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2761. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2762. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2763. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2764. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2765. if (dt != null && dt.Rows.Count > 0)
  2766. {
  2767. foreach (DataRow dr in dt.Rows)
  2768. {
  2769. try
  2770. {
  2771. // 对象操作
  2772. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2773. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2774. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2775. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2776. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2777. if (dStruct.PageSize != 100000)
  2778. {
  2779. if (dr["DispatchSort"].ToString() == "2")
  2780. {
  2781. dr["gongchuang"] = 200;
  2782. }
  2783. else if ("外协".Equals(dr["ToType"].ToString()))
  2784. {
  2785. dr["gongchuang"] = 200;
  2786. }
  2787. else if ("内部".Equals(dr["ToType"].ToString()))
  2788. {
  2789. dr["gongchuang"] = -1;
  2790. }
  2791. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2792. {
  2793. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2794. dr["gongchuang"] = response.code;
  2795. }
  2796. }
  2797. }
  2798. catch (NullReferenceException ex)
  2799. {
  2800. }
  2801. }
  2802. }
  2803. writeGridDataTableJson(dStruct.TotalCount, dt);
  2804. }
  2805. public void get_erp_mydesignlist()
  2806. {
  2807. DataStruct dStruct = GetPostStruct();
  2808. List<string> lw = new List<string>();
  2809. string tid = GetPostString("ctid");
  2810. if (tid.Length > 0)
  2811. {
  2812. string select_tid = getTidByCtid(tid);
  2813. lw.Add(string.Format("tid='{0}'", select_tid));
  2814. }
  2815. string shopname = GetPostString("shopname");
  2816. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2817. string buyernick = GetPostString("buyer_nick");
  2818. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2819. string customer = GetPostString("customer");
  2820. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2821. string orderState = GetPostString("orderState");
  2822. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2823. //lw.Add(string.Format("OrderState<6"));
  2824. string date1 = GetPostString("date1");
  2825. string date2 = GetPostString("date2");
  2826. string dw = GetDateWhere("pay_time", date1, date2);
  2827. if (dw.Length > 0) lw.Add(dw);
  2828. string apdate1 = GetPostString("apdate1");
  2829. string apdate2 = GetPostString("apdate2");
  2830. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2831. if (dwap.Length > 0) lw.Add(dwap);
  2832. string price1 = GetPostString("price1");
  2833. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2834. string price2 = GetPostString("price2");
  2835. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2836. string olddownload = GetPostString("olddown");
  2837. if (olddownload == "1")
  2838. {
  2839. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2840. }
  2841. else if (olddownload == "2")
  2842. {
  2843. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2844. }
  2845. string sellermemo = GetPostString("seller_memo");
  2846. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2847. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2848. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2849. {
  2850. if (CurrentUser.User.TeamIds.Length > 0)
  2851. {
  2852. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2853. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2854. else
  2855. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2856. }
  2857. else
  2858. {
  2859. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2860. }
  2861. }
  2862. if (tid.Length <= 0)
  2863. {
  2864. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2865. }
  2866. lw.Add(string.Format("IsReturn!=3"));
  2867. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2868. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2869. string teamids = CurrentUser.User.TeamIds.ToString();
  2870. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2871. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2872. if (dt != null && dt.Rows.Count > 0)
  2873. {
  2874. foreach (DataRow dr in dt.Rows)
  2875. {
  2876. try
  2877. {
  2878. // 对象操作
  2879. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2880. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2881. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2882. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2883. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2884. if (dStruct.PageSize != 100000)
  2885. {
  2886. if (dr["DispatchSort"].ToString() == "2")
  2887. {
  2888. dr["gongchuang"] = 200;
  2889. }
  2890. else if ("外协".Equals(dr["ToType"].ToString()))
  2891. {
  2892. dr["gongchuang"] = 200;
  2893. }
  2894. else if ("内部".Equals(dr["ToType"].ToString()))
  2895. {
  2896. dr["gongchuang"] = -1;
  2897. }
  2898. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2899. {
  2900. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2901. dr["gongchuang"] = response.code;
  2902. }
  2903. }
  2904. }
  2905. catch (NullReferenceException ex)
  2906. {
  2907. }
  2908. }
  2909. }
  2910. writeGridDataTableJson(dStruct.TotalCount, dt);
  2911. }
  2912. public void set_erp_startdesign()
  2913. {
  2914. if (UrlPostParmsCheck("ctid"))
  2915. {
  2916. string eid = GetPostString("ctid");
  2917. CeErpTradeCell entity = null;
  2918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2919. if (entity != null)
  2920. {
  2921. if (entity.OrderState != 3)
  2922. {
  2923. returnErrorMsg("请刷新,订单已经设计了");
  2924. return;
  2925. }
  2926. entity.StartDesignTime = DateTime.Now;
  2927. entity.OrderState = 4;
  2928. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2929. {
  2930. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2931. entity.SupplierId = suid;
  2932. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2933. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2934. }
  2935. entity.UpdateTime = DateTime.Now;
  2936. //entity.MakeSupplier = suname;
  2937. entity.Update();
  2938. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2939. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2940. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2941. commonHelper.getCytPrice(entity);
  2942. returnSuccessMsg("操作成功!");
  2943. return;
  2944. }
  2945. returnErrorMsg("找不到记录");
  2946. }
  2947. }
  2948. public void ins_erp_designselfmemo()
  2949. {
  2950. if (UrlPostParmsCheck("ctid"))
  2951. {
  2952. string eid = GetPostString("ctid");
  2953. string con = GetPostString("con");
  2954. CeErpTradeCell entity = null;
  2955. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2956. if (entity != null)
  2957. {
  2958. entity.DesignSelfMemo = con;
  2959. entity.Update();
  2960. returnSuccessMsg("操作成功!");
  2961. return;
  2962. }
  2963. returnErrorMsg("找不到记录");
  2964. }
  2965. }
  2966. public void ins_erp_designprice()
  2967. {
  2968. if (UrlPostParmsCheck("ctid"))
  2969. {
  2970. string eid = GetPostString("ctid");
  2971. int uid = CurrentUser.UserID;
  2972. string userName = CurrentUser.UserName;
  2973. CeErpTradeCell entity = null;
  2974. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2975. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2976. if (entitys == null)
  2977. {
  2978. entitys = new CeErpDesignerBill();
  2979. }
  2980. if (entity != null)
  2981. {
  2982. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2983. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2984. entity.StartDesignTime = DateTime.Now;
  2985. entity.OrderState = 4;
  2986. string suname = "";
  2987. if (entity.SupplierId == 0)
  2988. {
  2989. int sid = commonHelper.autoDistributeToSupplier(entity);
  2990. entity.SupplierId = sid;
  2991. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2992. }
  2993. entity.Update();
  2994. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2995. if (ceErpUserPost != null)
  2996. {
  2997. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2998. if (ceErpPost != null)
  2999. {
  3000. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3001. {
  3002. entitys.tid = entity.ctid;
  3003. entitys.oid = entity.tid;
  3004. entitys.uid = uid;
  3005. entitys.userName = userName;
  3006. entitys.designerType = 1;
  3007. entitys.designerTypeText = "内部设计师";
  3008. entitys.price = Convert.ToDouble(GetPostString("price"));
  3009. entitys.designNum = GetPostInt("designNum");
  3010. entitys.modifyNum = GetPostInt("modifyNum");
  3011. entitys.designSize = GetPostString("designSize");
  3012. entitys.modifySize = GetPostString("modifySize");
  3013. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3014. {
  3015. entitys.create_time = DateTime.Now;
  3016. entitys.create_u_id = uid;
  3017. entitys.create_u_name = userName;
  3018. entitys.Save();
  3019. }
  3020. else
  3021. {
  3022. entitys.update_time = DateTime.Now;
  3023. entitys.update_u_id = uid;
  3024. entitys.update_u_name = userName;
  3025. entitys.Update();
  3026. }
  3027. }
  3028. }
  3029. }
  3030. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3031. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3032. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3033. if (suname != "")
  3034. {
  3035. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3036. }
  3037. commonHelper.getCytPrice(entity);
  3038. returnSuccessMsg("操作成功!");
  3039. return;
  3040. }
  3041. returnErrorMsg("找不到记录");
  3042. }
  3043. }
  3044. public void upload_erp_filecomplete()
  3045. {
  3046. if (UrlPostParmsCheck("ctid"))
  3047. {
  3048. string eid = GetPostString("ctid");
  3049. CeErpTradeCell entity = null;
  3050. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3051. if (entity != null)
  3052. {
  3053. entity.OrderState = 5; //设计完成
  3054. entity.Update();
  3055. returnSuccessMsg(eid + "上传成功,设计完成!");
  3056. return;
  3057. }
  3058. returnErrorMsg("找不到订单记录");
  3059. }
  3060. }
  3061. public void get_erp_designovertimelist()
  3062. {
  3063. DataStruct dStruct = GetPostStruct();
  3064. List<string> lw = new List<string>();
  3065. string tid = GetPostString("ctid");
  3066. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3067. string shopname = GetPostString("shopname");
  3068. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3069. string buyernick = GetPostString("buyer_nick");
  3070. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3071. string ResponsibleMan = GetPostString("responsible");
  3072. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3073. string date1 = GetPostString("date1");
  3074. string date2 = GetPostString("date2");
  3075. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3076. if (dw.Length > 0) lw.Add(dw);
  3077. string price1 = GetPostString("price1");
  3078. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3079. string price2 = GetPostString("price2");
  3080. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3081. string orderState = GetPostString("orderState");
  3082. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3083. string sellermemo = GetPostString("seller_memo");
  3084. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3085. lw.Add(string.Format("UnusualTag=3"));
  3086. lw.Add(string.Format("IsRefund<={0}", 1));
  3087. dStruct.Order = "WaitDesignTime desc";
  3088. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3089. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3090. writeGridDataTableJson(dStruct.TotalCount, dt);
  3091. }
  3092. //设计管理 获取抢单大厅列表
  3093. public void get_erp_grabinglist()
  3094. {
  3095. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3096. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3097. bool oldOrder = false;
  3098. if (org != null)
  3099. {
  3100. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3101. }
  3102. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3103. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3104. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3105. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3106. //先处理订单数据
  3107. if (dt.Rows.Count > 0)
  3108. {
  3109. Dictionary<string, int> design = null;
  3110. int count = 0;
  3111. foreach (DataRow row in dt.Rows)
  3112. {
  3113. if (map.ContainsKey(row["ShopId"].ToString()))
  3114. {
  3115. map.TryGetValue(row["ShopId"].ToString(), out design);
  3116. }
  3117. else
  3118. {
  3119. design = new Dictionary<string, int>();
  3120. }
  3121. if (design.ContainsKey(row["ProductId"].ToString()))
  3122. {
  3123. design.TryGetValue(row["ProductId"].ToString(), out count);
  3124. }
  3125. count++;
  3126. design[row["ProductId"].ToString()] = count;
  3127. map[row["ShopId"].ToString()] = design;
  3128. }
  3129. }
  3130. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3131. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3132. //把店铺排序和技能排序分类
  3133. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3134. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3135. if (design_dt.Rows.Count > 0)
  3136. {
  3137. Dictionary<string, string> design = null;
  3138. List<string> shopIds = null;
  3139. foreach (DataRow row in design_dt.Rows)
  3140. {
  3141. if ("0".Equals(row["designId"].ToString()))
  3142. {
  3143. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3144. {
  3145. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3146. }
  3147. else
  3148. {
  3149. shopIds = new List<string>();
  3150. }
  3151. shopIds.Add(row["shopId"].ToString());
  3152. shop_orders[row["orders"].ToString()] = shopIds;
  3153. }
  3154. else
  3155. {
  3156. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3157. {
  3158. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3159. }
  3160. else
  3161. {
  3162. design = new Dictionary<string, string>();
  3163. }
  3164. design[row["orders"].ToString()] = row["designId"].ToString();
  3165. design_orders[row["shopId"].ToString()] = design;
  3166. }
  3167. }
  3168. //处理成key value后根据key排序
  3169. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3170. foreach (List<string> val in shop_orders.Values)
  3171. {
  3172. if (val != null)
  3173. {
  3174. foreach (string key in val)
  3175. {
  3176. if (design_orders.ContainsKey(key.ToString()))
  3177. {
  3178. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3179. }
  3180. }
  3181. }
  3182. }
  3183. }
  3184. //校验哪个优先级有订单
  3185. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3186. foreach (string key in shop_orders.Keys)
  3187. {
  3188. List<string> ids = null;
  3189. shop_orders.TryGetValue(key, out ids);
  3190. //id为shopid
  3191. foreach (string id in ids)
  3192. {
  3193. Dictionary<string, int> list = null;
  3194. Dictionary<string, string> desing = null;
  3195. map.TryGetValue(id, out list);
  3196. design_orders.TryGetValue(id, out desing);
  3197. if (list != null && desing != null)
  3198. {
  3199. foreach (var item in desing)
  3200. {
  3201. int count = 0;
  3202. if (list.ContainsKey(item.Value))
  3203. {
  3204. list.TryGetValue(item.Value, out count);
  3205. if (count > 0)
  3206. {
  3207. designIds[id] = item.Value;
  3208. break;
  3209. }
  3210. }
  3211. }
  3212. }
  3213. }
  3214. if (designIds.Count > 0)
  3215. {
  3216. break;
  3217. }
  3218. }
  3219. DataTable table = new DataTable();
  3220. table.Columns.Add("tid", typeof(string));
  3221. table.Columns.Add("ctid", typeof(string));
  3222. table.Columns.Add("seller_nick", typeof(string));
  3223. table.Columns.Add("productName", typeof(string));
  3224. table.Columns.Add("pay_time", typeof(string));
  3225. table.Columns.Add("seller_memo", typeof(string));
  3226. if (designIds.Count > 0)
  3227. {
  3228. string shopId = "";
  3229. string productId = "";
  3230. foreach (var designInfo in designIds)
  3231. {
  3232. shopId = designInfo.Key;
  3233. productId = designInfo.Value;
  3234. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3235. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3236. if (dt.Rows.Count > 0)
  3237. {
  3238. foreach (DataRow row in dt.Rows)
  3239. {
  3240. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3241. {
  3242. DataRow data = table.NewRow();
  3243. data["ctid"] = row["ctid"].ToString();
  3244. data["tid"] = row["tid"].ToString();
  3245. data["seller_nick"] = ceErpShop.ShopName;
  3246. data["pay_time"] = row["pay_time"].ToString();
  3247. data["seller_memo"] = row["seller_memo"].ToString();
  3248. data["productName"] = ceErpProduct.PType;
  3249. table.Rows.Add(data);
  3250. }
  3251. }
  3252. }
  3253. }
  3254. }
  3255. writeGridDataTableJson(table.Rows.Count, table);
  3256. }
  3257. private object rushLockObject = new object();
  3258. public void set_erp_grabingorder()
  3259. {
  3260. if (UrlPostParmsCheck("ctid"))
  3261. {
  3262. int total = CurrentUser.User.Person.Total;
  3263. int userId = CurrentUser.User.ID;
  3264. int noFinish = CurrentUser.User.Person.NoFinish;
  3265. int finalization = CurrentUser.User.Person.Finalization;
  3266. string eids = GetPostString("ctid");
  3267. string key = "RushKey_" + userId;
  3268. int count = 0;
  3269. if (erpRedis.RedisHelper.KeyExists(key))
  3270. {
  3271. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3272. if (redisCount != null)
  3273. {
  3274. count = Convert.ToInt32(redisCount);
  3275. }
  3276. }
  3277. if (count >= total)
  3278. {
  3279. returnErrorMsg("半小时内已经抢" + total + "单");
  3280. return;
  3281. }
  3282. string[] ctidlist = eids.Split(',');
  3283. if (count + ctidlist.Length > total)
  3284. {
  3285. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3286. return;
  3287. }
  3288. int itag = 0;
  3289. lock (rushLockObject)
  3290. {
  3291. if (ctidlist.Length > 0)
  3292. {
  3293. string[] dtList = new string[ctidlist.Length];
  3294. for (int i = 0; i < ctidlist.Length; i++)
  3295. {
  3296. dtList[i] = "'" + ctidlist[i] + "'";
  3297. }
  3298. 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"));
  3299. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3300. if (dt_user.Rows.Count > 0)
  3301. {
  3302. int doing = 0;//未定稿
  3303. int finish = 0;//已完成
  3304. foreach (DataRow dr in dt_user.Rows)
  3305. {
  3306. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3307. {
  3308. doing++;
  3309. }
  3310. else
  3311. {
  3312. finish++;
  3313. }
  3314. }
  3315. if (doing >= noFinish)
  3316. {
  3317. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3318. return;
  3319. }
  3320. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3321. {
  3322. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3323. return;
  3324. }
  3325. }
  3326. //校验选择单子状态
  3327. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3328. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3329. if (dt.Rows.Count > 0)
  3330. {
  3331. List<string> list = new List<string>();
  3332. foreach (DataRow dr in dt.Rows)
  3333. {
  3334. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3335. {
  3336. list.Add(dr["ctid"].ToString());
  3337. }
  3338. }
  3339. if (list.Count > 0)
  3340. {
  3341. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3342. return;
  3343. }
  3344. }
  3345. foreach (string ctid in ctidlist)
  3346. {
  3347. CeErpTradeCell entity = null;
  3348. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3349. if (entity != null)
  3350. {
  3351. entity.OrderState = 3;
  3352. entity.DesignUserId = CurrentUser.UserID;
  3353. entity.WaitDesignTime = DateTime.Now;
  3354. entity.StartDesignTime = DateTime.Now;
  3355. entity.Update();
  3356. commonHelper.UpdateRelationOrder(entity.ctid);
  3357. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3358. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3359. itag++;
  3360. }
  3361. }
  3362. }
  3363. }
  3364. count += ctidlist.Length;
  3365. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3366. if (itag == 0)
  3367. returnErrorMsg("没有找到相关订单");
  3368. else
  3369. returnSuccessMsg("抢单成功!");
  3370. return;
  3371. }
  3372. }
  3373. public void get_erp_waitorderlist()
  3374. {
  3375. DataStruct dStruct = GetPostStruct();
  3376. List<string> lw = new List<string>();
  3377. string tid = GetPostString("ctid");
  3378. if (tid.Length > 0)
  3379. {
  3380. string select_tid = getTidByCtid(tid);
  3381. lw.Add(string.Format("tid='{0}'", select_tid));
  3382. }
  3383. string shopname = GetPostString("shopname");
  3384. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3385. string buyernick = GetPostString("buyer_nick");
  3386. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3387. string customer = GetPostString("customer");
  3388. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3389. string design = GetPostString("design");
  3390. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3391. string orderState = GetPostString("orderState");
  3392. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3393. string supplier = GetPostString("supplier");
  3394. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3395. string sellermemo = GetPostString("seller_memo");
  3396. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3397. string otherMemo = GetPostString("otherMemo");
  3398. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3399. string address = GetPostString("address");
  3400. 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));
  3401. string date1 = GetPostString("date1");
  3402. string date2 = GetPostString("date2");
  3403. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3404. if (dw.Length > 0) lw.Add(dw);
  3405. string price1 = GetPostString("price1");
  3406. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3407. string price2 = GetPostString("price2");
  3408. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3409. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3410. lw.Add(string.Format("IsSample != 2 "));
  3411. lw.Add(string.Format("OrderState = 5 "));
  3412. lw.Add(string.Format("IsRefund<={0}", 1));
  3413. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3414. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3415. string pagesize = GetPostString("pagesize");
  3416. if (pagesize != null)
  3417. {
  3418. dStruct.PageSize = 200;
  3419. }
  3420. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3421. if (dt != null)
  3422. {
  3423. foreach (DataRow dr in dt.Rows)
  3424. {
  3425. 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();
  3426. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3427. {
  3428. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3429. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3430. entity.SupplierId = suid;
  3431. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3432. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3433. entity.Update();
  3434. }
  3435. }
  3436. }
  3437. writeGridDataTableJson(dStruct.TotalCount, dt);
  3438. }
  3439. public void get_erp_supplierwaitorderlist()
  3440. {
  3441. DataStruct dStruct = GetPostStruct();
  3442. List<string> lw = new List<string>();
  3443. string tid = GetPostString("ctid");
  3444. if (tid.Length > 0)
  3445. {
  3446. string select_tid = getTidByCtid(tid);
  3447. lw.Add(string.Format("tid='{0}'", select_tid));
  3448. }
  3449. string shopname = GetPostString("shopname");
  3450. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3451. string sellermemo = GetPostString("seller_memo");
  3452. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3453. string date1 = GetPostString("date1");
  3454. string date2 = GetPostString("date2");
  3455. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3456. if (dw.Length > 0) lw.Add(dw);
  3457. lw.Add(string.Format("OrderState = 5 "));
  3458. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3459. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3460. {
  3461. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3462. }
  3463. string supplier = GetPostString("supplier");
  3464. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3465. {
  3466. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3467. }
  3468. lw.Add(string.Format("IsRefund<={0}", 1));
  3469. dStruct.Order = "FinishDesignTime desc";
  3470. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3471. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3472. if (dt != null)
  3473. {
  3474. foreach (DataRow dr in dt.Rows)
  3475. {
  3476. 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();
  3477. }
  3478. }
  3479. writeGridDataTableJson(dStruct.TotalCount, dt);
  3480. }
  3481. public void upd_erp_verifytosupplier()
  3482. {
  3483. if (UrlPostParmsCheck("ctid"))
  3484. {
  3485. string eids = GetPostString("ctid");
  3486. CeErpTradeCell entity = null;
  3487. string[] eidsList = eids.Split(',');
  3488. if (eidsList.Length <= 0)
  3489. {
  3490. returnErrorMsg("订单号不能空");
  3491. return;
  3492. }
  3493. List<string> tLst = new List<string>();
  3494. foreach (string ctidstr in eidsList)
  3495. {
  3496. tLst.Add("'" + ctidstr + "'");
  3497. CeErpDataSendOrderInfo.createObject(ctidstr);
  3498. }
  3499. string needtids = string.Join(",", tLst.ToArray());
  3500. StringBuilder sql = new StringBuilder();
  3501. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3502. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3503. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3504. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3505. returnSuccessMsg("操作成功!");
  3506. return;
  3507. /**foreach (string ctidstr in eidsList)
  3508. {
  3509. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3510. if (entity != null)
  3511. {
  3512. if (entity.SupplierId == 0)
  3513. {
  3514. continue;
  3515. }
  3516. entity.IsVerifyToSupplier = true;
  3517. if (entity.IsReturn == 1) //1是供应商打回
  3518. {
  3519. entity.IsReturn = 0;
  3520. }
  3521. entity.FinishPlaceTime = DateTime.Now;
  3522. entity.PlaceUserId = CurrentUser.UserID;
  3523. entity.Update();
  3524. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3525. }
  3526. }
  3527. returnSuccessMsg("操作成功!");
  3528. return;**/
  3529. }
  3530. }
  3531. public void upd_erp_supplierback()
  3532. {
  3533. if (UrlPostParmsCheck("ctid"))
  3534. {
  3535. string eid = GetPostString("ctid");
  3536. string reason = GetPostString("returnreason");
  3537. CeErpTradeCell entity = null;
  3538. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3539. if (entity != null)
  3540. {
  3541. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3542. {
  3543. string key = "return_order_" + entity.SupplierId;
  3544. List<string> list = new List<string>();
  3545. if (RedisHelper.HasKey(key))
  3546. {
  3547. object data = RedisHelper.StringGet(key);
  3548. list = Convert.ToString(data).Split(',').ToList();
  3549. }
  3550. list.Add(eid);
  3551. RedisHelper.StringSet(key, string.Join(",", list));
  3552. }
  3553. entity.IsVerifyToSupplier = false;
  3554. entity.IsReturn = 1;
  3555. entity.ReturnTime = DateTime.Now;
  3556. entity.ReturnReason = reason;
  3557. if (entity.OrderState == 6)
  3558. {
  3559. entity.OrderState = 5;
  3560. }
  3561. entity.Update();
  3562. CeErpSukuraData.createInfo(entity.ctid, 5);
  3563. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3564. returnSuccessMsg("操作成功!");
  3565. return;
  3566. }
  3567. returnErrorMsg("找不到订单记录");
  3568. }
  3569. }
  3570. public void upd_erp_toaftersaleorder()
  3571. {
  3572. if (UrlPostParmsCheck("ctid"))
  3573. {
  3574. string eid = GetPostString("ctid");
  3575. string reason = GetPostString("returnreason");
  3576. CeErpTradeCell entity = null;
  3577. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3578. if (entity != null)
  3579. {
  3580. if (entity.isAfterSaleOrder != 1)
  3581. {
  3582. returnErrorMsg("带S的售后单才能打回给售后");
  3583. return;
  3584. }
  3585. if (entity.OrderState >= 5)
  3586. {
  3587. returnErrorMsg("已经设计完成了不能打回给售后");
  3588. return;
  3589. }
  3590. entity.OrderState = 0;
  3591. entity.IsReturn = 3;
  3592. entity.ReturnTime = DateTime.Now;
  3593. entity.UpdateTime = DateTime.Now;
  3594. entity.ReturnReason = reason;
  3595. entity.Update();
  3596. CeErpSukuraData.createInfo(entity.ctid, 5);
  3597. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3598. returnSuccessMsg("操作成功!");
  3599. return;
  3600. }
  3601. returnErrorMsg("找不到订单记录");
  3602. }
  3603. }
  3604. public void upd_erp_aftersaletodesign()
  3605. {
  3606. if (UrlPostParmsCheck("ctid"))
  3607. {
  3608. string eid = GetPostString("ctid");
  3609. CeErpTradeCell entity = null;
  3610. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3611. if (entity != null)
  3612. {
  3613. entity.OrderState = 3;
  3614. entity.IsReturn = 0;
  3615. entity.UpdateTime = DateTime.Now;
  3616. entity.Update();
  3617. CeErpSukuraData.createInfo(entity.ctid, 5);
  3618. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3619. returnSuccessMsg("操作成功!");
  3620. return;
  3621. }
  3622. returnErrorMsg("找不到订单记录");
  3623. }
  3624. }
  3625. public void assign_erp_supplier()
  3626. {
  3627. if (UrlPostParmsCheck("ctid"))
  3628. {
  3629. string eids = GetPostString("ctid");
  3630. int sid = GetPostInt("SupplierName");
  3631. string fromTag = GetPostString("tag");
  3632. string[] eidList = eids.Split(',');
  3633. if (eidList.Length <= 0)
  3634. {
  3635. returnErrorMsg("指派不能为空");
  3636. return;
  3637. }
  3638. string errMsg = "";
  3639. string suname = commonHelper.getSupplierNameById(sid);
  3640. foreach (string ctid in eidList)
  3641. {
  3642. CeErpTradeCell entity = null;
  3643. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3644. if (entity != null)
  3645. {
  3646. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3647. {
  3648. errMsg += (ctid + "指派失败!!!");
  3649. continue;
  3650. }
  3651. entity.SupplierId = sid;
  3652. entity.Update();
  3653. commonHelper.UpdateRelationOrder(entity.ctid);
  3654. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3655. if (entity.OrderState >= 6)
  3656. {
  3657. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3658. //{
  3659. // string msl = entity.MakeSupplier;
  3660. // string[] mslist = msl.Split(',');
  3661. // 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);
  3662. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3663. //}
  3664. //else
  3665. //{
  3666. StringBuilder sql = new StringBuilder();
  3667. 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);
  3668. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3669. //}
  3670. }
  3671. }
  3672. else
  3673. {
  3674. continue;
  3675. }
  3676. }
  3677. if (errMsg.Length > 0)
  3678. {
  3679. returnErrorMsg(errMsg);
  3680. return;
  3681. }
  3682. returnSuccessMsg("操作成功!");
  3683. return;
  3684. }
  3685. }
  3686. public void assign_erp_makesupplier()
  3687. {
  3688. if (UrlPostParmsCheck("ctid"))
  3689. {
  3690. string eids = GetPostString("ctid");
  3691. string sname = GetPostString("SupplierName");
  3692. string[] eidList = eids.Split(',');
  3693. if (eidList.Length <= 0)
  3694. {
  3695. returnErrorMsg("指派不能为空");
  3696. return;
  3697. }
  3698. List<string> tLst = new List<string>();
  3699. foreach (string ctid in eidList)
  3700. {
  3701. CeErpTradeCell entity = null;
  3702. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3703. if (entity != null)
  3704. {
  3705. entity.MakeSupplier = sname;
  3706. entity.Update();
  3707. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3708. tLst.Add("'" + ctid + "'");
  3709. }
  3710. else
  3711. {
  3712. continue;
  3713. }
  3714. }
  3715. string ctids = string.Join(",", tLst.ToArray());
  3716. StringBuilder sql2 = new StringBuilder();
  3717. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3718. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3719. returnSuccessMsg("操作成功!");
  3720. return;
  3721. }
  3722. }
  3723. public void ins_erp_returnreason()
  3724. {
  3725. if (UrlPostParmsCheck("ctid"))
  3726. {
  3727. string eid = GetPostString("ctid");
  3728. CeErpTradeCell entity = null;
  3729. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3730. string userpost = CurrentUser.UserPost.Post.Code;
  3731. if (entity != null)
  3732. {
  3733. bool isPlace = false;
  3734. if (entity.OrderState > 6)
  3735. {
  3736. returnErrorMsg("已发货无法打回!");
  3737. return;
  3738. }
  3739. if (entity.OrderState == 6)
  3740. {
  3741. isPlace = true;
  3742. }
  3743. bool isNeedUpdateCell2 = false;
  3744. if (entity.OrderState >= 6)
  3745. {
  3746. isNeedUpdateCell2 = true;
  3747. }
  3748. int returnTag = 2;
  3749. if (userpost == "Supplier")
  3750. {
  3751. returnTag = 1;
  3752. }
  3753. int toType = GetPostInt("totype");
  3754. string fromType = "3";
  3755. if (entity.OrderState < 5)
  3756. {
  3757. fromType = "3";
  3758. }
  3759. else
  3760. {
  3761. fromType = "4";
  3762. }
  3763. if (entity.IsXianHuo == 0)
  3764. {
  3765. if (returnTag == 2)
  3766. {
  3767. if (toType == 1)
  3768. {
  3769. entity.OrderState = 0;
  3770. entity.ReturnUserType = 1;
  3771. string clearman = GetPostString("clearman");
  3772. if (!string.IsNullOrEmpty(clearman))
  3773. {
  3774. entity.DesignUserId = 0;
  3775. }
  3776. }
  3777. else
  3778. {
  3779. entity.OrderState = 3;
  3780. entity.ReturnUserType = 2;
  3781. }
  3782. entity.IsReadTag = 1;
  3783. }
  3784. else if (returnTag == 1)
  3785. {
  3786. entity.OrderState = 5;
  3787. }
  3788. entity.IsVerifyToSupplier = false;
  3789. }
  3790. if (entity.IsXianHuo == 1)
  3791. {
  3792. entity.OrderState = 5;
  3793. }
  3794. entity.UnusualTag = 0;
  3795. entity.UnusualTime = null;
  3796. entity.UnusualCon = "";
  3797. entity.IsReturn = returnTag;
  3798. entity.ReturnTime = DateTime.Now;
  3799. entity.UpdateTime = DateTime.Now;
  3800. entity.ReturnReason = GetPostString("returnreason");
  3801. entity.Update();
  3802. if (entity.OrderState == 3)
  3803. {
  3804. ApiVo apiVo = new ApiVo();
  3805. apiVo.orderNumber = entity.ctid;
  3806. apiVo.actionName = "rebutDesign";
  3807. apiVo.orderRemarks = entity.ReturnReason;
  3808. designHelper.API_WorkCore(apiVo);//rebutDesign
  3809. }
  3810. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3811. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3812. {
  3813. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3814. }
  3815. CeErpSukuraData.createInfo(entity.ctid, 5);
  3816. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3818. if (isPlace)
  3819. {
  3820. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3821. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3822. if (dth != null && dth.Rows.Count > 0)
  3823. {
  3824. dataSendOrderBean dataSendOrderBean = null;
  3825. foreach (DataRow item in dth.Rows)
  3826. {
  3827. try
  3828. {
  3829. dataSendOrderBean = new dataSendOrderBean();
  3830. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3831. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3832. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3833. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3834. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3835. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3836. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3837. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3838. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3839. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3840. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3841. dataSendOrderBean.Radio1723534706288 = "打回";
  3842. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3843. if (result != null)
  3844. {
  3845. if ("0".Equals(result.errcode))
  3846. {
  3847. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3848. }
  3849. else
  3850. {
  3851. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3852. }
  3853. }
  3854. }
  3855. catch (Exception ex)
  3856. {
  3857. }
  3858. }
  3859. }
  3860. }
  3861. if (isNeedUpdateCell2)
  3862. {
  3863. if (entity.MakeSupplier.IndexOf(",") != -1)
  3864. {
  3865. StringBuilder sql2 = new StringBuilder();
  3866. 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);
  3867. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3868. }
  3869. else
  3870. {
  3871. StringBuilder sql2 = new StringBuilder();
  3872. 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);
  3873. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3874. }
  3875. }
  3876. returnSuccessMsg("操作成功!");
  3877. return;
  3878. }
  3879. returnErrorMsg("找不到订单记录");
  3880. }
  3881. }
  3882. public void cyt_erp_returnreason()
  3883. {
  3884. if (UrlPostParmsCheck("ctid"))
  3885. {
  3886. string eid = GetPostString("ctid");
  3887. CeErpTradeCell entity = null;
  3888. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3889. string userpost = CurrentUser.UserPost.Post.Code;
  3890. if (entity != null)
  3891. {
  3892. if (entity.OrderState > 6)
  3893. {
  3894. returnErrorMsg("已发货无法打回!");
  3895. return;
  3896. }
  3897. JObject jsonObject = new JObject
  3898. {
  3899. { "Userid", "77886" },
  3900. { "Pwd", "lt666888" },
  3901. { "LTOrderId",eid }
  3902. };
  3903. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3904. JObject jsonObjects = JObject.Parse(response);
  3905. string msg = (string)jsonObjects["msg"];
  3906. if (msg != "取消成功")
  3907. {
  3908. returnErrorMsg(msg);
  3909. return;
  3910. }
  3911. bool isNeedUpdateCell2 = false;
  3912. if (entity.OrderState >= 6)
  3913. {
  3914. isNeedUpdateCell2 = true;
  3915. }
  3916. int returnTag = 2;
  3917. if (userpost == "Supplier")
  3918. {
  3919. returnTag = 1;
  3920. }
  3921. if (entity.IsXianHuo == 0)
  3922. {
  3923. if (returnTag == 2)
  3924. {
  3925. int toType = GetPostInt("totype");
  3926. if (toType == 1)
  3927. {
  3928. entity.OrderState = 0;
  3929. entity.ReturnUserType = 1;
  3930. }
  3931. else
  3932. {
  3933. entity.OrderState = 4;
  3934. entity.ReturnUserType = 2;
  3935. }
  3936. entity.IsReadTag = 1;
  3937. }
  3938. else if (returnTag == 1)
  3939. {
  3940. entity.OrderState = 5;
  3941. }
  3942. entity.IsVerifyToSupplier = false;
  3943. }
  3944. entity.UnusualTag = 0;
  3945. entity.UnusualTime = null;
  3946. entity.UnusualCon = "";
  3947. entity.IsReturn = returnTag;
  3948. entity.ReturnTime = DateTime.Now;
  3949. entity.ReturnReason = GetPostString("returnreason");
  3950. entity.Update();
  3951. if (entity.OrderState == 4)
  3952. {
  3953. ApiVo apiVo = new ApiVo();
  3954. apiVo.orderNumber = entity.ctid;
  3955. apiVo.actionName = "rebutDesign";
  3956. apiVo.orderRemarks = entity.ReturnReason;
  3957. designHelper.API_WorkCore(apiVo);//rebutDesign
  3958. }
  3959. CeErpSukuraData.createInfo(entity.ctid, 5);
  3960. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3961. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3962. if (isNeedUpdateCell2)
  3963. {
  3964. if (entity.MakeSupplier.IndexOf(",") != -1)
  3965. {
  3966. StringBuilder sql2 = new StringBuilder();
  3967. 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);
  3968. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3969. }
  3970. else
  3971. {
  3972. StringBuilder sql2 = new StringBuilder();
  3973. 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);
  3974. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3975. }
  3976. }
  3977. returnSuccessMsg("操作成功!");
  3978. return;
  3979. }
  3980. returnErrorMsg("找不到订单记录");
  3981. }
  3982. }
  3983. public void upd_erp_xianhuoreturntag()
  3984. {
  3985. if (UrlPostParmsCheck("ctid"))
  3986. {
  3987. string eids = GetPostString("ctid");
  3988. string[] ctids = eids.Split(',');
  3989. foreach (string ctid in ctids)
  3990. {
  3991. CeErpTradeCell entity = null;
  3992. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3993. if (entity != null)
  3994. {
  3995. entity.IsReturn = 0;
  3996. entity.Update();
  3997. CeErpSukuraData.createInfo(entity.ctid, 5);
  3998. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3999. }
  4000. }
  4001. returnSuccessMsg("操作成功!");
  4002. return;
  4003. }
  4004. }
  4005. public void get_erp_waitdeliverylist()
  4006. {
  4007. DataStruct dStruct = GetPostStruct();
  4008. List<string> lw = new List<string>();
  4009. string tid = GetPostString("ctid");
  4010. if (tid.Length > 0)
  4011. {
  4012. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4013. if (tid.Length > 5)
  4014. {
  4015. List<string> tids = getTidByCtidLike(tid);
  4016. if (tids.Count > 0 && tids.Count < 10)
  4017. {
  4018. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4019. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4020. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4021. {
  4022. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4023. }
  4024. }
  4025. }
  4026. lw.Add(tid_sql);
  4027. }
  4028. string shopname = GetPostString("shopname");
  4029. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4030. string buyernick = GetPostString("buyer_nick");
  4031. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4032. //if (tid.Length == 0 && buyernick.Length == 0)
  4033. //{
  4034. // lw.Add(string.Format("IsRefund<={0}", 1));
  4035. //}
  4036. string customer = GetPostString("customer");
  4037. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4038. string design = GetPostString("design");
  4039. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4040. string orderState = GetPostString("orderState");
  4041. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4042. string address = GetPostString("address");
  4043. 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));
  4044. string sellermemo = GetPostString("seller_memo");
  4045. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4046. string supplier = GetPostString("supplier");
  4047. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4048. string OrderArea = GetPostString("order_area");
  4049. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4050. string placedate1 = GetPostString("placedate1");
  4051. string placedate2 = GetPostString("placedate2");
  4052. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4053. if (fdw.Length > 0) lw.Add(fdw);
  4054. string price1 = GetPostString("price1");
  4055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4056. string price2 = GetPostString("price2");
  4057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4058. string unusualCon = GetPostString("unusualcon");
  4059. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4060. string otherMemo = GetPostString("otherMemo");
  4061. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4062. string posTag = CurrentUser.UserPost.Post.Code;
  4063. if (posTag == "Supplier")
  4064. {
  4065. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4066. }
  4067. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4068. lw.Add(string.Format("type != 'PDD' "));
  4069. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4070. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4071. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4072. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4073. writeGridDataTableJson(dStruct.TotalCount, dt);
  4074. }
  4075. public void get_erp_changedeliverylist()
  4076. {
  4077. DataStruct dStruct = GetPostStruct();
  4078. List<string> lw = new List<string>();
  4079. string tid = GetPostString("ctid");
  4080. if (tid.Length > 0)
  4081. {
  4082. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4083. if (tid.Length > 5)
  4084. {
  4085. List<string> tids = getTidByCtidLike(tid);
  4086. if (tids.Count > 0 && tids.Count < 10)
  4087. {
  4088. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4089. }
  4090. }
  4091. lw.Add(tid_sql);
  4092. }
  4093. string shopname = GetPostString("shopname");
  4094. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4095. string buyernick = GetPostString("buyer_nick");
  4096. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4097. //if (tid.Length == 0 && buyernick.Length == 0)
  4098. //{
  4099. // lw.Add(string.Format("IsRefund<={0}", 1));
  4100. //}
  4101. string customer = GetPostString("customer");
  4102. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4103. string design = GetPostString("design");
  4104. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4105. string orderState = GetPostString("orderState");
  4106. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4107. string address = GetPostString("address");
  4108. 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));
  4109. string sellermemo = GetPostString("seller_memo");
  4110. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4111. string supplier = GetPostString("supplier");
  4112. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4113. string OrderArea = GetPostString("order_area");
  4114. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4115. string placedate1 = GetPostString("placedate1");
  4116. string placedate2 = GetPostString("placedate2");
  4117. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4118. if (fdw.Length > 0) lw.Add(fdw);
  4119. string price1 = GetPostString("price1");
  4120. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4121. string price2 = GetPostString("price2");
  4122. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4123. string unusualCon = GetPostString("unusualcon");
  4124. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4125. string otherMemo = GetPostString("otherMemo");
  4126. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4127. string posTag = CurrentUser.UserPost.Post.Code;
  4128. if (posTag == "Supplier")
  4129. {
  4130. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4131. }
  4132. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4133. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4134. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4135. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4136. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4137. /*if (tid.Length > 0)
  4138. {
  4139. List<string> tids = new List<string>();
  4140. if (dt != null && dt.Rows.Count > 0)
  4141. {
  4142. foreach (DataRow item in dt.Rows)
  4143. {
  4144. tids.Add("'" + item["tid"] + "'");
  4145. }
  4146. }
  4147. if (tids.Count > 0)
  4148. {
  4149. lw.RemoveAt(0);
  4150. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4152. dt = WebCache.GetData("view_erptradecell", dStruct);
  4153. }
  4154. }*/
  4155. writeGridDataTableJson(dStruct.TotalCount, dt);
  4156. }
  4157. public void get_erp_pddderiving()
  4158. {
  4159. DataStruct dStruct = GetPostStruct();
  4160. List<string> lw = new List<string>();
  4161. string tid = GetPostString("ctid");
  4162. if (tid.Length > 0)
  4163. {
  4164. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4165. if (tid.Length > 5)
  4166. {
  4167. List<string> tids = getTidByCtidLike(tid);
  4168. if (tids.Count > 0 && tids.Count < 10)
  4169. {
  4170. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4171. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4172. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4173. {
  4174. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4175. }
  4176. }
  4177. }
  4178. lw.Add(tid_sql);
  4179. }
  4180. string shopname = GetPostString("shopname");
  4181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4182. string buyernick = GetPostString("buyer_nick");
  4183. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4184. //if (tid.Length == 0 && buyernick.Length == 0)
  4185. //{
  4186. // lw.Add(string.Format("IsRefund<={0}", 1));
  4187. //}
  4188. string customer = GetPostString("customer");
  4189. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4190. string design = GetPostString("design");
  4191. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4192. string orderState = GetPostString("orderState");
  4193. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4194. string address = GetPostString("address");
  4195. 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));
  4196. string sellermemo = GetPostString("seller_memo");
  4197. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4198. string supplier = GetPostString("supplier");
  4199. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4200. string OrderArea = GetPostString("order_area");
  4201. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4202. string placedate1 = GetPostString("placedate1");
  4203. string placedate2 = GetPostString("placedate2");
  4204. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4205. if (fdw.Length > 0) lw.Add(fdw);
  4206. string price1 = GetPostString("price1");
  4207. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4208. string price2 = GetPostString("price2");
  4209. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4210. string unusualCon = GetPostString("unusualcon");
  4211. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4212. string posTag = CurrentUser.UserPost.Post.Code;
  4213. if (posTag == "Supplier")
  4214. {
  4215. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4216. }
  4217. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4218. lw.Add(string.Format("type = 'PDD' "));
  4219. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4220. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4222. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4223. /*if (tid.Length > 0)
  4224. {
  4225. List<string> tids = new List<string>();
  4226. if (dt != null && dt.Rows.Count > 0)
  4227. {
  4228. foreach (DataRow item in dt.Rows)
  4229. {
  4230. tids.Add("'" + item["tid"] + "'");
  4231. }
  4232. }
  4233. if (tids.Count > 0)
  4234. {
  4235. lw.RemoveAt(0);
  4236. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4237. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4238. dt = WebCache.GetData("view_erptradecell", dStruct);
  4239. }
  4240. }*/
  4241. writeGridDataTableJson(dStruct.TotalCount, dt);
  4242. }
  4243. public void get_erp_jdderiving()
  4244. {
  4245. DataStruct dStruct = GetPostStruct();
  4246. List<string> lw = new List<string>();
  4247. string tid = GetPostString("ctid");
  4248. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4249. string shopname = GetPostString("shopname");
  4250. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4251. string buyernick = GetPostString("buyer_nick");
  4252. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4253. //if (tid.Length == 0 && buyernick.Length == 0)
  4254. //{
  4255. // lw.Add(string.Format("IsRefund<={0}", 1));
  4256. //}
  4257. string customer = GetPostString("customer");
  4258. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4259. string design = GetPostString("design");
  4260. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4261. string orderState = GetPostString("orderState");
  4262. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4263. string address = GetPostString("address");
  4264. 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));
  4265. string sellermemo = GetPostString("seller_memo");
  4266. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4267. string supplier = GetPostString("supplier");
  4268. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4269. string OrderArea = GetPostString("order_area");
  4270. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4271. string placedate1 = GetPostString("placedate1");
  4272. string placedate2 = GetPostString("placedate2");
  4273. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4274. if (fdw.Length > 0) lw.Add(fdw);
  4275. string price1 = GetPostString("price1");
  4276. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4277. string price2 = GetPostString("price2");
  4278. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4279. string unusualCon = GetPostString("unusualcon");
  4280. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4281. string posTag = CurrentUser.UserPost.Post.Code;
  4282. if (posTag == "Supplier")
  4283. {
  4284. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4285. }
  4286. lw.Add(string.Format("OrderState = 6 "));
  4287. lw.Add(string.Format("type = 'JD' "));
  4288. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4289. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4290. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4291. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4292. writeGridDataTableJson(dStruct.TotalCount, dt);
  4293. }
  4294. public void get_erp_demoorderlist()
  4295. {
  4296. DataStruct dStruct = GetPostStruct();
  4297. List<string> lw = new List<string>();
  4298. string tid = GetPostString("ctid");
  4299. if (tid.Length > 0)
  4300. {
  4301. string select_tid = getTidByCtid(tid);
  4302. lw.Add(string.Format("tid='{0}'", select_tid));
  4303. }
  4304. string shopname = GetPostString("shopname");
  4305. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4306. string buyernick = GetPostString("buyer_nick");
  4307. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4308. string customer = GetPostString("customer");
  4309. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4310. string design = GetPostString("design");
  4311. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4312. string orderState = GetPostString("orderState");
  4313. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4314. string address = GetPostString("address");
  4315. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4316. string sellermemo = GetPostString("seller_memo");
  4317. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4318. string supplier = GetPostString("supplier");
  4319. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4320. string OrderArea = GetPostString("order_area");
  4321. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4322. string date1 = GetPostString("date1");
  4323. string date2 = GetPostString("date2");
  4324. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4325. if (dw.Length > 0) lw.Add(dw);
  4326. string price1 = GetPostString("price1");
  4327. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4328. string price2 = GetPostString("price2");
  4329. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4330. string posTag = CurrentUser.UserPost.Post.Code;
  4331. if (posTag == "Supplier")
  4332. {
  4333. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4334. }
  4335. //lw.Add(string.Format("OrderState = 6 "));
  4336. lw.Add(string.Format("IsSample={0}", 3));
  4337. lw.Add(string.Format("IsRefund<={0}", 1));
  4338. dStruct.Order = "pay_time desc";
  4339. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4340. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4341. writeGridDataTableJson(dStruct.TotalCount, dt);
  4342. }
  4343. public void save_erp_checkmemo()
  4344. {
  4345. if (UrlPostParmsCheck("ctid"))
  4346. {
  4347. string ctid = GetPostString("ctid");
  4348. CeErpTradeCell entity = null;
  4349. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4350. if (entity != null)
  4351. {
  4352. entity.CheckMemo = GetPostString("CheckMemo");
  4353. entity.Update();
  4354. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4355. if (trade != null)
  4356. {
  4357. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4358. }
  4359. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4360. returnSuccessMsg("保存成功!");
  4361. return;
  4362. }
  4363. returnErrorMsg("找不到记录");
  4364. }
  4365. }
  4366. public void get_erp_returnlist()
  4367. {
  4368. DataStruct dStruct = GetPostStruct();
  4369. List<string> lw = new List<string>();
  4370. string tid = GetPostString("ctid");
  4371. if (tid.Length > 0)
  4372. {
  4373. string select_tid = getTidByCtid(tid);
  4374. lw.Add(string.Format("tid='{0}'", select_tid));
  4375. }
  4376. string shopname = GetPostString("shopname");
  4377. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4378. string buyernick = GetPostString("buyer_nick");
  4379. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4380. string customer = GetPostString("customer");
  4381. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4382. string design = GetPostString("design");
  4383. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4384. string orderState = GetPostString("orderState");
  4385. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4386. string address = GetPostString("address");
  4387. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4388. string sellermemo = GetPostString("seller_memo");
  4389. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4390. string supplier = GetPostString("supplier");
  4391. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4392. string date1 = GetPostString("date1");
  4393. string date2 = GetPostString("date2");
  4394. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4395. if (dw.Length > 0) lw.Add(dw);
  4396. string bdate1 = GetPostString("backdate1");
  4397. string bdate2 = GetPostString("backdate2");
  4398. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4399. if (dw_back.Length > 0) lw.Add(dw_back);
  4400. string price1 = GetPostString("price1");
  4401. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4402. string price2 = GetPostString("price2");
  4403. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4404. lw.Add(string.Format("IsReturn>0"));
  4405. lw.Add(string.Format("IsXianHuo=0"));
  4406. lw.Add(string.Format("IsReturn!=3"));
  4407. string backtype = GetPostString("backtype");
  4408. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4409. dStruct.Order = "FinishDesignTime desc";
  4410. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4411. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4412. writeGridDataTableJson(dStruct.TotalCount, dt);
  4413. }
  4414. public void get_erp_today_sumreturn()
  4415. {
  4416. DataStruct dStruct = GetPostStruct();
  4417. List<string> lw = new List<string>();
  4418. string bdate1 = GetPostString("returnTimeS");
  4419. string bdate2 = GetPostString("returnTimeE");
  4420. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4421. if (dw_back.Length > 0) lw.Add(dw_back);
  4422. lw.Add(string.Format("IsReturn=0"));
  4423. lw.Add(string.Format("IsXianHuo=0"));
  4424. string mainWhere = string.Join(" and ", lw.ToArray());
  4425. string sql = "";
  4426. if (dw_back.Length > 0)
  4427. {
  4428. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4429. }
  4430. else
  4431. {
  4432. 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 + "'";
  4433. }
  4434. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4435. decimal total = 0, today_finish = 0;
  4436. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4437. {
  4438. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4439. }
  4440. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4441. {
  4442. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4443. }
  4444. var res = new
  4445. {
  4446. data = total,
  4447. data1 = today_finish,
  4448. };
  4449. string ro_jsond = JsonConvert.SerializeObject(res);
  4450. returnSuccess(ro_jsond);
  4451. return;
  4452. }
  4453. public void get_erp_allreturnlist()
  4454. {
  4455. DataStruct dStruct = GetPostStruct();
  4456. List<string> lw = new List<string>();
  4457. string tid = GetPostString("ctid");
  4458. if (tid.Length > 0)
  4459. {
  4460. string select_tid = getTidByCtid(tid);
  4461. lw.Add(string.Format("tid='{0}'", select_tid));
  4462. }
  4463. string shopname = GetPostString("shopname");
  4464. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4465. string buyernick = GetPostString("buyer_nick");
  4466. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4467. string customer = GetPostString("customer");
  4468. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4469. string design = GetPostString("design");
  4470. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4471. string orderState = GetPostString("orderState");
  4472. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4473. string address = GetPostString("address");
  4474. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4475. string sellermemo = GetPostString("seller_memo");
  4476. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4477. string supplier = GetPostString("supplier");
  4478. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4479. string date1 = GetPostString("date1");
  4480. string date2 = GetPostString("date2");
  4481. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4482. if (dw.Length > 0) lw.Add(dw);
  4483. string bdate1 = GetPostString("backdate1");
  4484. string bdate2 = GetPostString("backdate2");
  4485. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4486. if (dw_back.Length > 0) lw.Add(dw_back);
  4487. string price1 = GetPostString("price1");
  4488. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4489. string price2 = GetPostString("price2");
  4490. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4491. string backreason = GetPostString("backreason");
  4492. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4493. lw.Add(string.Format("IsXianHuo=0"));
  4494. lw.Add(string.Format("ReturnTime != ''"));
  4495. string backtype = GetPostString("backtype");
  4496. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4497. dStruct.Order = "FinishDesignTime desc";
  4498. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4499. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4500. writeGridDataTableJson(dStruct.TotalCount, dt);
  4501. }
  4502. public void get_erp_aftersalereturnlist()
  4503. {
  4504. DataStruct dStruct = GetPostStruct();
  4505. List<string> lw = new List<string>();
  4506. string tid = GetPostString("ctid");
  4507. if (tid.Length > 0)
  4508. {
  4509. string select_tid = getTidByCtid(tid);
  4510. lw.Add(string.Format("tid='{0}'", select_tid));
  4511. }
  4512. string shopname = GetPostString("shopname");
  4513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4514. string buyernick = GetPostString("buyer_nick");
  4515. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4516. string customer = GetPostString("customer");
  4517. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4518. string design = GetPostString("design");
  4519. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4520. string orderState = GetPostString("orderState");
  4521. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4522. string address = GetPostString("address");
  4523. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4524. string sellermemo = GetPostString("seller_memo");
  4525. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4526. string supplier = GetPostString("supplier");
  4527. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4528. string date1 = GetPostString("date1");
  4529. string date2 = GetPostString("date2");
  4530. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4531. if (dw.Length > 0) lw.Add(dw);
  4532. string bdate1 = GetPostString("backdate1");
  4533. string bdate2 = GetPostString("backdate2");
  4534. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4535. if (dw_back.Length > 0) lw.Add(dw_back);
  4536. string price1 = GetPostString("price1");
  4537. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4538. string price2 = GetPostString("price2");
  4539. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4540. lw.Add(string.Format("IsReturn=3"));
  4541. string backtype = GetPostString("backtype");
  4542. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4543. string backreason = GetPostString("backreason");
  4544. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4545. dStruct.Order = "ReturnTime desc";
  4546. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4547. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4548. writeGridDataTableJson(dStruct.TotalCount, dt);
  4549. }
  4550. public void get_erp_xianhuoreturnlist()
  4551. {
  4552. DataStruct dStruct = GetPostStruct();
  4553. List<string> lw = new List<string>();
  4554. string tid = GetPostString("ctid");
  4555. if (tid.Length > 0)
  4556. {
  4557. string select_tid = getTidByCtid(tid);
  4558. lw.Add(string.Format("tid='{0}'", select_tid));
  4559. }
  4560. string shopname = GetPostString("shopname");
  4561. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4562. string buyernick = GetPostString("buyer_nick");
  4563. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4564. string customer = GetPostString("customer");
  4565. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4566. string design = GetPostString("design");
  4567. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4568. string orderState = GetPostString("orderState");
  4569. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4570. string address = GetPostString("address");
  4571. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4572. string sellermemo = GetPostString("seller_memo");
  4573. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4574. string supplier = GetPostString("supplier");
  4575. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4576. string OrderArea = GetPostString("order_area");
  4577. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4578. string date1 = GetPostString("date1");
  4579. string date2 = GetPostString("date2");
  4580. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4581. if (dw.Length > 0) lw.Add(dw);
  4582. string price1 = GetPostString("price1");
  4583. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4584. string price2 = GetPostString("price2");
  4585. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4586. string posTag = CurrentUser.UserPost.Post.Code;
  4587. if (posTag == "Supplier")
  4588. {
  4589. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4590. }
  4591. lw.Add(string.Format("OrderState=6 "));
  4592. lw.Add(string.Format("IsXianHuo=1 "));
  4593. lw.Add(string.Format("IsReturn>0 "));
  4594. lw.Add(string.Format("IsReturn!=3"));
  4595. lw.Add(string.Format("IsRefund<={0}", 1));
  4596. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4597. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4598. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4599. writeGridDataTableJson(dStruct.TotalCount, dt);
  4600. }
  4601. public void set_erp_orderdelivery()
  4602. {
  4603. if (UrlPostParmsCheck("ctid"))
  4604. {
  4605. string eid = GetPostString("ctid");
  4606. CeErpTradeCell entity = null;
  4607. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4608. if (entity != null)
  4609. {
  4610. if (entity.OrderState >= 7)
  4611. {
  4612. returnErrorMsg("此单已发货,无需重复发货");
  4613. return;
  4614. }
  4615. if (entity.OrderState != 6)
  4616. {
  4617. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4618. return;
  4619. }
  4620. string shop = GetPostString("seller_nick");
  4621. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4622. string comName = GetPostString("comName");
  4623. string comCode = GetPostString("comCode");
  4624. string outSid = GetPostString("outSid");
  4625. string deliveryType = GetPostString("deliveryType");
  4626. string deliveryMemo = GetPostString("deliveryMemo");
  4627. outSid = outSid.Trim();
  4628. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4629. if (mainEn == null)
  4630. {
  4631. returnErrorMsg("找不到原始订单记录");
  4632. return;
  4633. }
  4634. bool isInitOrderDeliv = false;
  4635. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4636. {
  4637. isInitOrderDeliv = true;
  4638. }
  4639. string apires = "";
  4640. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4641. 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)
  4642. {
  4643. apires = "发货成功true";
  4644. }
  4645. else
  4646. {
  4647. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4648. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4649. }
  4650. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4651. {
  4652. entity.OrderState = 7;//发货后订单已发货
  4653. entity.OutSid = outSid;
  4654. entity.MemoOpt = 0;
  4655. entity.UpdateTime = DateTime.Now;
  4656. entity.FinishDeliveryTime = DateTime.Now;
  4657. entity.Update();
  4658. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4659. commonHelper.UpdateRelationOrder(entity.ctid);
  4660. //还要插入快递信息到 快递信息表
  4661. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4662. exinfo.tid = eid;
  4663. exinfo.out_sid = outSid;
  4664. exinfo.company_code = comCode;
  4665. exinfo.company_name = comName;
  4666. exinfo.delivery_memo = deliveryMemo;
  4667. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4668. exinfo.deliveryType = deliveryType;
  4669. exinfo.Create();
  4670. returnSuccessMsg("发货操作成功!");
  4671. commonHelper.UpdateRelationOrder(entity.ctid);
  4672. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4673. CeErpSukuraData.createInfo(entity.ctid, 4);
  4674. if (entity.SupplierId == 64)
  4675. {
  4676. commonHelper.sendCytExpress(exinfo);
  4677. }
  4678. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4679. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4680. }
  4681. else
  4682. {
  4683. string errmsg = commonHelper.KeepChinese(apires);
  4684. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4685. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4686. }
  4687. return;
  4688. }
  4689. returnErrorMsg("找不到订单记录");
  4690. }
  4691. }
  4692. public void set_erp_multidelivery()
  4693. {
  4694. string eids = GetPostString("tids");
  4695. string[] eidList = eids.Split(',');
  4696. if (eidList.Length <= 0)
  4697. {
  4698. returnErrorMsg("发货不能为空");
  4699. return;
  4700. }
  4701. foreach (string ctid in eidList)
  4702. {
  4703. if (ctid.Length <= 0) continue;
  4704. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4705. if (expInfo != null)
  4706. {
  4707. StringBuilder sql = new StringBuilder();
  4708. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4709. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4710. if (dt.Rows.Count > 0)
  4711. {
  4712. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4713. {
  4714. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4715. expInfo.state = "异常";
  4716. expInfo.isMultiDelivery = 1;
  4717. expInfo.Update();
  4718. continue;
  4719. }
  4720. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4721. {
  4722. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4723. expInfo.state = "异常";
  4724. expInfo.Update();
  4725. continue;
  4726. }
  4727. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4728. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4729. bool isInitOrderDeliv = false;
  4730. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4731. {
  4732. isInitOrderDeliv = true;
  4733. expInfo.isMultiDelivery = 1;
  4734. }
  4735. if (ctid.IndexOf("N") != -1)
  4736. {
  4737. StringBuilder sqlbucha = new StringBuilder();
  4738. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4739. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4740. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4741. commonHelper.UpdateRelationOrder(ctid);
  4742. expInfo.delivery_memo = "发货成功";
  4743. expInfo.state = "发货成功";
  4744. expInfo.isMultiDelivery = 1;
  4745. expInfo.Update();
  4746. }
  4747. else
  4748. {
  4749. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4750. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4751. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4752. {
  4753. expInfo.delivery_memo = "发货成功";
  4754. expInfo.state = "发货成功";
  4755. expInfo.isMultiDelivery = 1;
  4756. expInfo.Update();
  4757. commonHelper.UpdateRelationOrder(ctid);
  4758. CeErpSukuraData.createInfo(ctid, 4);
  4759. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4760. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4761. }
  4762. else
  4763. {
  4764. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4765. expInfo.state = "异常";
  4766. expInfo.Update();
  4767. }
  4768. }
  4769. }
  4770. }
  4771. }
  4772. returnSuccessMsg("操作完成");
  4773. }
  4774. public void reset_erp_memoopt()
  4775. {
  4776. if (UrlPostParmsCheck("ctid"))
  4777. {
  4778. string eid = GetPostString("ctid");
  4779. CeErpTradeCell entity = null;
  4780. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4781. if (entity != null)
  4782. {
  4783. string stropt = "";
  4784. if (entity.MemoOpt == 1)
  4785. {
  4786. stropt = "“改稿”";
  4787. }
  4788. else if (entity.MemoOpt == 2)
  4789. {
  4790. stropt = "“定稿”";
  4791. }
  4792. else if (entity.MemoOpt == 3)
  4793. {
  4794. stropt = "“完成查货”";
  4795. CeErpSukuraData.createInfo(entity.ctid, 6);
  4796. }
  4797. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4798. entity.UpdateTime = DateTime.Now;
  4799. entity.MemoOpt = 0;
  4800. entity.Update();
  4801. returnSuccessMsg("操作成功!");
  4802. return;
  4803. }
  4804. returnErrorMsg("找不到记录");
  4805. }
  4806. }
  4807. public void get_erp_deliveryunusual()
  4808. {
  4809. DataStruct dStruct = GetPostStruct();
  4810. List<string> lw = new List<string>();
  4811. string tid = GetPostString("ctid");
  4812. if (tid.Length > 0)
  4813. {
  4814. string select_tid = getTidByCtid(tid);
  4815. lw.Add(string.Format("tid='{0}'", select_tid));
  4816. }
  4817. string shopname = GetPostString("shopname");
  4818. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4819. string buyernick = GetPostString("buyer_nick");
  4820. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4821. string customer = GetPostString("customer");
  4822. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4823. string design = GetPostString("design");
  4824. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4825. string sellermemo = GetPostString("seller_memo");
  4826. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4827. string supplier = GetPostString("supplier");
  4828. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4829. string date1 = GetPostString("date1");
  4830. string date2 = GetPostString("date2");
  4831. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4832. if (dw.Length > 0) lw.Add(dw);
  4833. string placedate1 = GetPostString("placedate1");
  4834. string placedate2 = GetPostString("placedate2");
  4835. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4836. if (dw_place.Length > 0) lw.Add(dw_place);
  4837. string price1 = GetPostString("price1");
  4838. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4839. string price2 = GetPostString("price2");
  4840. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4841. string unusualCon = GetPostString("unusualcon");
  4842. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4843. string posTag = CurrentUser.UserPost.Post.Code;
  4844. if (posTag == "Supplier")
  4845. {
  4846. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4847. }
  4848. lw.Add(string.Format("OrderState = 6"));
  4849. lw.Add(string.Format("UnusualTag = 5"));
  4850. lw.Add(string.Format("IsRefund<={0}", 1));
  4851. dStruct.Order = "FinishPlaceTime desc";
  4852. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4853. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4854. writeGridDataTableJson(dStruct.TotalCount, dt);
  4855. }
  4856. public void get_erp_deliveryedlist()
  4857. {
  4858. DataStruct dStruct = GetPostStruct();
  4859. List<string> lw = new List<string>();
  4860. string tid = GetPostString("ctid");
  4861. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4862. string shopname = GetPostString("shopname");
  4863. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4864. string buyernick = GetPostString("buyer_nick");
  4865. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4866. string customer = GetPostString("customer");
  4867. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4868. string design = GetPostString("design");
  4869. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4870. string sellermemo = GetPostString("seller_memo");
  4871. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4872. string logistics = GetPostString("logistics");
  4873. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4874. string date1 = GetPostString("date1");
  4875. string date2 = GetPostString("date2");
  4876. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4877. //if (dw.Length > 0) lw.Add(dw);
  4878. string placedate1 = GetPostString("placedate1");
  4879. string placedate2 = GetPostString("placedate2");
  4880. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4881. if (fdw.Length > 0) lw.Add(fdw);
  4882. string devdate1 = GetPostString("deliverydate1");
  4883. string devdate2 = GetPostString("deliverydate2");
  4884. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4885. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4886. string price1 = GetPostString("price1");
  4887. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4888. string price2 = GetPostString("price2");
  4889. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4890. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4891. {
  4892. if (tid.Length > 0)
  4893. {
  4894. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4895. if (tid.Length > 5)
  4896. {
  4897. List<string> tids = getTidByCtidLike(tid);
  4898. if (tids.Count > 0 && tids.Count < 10)
  4899. {
  4900. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4901. }
  4902. }
  4903. lw.Add(tid_sql);
  4904. }
  4905. if (buyernick.Length > 0)
  4906. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4907. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4908. if (dw.Length > 0) lw.Add(dw);
  4909. }
  4910. else
  4911. {
  4912. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4913. }
  4914. string posTag = CurrentUser.UserPost.Post.Code;
  4915. if (posTag == "Supplier")
  4916. {
  4917. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4918. }
  4919. else
  4920. {
  4921. string supplier = GetPostString("supplier");
  4922. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4923. }
  4924. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4925. lw.Add(string.Format("type != 'PDD' "));
  4926. lw.Add(string.Format("IsRefund!={0}", 2));
  4927. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4928. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4929. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4930. /*if (tid.Length > 0)
  4931. {
  4932. List<string> tids = new List<string>();
  4933. if (dt != null && dt.Rows.Count > 0)
  4934. {
  4935. foreach (DataRow item in dt.Rows)
  4936. {
  4937. tids.Add("'" + item["tid"] + "'");
  4938. }
  4939. }
  4940. if (tids.Count > 0)
  4941. {
  4942. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4943. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4944. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4945. dt = WebCache.GetData("view_erptradecell", dStruct);
  4946. }
  4947. }*/
  4948. if (dt != null)
  4949. {
  4950. foreach (DataRow dr in dt.Rows)
  4951. {
  4952. 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();
  4953. }
  4954. }
  4955. writeGridDataTableJson(dStruct.TotalCount, dt);
  4956. }
  4957. public void get_erp_pdddeliveryed()
  4958. {
  4959. DataStruct dStruct = GetPostStruct();
  4960. List<string> lw = new List<string>();
  4961. string tid = GetPostString("ctid");
  4962. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4963. string shopname = GetPostString("shopname");
  4964. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4965. string buyernick = GetPostString("buyer_nick");
  4966. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4967. string customer = GetPostString("customer");
  4968. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4969. string design = GetPostString("design");
  4970. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4971. string sellermemo = GetPostString("seller_memo");
  4972. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4973. string logistics = GetPostString("logistics");
  4974. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4975. string date1 = GetPostString("date1");
  4976. string date2 = GetPostString("date2");
  4977. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4978. //if (dw.Length > 0) lw.Add(dw);
  4979. string placedate1 = GetPostString("placedate1");
  4980. string placedate2 = GetPostString("placedate2");
  4981. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4982. if (fdw.Length > 0) lw.Add(fdw);
  4983. string devdate1 = GetPostString("deliverydate1");
  4984. string devdate2 = GetPostString("deliverydate2");
  4985. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4986. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4987. string price1 = GetPostString("price1");
  4988. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4989. string price2 = GetPostString("price2");
  4990. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4991. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4992. {
  4993. if (tid.Length > 0)
  4994. {
  4995. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4996. if (tid.Length > 5)
  4997. {
  4998. List<string> tids = getTidByCtidLike(tid);
  4999. if (tids.Count > 0 && tids.Count < 10)
  5000. {
  5001. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5002. }
  5003. }
  5004. lw.Add(tid_sql);
  5005. }
  5006. if (buyernick.Length > 0)
  5007. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5008. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5009. if (dw.Length > 0) lw.Add(dw);
  5010. }
  5011. else
  5012. {
  5013. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5014. }
  5015. string posTag = CurrentUser.UserPost.Post.Code;
  5016. if (posTag == "Supplier")
  5017. {
  5018. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5019. }
  5020. else
  5021. {
  5022. string supplier = GetPostString("supplier");
  5023. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5024. }
  5025. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5026. lw.Add(string.Format("type = 'PDD' "));
  5027. lw.Add(string.Format("IsRefund!={0}", 2));
  5028. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5029. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5030. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5031. /* if (tid.Length > 0)
  5032. {
  5033. List<string> tids = new List<string>();
  5034. if (dt != null && dt.Rows.Count > 0)
  5035. {
  5036. foreach (DataRow item in dt.Rows)
  5037. {
  5038. tids.Add("'" + item["tid"] + "'");
  5039. }
  5040. }
  5041. if (tids.Count > 0)
  5042. {
  5043. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5044. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5046. dt = WebCache.GetData("view_erptradecell", dStruct);
  5047. }
  5048. }*/
  5049. foreach (DataRow dr in dt.Rows)
  5050. {
  5051. 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();
  5052. }
  5053. writeGridDataTableJson(dStruct.TotalCount, dt);
  5054. }
  5055. public void get_erp_jddeliveryed()
  5056. {
  5057. DataStruct dStruct = GetPostStruct();
  5058. List<string> lw = new List<string>();
  5059. string tid = GetPostString("ctid");
  5060. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5061. string shopname = GetPostString("shopname");
  5062. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5063. string buyernick = GetPostString("buyer_nick");
  5064. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5065. string customer = GetPostString("customer");
  5066. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5067. string design = GetPostString("design");
  5068. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5069. string sellermemo = GetPostString("seller_memo");
  5070. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5071. string date1 = GetPostString("date1");
  5072. string date2 = GetPostString("date2");
  5073. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5074. //if (dw.Length > 0) lw.Add(dw);
  5075. string placedate1 = GetPostString("placedate1");
  5076. string placedate2 = GetPostString("placedate2");
  5077. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5078. if (fdw.Length > 0) lw.Add(fdw);
  5079. string devdate1 = GetPostString("deliverydate1");
  5080. string devdate2 = GetPostString("deliverydate2");
  5081. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5082. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5083. string price1 = GetPostString("price1");
  5084. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5085. string price2 = GetPostString("price2");
  5086. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5087. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5088. {
  5089. if (tid.Length > 0)
  5090. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5091. if (buyernick.Length > 0)
  5092. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5093. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5094. if (dw.Length > 0) lw.Add(dw);
  5095. }
  5096. else
  5097. {
  5098. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5099. }
  5100. string posTag = CurrentUser.UserPost.Post.Code;
  5101. if (posTag == "Supplier")
  5102. {
  5103. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5104. }
  5105. else
  5106. {
  5107. string supplier = GetPostString("supplier");
  5108. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5109. }
  5110. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5111. lw.Add(string.Format("type = 'JD' "));
  5112. lw.Add(string.Format("IsRefund!={0}", 2));
  5113. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5114. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5115. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5116. foreach (DataRow dr in dt.Rows)
  5117. {
  5118. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5119. }
  5120. writeGridDataTableJson(dStruct.TotalCount, dt);
  5121. }
  5122. public void get_erp_allplacelist()
  5123. {
  5124. DataStruct dStruct = GetPostStruct();
  5125. List<string> lw = new List<string>();
  5126. string tid = GetPostString("ctid");
  5127. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5128. string shopname = GetPostString("shopname");
  5129. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5130. string buyernick = GetPostString("buyer_nick");
  5131. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5132. string customer = GetPostString("customer");
  5133. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5134. string design = GetPostString("design");
  5135. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5136. string sellermemo = GetPostString("seller_memo");
  5137. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5138. string supplier = GetPostString("supplier");
  5139. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5140. string date1 = GetPostString("date1");
  5141. string date2 = GetPostString("date2");
  5142. string pldate1 = GetPostString("placedate1");
  5143. string pldate2 = GetPostString("placedate2");
  5144. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5145. //if (dw.Length > 0) lw.Add(dw);
  5146. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5147. {
  5148. if (tid.Length > 0)
  5149. {
  5150. string select_tid = getTidByCtid(tid);
  5151. lw.Add(string.Format("tid='{0}'", select_tid));
  5152. }
  5153. if (buyernick.Length > 0)
  5154. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5155. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5156. if (dw.Length > 0) lw.Add(dw);
  5157. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5158. if (dw_place.Length > 0) lw.Add(dw_place);
  5159. }
  5160. else
  5161. {
  5162. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5163. {
  5164. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5165. }
  5166. }
  5167. string price1 = GetPostString("price1");
  5168. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5169. string price2 = GetPostString("price2");
  5170. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5171. string posTag = CurrentUser.UserPost.Post.Code;
  5172. if (posTag == "Supplier")
  5173. {
  5174. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5175. }
  5176. lw.Add(string.Format("OrderState >= 6"));
  5177. lw.Add(string.Format("IsSample != 2 "));
  5178. //lw.Add(string.Format("isDianziOrder = 0 "));
  5179. lw.Add(string.Format("SupplierId > 0 "));
  5180. //lw.Add(string.Format("IsRefund<={0}", 1));
  5181. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5182. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5183. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5184. foreach (DataRow dr in dt.Rows)
  5185. {
  5186. 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();
  5187. }
  5188. writeGridDataTableJson(dStruct.TotalCount, dt);
  5189. }
  5190. public void get_erp_financeallplacelist()
  5191. {
  5192. DataStruct dStruct = GetPostStruct();
  5193. List<string> lw = new List<string>();
  5194. string tid = GetPostString("ctid");
  5195. string shopname = GetPostString("shopname");
  5196. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5197. string buyernick = GetPostString("buyer_nick");
  5198. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5199. string customer = GetPostString("customer");
  5200. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5201. string design = GetPostString("design");
  5202. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5203. string sellermemo = GetPostString("seller_memo");
  5204. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5205. string supplier = GetPostString("supplier");
  5206. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5207. string date1 = GetPostString("date1");
  5208. string date2 = GetPostString("date2");
  5209. string pldate1 = GetPostString("placedate1");
  5210. string pldate2 = GetPostString("placedate2");
  5211. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5212. {
  5213. if (tid.Length > 0)
  5214. {
  5215. string select_tid = getTidByCtid(tid);
  5216. lw.Add(string.Format("tid='{0}'", select_tid));
  5217. }
  5218. if (buyernick.Length > 0)
  5219. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5220. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5221. if (dw.Length > 0) lw.Add(dw);
  5222. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5223. if (dw_place.Length > 0) lw.Add(dw_place);
  5224. }
  5225. else
  5226. {
  5227. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5228. {
  5229. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5230. }
  5231. }
  5232. string price1 = GetPostString("price1");
  5233. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5234. string price2 = GetPostString("price2");
  5235. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5236. string posTag = CurrentUser.UserPost.Post.Code;
  5237. if (posTag == "Supplier")
  5238. {
  5239. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5240. }
  5241. //lw.Add(string.Format("OrderState >= 6"));
  5242. lw.Add(string.Format("IsSample != 2 "));
  5243. lw.Add(string.Format("isDianziOrder = 0 "));
  5244. //lw.Add(string.Format("IsRefund<={0}", 1));
  5245. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5246. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5247. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5248. foreach (DataRow dr in dt.Rows)
  5249. {
  5250. 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();
  5251. }
  5252. writeGridDataTableJson(dStruct.TotalCount, dt);
  5253. }
  5254. public void get_erp_expresslist()
  5255. {
  5256. int listtype = GetInt("ltype");
  5257. DataStruct dStruct = GetPostStruct();
  5258. List<string> lw = new List<string>();
  5259. string tid = GetPostString("tid");
  5260. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5261. string outsid = GetPostString("out_sid");
  5262. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5263. string importer = GetPostString("ImportUserName");
  5264. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5265. string file = GetPostString("import_file");
  5266. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5267. string printman = GetPostString("printman");
  5268. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5269. string date1 = GetPostString("date1");
  5270. string date2 = GetPostString("date2");
  5271. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5272. if (dw.Length > 0) lw.Add(dw);
  5273. string fdate1 = GetPostString("finishdate1");
  5274. string fdate2 = GetPostString("finishdate2");
  5275. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5276. if (fdw.Length > 0) lw.Add(fdw);
  5277. string supplierId = GetPostString("supplierId");
  5278. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5279. if (listtype == 1)
  5280. {
  5281. lw.Add(string.Format("importUserId !=0"));
  5282. }
  5283. string posTag = CurrentUser.UserPost.Post.Code;
  5284. if (posTag == "Supplier")
  5285. {
  5286. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5287. }
  5288. if (dStruct.PageSize != 100000)
  5289. {
  5290. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5291. }
  5292. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5293. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5294. writeGridDataTableJson(dStruct.TotalCount, dt);
  5295. }
  5296. public void set_erp_buchaorderdelivery()
  5297. {
  5298. if (UrlPostParmsCheck("ctid"))
  5299. {
  5300. string eid = GetPostString("ctid");
  5301. CeErpTradeCell entity = null;
  5302. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5303. if (entity != null)
  5304. {
  5305. if (entity.IsSample != 2)
  5306. {
  5307. returnErrorMsg("补差价单才能标记为已发货");
  5308. return;
  5309. }
  5310. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5311. entity.OrderState = 7;
  5312. entity.Update();
  5313. returnSuccessMsg("操作成功!");
  5314. return;
  5315. }
  5316. returnErrorMsg("找不到记录");
  5317. }
  5318. }
  5319. public void get_stdtemplates()
  5320. {
  5321. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5322. //string res = taobaoHelper.test();
  5323. string res = apiHelper.API_PrintTemplate();
  5324. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5325. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5326. {
  5327. int sidx = res.IndexOf("error_code");
  5328. int eidx = res.IndexOf("success");
  5329. string msg = res.Substring(sidx, eidx - sidx);
  5330. returnErrorMsg(msg);
  5331. return;
  5332. }
  5333. if (res.Length <= 0)
  5334. {
  5335. returnErrorMsg("模板数据为空!");
  5336. return;
  5337. }
  5338. ReturnSuccess(res);
  5339. }
  5340. public void cancel_print_order()
  5341. {
  5342. if (UrlPostParmsCheck("ctid"))
  5343. {
  5344. string ctid = GetPostString("ctid");
  5345. CeErpTradeCell entity = null;
  5346. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5347. if (entity != null)
  5348. {
  5349. string res = "";
  5350. string code = entity.LastBillWaybillCode;
  5351. if (code == "")
  5352. {
  5353. code = entity.OutSid;
  5354. }
  5355. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5356. XLog.SaveLog(0, "取消面单" + res);
  5357. }
  5358. }
  5359. }
  5360. public void set_erp_printwaybill()
  5361. {
  5362. if (UrlPostParmsCheck("ctid"))
  5363. {
  5364. string ctid = GetPostString("ctid");
  5365. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5366. string cpName = GetPostString("cpname");
  5367. string isTogether = GetPostString("together");
  5368. string printType = GetPostString("printType");
  5369. //var res_obj = new
  5370. //{
  5371. // restype = 1,
  5372. // 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\"}"
  5373. //};
  5374. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5375. //ReturnSuccess(ro_json);
  5376. //return;
  5377. bool isUseLastWayBillCode = false;
  5378. CeErpTradeCell entity = null;
  5379. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5380. if (entity != null)
  5381. {
  5382. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5383. {
  5384. isUseLastWayBillCode = true;
  5385. }
  5386. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5387. {
  5388. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5389. return;
  5390. }
  5391. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5392. {
  5393. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5394. return;
  5395. }
  5396. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5397. {
  5398. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5399. return;
  5400. }
  5401. }
  5402. string res = "";
  5403. Api_waybill_code_response_Obj fullObj = null;
  5404. string pData_str = "";
  5405. string curUseWayBillCode = "";
  5406. if (isUseLastWayBillCode == false)
  5407. {
  5408. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5409. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5410. if (res.IndexOf("failure") != -1)
  5411. {
  5412. //int idx = res.IndexOf("sub_message");
  5413. //int idx2 = res.IndexOf("flag");
  5414. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5415. string errMsgNeed = commonHelper.KeepChinese(res);
  5416. var res_objd = new
  5417. {
  5418. restype = 0,
  5419. data = "获取面单失败" + errMsgNeed
  5420. };
  5421. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5422. returnSuccess(ro_jsond);
  5423. if (res.IndexOf("停发") != -1)
  5424. {
  5425. entity.UnusualCon = "物流停发";
  5426. entity.Update();
  5427. }
  5428. //returnErrorMsg("获取面单失败,"+emsg);
  5429. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5430. return;
  5431. }
  5432. else if (res.IndexOf("errorMsg") != -1)
  5433. {
  5434. //int idx = res.IndexOf("errorMsg");
  5435. //int idx2 = res.IndexOf("}]}");
  5436. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5437. string errMsgNeed = commonHelper.KeepChinese(res);
  5438. var res_objf = new
  5439. {
  5440. restype = 0,
  5441. data = "获取面单失败2" + errMsgNeed
  5442. };
  5443. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5444. if (res.IndexOf("停发") != -1)
  5445. {
  5446. entity.UnusualCon = "物流停发";
  5447. entity.Update();
  5448. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5449. if (trade != null)
  5450. {
  5451. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5452. }
  5453. }
  5454. returnSuccess(ro_jsonf);
  5455. //returnErrorMsg("获取面单失败," + emsg);
  5456. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5457. return;
  5458. }
  5459. try
  5460. {
  5461. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5462. //res = res.Replace(" ", "");
  5463. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5464. }
  5465. catch (Exception ex)
  5466. {
  5467. XLog.SaveLog(0, "生成fullObj" + res);
  5468. var res_objf = new
  5469. {
  5470. restype = 0,
  5471. data = "生成fullObj发生错误" + ex.Message
  5472. };
  5473. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5474. returnSuccess(ro_jsonf);
  5475. return;
  5476. }
  5477. if (fullObj.response.data.content.Count > 0)
  5478. {
  5479. ContentItem codeObj = fullObj.response.data.content[0];
  5480. if (cpCode.IndexOf("SFFQ-") != -1)
  5481. {
  5482. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5483. }
  5484. else
  5485. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5486. curUseWayBillCode = codeObj.waybillCode;
  5487. }
  5488. else
  5489. {
  5490. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5491. var res_objf = new
  5492. {
  5493. restype = 0,
  5494. data = "生成fullObj找不到快递单号waybillCode"
  5495. };
  5496. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5497. returnSuccess(ro_jsonf);
  5498. return;
  5499. }
  5500. }
  5501. else
  5502. {
  5503. //使用上次打印的快递单号
  5504. if (cpCode == "SFFQ-LY")
  5505. {
  5506. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5507. }
  5508. else
  5509. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5510. curUseWayBillCode = entity.LastBillWaybillCode;
  5511. }
  5512. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5513. {
  5514. var res_obje = new
  5515. {
  5516. restype = 0,
  5517. data = "获取加密打印数据失败"
  5518. };
  5519. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5520. returnSuccess(ro_jsone);
  5521. entity.LastBillCpCode = cpCode;
  5522. entity.LastBillWaybillCode = curUseWayBillCode;
  5523. entity.Update();
  5524. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5525. //returnErrorMsg("获取加密打印数据失败");
  5526. return;
  5527. }
  5528. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5529. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5530. string btnType = "";
  5531. string errorMsg = "";
  5532. if (entity != null)
  5533. {
  5534. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5535. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5536. //cpcode是 YTO-CAINIAO
  5537. //string comCode = cpCode.Split('-')[0].ToString();
  5538. string apires = "";
  5539. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5540. //isTogether=2是新的合包弹窗
  5541. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5542. {
  5543. if (ctid.IndexOf("N") != -1)
  5544. {
  5545. apires = "发货成功";
  5546. }
  5547. else
  5548. {
  5549. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5550. }
  5551. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5552. //打单后发货
  5553. StringBuilder sql = new StringBuilder();
  5554. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5555. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5556. {
  5557. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5558. }
  5559. else
  5560. {
  5561. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5562. }
  5563. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5564. foreach (DataRow row in dt.Rows)
  5565. {
  5566. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5567. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5568. {
  5569. try
  5570. {
  5571. btnType = "待发货";
  5572. entity.OutSid = curUseWayBillCode;
  5573. entity.OrderState = 7;
  5574. entity.IsUrgency = false;
  5575. entity.LastBillCpCode = "";
  5576. entity.LastBillWaybillCode = "";
  5577. entity.FinishDeliveryTime = DateTime.Now;
  5578. entity.IsReturn = 0;
  5579. entity.MemoOpt = 0;
  5580. entity.UpdateTime = DateTime.Now;
  5581. entity.Update();
  5582. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5583. //还要插入快递信息到 快递信息表
  5584. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5585. exinfo.tid = entity.ctid;
  5586. exinfo.out_sid = curUseWayBillCode;
  5587. exinfo.company_code = cpCode;
  5588. exinfo.company_name = cpName;
  5589. exinfo.supplierUserName = supplierName;
  5590. exinfo.deliveryType = "发货成功";
  5591. exinfo.print_time = DateTime.Now;
  5592. exinfo.printUser = CurrentUser.UserName;
  5593. exinfo.postData = pData_str;
  5594. exinfo.Create();
  5595. commonHelper.UpdateRelationOrder(entity.ctid);
  5596. CeErpSukuraData.createInfo(ctid, 4);
  5597. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5598. if (entity.SupplierId == 64)
  5599. {
  5600. commonHelper.sendCytExpress(exinfo);
  5601. }
  5602. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5603. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5604. }
  5605. catch (Exception ex)
  5606. {
  5607. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5608. }
  5609. }
  5610. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5611. {
  5612. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5613. if (entity.OrderState == 6)
  5614. {
  5615. entity.OrderState = 7;
  5616. }
  5617. entity.UpdateTime = DateTime.Now;
  5618. entity.FinishDeliveryTime = DateTime.Now;
  5619. btnType = "已发货";
  5620. entity.Update();
  5621. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5622. exinfo.tid = entity.ctid;
  5623. exinfo.out_sid = curUseWayBillCode;
  5624. exinfo.company_code = cpCode;
  5625. exinfo.company_name = cpName;
  5626. exinfo.supplierUserName = supplierName;
  5627. exinfo.deliveryType = "发货成功";
  5628. exinfo.print_time = DateTime.Now;
  5629. exinfo.printUser = CurrentUser.UserName;
  5630. exinfo.postData = pData_str;
  5631. exinfo.Create();
  5632. commonHelper.UpdateRelationOrder(entity.ctid);
  5633. CeErpSukuraData.createInfo(entity.ctid, 4);
  5634. if (entity.SupplierId == 64)
  5635. {
  5636. commonHelper.sendCytExpress(exinfo);
  5637. }
  5638. //不处理
  5639. }
  5640. else
  5641. {
  5642. entity.UpdateTime = DateTime.Now;
  5643. entity.LastBillCpCode = cpCode;
  5644. entity.LastBillWaybillCode = curUseWayBillCode;
  5645. entity.Update();
  5646. string errmsg = commonHelper.KeepChinese(apires);
  5647. var res_objz = new
  5648. {
  5649. restype = 0,
  5650. data = "打单后发货失败"
  5651. };
  5652. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5653. returnSuccess(ro_jsonz);
  5654. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5655. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5656. return;
  5657. }
  5658. }
  5659. }
  5660. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5661. {
  5662. string ctids = GetPostString("ctids");
  5663. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5664. List<string> list = new List<string>();
  5665. List<string> send_list = new List<string>();
  5666. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5667. CeErpTrade ceErpTrade = new CeErpTrade();
  5668. //可合包的合并一起发货
  5669. if (dt == null && string.IsNullOrEmpty(ctids))
  5670. {
  5671. var res_objz = new
  5672. {
  5673. restype = 0,
  5674. data = "打单后发货失败"
  5675. };
  5676. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5677. returnSuccess(ro_jsonz);
  5678. return;
  5679. }
  5680. if (!string.IsNullOrEmpty(ctids))
  5681. {
  5682. StringBuilder sql = new StringBuilder();
  5683. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5684. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5685. }
  5686. foreach (DataRow row in dt.Rows)
  5687. {
  5688. list.Add("'" + row["ctid"] + "'");
  5689. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5690. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5691. if (ctid.IndexOf("N") != -1)
  5692. {
  5693. apires = "发货成功";
  5694. }
  5695. else
  5696. {
  5697. if (!send_list.Contains(ceErpTrade.tid))
  5698. {
  5699. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5700. }
  5701. else
  5702. {
  5703. apires = "发货成功";
  5704. }
  5705. }
  5706. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5707. {
  5708. send_list.Add(ceErpTrade.tid);
  5709. try
  5710. {
  5711. btnType = "待发货";
  5712. ceErpTradeCell.OutSid = curUseWayBillCode;
  5713. ceErpTradeCell.OrderState = 7;
  5714. ceErpTradeCell.IsUrgency = false;
  5715. ceErpTradeCell.LastBillCpCode = "";
  5716. ceErpTradeCell.LastBillWaybillCode = "";
  5717. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5718. ceErpTradeCell.IsReturn = 0;
  5719. ceErpTradeCell.MemoOpt = 0;
  5720. ceErpTradeCell.UpdateTime = DateTime.Now;
  5721. ceErpTradeCell.Update();
  5722. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5723. //还要插入快递信息到 快递信息表
  5724. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5725. exinfo.tid = ceErpTradeCell.ctid;
  5726. exinfo.out_sid = curUseWayBillCode;
  5727. exinfo.company_code = cpCode;
  5728. exinfo.company_name = cpName;
  5729. exinfo.supplierUserName = supplierName;
  5730. exinfo.deliveryType = "发货成功";
  5731. exinfo.print_time = DateTime.Now;
  5732. exinfo.printUser = CurrentUser.UserName;
  5733. exinfo.postData = pData_str;
  5734. exinfo.Create();
  5735. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5736. CeErpSukuraData.createInfo(ctid, 4);
  5737. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5738. if (ceErpTradeCell.SupplierId == 64)
  5739. {
  5740. commonHelper.sendCytExpress(exinfo);
  5741. }
  5742. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5743. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5744. }
  5745. catch (Exception ex)
  5746. {
  5747. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5748. }
  5749. }
  5750. else
  5751. {
  5752. ceErpTradeCell.UpdateTime = DateTime.Now;
  5753. ceErpTradeCell.LastBillCpCode = cpCode;
  5754. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5755. ceErpTradeCell.Update();
  5756. string errmsg = commonHelper.KeepChinese(apires);
  5757. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5758. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5759. }
  5760. }
  5761. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5762. }
  5763. }
  5764. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5765. var res_obj = new
  5766. {
  5767. restype = 1,
  5768. data = pData_str,
  5769. errorMsg
  5770. };
  5771. string ro_json = JsonConvert.SerializeObject(res_obj);
  5772. ReturnSuccess(ro_json);
  5773. return;
  5774. }
  5775. }
  5776. private string GetUTF8String(byte[] vs)
  5777. {
  5778. throw new NotImplementedException();
  5779. }
  5780. public void set_erp_printwaybill_cn()
  5781. {
  5782. if (UrlPostParmsCheck("ctid"))
  5783. {
  5784. string ctid = GetPostString("ctid");
  5785. string cpCode = GetPostString("cpcode");
  5786. string cpName = GetPostString("cpname");
  5787. string tempUrl = GetPostString("tempurl");
  5788. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5789. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5790. //string res = taobaoHelper.test();
  5791. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5792. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5793. {
  5794. int sidx = res.IndexOf("errorMsg");
  5795. int eidx = res.IndexOf("}");
  5796. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5797. var res_objzxx = new
  5798. {
  5799. restype = 0,
  5800. data = msg
  5801. };
  5802. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5803. returnSuccess(ro_jsonzxx);
  5804. //returnErrorMsg(msg);
  5805. return;
  5806. }
  5807. int idx = res.IndexOf("waybillCode");
  5808. int idx2 = res.IndexOf("printData");
  5809. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5810. string eid = GetPostString("ctid");
  5811. CeErpTradeCell entity = null;
  5812. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5813. if (entity != null)
  5814. {
  5815. string osid = entity.OutSid;
  5816. entity.OutSid = osid + "," + outsid;
  5817. entity.FinishDeliveryTime = DateTime.Now;
  5818. entity.OrderState = 7;
  5819. entity.UpdateTime = DateTime.Now;
  5820. entity.IsReturn = 0;
  5821. entity.Update();
  5822. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5823. exinfo.tid = entity.ctid;
  5824. exinfo.out_sid = outsid;
  5825. exinfo.company_code = cpCode;
  5826. exinfo.company_name = cpName;
  5827. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5828. exinfo.deliveryType = "发货成功";
  5829. exinfo.print_time = DateTime.Now;
  5830. exinfo.printUser = CurrentUser.UserName;
  5831. exinfo.Create();
  5832. if (entity.SupplierId == 64)
  5833. {
  5834. commonHelper.sendCytExpress(exinfo);
  5835. }
  5836. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5837. }
  5838. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5839. var res_objz = new
  5840. {
  5841. restype = 1,
  5842. data = res
  5843. };
  5844. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5845. returnSuccess(ro_jsonz);
  5846. //ReturnSuccess(res);
  5847. }
  5848. }
  5849. ////打单,打印面单 获取面单号
  5850. //public void set_erp_printwaybill()
  5851. //{
  5852. // if (UrlPostParmsCheck("ctid"))
  5853. // {
  5854. // string ctid = GetPostString("ctid");
  5855. // string cpCode = GetPostString("cpcode");
  5856. // string tempUrl = GetPostString("tempurl");
  5857. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5858. // //string res = taobaoHelper.test();
  5859. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5860. // if (res.IndexOf("error_response") != -1)
  5861. // {
  5862. // int sidx = res.IndexOf("sub_msg");
  5863. // int eidx = res.IndexOf("request_id");
  5864. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5865. // returnErrorMsg(msg);
  5866. // return;
  5867. // }
  5868. // int idx = res.IndexOf("waybill_code");
  5869. // int idx2 = res.IndexOf("}]}");
  5870. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5871. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5872. // ReturnSuccess(res);
  5873. // }
  5874. //}
  5875. public void cancel_erp_aftersale()
  5876. {
  5877. if (UrlPostParmsCheck("ctid"))
  5878. {
  5879. string eid = GetPostString("ctid");
  5880. CeErpTradeCell entity = null;
  5881. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5882. if (entity != null)
  5883. {
  5884. //有过处理的售后,取消也不能删除 售 字,保留
  5885. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5886. {
  5887. entity.AfterSaleState = 4;
  5888. }
  5889. else
  5890. entity.AfterSaleState = 0;
  5891. entity.UpdateTime = DateTime.Now;
  5892. entity.Update();
  5893. returnSuccessMsg("操作成功!");
  5894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5895. return;
  5896. }
  5897. returnErrorMsg("找不到订单记录");
  5898. }
  5899. }
  5900. public void get_erp_aftersalelist()
  5901. {
  5902. DataStruct dStruct = GetPostStruct();
  5903. List<string> lw = new List<string>();
  5904. int st = GetInt("st");
  5905. string tid = GetPostString("ctid");
  5906. if (st == 3)
  5907. {
  5908. if (tid.Length > 0)
  5909. {
  5910. string select_tid = getTidByCtid(tid);
  5911. lw.Add(string.Format("tid='{0}'", select_tid));
  5912. }
  5913. }
  5914. else
  5915. {
  5916. if (tid.Length > 0)
  5917. {
  5918. string select_tid = getTidByCtid(tid);
  5919. lw.Add(string.Format("tid='{0}'", select_tid));
  5920. }
  5921. }
  5922. string shopname = GetPostString("shopname");
  5923. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5924. string buyernick = GetPostString("buyer_nick");
  5925. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5926. string sellermemo = GetPostString("seller_memo");
  5927. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5928. string orderState = GetPostString("orderState");
  5929. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5930. string afterState = GetPostString("afterstate");
  5931. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5932. string date1 = GetPostString("date1");
  5933. string date2 = GetPostString("date2");
  5934. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5935. if (dw.Length > 0) lw.Add(dw);
  5936. string price1 = GetPostString("price1");
  5937. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5938. string price2 = GetPostString("price2");
  5939. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5940. //lw.Add(string.Format("IsRefund!={0}", 1));
  5941. string reason = GetPostString("reason");
  5942. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5943. string method = GetPostString("method");
  5944. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5945. string handler = GetPostString("handler");
  5946. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5947. string handledate1 = GetPostString("handledate1");
  5948. string handledate2 = GetPostString("handledate2");
  5949. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5950. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5951. string finish1 = GetPostString("finishdate1");
  5952. string finish2 = GetPostString("finishdate2");
  5953. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5954. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5955. string afterdate1 = GetPostString("afterdate1");
  5956. string afterdate2 = GetPostString("afterdate2");
  5957. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5958. if (afterDate.Length > 0) lw.Add(afterDate);
  5959. string supplier = GetPostString("supplier");
  5960. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5961. string responsible = GetPostString("responsibleman");
  5962. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5963. string customer = GetPostString("customer");
  5964. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5965. string design = GetPostString("design");
  5966. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5967. string afterMemoType = GetPostString("aftermemotype");
  5968. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5969. string posCode = CurrentUser.UserPost.Post.Code;
  5970. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5971. //{
  5972. // string vstate = GetPostString("vstate");
  5973. // if (vstate.Length > 0)
  5974. // {
  5975. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5976. // }
  5977. // if (posCode == "Supplier")
  5978. // {
  5979. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5980. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5981. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5982. // }
  5983. // else
  5984. // {
  5985. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5986. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5987. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5988. // {
  5989. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5990. // }
  5991. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5992. // {
  5993. // int orgid = CurrentUser.UserPost.OrgID;
  5994. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5995. // }
  5996. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5997. // {
  5998. // string shopid = CurrentUser.User.pemShop;
  5999. // lw.Add(string.Format("shopId in ({0})", shopid));
  6000. // }
  6001. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6002. // //{
  6003. // // int org_id = CurrentUser.UserPost.OrgID;
  6004. // // lw.Add(string.Format("OrgID={0}", org_id));
  6005. // //}
  6006. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6007. // }
  6008. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6009. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6010. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6011. //}
  6012. if (st == 5)
  6013. {
  6014. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6015. {
  6016. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6017. {
  6018. string shopid = CurrentUser.User.pemShop;
  6019. lw.Add(string.Format("shopId in ({0})", shopid));
  6020. }
  6021. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6022. {
  6023. int mrOrgid = CurrentUser.UserPost.OrgID;
  6024. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6025. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6026. }
  6027. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6028. //{
  6029. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6030. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6031. //}
  6032. else
  6033. {
  6034. string userIdStr = "";
  6035. if (posCode == "CustomerService")
  6036. {
  6037. userIdStr = CurrentUser.UserID + "_k";
  6038. }
  6039. else if (posCode == "Designer" || posCode == "wxDesigner")
  6040. {
  6041. userIdStr = CurrentUser.UserID + "_s";
  6042. }
  6043. else if (posCode == "Place")
  6044. {
  6045. userIdStr = CurrentUser.UserID + "_x";
  6046. }
  6047. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6048. }
  6049. }
  6050. string placedate1 = GetPostString("placedate1");
  6051. string placedate2 = GetPostString("placedate2");
  6052. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6053. if (dwplace.Length > 0) lw.Add(dwplace);
  6054. string supState = GetPostString("supState");
  6055. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6056. string searchType = GetPostString("searchType");
  6057. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6058. {
  6059. lw.Add(string.Format("BackNum>1"));
  6060. }
  6061. lw.Add(string.Format("AfterSaleState>0"));
  6062. if (ex_psize > 0)
  6063. {
  6064. if (CurrentUser.UserPost.Post.Code == "Finance")
  6065. dStruct.Order = "pay_time desc";
  6066. else
  6067. dStruct.Order = "HandleTime desc";
  6068. }
  6069. else
  6070. dStruct.Order = "HandleTime desc";
  6071. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6072. DataTable dt = WebCache.GetData("view_test", dStruct);
  6073. writeGridDataTableJson(dStruct.TotalCount, dt);
  6074. }
  6075. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6076. //{
  6077. // lw.Add(string.Format("AfterSaleState=4"));
  6078. // string code = CurrentUser.UserPost.Post.Code;
  6079. // if (code == "CustomerService")
  6080. // {
  6081. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6082. // }
  6083. // else if (code == "Designer" || code == "DesignerMr")
  6084. // {
  6085. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6086. // }
  6087. // else if (code == "Place" || code == "PlaceMr")
  6088. // {
  6089. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6090. // }
  6091. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6092. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6093. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6094. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6095. //}
  6096. //else //处理中的售后,待处理和处理中合并
  6097. //{
  6098. // if (afterState.Length <= 0)
  6099. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6100. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6101. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6102. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6103. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6104. //}
  6105. }
  6106. public void get_erp_disagreeftersalelist()
  6107. {
  6108. DataStruct dStruct = GetPostStruct();
  6109. List<string> lw = new List<string>();
  6110. int st = 2;
  6111. string tid = GetPostString("ctid");
  6112. if (tid.Length > 0)
  6113. {
  6114. string select_tid = getTidByCtid(tid);
  6115. lw.Add(string.Format("tid='{0}'", select_tid));
  6116. }
  6117. string shopname = GetPostString("shopname");
  6118. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6119. string buyernick = GetPostString("buyer_nick");
  6120. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6121. string sellermemo = GetPostString("seller_memo");
  6122. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6123. string orderState = GetPostString("orderState");
  6124. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6125. string afterState = GetPostString("afterstate");
  6126. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6127. string date1 = GetPostString("date1");
  6128. string date2 = GetPostString("date2");
  6129. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6130. if (dw.Length > 0) lw.Add(dw);
  6131. string price1 = GetPostString("price1");
  6132. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6133. string price2 = GetPostString("price2");
  6134. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6135. //lw.Add(string.Format("IsRefund!={0}", 1));
  6136. string reason = GetPostString("reason");
  6137. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6138. string method = GetPostString("method");
  6139. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6140. string handler = GetPostString("handler");
  6141. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6142. string handledate1 = GetPostString("handledate1");
  6143. string handledate2 = GetPostString("handledate2");
  6144. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6145. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6146. string afterdate1 = GetPostString("afterdate1");
  6147. string afterdate2 = GetPostString("afterdate2");
  6148. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6149. if (afterDate.Length > 0) lw.Add(afterDate);
  6150. string backdate1 = GetPostString("backdate1");
  6151. string backdate2 = GetPostString("backdate2");
  6152. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6153. if (backDate.Length > 0) lw.Add(backDate);
  6154. string supplier = GetPostString("supplier");
  6155. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6156. string responsible = GetPostString("responsibleman");
  6157. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6158. string customer = GetPostString("customer");
  6159. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6160. string design = GetPostString("design");
  6161. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6162. string afterSaleMemo = GetPostString("afterSaleMemo");
  6163. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6164. string afterMemoType = GetPostString("aftermemotype");
  6165. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6166. string aftersakereason = GetPostString("aftersakereason");
  6167. if (aftersakereason.Length > 0)
  6168. {
  6169. if (aftersakereason == "1")
  6170. {
  6171. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6172. }
  6173. if (aftersakereason == "2")
  6174. {
  6175. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6176. }
  6177. }
  6178. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6179. string poscode = CurrentUser.UserPost.Post.Code;
  6180. if (poscode != "SysAdmin")
  6181. {
  6182. string shopid = CurrentUser.User.pemShop;
  6183. lw.Add(string.Format("shopId in ({0})", shopid));
  6184. }
  6185. string searchType = GetPostString("searchType");
  6186. if (searchType == "wait")
  6187. {
  6188. lw.Add(string.Format("HandleTime is null"));
  6189. }
  6190. if (searchType == "handling")
  6191. {
  6192. lw.Add(string.Format("HandleTime is not null "));
  6193. }
  6194. if (searchType == "back" || searchType == "puBack")
  6195. {
  6196. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6197. }
  6198. if (searchType == "reBack")
  6199. {
  6200. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6201. }
  6202. if (searchType == "moreBack")
  6203. {
  6204. lw.Add(string.Format("backNum > 1"));
  6205. }
  6206. lw.Add(string.Format("(AfterSaleState=5)"));
  6207. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6208. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6209. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6210. writeGridDataTableJson(dStruct.TotalCount, dt);
  6211. }
  6212. public void get_erp_handlingaftersalelist()
  6213. {
  6214. DataStruct dStruct = GetPostStruct();
  6215. List<string> lw = new List<string>();
  6216. int st = 2;
  6217. string tid = GetPostString("ctid");
  6218. if (tid.Length > 0)
  6219. {
  6220. string select_tid = getTidByCtid(tid);
  6221. lw.Add(string.Format("tid='{0}'", select_tid));
  6222. }
  6223. string shopname = GetPostString("shopname");
  6224. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6225. string buyernick = GetPostString("buyer_nick");
  6226. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6227. string sellermemo = GetPostString("seller_memo");
  6228. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6229. string orderState = GetPostString("orderState");
  6230. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6231. string afterState = GetPostString("afterstate");
  6232. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6233. string date1 = GetPostString("date1");
  6234. string date2 = GetPostString("date2");
  6235. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6236. if (dw.Length > 0) lw.Add(dw);
  6237. string price1 = GetPostString("price1");
  6238. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6239. string price2 = GetPostString("price2");
  6240. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6241. //lw.Add(string.Format("IsRefund!={0}", 1));
  6242. string reason = GetPostString("reason");
  6243. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6244. string method = GetPostString("method");
  6245. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6246. string handler = GetPostString("handler");
  6247. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6248. string handledate1 = GetPostString("handledate1");
  6249. string handledate2 = GetPostString("handledate2");
  6250. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6251. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6252. string afterdate1 = GetPostString("afterdate1");
  6253. string afterdate2 = GetPostString("afterdate2");
  6254. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6255. if (afterDate.Length > 0) lw.Add(afterDate);
  6256. string supplier = GetPostString("supplier");
  6257. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6258. string responsible = GetPostString("responsibleman");
  6259. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6260. string customer = GetPostString("customer");
  6261. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6262. string design = GetPostString("design");
  6263. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6264. string afterSaleMemo = GetPostString("afterSaleMemo");
  6265. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6266. string afterMemoType = GetPostString("aftermemotype");
  6267. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6268. string afterresult = GetPostString("afterresult");
  6269. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6270. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6271. string poscode = CurrentUser.UserPost.Post.Code;
  6272. if (poscode != "SysAdmin")
  6273. {
  6274. string shopid = CurrentUser.User.pemShop;
  6275. lw.Add(string.Format("shopId in ({0})", shopid));
  6276. }
  6277. string searchType = GetPostString("searchType");
  6278. if (searchType == "wait")
  6279. {
  6280. lw.Add(string.Format("HandleTime is null"));
  6281. }
  6282. if (searchType == "documentary")
  6283. {
  6284. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6285. }
  6286. if (searchType == "handling")
  6287. {
  6288. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6289. }
  6290. if (searchType == "back" || searchType == "puBack")
  6291. {
  6292. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6293. }
  6294. if (searchType == "reBack")
  6295. {
  6296. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6297. }
  6298. if (afterState.Length <= 0)
  6299. {
  6300. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6301. }
  6302. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6303. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6304. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6305. writeGridDataTableJson(dStruct.TotalCount, dt);
  6306. }
  6307. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6308. //public void get_erp_back_handlingaftersalelist()
  6309. //{
  6310. // DataStruct dStruct = GetPostStruct();
  6311. // List<string> lw = new List<string>();
  6312. // string tid = GetPostString("ctid");
  6313. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6314. // string shopname = GetPostString("shopname");
  6315. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6316. // string buyernick = GetPostString("buyer_nick");
  6317. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6318. // string sellermemo = GetPostString("seller_memo");
  6319. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6320. // string orderState = GetPostString("orderState");
  6321. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6322. // string afterState = GetPostString("afterstate");
  6323. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6324. // string date1 = GetPostString("date1");
  6325. // string date2 = GetPostString("date2");
  6326. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6327. // if (dw.Length > 0) lw.Add(dw);
  6328. // string price1 = GetPostString("price1");
  6329. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6330. // string price2 = GetPostString("price2");
  6331. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6332. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6333. // string reason = GetPostString("reason");
  6334. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6335. // string method = GetPostString("method");
  6336. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6337. // string handler = GetPostString("handler");
  6338. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6339. // string handledate1 = GetPostString("handledate1");
  6340. // string handledate2 = GetPostString("handledate2");
  6341. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6342. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6343. // string afterdate1 = GetPostString("afterdate1");
  6344. // string afterdate2 = GetPostString("afterdate2");
  6345. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6346. // if (afterDate.Length > 0) lw.Add(afterDate);
  6347. // string supplier = GetPostString("supplier");
  6348. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6349. // string responsible = GetPostString("responsibleman");
  6350. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6351. // string customer = GetPostString("customer");
  6352. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6353. // string design = GetPostString("design");
  6354. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6355. // string afterMemoType = GetPostString("aftermemotype");
  6356. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6357. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6358. // if (afterState.Length <= 0)
  6359. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6360. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6361. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6362. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6363. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6364. //}
  6365. public void get_erp_aftersaleverifylist()
  6366. {
  6367. DataStruct dStruct = GetPostStruct();
  6368. List<string> lw = new List<string>();
  6369. string tid = GetPostString("ctid");
  6370. if (tid.Length > 0)
  6371. {
  6372. string select_tid = getTidByCtid(tid);
  6373. lw.Add(string.Format("otid='{0}'", select_tid));
  6374. }
  6375. string shopname = GetPostString("shopname");
  6376. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6377. string buyernick = GetPostString("buyer_nick");
  6378. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6379. string sellermemo = GetPostString("seller_memo");
  6380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6381. string orderState = GetPostString("orderState");
  6382. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6383. //lw.Add(string.Format("IsRefund!={0}", 1));
  6384. string reason = GetPostString("reason");
  6385. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6386. string method = GetPostString("method");
  6387. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6388. string handler = GetPostString("handler");
  6389. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6390. string handledate1 = GetPostString("handledate1");
  6391. string handledate2 = GetPostString("handledate2");
  6392. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6393. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6394. string finish1 = GetPostString("finishdate1");
  6395. string finish2 = GetPostString("finishdate2");
  6396. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6397. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6398. string supplier = GetPostString("supplier");
  6399. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6400. string responsible = GetPostString("responsibleman");
  6401. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6402. string posCode = CurrentUser.UserPost.Post.Code;
  6403. string vstate = GetPostString("vstate");
  6404. if (vstate.Length > 0)
  6405. {
  6406. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6407. }
  6408. if (posCode == "Supplier")
  6409. {
  6410. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6411. lw.Add(string.Format("VerifyState = 0"));
  6412. lw.Add("type = 1");
  6413. lw.Add(string.Format("AfterSaleState={0}", 3));
  6414. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6415. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6416. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6417. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6418. writeGridDataTableJson(dStruct.TotalCount, dt);
  6419. }
  6420. else if (posCode == "logistics")
  6421. {
  6422. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6423. lw.Add(string.Format("VerifyState = 0"));
  6424. lw.Add("type = 2");
  6425. lw.Add(string.Format("AfterSaleState={0}", 3));
  6426. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6427. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6428. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6429. writeGridDataTableJson(dStruct.TotalCount, dt);
  6430. }
  6431. else
  6432. {
  6433. lw.Add(string.Format("(AfterSaleState = 3)"));
  6434. string reasonState = GetPostString("reasonState");
  6435. lw.Add("type = 0");
  6436. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6437. || posCode == "Summarize" || posCode == "Finance")
  6438. {
  6439. if (reasonState == "2")
  6440. {
  6441. lw.Add("VerifyState = 3");
  6442. }
  6443. else if (reasonState == "1")
  6444. {
  6445. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6446. }
  6447. else
  6448. {
  6449. lw.Add("VerifyState in (0,3)");
  6450. }
  6451. //不加条件,可以看全部
  6452. }
  6453. 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")
  6454. {
  6455. int orgid = CurrentUser.UserPost.OrgID;
  6456. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6457. if (string.IsNullOrEmpty(manageOrgId))
  6458. {
  6459. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6460. }
  6461. else
  6462. {
  6463. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6464. }
  6465. if (reasonState == "1")
  6466. {
  6467. lw.Add("VerifyState = 3");
  6468. }
  6469. else if (reasonState == "2")
  6470. {
  6471. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6472. }
  6473. else
  6474. {
  6475. }
  6476. }
  6477. else
  6478. {
  6479. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6480. }
  6481. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6482. //{
  6483. // int org_id = CurrentUser.UserPost.OrgID;
  6484. // lw.Add(string.Format("OrgID={0}", org_id));
  6485. //}
  6486. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6487. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6488. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6489. writeGridDataTableJson(dStruct.TotalCount, dt);
  6490. }
  6491. }
  6492. public void get_erp_finishaftersalelist()
  6493. {
  6494. DataStruct dStruct = GetPostStruct();
  6495. List<string> lw = new List<string>();
  6496. int st = 4;
  6497. string tid = GetPostString("ctid");
  6498. if (tid.Length > 0)
  6499. {
  6500. string select_tid = getTidByCtid(tid);
  6501. lw.Add(string.Format("otid='{0}'", select_tid));
  6502. }
  6503. string shopname = GetPostString("shopname");
  6504. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6505. //lw.Add(string.Format("IsRefund!={0}", 1));
  6506. string reason = GetPostString("reason");
  6507. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6508. string method = GetPostString("method");
  6509. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6510. string buyernick = GetPostString("buyer_nick");
  6511. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6512. string handler = GetPostString("handler");
  6513. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6514. string handledate1 = GetPostString("handledate1");
  6515. string handledate2 = GetPostString("handledate2");
  6516. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6517. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6518. string finish1 = GetPostString("finishdate1");
  6519. string finish2 = GetPostString("finishdate2");
  6520. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6521. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6522. string supplier = GetPostString("supplier");
  6523. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6524. string responsible = GetPostString("responsibleman");
  6525. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6526. string vstate = GetPostString("vstate");
  6527. if (vstate.Length > 0)
  6528. {
  6529. if ("3".Equals(vstate))
  6530. {
  6531. lw.Add(string.Format("IsTem=1"));
  6532. }
  6533. else
  6534. {
  6535. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6536. }
  6537. }
  6538. lw.Add(string.Format("AfterSaleState=4"));
  6539. string code = CurrentUser.UserPost.Post.Code;
  6540. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6541. {
  6542. //不加条件,可以看全部
  6543. }
  6544. else if (code == "Supplier")
  6545. {
  6546. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6547. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6548. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6549. }
  6550. else if (code == "logistics")
  6551. {
  6552. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6553. lw.Add("type = 2");
  6554. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6555. }
  6556. 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")
  6557. {
  6558. int orgid = CurrentUser.UserPost.OrgID;
  6559. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6560. if (string.IsNullOrEmpty(manageOrgIds))
  6561. {
  6562. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6563. }
  6564. else
  6565. {
  6566. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6567. }
  6568. }
  6569. else
  6570. {
  6571. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6572. }
  6573. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6574. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6575. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6576. writeGridDataTableJson(dStruct.TotalCount, dt);
  6577. }
  6578. public void handle_erp_aftersale()
  6579. {
  6580. if (UrlPostParmsCheck("ctid"))
  6581. {
  6582. string eid = GetPostString("ctid");
  6583. string responStr = GetPostString("AfterSaleResponsible");
  6584. if (responStr.Length <= 0)
  6585. {
  6586. returnErrorMsg("售后责任人不能为空");
  6587. return;
  6588. }
  6589. bool isDesign = false;
  6590. double designFree = 0.00;
  6591. int responsibleId = 0;
  6592. CeErpTradeCell entity = null;
  6593. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6594. if (entity != null)
  6595. {
  6596. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6597. string afterMethod = GetPostString("AfterSaleMethod");
  6598. if (isNeedNewOrder == 1)
  6599. {
  6600. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6601. bool ishav = true;
  6602. if (newentity == null)
  6603. {
  6604. newentity = entity.Clone() as CeErpTradeCell;
  6605. ishav = false;
  6606. newentity.ctid = "S_" + entity.ctid;
  6607. newentity.OrderState = 0;
  6608. //唯一标识
  6609. newentity.OrderSn = newentity.ctid;
  6610. string orderSn = dataHelper.getSaleOrderSn();
  6611. if (orderSn != "")
  6612. {
  6613. newentity.OrderSn = orderSn;
  6614. }
  6615. }
  6616. newentity.UpdateTime = DateTime.Now;
  6617. newentity.AfterSaleState = 0;
  6618. newentity.AfterSaleMethod = afterMethod;
  6619. if (!ishav)
  6620. {
  6621. string memo_str = newentity.seller_memo;
  6622. memo_str = memo_str.Replace("(", "(");
  6623. memo_str = memo_str.Replace(")", ")");
  6624. int sIndex = memo_str.IndexOf("(");
  6625. int eIndex = memo_str.IndexOf(")");
  6626. if (sIndex == -1 || eIndex == -1)
  6627. {
  6628. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6629. return;
  6630. }
  6631. string first = memo_str.Substring(0, sIndex + 1);
  6632. string memoCtid = newentity.OrderSn;
  6633. //if (memoCtid.IndexOf("C") != -1)
  6634. //{
  6635. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6636. //if (CIdx.IndexOf("+") != -1)
  6637. //{
  6638. //CIdx = "C" + CIdx.Split('+')[1];
  6639. //}
  6640. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6641. //}
  6642. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6643. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6644. string newMemo = first + memoCtid + last;
  6645. newentity.seller_memo = newMemo;
  6646. newentity.FinishPlaceTime = null;
  6647. newentity.UnusualTag = 0;
  6648. newentity.UnusualCon = "";
  6649. newentity.UnusualTime = null;
  6650. newentity.AfterSaleMemo = "";
  6651. newentity.AfterSaleMethod = afterMethod;
  6652. newentity.AfterSalePreTime = null;
  6653. newentity.AfterSaleReason = "";
  6654. newentity.AfterSaleResponsible = "";
  6655. newentity.AfterSaleState = 0;
  6656. newentity.AfterSaleTime = null;
  6657. newentity.AfterSaleUserId = 0;
  6658. newentity.AfterSaleSupplierState = 0;
  6659. newentity.LastBillWaybillCode = "";
  6660. newentity.LastBillCpCode = "";
  6661. newentity.FinishAfterSaleTime = null;
  6662. newentity.HandleTime = null;
  6663. newentity.IsSF = 0;
  6664. newentity.IsOldCustomer = 0;
  6665. newentity.UrgencyTime = null;
  6666. newentity.ResponsibleUserId = "";
  6667. newentity.IsVerifyToSupplier = false;
  6668. newentity.payment = 0;
  6669. newentity.CheckMemo = "";
  6670. newentity.OutSid = "";
  6671. newentity.CheckOrderTime = null;
  6672. newentity.MemoOpt = 0;
  6673. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6674. }
  6675. newentity.isAfterSaleOrder = 1;
  6676. newentity.IsRefund = 0;
  6677. string receiveMobile = GetPostString("receiver_mobile");
  6678. if (receiveMobile.Length > 0)
  6679. {
  6680. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6681. if (trade != null)
  6682. {
  6683. trade.receiver_name = GetPostString("receiver_name");
  6684. trade.receiver_mobile = receiveMobile;
  6685. trade.receiver_state = GetPostString("receiver_state");
  6686. trade.receiver_city = GetPostString("receiver_city");
  6687. trade.receiver_district = GetPostString("receiver_district");
  6688. trade.receiver_address = GetPostString("receiver_address");
  6689. newentity.IsOffLineOrder = 1;
  6690. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6691. }
  6692. }
  6693. string st = GetPostString("ToState");
  6694. if (st.Length > 0)
  6695. {
  6696. if (newentity.OrderState <= 3)
  6697. {
  6698. newentity.WaitDesignTime = DateTime.Now;
  6699. newentity.StartDesignTime = null;
  6700. newentity.FinishDesignTime = null;
  6701. newentity.OrderState = 3;
  6702. if (st == "下单员")
  6703. {
  6704. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6705. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6706. {
  6707. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6708. }
  6709. }
  6710. else
  6711. {
  6712. newentity.WaitDesignTime = DateTime.Now;
  6713. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6714. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6715. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6716. {
  6717. DataRow user = dt1.Rows[0];
  6718. //找主管
  6719. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6720. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6721. if (dt != null && dt.Rows.Count > 0)
  6722. {
  6723. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6724. newentity.DesignUserId = designMr;
  6725. string key = "aftersale_order_" + designMr;
  6726. if (RedisHelper.HasKey(key))
  6727. {
  6728. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6729. list.Add(newentity.ctid);
  6730. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6731. }
  6732. }
  6733. //账号正常
  6734. if (user["State"].ToString() == "0")
  6735. {
  6736. newentity.DesignUserId = entity.DesignUserId;
  6737. string key = "aftersale_order_" + entity.DesignUserId;
  6738. if (RedisHelper.HasKey(key))
  6739. {
  6740. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6741. list.Add(newentity.ctid);
  6742. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6743. }
  6744. }
  6745. }
  6746. }
  6747. }
  6748. if (entity.IsXianHuo == 1)
  6749. {
  6750. newentity.OrderState = 6;
  6751. entity.FinishPlaceTime = DateTime.Now;
  6752. }
  6753. }
  6754. if (ishav)
  6755. {
  6756. newentity.Update();
  6757. }
  6758. else
  6759. {
  6760. newentity.Create();
  6761. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6762. newCellExtend.ctid = newentity.ctid;
  6763. newCellExtend.orderFrom = 20;
  6764. newCellExtend.orderType = 30;
  6765. if (st == "下单员")
  6766. {
  6767. }
  6768. else
  6769. {
  6770. newCellExtend.ReprintTime = DateTime.Now;
  6771. }
  6772. newCellExtend.Create();
  6773. }
  6774. if (st != "下单员")
  6775. {
  6776. if (entity.DispatchSort == 2)
  6777. {
  6778. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6779. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6780. }
  6781. }
  6782. }
  6783. //处理售后扩展
  6784. string resIdStr = GetPostString("ResponsibleUserId");
  6785. string refundFees = GetPostString("refundFrees");
  6786. int IsComplain = GetPostInt("isComplain");
  6787. int IsBad = GetPostInt("isBad");
  6788. string IsOriginal = GetPostString("isOriginal");
  6789. double diffResultPrice = GetPostDouble("diffResultPrice");
  6790. string textResult = GetPostString("textResult");
  6791. string supplierResponsible = GetPostString("supplierResponsible");
  6792. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6793. if (ceErpTradeAfterSaleExtend == null)
  6794. {
  6795. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6796. ceErpTradeAfterSaleExtend.tid = eid;
  6797. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6798. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6799. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6800. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6801. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6802. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6803. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6804. ceErpTradeAfterSaleExtend.Create();
  6805. }
  6806. else
  6807. {
  6808. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6809. {
  6810. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6811. }
  6812. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6813. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6814. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6815. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6816. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6817. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6818. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6819. ceErpTradeAfterSaleExtend.Update();
  6820. }
  6821. int gysid = GetPostInt("ResponsibleSupId");
  6822. if (entity.AfterSaleUserId == 0)
  6823. {
  6824. entity.AfterSaleUserId = CurrentUser.UserID;
  6825. }
  6826. entity.ResponsibleUserId = resIdStr;
  6827. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6828. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6829. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6830. {
  6831. CeErpTradeResponsible.DelByTid(eid, -1);
  6832. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6833. int backNum = 0;
  6834. if (number != null)
  6835. {
  6836. backNum = number.BackNum;
  6837. }
  6838. char[] separator = { ',' };
  6839. string[] sArray = resIdStr.Split(separator);
  6840. string[] refundFreeList = { };
  6841. if (refundFees.Length > 0)
  6842. {
  6843. refundFreeList = refundFees.Split(separator);
  6844. }
  6845. int index = -1;
  6846. foreach (string i in sArray)
  6847. {
  6848. index++;
  6849. if (i.Length <= 0) continue;
  6850. char[] separator2 = { '_' };
  6851. string idstr = i.Split(separator2)[0];
  6852. string idtype = i.Split(separator2)[1];
  6853. double refudFree = 0;
  6854. if (refundFreeList.Length > 0)
  6855. {
  6856. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6857. }
  6858. if (idtype == "s")
  6859. {
  6860. isDesign = true;
  6861. designFree = refudFree;
  6862. }
  6863. int userId = Convert.ToInt32(idstr);
  6864. int type = 0;
  6865. if (idtype == "g")
  6866. {
  6867. type = 1;
  6868. }
  6869. if (idtype == "w")
  6870. {
  6871. type = 2;
  6872. }
  6873. if (idtype == "t")
  6874. {
  6875. type = 3;
  6876. }
  6877. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6878. if (ceErpTradeResponsible == null)
  6879. {
  6880. ceErpTradeResponsible = new CeErpTradeResponsible();
  6881. ceErpTradeResponsible.tid = eid;
  6882. ceErpTradeResponsible.UserId = userId;
  6883. ceErpTradeResponsible.createdTime = DateTime.Now;
  6884. ceErpTradeResponsible.type = type;
  6885. if (type == 1)
  6886. {
  6887. ceErpTradeResponsible.IsSup = 1;
  6888. }
  6889. if (type == 2)
  6890. {
  6891. ceErpTradeResponsible.IsFlow = 1;
  6892. }
  6893. }
  6894. ceErpTradeResponsible.RefundFee = refudFree;
  6895. ceErpTradeResponsible.VerifyState = 0;
  6896. if (userId == 2125 || idtype == "w")
  6897. {
  6898. ceErpTradeResponsible.VerifyState = 1;
  6899. }
  6900. if (idtype == "w" && userId == 101)
  6901. {
  6902. ceErpTradeResponsible.VerifyState = 0;
  6903. }
  6904. if (ceErpTradeResponsible.ID > 0)
  6905. {
  6906. ceErpTradeResponsible.Update();
  6907. }
  6908. else
  6909. {
  6910. ceErpTradeResponsible.Create();
  6911. }
  6912. if (isDesign)
  6913. {
  6914. responsibleId = ceErpTradeResponsible.ID;
  6915. }
  6916. }
  6917. CeErpTradeResponsible.NumByTid(backNum, eid);
  6918. }
  6919. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6920. if (ceErpTradeCellExtend != null)
  6921. {
  6922. ceErpTradeCellExtend.returnVisit = 0;
  6923. ceErpTradeCellExtend.Update();
  6924. }
  6925. if (entity.HandleTime != null)
  6926. {
  6927. if (entity.AfterSaleState == 1)
  6928. {
  6929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6930. }
  6931. else
  6932. {
  6933. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6934. }
  6935. }
  6936. else
  6937. {
  6938. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6939. entity.HandleTime = DateTime.Now;
  6940. }
  6941. bool isCompale = false;
  6942. if (entity.AfterSaleState == 5)
  6943. {
  6944. isCompale = true;
  6945. entity.AfterSaleState = 3;
  6946. }
  6947. entity.AfterSaleSupplierState = 0;
  6948. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6949. {
  6950. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6951. }
  6952. string sImgs = GetPostString("img");
  6953. entity.AfterSaleSupplierImg = sImgs;
  6954. entity.supRefundType = GetPostString("supRefundType");
  6955. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6956. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6957. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6958. entity.AfterSaleMemoType = GetPostString("MemoType");
  6959. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6960. {
  6961. //entity.AfterSaleSupplierState = 2;
  6962. }
  6963. string df = GetPostString("DeductFee");
  6964. if (df == "")
  6965. {
  6966. df = "0";
  6967. }
  6968. string rf = GetPostString("RefundFee");
  6969. if (rf == "")
  6970. {
  6971. rf = "0";
  6972. }
  6973. string pm = GetPostString("AfterSalePayment");
  6974. if (pm == "")
  6975. {
  6976. pm = "0";
  6977. }
  6978. entity.AfterSalePayment = Convert.ToDouble(pm);
  6979. entity.DeductFee = Convert.ToDouble(df);
  6980. entity.RefundFee = Convert.ToDouble(rf);
  6981. entity.UpdateTime = DateTime.Now;
  6982. entity.Update();
  6983. string toState = GetPostString("ToState");
  6984. string original = GetPostString("isOriginal");
  6985. ApiVo apiVo = new ApiVo();
  6986. apiVo.orderNumber = entity.ctid;
  6987. apiVo.actionName = "afterDesign";
  6988. apiVo.orderRemarks = entity.AfterSaleMethod;
  6989. apiVo.reasonRemarks = entity.AfterSaleReason;
  6990. apiVo.isDesign = isDesign;
  6991. apiVo.designFree = designFree;
  6992. apiVo.responsibleId = responsibleId;
  6993. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6994. if (toState == "设计师")
  6995. {
  6996. apiVo.isOriginal = Convert.ToBoolean(original);
  6997. }
  6998. designHelper.API_WorkCore(apiVo);//afterDesign
  6999. CeErpMethod methodSql = new CeErpMethod();
  7000. methodSql.con = entity.AfterSaleMethod;
  7001. methodSql.addTime = DateTime.Now;
  7002. methodSql.Create();
  7003. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7004. CeErpMethod.ExecuteNonQuery(delsql);
  7005. if (isCompale)
  7006. {
  7007. aftersale_data_change(entity.ctid);
  7008. }
  7009. returnSuccessMsg("操作成功!");
  7010. return;
  7011. }
  7012. returnErrorMsg("找不到订单记录");
  7013. }
  7014. }
  7015. public void ins_erp_toresponsible()
  7016. {
  7017. if (UrlPostParmsCheck("ctid"))
  7018. {
  7019. string eid = GetPostString("ctid");
  7020. CeErpTradeCell entity = null;
  7021. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7022. if (entity != null)
  7023. {
  7024. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7025. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7026. {
  7027. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7028. return;
  7029. }
  7030. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7031. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7032. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7033. if (entity.AfterSalePreTime == null)
  7034. {
  7035. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7036. {
  7037. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7038. }
  7039. }
  7040. entity.AfterSalePreTime = DateTime.Now;
  7041. //预完成给售后主管审核客户问题直接完成
  7042. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7043. {
  7044. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7045. {
  7046. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7047. }
  7048. }
  7049. ceErpTradeAfterSaleExtend.Update();
  7050. entity.AfterSaleState = 2;
  7051. entity.UpdateTime = DateTime.Now;
  7052. entity.Update();
  7053. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7054. aftersale_data_change(entity.ctid);
  7055. returnSuccessMsg("操作成功!");
  7056. return;
  7057. }
  7058. returnErrorMsg("找不到订单记录");
  7059. }
  7060. }
  7061. public void cancel_erp_aftersaleanddelnew()
  7062. {
  7063. if (UrlPostParmsCheck("ctid"))
  7064. {
  7065. string eid = GetPostString("ctid");
  7066. CeErpTradeCell entity = null;
  7067. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7068. if (entity != null)
  7069. {
  7070. entity.AfterSaleState = 0;
  7071. entity.AfterSaleReason = "";
  7072. entity.AfterSaleMethod = "";
  7073. entity.AfterSaleMemo = "";
  7074. entity.AfterSaleResponsible = "";
  7075. entity.ResponsibleUserId = "";
  7076. entity.DeductFee = 0;
  7077. entity.RefundFee = 0;
  7078. entity.IsArbitrate = 0;
  7079. CeErpTradeResponsible.DelByTid(eid, -1);
  7080. entity.Update();
  7081. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7082. if (after != null)
  7083. {
  7084. if (after.OrderState < 5)
  7085. CeErpTradeCell.DelByCtid("S_" + eid);
  7086. }
  7087. returnSuccessMsg("操作成功!");
  7088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7089. return;
  7090. }
  7091. returnErrorMsg("找不到订单记录");
  7092. }
  7093. }
  7094. public void get_erp_aftersale_pregather()
  7095. {
  7096. List<string> lw = new List<string>();
  7097. int st = GetInt("st");
  7098. string tid = GetPostString("ctid");
  7099. if (tid.Length > 0)
  7100. {
  7101. string select_tid = getTidByCtid(tid);
  7102. lw.Add(string.Format("tid='{0}'", select_tid));
  7103. }
  7104. string shopname = GetPostString("shopname");
  7105. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7106. string buyernick = GetPostString("buyer_nick");
  7107. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7108. string sellermemo = GetPostString("seller_memo");
  7109. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7110. string orderState = GetPostString("orderState");
  7111. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7112. string reason = GetPostString("reason");
  7113. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7114. string method = GetPostString("method");
  7115. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7116. string handler = GetPostString("handler");
  7117. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7118. string handledate1 = GetPostString("handledate1");
  7119. string handledate2 = GetPostString("handledate2");
  7120. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7121. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7122. string supplier = GetPostString("supplier");
  7123. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7124. string responsible = GetPostString("responsibleman");
  7125. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7126. string customer = GetPostString("customer");
  7127. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7128. string design = GetPostString("design");
  7129. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7130. string afterMemoType = GetPostString("aftermemotype");
  7131. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7132. string afterSaleMemo = GetPostString("afterSaleMemo");
  7133. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7134. string afterresult = GetPostString("afterresult");
  7135. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7136. string poscode = CurrentUser.UserPost.Post.Code;
  7137. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7138. {
  7139. string shopid = CurrentUser.User.pemShop;
  7140. lw.Add(string.Format("shopId in ({0})", shopid));
  7141. }
  7142. var mainwhere = string.Join(" and ", lw.ToArray());
  7143. string ro_json = "";
  7144. string type = GetPostString("gather_type");
  7145. int number = 0;
  7146. if (poscode == "AfterSale")
  7147. {
  7148. //处理中
  7149. if (type == "Handling")
  7150. {
  7151. 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) : ""));
  7152. DataTable dt = null;
  7153. try
  7154. {
  7155. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7156. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7157. }
  7158. catch (Exception e)
  7159. {
  7160. dt = new DataTable();
  7161. }
  7162. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7163. return;
  7164. }
  7165. if (type == "Wait")
  7166. {
  7167. //待处理
  7168. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7169. DataTable dt1 = null;
  7170. try
  7171. {
  7172. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7173. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7174. }
  7175. catch (Exception e)
  7176. {
  7177. dt1 = new DataTable();
  7178. }
  7179. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7180. return;
  7181. }
  7182. if (type == "back")
  7183. {
  7184. //打回
  7185. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7186. DataTable dt2 = null;
  7187. try
  7188. {
  7189. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7190. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7191. }
  7192. catch (Exception e)
  7193. {
  7194. dt2 = new DataTable();
  7195. }
  7196. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7197. return;
  7198. }
  7199. if (type == "preCompletion")
  7200. {
  7201. //预完成
  7202. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7203. DataTable dt3 = null;
  7204. try
  7205. {
  7206. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7207. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7208. }
  7209. catch (Exception e)
  7210. {
  7211. dt3 = new DataTable();
  7212. }
  7213. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7214. return;
  7215. }
  7216. if (type == "documentary")
  7217. {
  7218. //跟单中
  7219. 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) : ""));
  7220. DataTable dt4 = null;
  7221. try
  7222. {
  7223. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7224. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7225. }
  7226. catch (Exception e)
  7227. {
  7228. dt4 = new DataTable();
  7229. }
  7230. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7231. return;
  7232. }
  7233. if (type == "reBack")
  7234. {
  7235. //被打回
  7236. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7237. DataTable dt1 = null;
  7238. try
  7239. {
  7240. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7241. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7242. }
  7243. catch (Exception e)
  7244. {
  7245. dt1 = new DataTable();
  7246. }
  7247. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7248. return;
  7249. }
  7250. }
  7251. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7252. {
  7253. if (type == "puBack")
  7254. {
  7255. //退回
  7256. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7257. DataTable dt = null;
  7258. try
  7259. {
  7260. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7261. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7262. }
  7263. catch (Exception e)
  7264. {
  7265. dt = new DataTable();
  7266. }
  7267. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7268. return;
  7269. }
  7270. if (type == "reBack")
  7271. {
  7272. //打回
  7273. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7274. DataTable dt1 = null;
  7275. try
  7276. {
  7277. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7278. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7279. }
  7280. catch (Exception e)
  7281. {
  7282. dt1 = new DataTable();
  7283. }
  7284. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7285. return;
  7286. }
  7287. if (type == "examEd")
  7288. {
  7289. //已审核
  7290. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7291. DataTable dt2 = null;
  7292. try
  7293. {
  7294. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7295. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7296. }
  7297. catch (Exception e)
  7298. {
  7299. dt2 = new DataTable();
  7300. }
  7301. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7302. return;
  7303. }
  7304. if (type == "waitExam")
  7305. {
  7306. //待审核
  7307. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7308. DataTable dt3 = null;
  7309. try
  7310. {
  7311. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7312. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7313. }
  7314. catch (Exception e)
  7315. {
  7316. dt3 = new DataTable();
  7317. }
  7318. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7319. return;
  7320. }
  7321. if (type == "Handling")
  7322. {
  7323. //处理中
  7324. 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) : ""));
  7325. DataTable dt4 = null;
  7326. try
  7327. {
  7328. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7329. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7330. }
  7331. catch (Exception e)
  7332. {
  7333. dt4 = new DataTable();
  7334. }
  7335. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7336. return;
  7337. }
  7338. if (type == "Wait")
  7339. {
  7340. //待处理
  7341. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7342. DataTable dt5 = null;
  7343. try
  7344. {
  7345. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7346. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7347. }
  7348. catch (Exception e)
  7349. {
  7350. dt5 = new DataTable();
  7351. }
  7352. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7353. return;
  7354. }
  7355. if (type == "documentary")
  7356. {
  7357. //跟单中
  7358. 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) : ""));
  7359. DataTable dt6 = null;
  7360. try
  7361. {
  7362. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7363. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7364. }
  7365. catch (Exception e)
  7366. {
  7367. dt6 = new DataTable();
  7368. }
  7369. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7370. return;
  7371. }
  7372. }
  7373. returnSuccess(ro_json);
  7374. }
  7375. public void end_erp_aftersale()
  7376. {
  7377. if (UrlPostParmsCheck("ctid"))
  7378. {
  7379. string eid = GetPostString("ctid");
  7380. CeErpTradeCell entity = null;
  7381. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7382. if (entity != null)
  7383. {
  7384. string stype = GetPostString("stype");
  7385. string typeStr = stype;
  7386. entity.AfterSaleState = 4;
  7387. entity.FinishAfterSaleTime = DateTime.Now;
  7388. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7389. entity.Update();
  7390. ApiVo apiVo = new ApiVo();
  7391. apiVo.orderNumber = entity.ctid;
  7392. apiVo.actionName = "afterOver";
  7393. designHelper.API_WorkCore(apiVo); //afterOver
  7394. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7395. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7396. CeErpSukuraData.createInfo(entity.ctid, 8);
  7397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7398. returnSuccessMsg("操作成功!");
  7399. return;
  7400. }
  7401. returnErrorMsg("找不到订单记录");
  7402. }
  7403. }
  7404. public void ins_erp_finishaftersale()
  7405. {
  7406. if (UrlPostParmsCheck("id"))
  7407. {
  7408. string eid = GetPostString("id");
  7409. CeErpTradeResponsible entity = null;
  7410. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7411. if (entity != null)
  7412. {
  7413. entity.VerifyState = 1;
  7414. entity.VerifyTime = DateTime.Now;
  7415. entity.Update();
  7416. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7417. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7418. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7419. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7420. if (dt.Rows.Count <= 0)
  7421. {
  7422. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7423. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7424. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7425. CeErpSukuraData.createInfo(entity.tid, 8);
  7426. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7427. {
  7428. CeErpDesignerBill.Del(entity.tid);
  7429. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7430. }
  7431. }
  7432. returnSuccessMsg("操作成功!");
  7433. return;
  7434. }
  7435. returnErrorMsg("找不到订单记录");
  7436. }
  7437. }
  7438. public void upd_erp_arbitrateaftersale()
  7439. {
  7440. if (UrlPostParmsCheck("id"))
  7441. {
  7442. string eid = GetPostString("id");
  7443. CeErpTradeResponsible entity = null;
  7444. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7445. if (entity != null)
  7446. {
  7447. entity.IsArbitrate = 1;
  7448. entity.ArbitradeMemo = GetPostString("reason");
  7449. entity.VerifyState = 2;
  7450. entity.Update();
  7451. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7452. if (tradecell != null)
  7453. {
  7454. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7455. tradecell.IsArbitrate = 1;
  7456. tradecell.Update();
  7457. }
  7458. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7459. returnSuccessMsg("操作成功!");
  7460. return;
  7461. }
  7462. returnErrorMsg("找不到订单记录");
  7463. }
  7464. }
  7465. public void upd_erp_backaftersale()
  7466. {
  7467. if (UrlPostParmsCheck("tid"))
  7468. {
  7469. string eid = GetPostString("tid");
  7470. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7471. int backNum = 0;
  7472. if (number != null)
  7473. {
  7474. backNum = number.BackNum;
  7475. }
  7476. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7477. CeErpTradeCell entity = null;
  7478. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7479. if (entity != null)
  7480. {
  7481. entity.AfterSaleBackReason = GetPostString("backreason");
  7482. entity.AfterSaleState = 1;
  7483. entity.AfterSaleSupplierState = 0;
  7484. entity.UpdateTime = DateTime.Now;
  7485. entity.Update();
  7486. returnSuccessMsg("操作成功!");
  7487. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7488. return;
  7489. }
  7490. returnErrorMsg("找不到订单记录");
  7491. }
  7492. }
  7493. public void get_erp_supplieraftersalelist()
  7494. {
  7495. DataStruct dStruct = GetPostStruct();
  7496. List<string> lw = new List<string>();
  7497. string tid = GetPostString("ctid");
  7498. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7499. string shopname = GetPostString("shopname");
  7500. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7501. string buyernick = GetPostString("buyer_nick");
  7502. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7503. string sellermemo = GetPostString("seller_memo");
  7504. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7505. string orderState = GetPostString("orderState");
  7506. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7507. string afterState = GetPostString("afterstate");
  7508. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7509. string date1 = GetPostString("date1");
  7510. string date2 = GetPostString("date2");
  7511. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7512. if (dw.Length > 0) lw.Add(dw);
  7513. string price1 = GetPostString("price1");
  7514. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7515. string price2 = GetPostString("price2");
  7516. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7517. string reason = GetPostString("reason");
  7518. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7519. string method = GetPostString("method");
  7520. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7521. string handledate1 = GetPostString("handledate1");
  7522. string handledate2 = GetPostString("handledate2");
  7523. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7524. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7525. string handler = GetPostString("handler");
  7526. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7527. string afterdate1 = GetPostString("afterdate1");
  7528. string afterdate2 = GetPostString("afterdate2");
  7529. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7530. if (afterDate.Length > 0) lw.Add(afterDate);
  7531. string customer = GetPostString("customer");
  7532. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7533. string design = GetPostString("design");
  7534. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7535. string afterMemoType = GetPostString("aftermemotype");
  7536. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7537. string vstate = GetPostString("vstate");
  7538. if (vstate.Length > 0)
  7539. {
  7540. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7541. }
  7542. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7543. string supplier = GetPostString("supplier");
  7544. int supid = commonHelper.getSupplierIDByName(supplier);
  7545. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7546. string posCode = CurrentUser.UserPost.Post.Code;
  7547. if (posCode == "Supplier")
  7548. {
  7549. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7550. }
  7551. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7552. {
  7553. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7554. }
  7555. else
  7556. {
  7557. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7558. }
  7559. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7560. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7562. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7563. writeGridDataTableJson(dStruct.TotalCount, dt);
  7564. }
  7565. public void upd_erp_supverifyaftersale()
  7566. {
  7567. if (UrlPostParmsCheck("id"))
  7568. {
  7569. string id = GetPostString("id");
  7570. int st = GetPostInt("afterstate");
  7571. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7572. CeErpTradeCell entity = null;
  7573. if (ceErpTradeResponsible != null)
  7574. {
  7575. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7576. }
  7577. string afmemo = GetPostString("supmemo");
  7578. string image = GetPostString("image");
  7579. if (entity != null)
  7580. {
  7581. entity.AfterSaleSupplierState = st;
  7582. entity.AfterSaleSupplierMemo = afmemo;
  7583. if (st == 1)
  7584. {
  7585. ceErpTradeResponsible.VerifyState = 1;
  7586. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7587. ceErpTradeResponsible.Update();
  7588. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7589. if (isAll)
  7590. {
  7591. entity.AfterSaleState = 4;
  7592. entity.FinishAfterSaleTime = DateTime.Now;
  7593. }
  7594. }
  7595. else
  7596. {
  7597. CeErpTradeResponsible.dateByTid(entity.ctid);
  7598. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7599. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7600. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7601. if (num <= 1)
  7602. {
  7603. entity.AfterSaleState = 1;
  7604. }
  7605. else
  7606. {
  7607. entity.AfterSaleState = 5;
  7608. }
  7609. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7610. if (ceErpTradeAfterSaleExtend != null)
  7611. {
  7612. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7613. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7614. ceErpTradeAfterSaleExtend.Update();
  7615. }
  7616. else
  7617. {
  7618. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7619. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7620. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7621. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7622. ceErpTradeAfterSaleExtend.Create();
  7623. }
  7624. }
  7625. if (entity.AfterSaleState == 4)
  7626. {
  7627. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7628. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7629. {
  7630. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7631. }
  7632. ApiVo apiVo = new ApiVo();
  7633. apiVo.orderNumber = entity.ctid;
  7634. apiVo.actionName = "afterOver";
  7635. designHelper.API_WorkCore(apiVo); //afterOver
  7636. }
  7637. entity.UpdateTime = DateTime.Now;
  7638. entity.Update();
  7639. returnSuccessMsg("操作成功!");
  7640. CeErpSukuraData.createInfo(entity.ctid, 8);
  7641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7642. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7643. return;
  7644. }
  7645. returnErrorMsg("找不到订单记录");
  7646. }
  7647. }
  7648. public void upd_erp_masteraftersale()
  7649. {
  7650. if (UrlPostParmsCheck("id"))
  7651. {
  7652. string id = GetPostString("id");
  7653. int st = GetPostInt("afterstate");
  7654. string afmemo = GetPostString("supmemo");
  7655. string image = GetPostString("image");
  7656. string textResult = GetPostString("textResult");
  7657. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7658. if (ceErpTradeResponsible != null)
  7659. {
  7660. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7661. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7662. ceErpTradeResponsible.Update();
  7663. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7664. if (entity != null)
  7665. {
  7666. entity.AfterSaleSupplierState = st;
  7667. entity.AfterSaleSupplierMemo = afmemo;
  7668. if (st == 1)
  7669. {
  7670. }
  7671. else
  7672. {
  7673. CeErpTradeResponsible.dateByTid(entity.ctid);
  7674. //退回到售后
  7675. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7676. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7677. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7678. if (num <= 1)
  7679. {
  7680. entity.AfterSaleState = 1;
  7681. }
  7682. else
  7683. {
  7684. entity.AfterSaleState = 5;
  7685. }
  7686. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7687. if (ceErpTradeAfterSaleExtend != null)
  7688. {
  7689. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7690. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7691. ceErpTradeAfterSaleExtend.Update();
  7692. }
  7693. else
  7694. {
  7695. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7696. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7697. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7698. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7699. ceErpTradeAfterSaleExtend.Create();
  7700. }
  7701. }
  7702. entity.UpdateTime = DateTime.Now;
  7703. entity.Update();
  7704. returnSuccessMsg("操作成功!");
  7705. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7706. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7707. return;
  7708. }
  7709. }
  7710. returnErrorMsg("找不到订单记录");
  7711. }
  7712. }
  7713. public void upd_erp_personaftersale()
  7714. {
  7715. if (UrlPostParmsCheck("id"))
  7716. {
  7717. //林小连
  7718. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7719. {
  7720. upd_erp_masteraftersale();
  7721. return;
  7722. }
  7723. string id = GetPostString("id");
  7724. int st = GetPostInt("afterstate");
  7725. string afmemo = GetPostString("supmemo");
  7726. string image = GetPostString("image");
  7727. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7728. if (ceErpTradeResponsible != null)
  7729. {
  7730. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7731. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7732. ceErpTradeResponsible.Update();
  7733. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7734. if (entity != null)
  7735. {
  7736. entity.AfterSaleSupplierMemo = afmemo;
  7737. entity.AfterSaleSupplierState = st;
  7738. if (st == 1)
  7739. {
  7740. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7741. if (isAll)
  7742. {
  7743. entity.AfterSaleState = 4;
  7744. entity.FinishAfterSaleTime = DateTime.Now;
  7745. }
  7746. }
  7747. else
  7748. {
  7749. CeErpTradeResponsible.dateByTid(entity.ctid);
  7750. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7751. if (ceErpTradeAfterSaleExtend != null)
  7752. {
  7753. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7754. ceErpTradeAfterSaleExtend.Update();
  7755. }
  7756. else
  7757. {
  7758. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7759. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7760. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7761. ceErpTradeAfterSaleExtend.Create();
  7762. }
  7763. //退回到主管
  7764. //entity.AfterSaleState = 2;
  7765. }
  7766. if (entity.AfterSaleState == 4)
  7767. {
  7768. ApiVo apiVo = new ApiVo();
  7769. apiVo.orderNumber = entity.ctid;
  7770. apiVo.actionName = "afterOver";
  7771. designHelper.API_WorkCore(apiVo); //afterOver
  7772. }
  7773. entity.UpdateTime = DateTime.Now;
  7774. entity.Update();
  7775. returnSuccessMsg("操作成功!");
  7776. CeErpSukuraData.createInfo(entity.ctid, 8);
  7777. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7778. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7779. return;
  7780. }
  7781. }
  7782. returnErrorMsg("找不到订单记录");
  7783. }
  7784. }
  7785. public void set_erp_supplierrefundtag()
  7786. {
  7787. if (UrlPostParmsCheck("ctid"))
  7788. {
  7789. string eid = GetPostString("ctid");
  7790. CeErpTradeCell entity = null;
  7791. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7792. if (entity != null)
  7793. {
  7794. entity.IsSupplierRefund = GetPostInt("tag");
  7795. entity.Update();
  7796. returnSuccessMsg("操作成功!");
  7797. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7798. return;
  7799. }
  7800. returnErrorMsg("找不到订单记录");
  7801. }
  7802. }
  7803. public void get_erp_refundlist()
  7804. {
  7805. DataStruct dStruct = GetPostStruct();
  7806. List<string> lw = new List<string>();
  7807. string tid = GetPostString("tid");
  7808. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7809. //string rid = GetPostString("refund_id");
  7810. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7811. string shopname = GetPostString("shopname");
  7812. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7813. string buyernick = GetPostString("buyer_nick");
  7814. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7815. string customer = GetPostString("customer");
  7816. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7817. string design = GetPostString("design");
  7818. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7819. string sellermemo = GetPostString("seller_memo");
  7820. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7821. //string date1 = GetPostString("date1");
  7822. //string date2 = GetPostString("date2");
  7823. //string dateType = GetPostString("dateType");
  7824. //if (dateType.Length > 0)
  7825. //{
  7826. // if (dateType == "1001") dateType = "0";
  7827. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7828. // if (searchDT.Count == 2)
  7829. // {
  7830. // date1 = searchDT[0].ToString();
  7831. // date2 = searchDT[1].ToString();
  7832. // }
  7833. //}
  7834. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7835. //if (dw.Length > 0) lw.Add(dw);
  7836. string redate1 = GetPostString("refunddate1");
  7837. string redate2 = GetPostString("refunddate2");
  7838. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7839. if (dwdate.Length > 0) lw.Add(dwdate);
  7840. string price1 = GetPostString("price1");
  7841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7842. string price2 = GetPostString("price2");
  7843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7844. string ispartrefund = GetPostString("ispartrefund");
  7845. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7846. string refundState = GetPostString("refundvstate");
  7847. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7848. int st = GetInt("st");
  7849. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7850. {
  7851. string responsible = GetPostString("responsibleman");
  7852. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7853. lw.Add(string.Format("RefundState>={0}", st));
  7854. string code = CurrentUser.UserPost.Post.Code;
  7855. if (code == "CustomerService")
  7856. {
  7857. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7858. }
  7859. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7860. {
  7861. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7862. }
  7863. else if (code == "Place" || code == "PlaceMr")
  7864. {
  7865. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7866. }
  7867. dStruct.Order = "RefundState asc,created desc";
  7868. }
  7869. else if (st == 10)
  7870. {
  7871. string responsible = GetPostString("responsibleman");
  7872. if (responsible == "空白")
  7873. {
  7874. lw.Add(string.Format("ResponsibleUserName = ''"));
  7875. }
  7876. else if (responsible.Length > 0)
  7877. {
  7878. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7879. }
  7880. lw.Add(string.Format("RefundState>=0"));
  7881. dStruct.Order = "created desc";
  7882. }
  7883. else
  7884. {
  7885. string responsible = GetPostString("responsibleman");
  7886. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7887. lw.Add(string.Format("RefundState={0}", st));
  7888. dStruct.Order = "created desc";
  7889. }
  7890. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7891. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7892. dt.Columns.Add("refund_fees");
  7893. foreach (DataRow dr in dt.Rows)
  7894. {
  7895. String status = dr["status"].ToString();
  7896. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7897. {
  7898. dr["refund_fees"] = dr["refund_fee"];
  7899. }
  7900. else
  7901. {
  7902. dr["refund_fees"] = "0.0";
  7903. }
  7904. }
  7905. writeGridDataTableJson(dStruct.TotalCount, dt);
  7906. }
  7907. public void get_erp_refunddesignlist()
  7908. {
  7909. DataStruct dStruct = GetPostStruct();
  7910. List<string> lw = new List<string>();
  7911. string tid = GetPostString("tid");
  7912. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7913. string shopname = GetPostString("shopname");
  7914. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7915. string buyernick = GetPostString("buyer_nick");
  7916. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7917. string customer = GetPostString("customer");
  7918. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7919. string design = GetPostString("design");
  7920. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7921. string sellermemo = GetPostString("seller_memo");
  7922. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7923. string redate1 = GetPostString("refunddate1");
  7924. string redate2 = GetPostString("refunddate2");
  7925. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7926. if (dwdate.Length > 0) lw.Add(dwdate);
  7927. string price1 = GetPostString("price1");
  7928. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7929. string price2 = GetPostString("price2");
  7930. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7931. string ispartrefund = GetPostString("ispartrefund");
  7932. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7933. string designerorg = GetPostString("designerorg");
  7934. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7935. string refundState = GetPostString("refundState");
  7936. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7937. int myOrgid = CurrentUser.UserPost.OrgID;
  7938. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7939. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7940. {
  7941. if (CurrentUser.User.TeamIds.Length > 0)
  7942. {
  7943. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7944. }
  7945. else
  7946. {
  7947. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7948. }
  7949. }
  7950. else if ("SysAdmin".Equals(myOrgCode))
  7951. {
  7952. }
  7953. else
  7954. {
  7955. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7956. {
  7957. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7958. }
  7959. else
  7960. {
  7961. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7962. }
  7963. }
  7964. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7965. dStruct.Order = "created desc";
  7966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7967. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7968. dt.Columns.Add("refund_fees");
  7969. foreach (DataRow dr in dt.Rows)
  7970. {
  7971. String status = dr["status"].ToString();
  7972. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7973. {
  7974. dr["refund_fees"] = dr["refund_fee"];
  7975. }
  7976. else
  7977. {
  7978. dr["refund_fees"] = "0.0";
  7979. }
  7980. }
  7981. writeGridDataTableJson(dStruct.TotalCount, dt);
  7982. }
  7983. public void handle_erp_refundtag()
  7984. {
  7985. if (UrlPostParmsCheck("refund_id"))
  7986. {
  7987. string eid = GetPostString("refund_id");
  7988. string respMan = GetPostString("ResponsibleName");
  7989. if (respMan.Length <= 0)
  7990. {
  7991. returnErrorMsg("责任人不能为空");
  7992. return;
  7993. }
  7994. CeErpTradeRefund entity = null;
  7995. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7996. if (entity != null)
  7997. {
  7998. entity.ResponsibleUserName = respMan;
  7999. string userid = GetPostString("ResponsibleUserId");
  8000. if (userid.Length > 0)
  8001. {
  8002. entity.ResponsibleUserId = userid;
  8003. }
  8004. entity.Memo = GetPostString("Memo");
  8005. if (respMan.IndexOf("客服") != -1 ||
  8006. respMan.IndexOf("设计师") != -1 ||
  8007. respMan.IndexOf("下单员") != -1)
  8008. {
  8009. entity.RefundState = 2;
  8010. }
  8011. else
  8012. {
  8013. entity.RefundState = 3;
  8014. }
  8015. entity.modified = DateTime.Now;
  8016. entity.Update();
  8017. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8018. returnSuccessMsg("操作成功!");
  8019. return;
  8020. }
  8021. returnErrorMsg("找不到订单记录");
  8022. }
  8023. }
  8024. public void handle_erp_designrefundtag()
  8025. {
  8026. if (UrlPostParmsCheck("refund_id"))
  8027. {
  8028. string eid = GetPostString("refund_id");
  8029. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8030. if (ceErpTradeCellExtend == null)
  8031. {
  8032. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8033. ceErpTradeCellExtend.ctid = eid;
  8034. }
  8035. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8036. if (ceErpTradeCellExtend.ID > 0)
  8037. {
  8038. ceErpTradeCellExtend.Update();
  8039. }
  8040. else
  8041. {
  8042. ceErpTradeCellExtend.Create();
  8043. }
  8044. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8045. returnSuccessMsg("操作成功!");
  8046. return;
  8047. }
  8048. returnErrorMsg("找不到订单记录");
  8049. }
  8050. public void upd_erp_refundverify()
  8051. {
  8052. if (UrlPostParmsCheck("refund_id"))
  8053. {
  8054. string eid = GetPostString("refund_id");
  8055. CeErpTradeRefund entity = null;
  8056. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8057. if (entity != null)
  8058. {
  8059. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8060. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8061. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8062. {
  8063. entity.RefundState = 2;
  8064. }
  8065. else
  8066. {
  8067. entity.RefundState = 3;
  8068. }
  8069. entity.Update();
  8070. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8071. returnSuccessMsg("操作成功!");
  8072. return;
  8073. }
  8074. returnErrorMsg("找不到订单记录");
  8075. }
  8076. }
  8077. public void upd_erp_refundapprove()
  8078. {
  8079. if (UrlPostParmsCheck("refund_id"))
  8080. {
  8081. string eid = GetPostString("refund_id");
  8082. CeErpTradeRefund entity = null;
  8083. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8084. if (entity != null)
  8085. {
  8086. int apr = GetPostInt("approve");
  8087. if (apr == 0)
  8088. {
  8089. entity.RefundState = 1;
  8090. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8091. }
  8092. else if (apr == 1)
  8093. {
  8094. entity.RefundState = 3;
  8095. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8096. }
  8097. entity.modified = DateTime.Now;
  8098. entity.Update();
  8099. returnSuccessMsg("操作成功!");
  8100. return;
  8101. }
  8102. returnErrorMsg("找不到订单记录");
  8103. }
  8104. }
  8105. public void get_erp_billlist()
  8106. {
  8107. DataStruct dStruct = GetPostStruct();
  8108. List<string> lw = new List<string>();
  8109. string title = GetPostString("title");
  8110. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8111. string tid = GetPostString("tid");
  8112. string tids = GetPostString("tids");
  8113. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8114. if (tids.Length > 0)
  8115. {
  8116. tids = "'" + tids + "'";
  8117. tids = tids.Replace(",", "','");
  8118. lw.Add(string.Format("tid in ({0})", tids));
  8119. }
  8120. string shopname = GetPostString("shopname");
  8121. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8122. string buyernick = GetPostString("buyer_nick");
  8123. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8124. string customer = GetPostString("customer");
  8125. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8126. string date1 = GetPostString("date1");
  8127. string date2 = GetPostString("date2");
  8128. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8129. if (dw.Length > 0) lw.Add(dw);
  8130. string price1 = GetPostString("price1");
  8131. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8132. string price2 = GetPostString("price2");
  8133. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8134. string returndate1 = GetPostString("returndate1");
  8135. string returndate2 = GetPostString("returndate2");
  8136. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8137. if (dw1.Length > 0) lw.Add(dw1);
  8138. string billtype = GetPostString("billtype");
  8139. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8140. string billstate = GetPostString("billstate");
  8141. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8142. string usershop = CurrentUser.User.pemShop;
  8143. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8144. dStruct.Order = "createTime desc";
  8145. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8146. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8147. //foreach (DataRow dr in dt.Rows)
  8148. //{
  8149. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8150. //}
  8151. writeGridDataTableJson(dStruct.TotalCount, dt);
  8152. }
  8153. public void modify_erp_billinfo()
  8154. {
  8155. if (UrlPostParmsCheck("ID"))
  8156. {
  8157. string eid = GetPostString("ID");
  8158. CeErpBill bill_entity = null;
  8159. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8160. if (bill_entity != null)
  8161. {
  8162. bill_entity.tid = GetPostString("tid");
  8163. bill_entity.title = GetPostString("title");
  8164. bill_entity.tax = GetPostString("tax");
  8165. bill_entity.bank = GetPostString("bank");
  8166. bill_entity.bankac = GetPostString("bankac");
  8167. bill_entity.address = GetPostString("address");
  8168. bill_entity.phone = GetPostString("phone");
  8169. bill_entity.price = GetPostString("price");
  8170. bill_entity.productId = GetPostInt("ProductName");
  8171. bill_entity.num = GetPostInt("num");
  8172. bill_entity.unit = GetPostString("unit");
  8173. bill_entity.type = GetPostString("type");
  8174. bill_entity.sendType = GetPostString("SendType");
  8175. bill_entity.email = GetPostString("email");
  8176. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8177. bill_entity.shopName = GetPostString("ShopName");
  8178. bill_entity.applymemo = GetPostString("applymemo");
  8179. bill_entity.modifyTime = DateTime.Now;
  8180. bill_entity.createTime = DateTime.Now;
  8181. bill_entity.state = 0;
  8182. bill_entity.Update();
  8183. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8184. returnSuccessMsg("发票修改成功!");
  8185. return;
  8186. }
  8187. returnErrorMsg("找不到对应记录");
  8188. }
  8189. }
  8190. public void set_erp_invoicing()
  8191. {
  8192. if (UrlPostParmsCheck("id"))
  8193. {
  8194. try
  8195. {
  8196. string eid = GetPostString("id");
  8197. CeErpBill bill_entity = null;
  8198. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8199. if (bill_entity != null)
  8200. {
  8201. int ComId = GetPostInt("ComId");
  8202. //string memo = GetPostString("Memo");
  8203. int allInfo = GetPostInt("allinfo");
  8204. string clert = CurrentUser.User.Name;
  8205. //string detailValue = GetPostString("detailvalue");
  8206. string billId = bill_entity.billOrderId;
  8207. string[] billIdList = billId.Split(',');
  8208. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8209. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8210. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8211. {
  8212. billCount += 1;
  8213. }
  8214. if (billId.Length <= 0 || billIdList.Length != billCount)
  8215. {
  8216. bill_entity.billOrderId = "";
  8217. string prebill = "ltb";
  8218. for (int idx = 1; idx <= billCount; idx++)
  8219. {
  8220. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8221. string billoid = prebill + idx + dtstr;
  8222. bill_entity.billOrderId += billoid;
  8223. if (idx < billCount)
  8224. {
  8225. bill_entity.billOrderId += ",";
  8226. }
  8227. }
  8228. }
  8229. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8230. if (bill_entity.state == 5)
  8231. {
  8232. string errMsg = bill_entity.failerror;
  8233. string[] errlist = errMsg.Split('|');
  8234. string[] errTags = new string[errlist.Length];
  8235. for (int itag = 0; itag < errlist.Length; itag++)
  8236. {
  8237. if (errlist[itag].Length <= 0) continue;
  8238. errTags[itag] = errlist[itag].Split('&')[0];
  8239. }
  8240. for (int iii = 0; iii < errTags.Length; iii++)
  8241. {
  8242. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8243. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8244. if (billOrderList.Length >= erroBillOrderTag)
  8245. {
  8246. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8247. if (needModifyBillId.Length <= 19)
  8248. {
  8249. needModifyBillId = needModifyBillId + "1";
  8250. }
  8251. else
  8252. {
  8253. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8254. last = last + 1;
  8255. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8256. }
  8257. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8258. }
  8259. }
  8260. }
  8261. bool isHaveBillSucces = false;
  8262. string totalRes = "";
  8263. bill_entity.failerror = "";
  8264. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8265. {
  8266. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8267. totalRes += res;
  8268. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8269. {
  8270. isHaveBillSucces = true;
  8271. bill_entity.comId = ComId;
  8272. bill_entity.state = 1;
  8273. bill_entity.executeTime = DateTime.Now;
  8274. bill_entity.executeUser = clert;
  8275. }
  8276. else
  8277. {
  8278. bill_entity.state = 5;
  8279. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8280. }
  8281. }
  8282. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8283. bill_entity.Update();
  8284. if (isHaveBillSucces)
  8285. {
  8286. StringBuilder sql = new StringBuilder();
  8287. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8288. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8289. }
  8290. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8291. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8292. {
  8293. returnErrorMsg("开票失败");
  8294. }
  8295. else
  8296. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8297. return;
  8298. }
  8299. returnErrorMsg("找不到对应记录");
  8300. }
  8301. catch (Exception ex)
  8302. {
  8303. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8304. returnErrorMsg("操作失败");
  8305. }
  8306. }
  8307. }
  8308. public void get_erp_invoicing_back()
  8309. {
  8310. if (UrlPostParmsCheck("id"))
  8311. {
  8312. try
  8313. {
  8314. string id = GetPostString("id");
  8315. CeErpBill entiy = CeErpBill.Get(id);
  8316. if (entiy != null)
  8317. {
  8318. if (entiy.state == 0)
  8319. {
  8320. returnErrorMsg("发票还未开具");
  8321. return;
  8322. }
  8323. string[] billOrderList = entiy.billOrderId.Split(',');
  8324. int iTag = 0;
  8325. entiy.fplsh = "";
  8326. entiy.fpdm = "";
  8327. entiy.fphm = "";
  8328. foreach (string billOrderId in billOrderList)
  8329. {
  8330. iTag++;
  8331. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8332. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8333. {
  8334. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8335. try
  8336. {
  8337. Invoicing_get_response_Obj iObj = null;
  8338. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8339. if (iObj != null)
  8340. {
  8341. entiy.state = 2;
  8342. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8343. entiy.fpdm += iObj.list[0].c_fpdm;
  8344. entiy.fphm += iObj.list[0].c_fphm;
  8345. if (iTag < billOrderList.Length)
  8346. {
  8347. entiy.fplsh += ",";
  8348. entiy.fpdm += ",";
  8349. entiy.fphm += ",";
  8350. }
  8351. entiy.Update();
  8352. }
  8353. StringBuilder sql = new StringBuilder();
  8354. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8355. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8356. returnSuccessMsg("开票成功");
  8357. }
  8358. catch (Exception ex)
  8359. {
  8360. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8361. }
  8362. return;
  8363. }
  8364. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8365. {
  8366. var res_obj = new
  8367. {
  8368. data = "开票中"
  8369. };
  8370. string ro_json = JsonConvert.SerializeObject(res_obj);
  8371. returnSuccess(ro_json);
  8372. return;
  8373. }
  8374. else
  8375. {
  8376. int eidx = res.IndexOf("c_resultmsg");
  8377. int lidx = res.IndexOf("c_status");
  8378. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8379. entiy.state = 5;
  8380. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8381. entiy.Update();
  8382. returnErrorMsg("开票失败");
  8383. return;
  8384. }
  8385. }
  8386. }
  8387. }
  8388. catch (Exception ex)
  8389. {
  8390. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8391. }
  8392. return;
  8393. }
  8394. }
  8395. public void get_erp_invoicing()
  8396. {
  8397. if (UrlPostParmsCheck("id"))
  8398. {
  8399. try
  8400. {
  8401. string id = GetPostString("id");
  8402. CeErpBill entiy = CeErpBill.Get(id);
  8403. if (entiy != null)
  8404. {
  8405. if (entiy.state == 0)
  8406. {
  8407. returnErrorMsg("发票还未开具");
  8408. return;
  8409. }
  8410. if (entiy.sendType == "纸质发票")
  8411. {
  8412. if (entiy.img.Length <= 0)
  8413. {
  8414. returnErrorMsg("查无纸质发票");
  8415. return;
  8416. }
  8417. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8418. returnSuccess(returnres);
  8419. return;
  8420. }
  8421. string[] billOrderList = entiy.billOrderId.Split(',');
  8422. int iTag = 0;
  8423. string fpUrl = "";
  8424. entiy.fplsh = "";
  8425. entiy.fpdm = "";
  8426. entiy.fphm = "";
  8427. foreach (string billOrderId in billOrderList)
  8428. {
  8429. iTag++;
  8430. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8431. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8432. {
  8433. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8434. Invoicing_get_response_Obj iObj = null;
  8435. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8436. if (iObj != null)
  8437. {
  8438. //entiy.state = 2;
  8439. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8440. entiy.fpdm += iObj.list[0].c_fpdm;
  8441. entiy.fphm += iObj.list[0].c_fphm;
  8442. if (iTag < billOrderList.Length)
  8443. {
  8444. entiy.fplsh += ",";
  8445. entiy.fpdm += ",";
  8446. entiy.fphm += ",";
  8447. }
  8448. entiy.Update();
  8449. fpUrl += iObj.list[0].c_url + ",";
  8450. }
  8451. //returnSuccess(res);
  8452. StringBuilder sql = new StringBuilder();
  8453. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8454. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8455. }
  8456. else
  8457. {
  8458. int eidx = res.IndexOf("c_resultmsg");
  8459. //int lidx = res.IndexOf("c_status");
  8460. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8461. //开票失败
  8462. entiy.state = 5;
  8463. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8464. entiy.Update();
  8465. returnErrorMsg("开票失败");
  8466. return;
  8467. }
  8468. }
  8469. var returnObj = new
  8470. {
  8471. data = fpUrl
  8472. };
  8473. string ro_json = JsonConvert.SerializeObject(returnObj);
  8474. returnSuccess(ro_json);
  8475. }
  8476. }
  8477. catch (Exception ex)
  8478. {
  8479. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8480. }
  8481. return;
  8482. }
  8483. }
  8484. public void save_erp_billimg()
  8485. {
  8486. if (UrlPostParmsCheck("id"))
  8487. {
  8488. string eid = GetPostString("id");
  8489. CeErpBill bill_entity = null;
  8490. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8491. if (bill_entity != null)
  8492. {
  8493. bill_entity.img = GetPostString("img");
  8494. bill_entity.executeTime = DateTime.Now;
  8495. bill_entity.state = 2;
  8496. bill_entity.Update();
  8497. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8498. returnSuccessMsg("保存成功");
  8499. }
  8500. return;
  8501. }
  8502. }
  8503. public void upd_erp_billreturnback()
  8504. {
  8505. if (UrlPostParmsCheck("id"))
  8506. {
  8507. int eid = GetPostInt("id");
  8508. CeErpBill bill_entity = null;
  8509. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8510. if (bill_entity != null)
  8511. {
  8512. bill_entity.state = 3;
  8513. bill_entity.returnReason = GetPostString("reason");
  8514. bill_entity.Update();
  8515. returnSuccessMsg("驳回成功!");
  8516. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8517. }
  8518. return;
  8519. }
  8520. }
  8521. public void cancel_erp_bill()
  8522. {
  8523. if (UrlPostParmsCheck("id"))
  8524. {
  8525. int eid = GetPostInt("id");
  8526. int detailValue = GetPostInt("detailvalue");
  8527. CeErpBill bill_entity = null;
  8528. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8529. string cres = "";
  8530. string gres = "";
  8531. if (bill_entity != null)
  8532. {
  8533. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8534. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8535. {
  8536. int iTag = 0;
  8537. bill_entity.fplsh = "";
  8538. bill_entity.fpdm = "";
  8539. bill_entity.fphm = "";
  8540. foreach (string billOrderId in billOrderList)
  8541. {
  8542. iTag++;
  8543. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8544. if (gres.IndexOf("success") != -1)
  8545. {
  8546. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8547. Invoicing_get_response_Obj iObj = null;
  8548. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8549. if (iObj != null)
  8550. {
  8551. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8552. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8553. bill_entity.fphm += iObj.list[0].c_fphm;
  8554. if (iTag < billOrderList.Length)
  8555. {
  8556. bill_entity.fplsh += ",";
  8557. bill_entity.fpdm += ",";
  8558. bill_entity.fphm += ",";
  8559. }
  8560. bill_entity.Update();
  8561. }
  8562. }
  8563. else
  8564. {
  8565. returnErrorMsg(gres);
  8566. return;
  8567. }
  8568. }
  8569. }
  8570. if (bill_entity.sendType == "纸质发票")
  8571. {
  8572. //作废
  8573. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8574. //if (DateTime.Now.Month == extime.Month)
  8575. //{
  8576. //cres = taobaoHelper.cancel_invoicing(eid);
  8577. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8578. //{
  8579. bill_entity.state = 4;//已作废
  8580. bill_entity.Update();
  8581. returnSuccessMsg("发票已作废");
  8582. return;
  8583. //}
  8584. //else
  8585. //{
  8586. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8587. // bill_entity.Update();
  8588. // returnErrorMsg(cres);
  8589. // return;
  8590. //}
  8591. //}
  8592. //else
  8593. //{
  8594. // returnErrorMsg("纸质发票只能作废本月的发票");
  8595. // return;
  8596. //}
  8597. }
  8598. //红冲
  8599. int redTag = 0;
  8600. string[] fpdmList = bill_entity.fpdm.Split(',');
  8601. string[] fphmList = bill_entity.fphm.Split(',');
  8602. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8603. {
  8604. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8605. return;
  8606. }
  8607. foreach (string billOrderId in billOrderList)
  8608. {
  8609. redTag++;
  8610. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8611. cres += onecres;
  8612. cres += ",";
  8613. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8614. {
  8615. bill_entity.state = 4;//已作废
  8616. //bill_entity.Update();
  8617. //returnSuccessMsg("发票已红冲");
  8618. }
  8619. else if (onecres.IndexOf("重复冲红") != -1)
  8620. {
  8621. bill_entity.state = 4;//已作废
  8622. //bill_entity.Update();
  8623. //returnSuccessMsg("发票已红冲");
  8624. }
  8625. else
  8626. {
  8627. string errmsg = commonHelper.KeepChinese(onecres);
  8628. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8629. }
  8630. }
  8631. bill_entity.Update();
  8632. if (cres.IndexOf("失败") != -1)
  8633. returnErrorMsg("红冲失败");
  8634. else
  8635. returnSuccessMsg("发票已红冲");
  8636. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8637. return;
  8638. }
  8639. return;
  8640. }
  8641. }
  8642. public void del_erp_billorder()
  8643. {
  8644. if (UrlPostParmsCheck("id"))
  8645. {
  8646. string eid = GetPostString("id");
  8647. CeErpBill.Del(eid);
  8648. CeErpBill bill = CeErpBill.Get(eid);
  8649. if (bill != null)
  8650. {
  8651. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8652. }
  8653. returnSuccessMsg("删除成功");
  8654. }
  8655. }
  8656. public void finish_erp_bill()
  8657. {
  8658. if (UrlPostParmsCheck("ids"))
  8659. {
  8660. string eids = GetPostString("ids");
  8661. string[] list = eids.Split(',');
  8662. foreach (string eid in list)
  8663. {
  8664. CeErpBill bill = CeErpBill.Get(eid);
  8665. if (bill != null)
  8666. {
  8667. bill.state = 2;
  8668. bill.Update();
  8669. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8670. }
  8671. }
  8672. returnSuccessMsg("操作成功");
  8673. }
  8674. }
  8675. public void get_erp_returncash()
  8676. {
  8677. DataStruct dStruct = GetPostStruct();
  8678. List<string> lw = new List<string>();
  8679. string tid = GetPostString("tid");
  8680. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8681. string shopname = GetPostString("shopname");
  8682. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8683. string buyernick = GetPostString("buyer_nick");
  8684. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8685. string customer = GetPostString("customer");
  8686. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8687. string returndate1 = GetPostString("returndate1");
  8688. string returndate2 = GetPostString("returndate2");
  8689. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8690. if (dw.Length > 0) lw.Add(dw);
  8691. string finishDate1 = GetPostString("finishdate1");
  8692. string finishDate2 = GetPostString("finishdate2");
  8693. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8694. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8695. string returntype = GetPostString("returntype");
  8696. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8697. string returnvstate = GetPostString("returnvstate");
  8698. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8699. dStruct.Order = "created desc";
  8700. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8701. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8702. writeGridDataTableJson(dStruct.TotalCount, dt);
  8703. }
  8704. public void get_erp_staygoods()
  8705. {
  8706. DataStruct dStruct = GetPostStruct();
  8707. List<string> lw = new List<string>();
  8708. string tid = GetPostString("tid");
  8709. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8710. string shopname = GetPostString("shopname");
  8711. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8712. string wangwang = GetPostString("wangwang");
  8713. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8714. string customer = GetPostString("customer");
  8715. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8716. string returndate1 = GetPostString("returndate1");
  8717. string returndate2 = GetPostString("returndate2");
  8718. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8719. if (dw.Length > 0) lw.Add(dw);
  8720. string finishDate1 = GetPostString("finishdate1");
  8721. string finishDate2 = GetPostString("finishdate2");
  8722. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8723. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8724. string returnvstate = GetPostString("returnvstate");
  8725. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8726. string persuadetype = GetPostString("persuadetype");
  8727. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8728. string customerOrg = GetPostString("customerOrg");
  8729. if (customerOrg.Length > 0)
  8730. {
  8731. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8732. }
  8733. dStruct.Order = "creata_time desc";
  8734. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8735. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8736. writeGridDataTableJson(dStruct.TotalCount, dt);
  8737. }
  8738. public void upd_erp_staygoods()
  8739. {
  8740. if (UrlPostParmsCheck("id"))
  8741. {
  8742. int eid = GetPostInt("id");
  8743. CeErpStayGoods entity = null;
  8744. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8745. if (entity != null)
  8746. {
  8747. entity.audit_type = 1;
  8748. entity.audit_time = DateTime.Now;
  8749. entity.audit_u_id = CurrentUser.UserID;
  8750. entity.audit_u_name = CurrentUser.UserName;
  8751. entity.Update();
  8752. returnSuccessMsg("审核成功!");
  8753. return;
  8754. }
  8755. returnErrorMsg("找不到订单记录");
  8756. }
  8757. }
  8758. public void upd_erp_stayGoodsback()
  8759. {
  8760. if (UrlPostParmsCheck("id"))
  8761. {
  8762. int eid = GetPostInt("id");
  8763. CeErpStayGoods entity = null;
  8764. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8765. if (entity != null)
  8766. {
  8767. entity.audit_text = GetPostString("reason");
  8768. entity.audit_type = 2;
  8769. entity.audit_time = DateTime.Now;
  8770. entity.audit_u_id = CurrentUser.UserID;
  8771. entity.audit_u_name = CurrentUser.UserName;
  8772. entity.Update();
  8773. returnSuccessMsg("退回成功!");
  8774. return;
  8775. }
  8776. returnErrorMsg("找不到订单记录");
  8777. }
  8778. }
  8779. public void upd_erp_returncashverify()
  8780. {
  8781. if (UrlPostParmsCheck("ID"))
  8782. {
  8783. int eid = GetPostInt("ID");
  8784. CeErpReturnCash entity = null;
  8785. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8786. if (entity != null)
  8787. {
  8788. entity.cashstate = 1;
  8789. entity.verifytime = DateTime.Now;
  8790. entity.verifyuserid = CurrentUser.UserID;
  8791. entity.Update();
  8792. returnSuccessMsg("审核成功!");
  8793. return;
  8794. }
  8795. returnErrorMsg("找不到订单记录");
  8796. }
  8797. }
  8798. public void upd_all_erp_returncashverify()
  8799. {
  8800. if (UrlPostParmsCheck("ID"))
  8801. {
  8802. String[] list = GetPostString("ID").Split(',');
  8803. CeErpReturnCash entity = null;
  8804. for (int i = 0; i < list.Length; i++)
  8805. {
  8806. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8807. if (entity != null)
  8808. {
  8809. if (entity.cashstate == 1)
  8810. {
  8811. returnErrorMsg("已审核过的订单不需要在审核!");
  8812. return;
  8813. }
  8814. entity.cashstate = 1;
  8815. entity.verifytime = DateTime.Now;
  8816. entity.verifyuserid = CurrentUser.UserID;
  8817. entity.Update();
  8818. }
  8819. }
  8820. returnSuccessMsg("审核成功!");
  8821. return;
  8822. }
  8823. }
  8824. public void upd_erp_returncashback()
  8825. {
  8826. if (UrlPostParmsCheck("ID"))
  8827. {
  8828. int eid = GetPostInt("ID");
  8829. CeErpReturnCash entity = null;
  8830. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8831. if (entity != null)
  8832. {
  8833. entity.backreason = GetPostString("reason");
  8834. entity.cashstate = 2;
  8835. entity.verifytime = DateTime.Now;
  8836. entity.verifyuserid = CurrentUser.UserID;
  8837. entity.Update();
  8838. returnSuccessMsg("退回成功!");
  8839. return;
  8840. }
  8841. returnErrorMsg("找不到订单记录");
  8842. }
  8843. }
  8844. public void upd_erp_returnprice()
  8845. {
  8846. if (UrlPostParmsCheck("ID"))
  8847. {
  8848. int eid = GetPostInt("ID");
  8849. CeErpReturnCash entity = null;
  8850. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8851. if (entity != null)
  8852. {
  8853. if (entity.cashstate == 1)
  8854. {
  8855. returnErrorMsg("审核通过了不能改");
  8856. return;
  8857. }
  8858. entity.returnprice = GetPostDouble("returnprice");
  8859. entity.Update();
  8860. returnSuccessMsg("修改成功!");
  8861. return;
  8862. }
  8863. returnErrorMsg("找不到订单记录");
  8864. }
  8865. }
  8866. public void del_erp_returncash()
  8867. {
  8868. if (UrlPostParmsCheck("ID"))
  8869. {
  8870. int eid = GetPostInt("ID");
  8871. CeErpReturnCash.Del(eid);
  8872. returnSuccessMsg("操作成功");
  8873. return;
  8874. }
  8875. }
  8876. public void test_for_do_sql()
  8877. {
  8878. string sql = GetPostString("sqlstr");
  8879. if (sql.Length > 0)
  8880. {
  8881. try
  8882. {
  8883. DbHelper.DbConn.ExecuteNonQuery(sql);
  8884. var res_obj = new
  8885. {
  8886. data = "成功",
  8887. };
  8888. string ro_json = JsonConvert.SerializeObject(res_obj);
  8889. returnSuccess(ro_json);
  8890. }
  8891. catch (Exception ex)
  8892. {
  8893. var res_obj = new
  8894. {
  8895. data = ex.Message,
  8896. };
  8897. string ro_json = JsonConvert.SerializeObject(res_obj);
  8898. returnSuccess(ro_json);
  8899. }
  8900. }
  8901. }
  8902. public void get_user_info()
  8903. {
  8904. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8905. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8906. }
  8907. public void get_total_data()
  8908. {
  8909. int userId = CurrentUser.UserID;
  8910. string sql = "";
  8911. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8912. {
  8913. 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);
  8914. }
  8915. else
  8916. {
  8917. 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 " +
  8918. "(select ID from CE_ErpUser where ID = {0}) d " +
  8919. "left join " +
  8920. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8921. ") a on d.ID = a.id left join " +
  8922. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8923. ") b on a.id = b.id1 left join" +
  8924. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8925. ") c on a.id = c.id2;", userId);
  8926. }
  8927. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8928. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8929. }
  8930. public void get_date_area_total_data2()
  8931. {
  8932. int userId = CurrentUser.UserID;
  8933. string date_type = GetPostString("timetype");
  8934. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8935. string sql = "";
  8936. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8937. {
  8938. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8939. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8940. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8941. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8942. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8943. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8944. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8945. ") a on e.ID = a.id left join " +
  8946. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8947. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8948. ") b on a.id = b.id1 " +
  8949. "left join " +
  8950. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8951. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8952. ") c on a.id = c.id2 " +
  8953. "left join " +
  8954. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8955. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8956. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8957. }
  8958. else
  8959. {
  8960. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8961. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8962. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8963. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8964. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8965. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8966. ") a on e.ID = a.id left join " +
  8967. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8968. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8969. ") c on a.id = c.id2 " +
  8970. "left join " +
  8971. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8972. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8973. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8974. }
  8975. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8976. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8977. }
  8978. public void get_date_area_total_data()
  8979. {
  8980. int userId = CurrentUser.UserID;
  8981. string date_type = GetPostString("timetype");
  8982. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8983. string date1 = searchDT[0].ToString();
  8984. string date2 = searchDT[1].ToString();
  8985. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8986. {
  8987. SqlParameter[] sqlParameter ={
  8988. new SqlParameter("@userId", SqlDbType.Int,4),
  8989. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8990. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8991. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8992. };
  8993. sqlParameter[0].Value = userId;
  8994. sqlParameter[1].Value = date1;
  8995. sqlParameter[2].Value = date2;
  8996. sqlParameter[3].Direction = ParameterDirection.Output;
  8997. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8998. string res = sqlParameter[3].Value.ToString();
  8999. var res_obj = new
  9000. {
  9001. data = res
  9002. };
  9003. string ro_json = JsonConvert.SerializeObject(res_obj);
  9004. returnSuccess(ro_json);
  9005. }
  9006. else
  9007. {
  9008. SqlParameter[] sqlParameter ={
  9009. new SqlParameter("@userId", SqlDbType.Int,4),
  9010. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9011. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9012. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9013. };
  9014. sqlParameter[0].Value = userId;
  9015. sqlParameter[1].Value = date1;
  9016. sqlParameter[2].Value = date2;
  9017. sqlParameter[3].Direction = ParameterDirection.Output;
  9018. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9019. string res = sqlParameter[3].Value.ToString();
  9020. var res_obj = new
  9021. {
  9022. data = res
  9023. };
  9024. string ro_json = JsonConvert.SerializeObject(res_obj);
  9025. returnSuccess(ro_json);
  9026. }
  9027. //writeGridDataViewJson(dt.Rows.Count, dv);
  9028. }
  9029. public void get_order_list()
  9030. {
  9031. string strFields = GetPostString("paraFields");
  9032. string strOrder = GetPostString("paraOrder");
  9033. string strWhere = GetPostString("paraWhere");
  9034. string strPageSize = GetPostString("paraPageSize");
  9035. DataStruct dStruct = GetPostStruct();
  9036. dStruct.PageSize = int.Parse(strPageSize);
  9037. dStruct.Fileds = strFields;
  9038. dStruct.Order = strOrder;
  9039. dStruct.MainWhere = strWhere;
  9040. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9041. writeGridDataTableJson(dStruct.TotalCount, dt);
  9042. }
  9043. ////获取待开始订单列表
  9044. //public void get_wait_design_order_list()
  9045. //{
  9046. // string date_type = GetPostString("date_type");
  9047. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9048. // DataStruct dStruct = GetPostStruct();
  9049. // dStruct.PageSize = 1000;
  9050. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9051. // List<string> lw = new List<string>();
  9052. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9053. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9054. // dStruct.Order = "WaitDesignTime asc";
  9055. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9056. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9057. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9058. //}
  9059. //获取完成单量排名
  9060. public void get_finish_order_count_ranking()
  9061. {
  9062. /* string date_type = GetPostString("date_type");
  9063. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9064. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9065. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9066. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9067. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9068. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9069. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9070. writeGridDataTableJson(0, new DataTable());
  9071. }
  9072. public void get_finish_order_amount_ranking()
  9073. {
  9074. /*string date_type = GetPostString("date_type");
  9075. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9076. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9077. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9078. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9079. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9080. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9081. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9082. writeGridDataTableJson(0, new DataTable());
  9083. }
  9084. public void get_finish_refund_count_ranking()
  9085. {
  9086. string date_type = GetPostString("date_type");
  9087. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9088. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9089. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9090. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9091. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9092. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9093. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9094. writeGridDataTableJson(dt.Rows.Count, dt);
  9095. }
  9096. public void get_finish_refund_amount_ranking()
  9097. {
  9098. string date_type = GetPostString("date_type");
  9099. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9100. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9101. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9102. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9103. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9104. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9105. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9106. writeGridDataTableJson(dt.Rows.Count, dt);
  9107. }
  9108. public void set_erp_finishorder_director()
  9109. {
  9110. if (UrlPostParmsCheck("ctid"))
  9111. {
  9112. string eid = GetPostString("ctid");
  9113. CeErpTradeCell entity = null;
  9114. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9115. if (entity != null)
  9116. {
  9117. entity.OrderState = 8;
  9118. entity.Update();
  9119. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9120. returnSuccessMsg("操作成功!");
  9121. return;
  9122. }
  9123. returnErrorMsg("找不到记录");
  9124. }
  9125. }
  9126. public void get_erp_placeregistlist()
  9127. {
  9128. DataStruct dStruct = GetPostStruct();
  9129. List<string> lw = new List<string>();
  9130. string outsid = GetPostString("outsid");
  9131. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9132. string memo = GetPostString("memo");
  9133. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9134. string filename = GetPostString("filename");
  9135. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9136. string islate = GetPostString("islate");
  9137. if (islate.Length > 0)
  9138. {
  9139. if (islate == "1")
  9140. lw.Add(string.Format("OutLate>0"));
  9141. else
  9142. lw.Add(string.Format("OutLate=0"));
  9143. }
  9144. string placedate1 = GetPostString("placedate1");
  9145. string placedate2 = GetPostString("placedate2");
  9146. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9147. if (dw.Length > 0) lw.Add(dw);
  9148. string deliveryDate1 = GetPostString("deliverydate1");
  9149. string deliveryDate2 = GetPostString("deliverydate2");
  9150. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9151. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9152. dStruct.Order = "ID desc";
  9153. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9154. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9155. writeGridDataTableJson(dStruct.TotalCount, dt);
  9156. }
  9157. public void ins_erp_placeregist()
  9158. {
  9159. if (UrlPostParmsCheck("id"))
  9160. {
  9161. string eid = GetPostString("id");
  9162. CeErpPlaceRegister entity = null;
  9163. if (eid == "0")//新增
  9164. {
  9165. entity = new CeErpPlaceRegister();
  9166. string xdTime = GetPostString("placeTime");
  9167. if (xdTime.Length > 0)
  9168. {
  9169. entity.PlactTime = Convert.ToDateTime(xdTime);
  9170. }
  9171. string fhTime = GetPostString("deliveryTime");
  9172. if (fhTime.Length > 0)
  9173. {
  9174. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9175. }
  9176. string preTime = GetPostString("preOutTime");
  9177. if (preTime.Length > 0)
  9178. {
  9179. entity.PreOutTime = Convert.ToDateTime(preTime);
  9180. }
  9181. entity.DeliveryCount = GetPostInt("deliveryCount");
  9182. entity.ReceiveCount = GetPostInt("receiveCount");
  9183. entity.OutSid = GetPostString("outSid");
  9184. entity.FileName = GetPostString("fileName");
  9185. entity.Memo = GetPostString("memo");
  9186. entity.AddUserId = CurrentUser.UserID;
  9187. entity.CreateTime = DateTime.Now;
  9188. entity.Img = GetPostString("img");
  9189. entity.Supplier = GetPostInt("supplier");
  9190. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9191. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9192. {
  9193. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9194. DateTime dt2 = (DateTime)entity.PreOutTime;
  9195. TimeSpan span = dt1.Subtract(dt2);
  9196. if (span.Days > 0)
  9197. {
  9198. entity.OutLate = span.Days;
  9199. }
  9200. }
  9201. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9202. entity.Create();
  9203. returnSuccessMsg("添加成功!");
  9204. return;
  9205. }
  9206. else //修改
  9207. {
  9208. entity = CeErpPlaceRegister.Get(eid);
  9209. if (entity != null)
  9210. {
  9211. string xdTime = GetPostString("placeTime");
  9212. if (xdTime.Length > 0)
  9213. {
  9214. entity.PlactTime = Convert.ToDateTime(xdTime);
  9215. }
  9216. string fhTime = GetPostString("deliveryTime");
  9217. if (fhTime.Length > 0)
  9218. {
  9219. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9220. }
  9221. string preTime = GetPostString("preOutTime");
  9222. if (preTime.Length > 0)
  9223. {
  9224. entity.PreOutTime = Convert.ToDateTime(preTime);
  9225. }
  9226. entity.DeliveryCount = GetPostInt("deliveryCount");
  9227. entity.ReceiveCount = GetPostInt("receiveCount");
  9228. if (entity.DeliveryCount == entity.ReceiveCount)
  9229. {
  9230. entity.CurState = "已完成";
  9231. }
  9232. else
  9233. {
  9234. entity.CurState = "未完成";
  9235. }
  9236. entity.OutSid = GetPostString("outSid");
  9237. entity.FileName = GetPostString("fileName");
  9238. entity.Memo = GetPostString("memo");
  9239. entity.Img = GetPostString("img");
  9240. entity.Supplier = GetPostInt("supplier");
  9241. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9242. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9243. {
  9244. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9245. DateTime dt2 = (DateTime)entity.PreOutTime;
  9246. TimeSpan span = dt1.Subtract(dt2);
  9247. if (span.Days > 0)
  9248. {
  9249. entity.OutLate = span.Days;
  9250. }
  9251. }
  9252. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9253. entity.Update();
  9254. returnSuccessMsg("修改成功");
  9255. return;
  9256. }
  9257. returnErrorMsg("找不到对应的记录");
  9258. return;
  9259. }
  9260. }
  9261. returnErrorMsg("缺少必要参数");
  9262. }
  9263. public void del_erp_placeregist()
  9264. {
  9265. string eid = GetPostString("id");
  9266. CeErpPlaceRegister.Del(eid);
  9267. returnSuccessMsg("删除成功!");
  9268. return;
  9269. }
  9270. public void ins_erp_placeregistbyorder()
  9271. {
  9272. string ctid = GetPostString("ctid");
  9273. if (ctid.Length > 0)
  9274. {
  9275. StringBuilder sql = new StringBuilder();
  9276. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9277. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9278. if (dt.Rows.Count > 0)
  9279. {
  9280. foreach (DataRow dr in dt.Rows)
  9281. {
  9282. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9283. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9284. entity.AddUserId = CurrentUser.UserID;
  9285. entity.tid = dr["tid"].ToString();
  9286. entity.Did = Convert.ToString(dr["ctid"]);
  9287. entity.splitTag = dr["SplitTag"].ToString();
  9288. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9289. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9290. if (pre_ctid.Length > 0)
  9291. {
  9292. sellmemo = sellmemo.Replace(pre_ctid, "");
  9293. }
  9294. sellmemo = sellmemo.Replace("[", "");
  9295. sellmemo = sellmemo.Replace("]", "");
  9296. entity.FileName = sellmemo;
  9297. string count = dr["ProductCount"].ToString();
  9298. int usecount = commonHelper.getIntCountFromString(count);
  9299. entity.DeliveryCount = usecount;
  9300. entity.CurState = "未完成";
  9301. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9302. {
  9303. entity.Supplier = 24;//dl手提袋定制
  9304. }
  9305. else
  9306. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9307. entity.CreateTime = DateTime.Now;
  9308. entity.Create();
  9309. }
  9310. returnSuccessMsg("操作成功");
  9311. return;
  9312. }
  9313. returnErrorMsg("没有找到对应订单");
  9314. return;
  9315. }
  9316. returnErrorMsg("缺少订单编号");
  9317. return;
  9318. }
  9319. public void get_erp_persuadelist()
  9320. {
  9321. DataStruct dStruct = GetPostStruct();
  9322. List<string> lw = new List<string>();
  9323. string ctid = GetPostString("ctid");
  9324. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9325. string shopname = GetPostString("shopname");
  9326. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9327. string buyernick = GetPostString("buyer_nick");
  9328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9329. string customer = GetPostString("customer");
  9330. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9331. string returndate1 = GetPostString("returndate1");
  9332. string returndate2 = GetPostString("returndate2");
  9333. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9334. if (dw.Length > 0) lw.Add(dw);
  9335. string finishDate1 = GetPostString("finishdate1");
  9336. string finishDate2 = GetPostString("finishdate2");
  9337. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9338. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9339. string persuadetype = GetPostString("persuadetype");
  9340. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9341. string returnvstate = GetPostString("returnvstate");
  9342. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9343. dStruct.Order = "created desc";
  9344. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9345. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9346. writeGridDataTableJson(dStruct.TotalCount, dt);
  9347. }
  9348. public void upd_erp_returnpersuadeback()
  9349. {
  9350. if (UrlPostParmsCheck("ID"))
  9351. {
  9352. int eid = GetPostInt("ID");
  9353. CeErpPersuade entity = null;
  9354. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9355. if (entity != null)
  9356. {
  9357. entity.backreason = GetPostString("reason");
  9358. entity.pstate = 2;
  9359. entity.verifytime = DateTime.Now;
  9360. entity.verifyuserid = CurrentUser.UserID;
  9361. entity.Update();
  9362. returnSuccessMsg("退回成功!");
  9363. return;
  9364. }
  9365. returnErrorMsg("找不到订单记录");
  9366. }
  9367. }
  9368. public void upd_erp_returnpersuadeverify()
  9369. {
  9370. if (UrlPostParmsCheck("ID"))
  9371. {
  9372. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9373. {
  9374. returnErrorMsg("暂无权限审核");
  9375. return;
  9376. }
  9377. int eid = GetPostInt("ID");
  9378. CeErpPersuade entity = null;
  9379. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9380. if (entity != null)
  9381. {
  9382. entity.pstate = 1;
  9383. entity.verifytime = DateTime.Now;
  9384. entity.verifyuserid = CurrentUser.UserID;
  9385. entity.Update();
  9386. returnSuccessMsg("审核成功!");
  9387. return;
  9388. }
  9389. returnErrorMsg("找不到订单记录");
  9390. }
  9391. }
  9392. public void del_erp_persuade()
  9393. {
  9394. if (UrlPostParmsCheck("ID"))
  9395. {
  9396. int eid = GetPostInt("ID");
  9397. CeErpPersuade.Del(eid);
  9398. returnSuccessMsg("操作成功");
  9399. return;
  9400. }
  9401. }
  9402. public void get_erp_oldcustoupload()
  9403. {
  9404. DataStruct dStruct = GetPostStruct();
  9405. List<string> lw = new List<string>();
  9406. string buyernick = GetPostString("buyer_nick");
  9407. if (buyernick.Length > 0)
  9408. {
  9409. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9410. }
  9411. else
  9412. return;
  9413. dStruct.Order = "pay_time desc";
  9414. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9415. DataTable dt = null;
  9416. dt = WebCache.GetData("view_erptradecell", dStruct);
  9417. writeGridDataTableJson(dStruct.TotalCount, dt);
  9418. }
  9419. public void get_erp_checkorderlist()
  9420. {
  9421. DataStruct dStruct = GetPostStruct();
  9422. List<string> lw = new List<string>();
  9423. string tid = GetPostString("ctid");
  9424. if (tid.Length > 0)
  9425. {
  9426. string select_tid = getTidByCtid(tid);
  9427. lw.Add(string.Format("tid='{0}'", select_tid));
  9428. }
  9429. string shopname = GetPostString("shopname");
  9430. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9431. string buyernick = GetPostString("buyer_nick");
  9432. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9433. string customer = GetPostString("customer");
  9434. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9435. string design = GetPostString("design");
  9436. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9437. string orderState = GetPostString("orderState");
  9438. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9439. string address = GetPostString("address");
  9440. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9441. string sellermemo = GetPostString("seller_memo");
  9442. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9443. string supplier = GetPostString("supplier");
  9444. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9445. {
  9446. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9447. }
  9448. else
  9449. {
  9450. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9451. }
  9452. string date1 = GetPostString("date1");
  9453. string date2 = GetPostString("date2");
  9454. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9455. if (dw.Length > 0) lw.Add(dw);
  9456. string placedate1 = GetPostString("placedate1");
  9457. string placedate2 = GetPostString("placedate2");
  9458. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9459. if (fdw.Length > 0) lw.Add(fdw);
  9460. string price1 = GetPostString("price1");
  9461. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9462. string price2 = GetPostString("price2");
  9463. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9464. string checkst = GetPostString("checkstate");
  9465. if (checkst.Length > 0 && "10".Equals(checkst))
  9466. {
  9467. lw.Add(string.Format("CheckOut>0"));
  9468. }
  9469. else
  9470. {
  9471. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9472. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9473. }
  9474. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9475. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9476. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9477. writeGridDataTableJson(dStruct.TotalCount, dt);
  9478. }
  9479. public void ins_erp_startCheck()
  9480. {
  9481. if (UrlPostParmsCheck("ctid"))
  9482. {
  9483. string eid = GetPostString("ctid");
  9484. CeErpTradeCell entity = null;
  9485. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9486. if (entity != null)
  9487. {
  9488. entity.MemoOpt = 4;
  9489. entity.UpdateTime = DateTime.Now;
  9490. entity.Update();
  9491. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9492. CeErpSukuraData.createInfo(entity.ctid, 6);
  9493. returnSuccessMsg("操作成功!");
  9494. return;
  9495. }
  9496. returnErrorMsg("找不到记录");
  9497. }
  9498. }
  9499. public void upd_erp_sendXlw()
  9500. {
  9501. if (UrlPostParmsCheck("ctid"))
  9502. {
  9503. string eid = GetPostString("ctid");
  9504. CeErpTradeCell entity = null;
  9505. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9506. if (entity != null)
  9507. {
  9508. if (entity.IsSendGift == 1)
  9509. {
  9510. returnErrorMsg("请勿重复标记");
  9511. return;
  9512. }
  9513. entity.IsSendGift = 1;
  9514. entity.Update();
  9515. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9516. returnSuccessMsg("操作成功!");
  9517. return;
  9518. }
  9519. returnErrorMsg("找不到记录");
  9520. }
  9521. }
  9522. public void cancel_sendXlw()
  9523. {
  9524. if (UrlPostParmsCheck("ctid"))
  9525. {
  9526. string eid = GetPostString("ctid");
  9527. CeErpTradeCell entity = null;
  9528. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9529. if (entity != null)
  9530. {
  9531. if (entity.IsSendGift == 0)
  9532. {
  9533. returnErrorMsg("未标记小礼物");
  9534. return;
  9535. }
  9536. entity.IsSendGift = 0;
  9537. entity.Update();
  9538. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9539. returnSuccessMsg("操作成功!");
  9540. return;
  9541. }
  9542. returnErrorMsg("找不到记录");
  9543. }
  9544. }
  9545. public void get_erp_designbill()
  9546. {
  9547. DataStruct dStruct = GetPostStruct();
  9548. List<string> lw = new List<string>();
  9549. int isMy = GetInt("my");
  9550. if (isMy == 1)
  9551. {
  9552. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9553. }
  9554. string tid = GetPostString("tid");
  9555. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9556. string userName = GetPostString("design");
  9557. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9558. string price1 = GetPostString("price1");
  9559. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9560. string price2 = GetPostString("price2");
  9561. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9562. string rePrice1 = GetPostString("rePrice1");
  9563. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9564. string rePrice2 = GetPostString("rePrice2");
  9565. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9566. string designerType = GetPostString("designerType");
  9567. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9568. string orderState = GetPostString("orderState");
  9569. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9570. string endTime1 = GetPostString("endTime1");
  9571. string endTime2 = GetPostString("endTime2");
  9572. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9573. if (dw.Length > 0) lw.Add(dw);
  9574. string isDk = GetPostString("isDk");
  9575. if (isDk == "1")
  9576. {
  9577. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9578. }
  9579. else if (isDk == "0")
  9580. {
  9581. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9582. }
  9583. dStruct.Order = "oid, create_time desc";
  9584. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9585. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9586. writeGridDataTableJson(dStruct.TotalCount, dt);
  9587. }
  9588. public void upd_erp_designerbill()
  9589. {
  9590. if (UrlPostParmsCheck("ID"))
  9591. {
  9592. string eid = GetPostString("ID");
  9593. CeErpDesignerBill entity = null;
  9594. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9595. if (entity != null)
  9596. {
  9597. if (GetPostDouble("designerpirce") > 0)
  9598. {
  9599. entity.realPrice = GetPostDouble("designerpirce");
  9600. entity.update_time = DateTime.Now;
  9601. entity.update_u_id = CurrentUser.UserID;
  9602. entity.update_u_name = CurrentUser.UserName;
  9603. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9604. entity.Update();
  9605. returnSuccessMsg("操作成功!");
  9606. return;
  9607. }
  9608. else
  9609. {
  9610. entity.price = GetPostDouble("price");
  9611. entity.update_time = DateTime.Now;
  9612. entity.update_u_id = CurrentUser.UserID;
  9613. entity.update_u_name = CurrentUser.UserName;
  9614. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9615. entity.Update();
  9616. returnSuccessMsg("操作成功!");
  9617. return;
  9618. }
  9619. }
  9620. returnErrorMsg("找不到记录");
  9621. }
  9622. }
  9623. public void audit_erp_designerbill()
  9624. {
  9625. if (UrlPostParmsCheck("ID"))
  9626. {
  9627. string eid = GetPostString("ID");
  9628. CeErpDesignerBill entity = null;
  9629. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9630. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9631. if (entity != null)
  9632. {
  9633. entity.realPrice = GetPostDouble("designerpirce");
  9634. entity.update_time = DateTime.Now;
  9635. entity.update_u_id = CurrentUser.UserID;
  9636. entity.update_u_name = CurrentUser.UserName;
  9637. entity.isAudit = 1;
  9638. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9639. entity.Update();
  9640. if (orderEntity != null)
  9641. {
  9642. orderEntity.IsReadTag = 3;
  9643. orderEntity.Update();
  9644. }
  9645. returnSuccessMsg("操作成功!");
  9646. return;
  9647. }
  9648. returnErrorMsg("找不到记录");
  9649. }
  9650. }
  9651. public void all_audit_erp_designerbill()
  9652. {
  9653. if (UrlPostParmsCheck("idList"))
  9654. {
  9655. string[] list = GetPostString("idList").Split(',');
  9656. CeErpDesignerBill entity = null;
  9657. for (int i = 0; i < list.Length; i++)
  9658. {
  9659. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9660. if (entity == null) return;
  9661. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9662. if (orderEntity == null) return;
  9663. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9664. entity.update_time = DateTime.Now;
  9665. entity.update_u_id = CurrentUser.UserID;
  9666. entity.update_u_name = CurrentUser.UserName;
  9667. entity.isAudit = 1;
  9668. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9669. entity.Update();
  9670. orderEntity.IsReadTag = 3;
  9671. orderEntity.Update();
  9672. }
  9673. returnSuccessMsg("操作成功!");
  9674. return;
  9675. }
  9676. }
  9677. public void get_erp_sameorders()
  9678. {
  9679. if (UrlPostParmsCheck("ctid"))
  9680. {
  9681. string eid = GetPostString("ctid");
  9682. CeErpTradeCell entity = null;
  9683. entity = CeErpTradeCell.GetByCtid(eid);
  9684. if (entity != null)
  9685. {
  9686. StringBuilder sql = new StringBuilder();
  9687. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9688. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9689. var res = new
  9690. {
  9691. data = dt.Rows.Count
  9692. };
  9693. string ro_jsond = JsonConvert.SerializeObject(res);
  9694. returnSuccess(ro_jsond);
  9695. return;
  9696. }
  9697. returnErrorMsg("未找到订单");
  9698. return;
  9699. }
  9700. returnErrorMsg("缺少必要的参数");
  9701. }
  9702. public void get_erp_islasthavesameorder()
  9703. {
  9704. if (UrlPostParmsCheck("ctid"))
  9705. {
  9706. string eid = GetPostString("ctid");
  9707. string[] ctidList = eid.Split(',');
  9708. StringBuilder sql = new StringBuilder();
  9709. string tisCtid = "";
  9710. foreach (string ctid in ctidList)
  9711. {
  9712. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9713. if (entity != null)
  9714. {
  9715. sql = new StringBuilder();
  9716. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9717. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9718. if (dth.Rows.Count > 0)
  9719. {
  9720. tisCtid += entity.ctid;
  9721. tisCtid += ",";
  9722. }
  9723. }
  9724. }
  9725. if (tisCtid.Length > 0)
  9726. {
  9727. var res = new
  9728. {
  9729. data = tisCtid
  9730. };
  9731. string ro_jsond = JsonConvert.SerializeObject(res);
  9732. returnSuccess(ro_jsond);
  9733. }
  9734. else
  9735. {
  9736. var res = new
  9737. {
  9738. data = ""
  9739. };
  9740. string ro_jsond = JsonConvert.SerializeObject(res);
  9741. returnSuccess(ro_jsond);
  9742. }
  9743. return;
  9744. }
  9745. returnErrorMsg("缺少必要的参数");
  9746. }
  9747. public void file_client_down_url()
  9748. {
  9749. if (!UrlPostParmsCheck("userId"))
  9750. {
  9751. returnErrorMsg("缺少必要的参数");
  9752. }
  9753. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9754. }
  9755. public void checkout_form_data()
  9756. {
  9757. if (!UrlPostParmsCheck("tid"))
  9758. {
  9759. returnErrorMsg("缺少必要的参数");
  9760. }
  9761. string tid = GetPostString("tid");
  9762. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9763. if (ceErpOrderFormData != null)
  9764. {
  9765. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9766. returnSuccess(ro_jsond);
  9767. return;
  9768. }
  9769. returnErrorMsg("尚未有文件!");
  9770. }
  9771. public void back_supplier_audit()
  9772. {
  9773. int userId = CurrentUser.UserID;
  9774. StringBuilder sql = new StringBuilder();
  9775. 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);
  9776. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9777. if (dt.Rows.Count > 0)
  9778. {
  9779. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9780. }
  9781. else
  9782. {
  9783. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9784. }
  9785. }
  9786. public void back_supplier_query()
  9787. {
  9788. string eid = GetPostString("ctid");
  9789. if (eid != "")
  9790. {
  9791. StringBuilder sql = new StringBuilder();
  9792. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9793. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9794. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9795. }
  9796. else
  9797. {
  9798. returnErrorMsg("找不到订单记录");
  9799. return;
  9800. }
  9801. }
  9802. public void verified_to_order()
  9803. {
  9804. int userId = CurrentUser.UserID;
  9805. StringBuilder sql = new StringBuilder();
  9806. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9807. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9808. if (dt.Rows.Count > 0)
  9809. {
  9810. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9811. }
  9812. else
  9813. {
  9814. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9815. }
  9816. }
  9817. public void upd_supplier_audit()
  9818. {
  9819. if (UrlPostParmsCheck("ctid"))
  9820. {
  9821. string eid = GetPostString("ctid");
  9822. string reason = GetPostString("returnreason");
  9823. CeErpTradeCell entity = null;
  9824. CeWithdraw withdraw = null;
  9825. withdraw = CeWithdraw.GetByTid(eid);
  9826. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9827. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9828. {
  9829. if (withdraw != null)
  9830. {
  9831. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9832. {
  9833. returnSuccessMsg("您没有权限操作!");
  9834. return;
  9835. }
  9836. else
  9837. {
  9838. if (reason.Equals("1"))
  9839. {
  9840. if (entity.OrderState == -1)
  9841. {
  9842. if (entity.FinishPlaceTime == null)
  9843. {
  9844. entity.OrderState = 2;
  9845. }
  9846. else
  9847. {
  9848. entity.OrderState = 6;
  9849. }
  9850. }
  9851. entity.Update();
  9852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9853. if (withdraw != null)
  9854. {
  9855. withdraw.status = int.Parse(reason);
  9856. withdraw.Update();
  9857. }
  9858. returnSuccessMsg("操作成功!");
  9859. return;
  9860. }
  9861. else
  9862. {
  9863. withdraw.status = int.Parse(reason);
  9864. withdraw.acknowledgingtime = DateTime.Now;
  9865. withdraw.Update();
  9866. returnSuccessMsg("查看详细请点击线下订单查询");
  9867. return;
  9868. }
  9869. }
  9870. }
  9871. // 第一个字符是 'N'
  9872. }
  9873. if (eid[0] != 'N')
  9874. {
  9875. }
  9876. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9877. {
  9878. entity.IsVerifyToSupplier = false;
  9879. entity.IsReturn = 1;
  9880. entity.ReturnTime = DateTime.Now;
  9881. entity.ReturnReason = reason;
  9882. if (entity.OrderState == 6)
  9883. {
  9884. entity.OrderState = 5;
  9885. }
  9886. entity.Update();
  9887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9888. if (withdraw != null)
  9889. {
  9890. withdraw.status = int.Parse(reason);
  9891. withdraw.Update();
  9892. }
  9893. returnSuccessMsg("操作成功!");
  9894. return;
  9895. }
  9896. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9897. {
  9898. ;
  9899. if (withdraw != null)
  9900. {
  9901. withdraw.status = int.Parse(reason);
  9902. withdraw.acknowledgingtime = DateTime.Now;
  9903. withdraw.Update();
  9904. returnSuccessMsg("供应商取消撤回!");
  9905. return;
  9906. }
  9907. }
  9908. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9909. {
  9910. if (entity.OrderState == -1)
  9911. {
  9912. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9913. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9914. {
  9915. returnErrorMsg("订单spu没有确认无法通过审核!");
  9916. return;
  9917. }
  9918. if (entity.FinishPlaceTime == null)
  9919. {
  9920. entity.OrderState = 2;
  9921. }
  9922. else
  9923. {
  9924. entity.OrderState = 3;
  9925. }
  9926. commonHelper.getCytPrice(entity);
  9927. }
  9928. entity.Update();
  9929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9930. if (withdraw != null)
  9931. {
  9932. withdraw.status = int.Parse(reason);
  9933. withdraw.Update();
  9934. }
  9935. returnSuccessMsg("操作成功!");
  9936. return;
  9937. }
  9938. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9939. {
  9940. if (withdraw == null)
  9941. {
  9942. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9943. return;
  9944. }
  9945. }
  9946. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9947. {
  9948. if (withdraw != null)
  9949. {
  9950. withdraw.status = int.Parse(reason);
  9951. withdraw.acknowledgingtime = DateTime.Now;
  9952. withdraw.Update();
  9953. returnSuccessMsg("查看详细请点击线下订单查询");
  9954. return;
  9955. }
  9956. }
  9957. return;
  9958. }
  9959. }
  9960. //校验报价
  9961. public void refund_order_tip()
  9962. {
  9963. int userid = CurrentUser.UserID;
  9964. int sectionId = CurrentUser.UserPost.OrgID;
  9965. StringBuilder sql = new StringBuilder();
  9966. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9967. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9968. List<string> ids = new List<string>();
  9969. if (dth.Rows.Count > 0)
  9970. {
  9971. foreach (DataRow dr in dth.Rows)
  9972. {
  9973. ids.Add(dr["ID"].ToString());
  9974. }
  9975. try
  9976. {
  9977. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9978. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9979. }
  9980. catch (Exception ex)
  9981. {
  9982. }
  9983. }
  9984. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9985. }
  9986. public void refund_order_Design()
  9987. {
  9988. int userid = CurrentUser.UserID;
  9989. int sectionId = CurrentUser.UserPost.OrgID;
  9990. StringBuilder sql = new StringBuilder();
  9991. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9992. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9993. List<string> ids = new List<string>();
  9994. if (dth.Rows.Count > 0)
  9995. {
  9996. foreach (DataRow dr in dth.Rows)
  9997. {
  9998. ids.Add(dr["ID"].ToString());
  9999. }
  10000. try
  10001. {
  10002. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10003. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10004. }
  10005. catch (Exception ex)
  10006. {
  10007. }
  10008. }
  10009. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10010. }
  10011. public void change_order_info()
  10012. {
  10013. int userid = CurrentUser.UserID;
  10014. StringBuilder sql = new StringBuilder();
  10015. 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);
  10016. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10017. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10018. }
  10019. public void change_win_mome()
  10020. {
  10021. if (UrlPostParmsCheck("id,ctid"))
  10022. {
  10023. string id = GetPostString("id");
  10024. string ctid = GetPostString("ctid");
  10025. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10026. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10027. if (ce == null || ceErpMessageTip == null)
  10028. {
  10029. returnSuccessMsg("未找到对应的订单!");
  10030. return;
  10031. }
  10032. if (ce.OrderState >= 5)
  10033. {
  10034. returnSuccessMsg("已上传文件无法修改!");
  10035. return;
  10036. }
  10037. int type = GetPostInt("type");
  10038. string content = GetPostString("content");
  10039. if (type == 0)
  10040. {
  10041. content = content.Replace("(", "(");
  10042. content = content.Replace(")", ")");
  10043. string check = MidStrEx(content, "(", ")").Trim();
  10044. if (string.IsNullOrEmpty(check))
  10045. {
  10046. returnSuccessMsg("文件名格式不正确");
  10047. return;
  10048. }
  10049. }
  10050. ce.seller_memo = content;
  10051. ce.Update();
  10052. ceErpMessageTip.isVisit = true;
  10053. ceErpMessageTip.Update();
  10054. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10055. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10056. ApiVo apiVo = new ApiVo();
  10057. apiVo.orderNumber = ce.ctid;
  10058. apiVo.actionName = "demandDesign";
  10059. apiVo.orderRemarks = content;
  10060. apiVo.demandExamine = type + 1;
  10061. designHelper.API_WorkCore(apiVo);//demandDesign
  10062. returnSuccessMsg("修改成功!");
  10063. }
  10064. }
  10065. public static string MidStrEx(string sourse, string startstr, string endstr)
  10066. {
  10067. string result = string.Empty;
  10068. int startindex, endindex;
  10069. try
  10070. {
  10071. startindex = sourse.IndexOf(startstr);
  10072. if (startindex == -1)
  10073. return result;
  10074. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10075. endindex = tmpstr.IndexOf(endstr);
  10076. if (endindex == -1)
  10077. return result;
  10078. result = tmpstr.Remove(endindex);
  10079. }
  10080. catch (Exception ex)
  10081. {
  10082. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10083. }
  10084. return result;
  10085. }
  10086. public void refund_order_list()
  10087. {
  10088. int userid = CurrentUser.UserID;
  10089. int sectionId = CurrentUser.UserPost.OrgID;
  10090. StringBuilder sql = new StringBuilder();
  10091. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10092. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10093. DataStruct dStruct = GetPostStruct();
  10094. DataTable dt = null;
  10095. List<string> ids = new List<string>();
  10096. List<string> tids = new List<string>();
  10097. if (dth.Rows.Count > 0)
  10098. {
  10099. foreach (DataRow dr in dth.Rows)
  10100. {
  10101. tids.Add("'" + dr["tid"].ToString() + "'");
  10102. ids.Add(dr["id"].ToString());
  10103. }
  10104. try
  10105. {
  10106. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10107. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10108. List<string> lw = new List<string>();
  10109. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10110. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10111. dt = WebCache.GetData("view_orderlist", dStruct);
  10112. }
  10113. catch (Exception ex)
  10114. {
  10115. }
  10116. }
  10117. writeGridDataTableJson(dStruct.TotalCount, dt);
  10118. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10119. }
  10120. //新增
  10121. public void order_batch_downloads()
  10122. {
  10123. string ceid = GetPostString("tid");
  10124. String[] tid = ceid.Split(',');
  10125. order_batch_caiyingtong(tid);
  10126. /* (string success, string errors) = UploadFiles(tid);
  10127. returnSuccessMsg(success + errors);*/
  10128. return;
  10129. }
  10130. //报价接口
  10131. public void Get_To_Quote()
  10132. {
  10133. string ceid = GetPostString("ctid");
  10134. if (ceid != null)
  10135. {
  10136. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10137. if (entity != null)
  10138. {
  10139. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10140. {
  10141. return;
  10142. }
  10143. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10144. double price = 0;
  10145. if (cp == null)
  10146. {
  10147. JObject jsonObject12 = new JObject
  10148. {
  10149. { "UserId", "77886" },
  10150. { "Pwd", "lt666888" },
  10151. { "Filename", entity.seller_memo }
  10152. };
  10153. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10154. JObject jsonObjects1 = JObject.Parse(response1);
  10155. string ms1g = (string)jsonObjects1["msg"];
  10156. if (ms1g == "报价成功")
  10157. {
  10158. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10159. string data = (string)jsonObject1["price"];
  10160. 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 + "');";
  10161. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10162. returnSuccessMsg("获取报价成功:" + data);
  10163. price = Convert.ToDouble(data);
  10164. }
  10165. else
  10166. {
  10167. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10168. return;
  10169. }
  10170. }
  10171. String[] beizhu = entity.seller_memo.Split('-');
  10172. String chanp = "";
  10173. if (beizhu.Length > 0)
  10174. {
  10175. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10176. }
  10177. else
  10178. {
  10179. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10180. }
  10181. JObject jsonObject = new JObject
  10182. {
  10183. { "UserId", "77886" },
  10184. { "Pwd", "lt666888" },
  10185. { "Filename", chanp }
  10186. };
  10187. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10188. JObject jsonObjects = JObject.Parse(response);
  10189. string msg = (string)jsonObjects["msg"];
  10190. if (msg == "报价成功")
  10191. {
  10192. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10193. string data = (string)jsonObject1["price"];
  10194. 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 + "');";
  10195. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10196. returnSuccessMsg("获取报价成功:" + data);
  10197. price = Convert.ToDouble(data);
  10198. }
  10199. else
  10200. {
  10201. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10202. return;
  10203. }
  10204. if (price > 0)
  10205. {
  10206. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10207. if (ceErpTradeCellExtend == null)
  10208. {
  10209. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10210. ceErpTradeCellExtend.ctid = entity.ctid;
  10211. ceErpTradeCellExtend.payment_cyt = price;
  10212. ceErpTradeCellExtend.Create();
  10213. }
  10214. else
  10215. {
  10216. ceErpTradeCellExtend.payment_cyt = price;
  10217. ceErpTradeCellExtend.Update();
  10218. }
  10219. }
  10220. return;
  10221. }
  10222. }
  10223. else
  10224. {
  10225. returnErrorMsg("请至少选择一条数据");
  10226. return;
  10227. }
  10228. }
  10229. //新增
  10230. public void order_To_Supplier()
  10231. {
  10232. string ceid = GetPostString("tid");
  10233. String[] tid = ceid.Split(',');
  10234. if (tid.Length > 0)
  10235. {
  10236. try
  10237. {
  10238. for (int i = 0; i < tid.Length; i++)
  10239. {
  10240. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10241. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10242. entity.SupplierId = suid;
  10243. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10244. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10245. entity.Update();
  10246. }
  10247. }
  10248. catch (Exception ex)
  10249. {
  10250. returnErrorMsg("自动匹配供应商失败");
  10251. return;
  10252. }
  10253. }
  10254. else
  10255. {
  10256. returnErrorMsg("请至少选择一条数据");
  10257. return;
  10258. }
  10259. returnSuccessMsg("自动匹配供应商成功");
  10260. return;
  10261. }
  10262. public (string, string) UploadFiles(string[] urls)
  10263. {
  10264. string success = "";
  10265. string errors = "";
  10266. int userid = CurrentUser.UserID;
  10267. foreach (string url in urls)
  10268. {
  10269. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10270. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10271. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10272. {
  10273. JObject jsonObject = new JObject
  10274. {
  10275. { "Userid", "77886" },
  10276. { "pwd", "cyt86435015" },
  10277. { "content", base64FileContent },
  10278. { "ext", Path.GetExtension(fileName) }
  10279. };
  10280. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10281. JObject jsonObjects = JObject.Parse(response);
  10282. string msg = (string)jsonObjects["msg"];
  10283. if (msg.Equals("上传成功"))
  10284. {
  10285. success += url + " 上传成功";
  10286. }
  10287. else
  10288. {
  10289. errors += url + " 上传失败";
  10290. }
  10291. }
  10292. else
  10293. {
  10294. errors += url + " 格式出现问题";
  10295. }
  10296. }
  10297. if (urls.Length == 0)
  10298. {
  10299. return (success, errors);
  10300. }
  10301. return (success, errors);
  10302. }
  10303. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10304. {
  10305. return true; //总是接受
  10306. }
  10307. public static string HttpPost(string url, string param = null)
  10308. {
  10309. HttpWebRequest request;
  10310. //如果是发送HTTPS请求
  10311. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10312. {
  10313. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10314. request = WebRequest.Create(url) as HttpWebRequest;
  10315. request.ProtocolVersion = HttpVersion.Version10;
  10316. }
  10317. else
  10318. {
  10319. request = WebRequest.Create(url) as HttpWebRequest;
  10320. }
  10321. request.Method = "POST";
  10322. request.ContentType = "application/json";
  10323. request.Accept = "*/*";
  10324. request.Timeout = 120000;
  10325. request.AllowAutoRedirect = false;
  10326. StreamWriter requestStream = null;
  10327. WebResponse response = null;
  10328. string responseStr = null;
  10329. try
  10330. {
  10331. requestStream = new StreamWriter(request.GetRequestStream());
  10332. requestStream.Write(param);
  10333. requestStream.Close();
  10334. response = request.GetResponse();
  10335. if (response != null)
  10336. {
  10337. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10338. responseStr = reader.ReadToEnd();
  10339. reader.Close();
  10340. }
  10341. }
  10342. catch (Exception ex)
  10343. {
  10344. return ex.Message;
  10345. }
  10346. finally
  10347. {
  10348. request = null;
  10349. requestStream = null;
  10350. response = null;
  10351. }
  10352. return responseStr;
  10353. }
  10354. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10355. {
  10356. string base64FileContent;
  10357. string fileName;
  10358. using (WebClient webClient = new WebClient())
  10359. {
  10360. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10361. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10362. {
  10363. using (Stream stream = response.GetResponseStream())
  10364. {
  10365. using (MemoryStream memoryStream = new MemoryStream())
  10366. {
  10367. stream.CopyTo(memoryStream);
  10368. byte[] fileBytes = memoryStream.ToArray();
  10369. base64FileContent = Convert.ToBase64String(fileBytes);
  10370. fileName = response.Headers["Content-Disposition"];
  10371. if (!string.IsNullOrEmpty(fileName))
  10372. {
  10373. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10374. if (index >= 0)
  10375. {
  10376. fileName = fileName.Substring(index + 9).Trim('\"');
  10377. }
  10378. }
  10379. else
  10380. {
  10381. fileName = Path.GetFileName(downloadUrl);
  10382. }
  10383. }
  10384. }
  10385. }
  10386. }
  10387. return (fileName, base64FileContent);
  10388. }
  10389. //新增
  10390. public void order_batch_caiyingtong(string[] downloadUrls)
  10391. {
  10392. try
  10393. {
  10394. //遍历文件
  10395. DataStruct dStruct = GetPostStruct();
  10396. DataTable dt = null;
  10397. int userid = CurrentUser.UserID;
  10398. List<string> ids = new List<string>();//失败组
  10399. List<string> tids = new List<string>();
  10400. using (WebClient webClient = new WebClient())
  10401. {
  10402. foreach (var url in downloadUrls)
  10403. {
  10404. try
  10405. {
  10406. tids.Add("'" + url + "'");
  10407. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10408. if (entity != null)
  10409. {
  10410. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10411. if (cp == null)
  10412. {
  10413. JObject jsonObject = new JObject
  10414. {
  10415. { "Userid", "77886" },
  10416. { "pwd", "lt666888" },
  10417. { "Filename",entity.seller_memo }
  10418. };
  10419. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10420. JObject jsonObjects = JObject.Parse(response);
  10421. string msg = (string)jsonObjects["msg"];
  10422. if (msg == "报价成功")
  10423. {
  10424. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10425. DownloadAndConvertToBase64(url1);
  10426. }
  10427. else
  10428. {
  10429. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10430. }
  10431. }
  10432. else
  10433. {
  10434. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10435. JObject jsonObject = new JObject
  10436. {
  10437. { "Userid", "77886" },
  10438. { "pwd", "lt666888" },
  10439. { "Filename",chanp }
  10440. };
  10441. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10442. JObject jsonObjects = JObject.Parse(response);
  10443. string msg = (string)jsonObjects["msg"];
  10444. if (msg == "报价成功")
  10445. {
  10446. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10447. DownloadAndConvertToBase64(url1);
  10448. }
  10449. else
  10450. {
  10451. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10452. }
  10453. }
  10454. }
  10455. // 上传文件到FTP
  10456. }
  10457. catch (Exception ex)
  10458. {
  10459. Console.WriteLine($"An error occurred: {ex.Message}");
  10460. }
  10461. }
  10462. List<string> lw = new List<string>();
  10463. lw.Add(string.Format("( OrderState < 6 )"));
  10464. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10465. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10466. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10467. if (dt.Rows.Count > 0)
  10468. {
  10469. foreach (DataRow dr in dt.Rows)
  10470. {
  10471. ids.Add(dr["ctid"].ToString());
  10472. }
  10473. }
  10474. String ErrorMsgs = "";
  10475. foreach (String id in ids)
  10476. {
  10477. ErrorMsgs += id + ",";
  10478. }
  10479. if (ErrorMsgs.Length > 1)
  10480. {
  10481. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10482. }
  10483. if (ErrorMsgs.Length < 1)
  10484. {
  10485. ErrorMsgs = "上传成功";
  10486. returnSuccessMsg(ErrorMsgs);
  10487. }
  10488. else
  10489. {
  10490. returnErrorMsg("以下订单" + ErrorMsgs);
  10491. }
  10492. }
  10493. // 删除文件夹及其内容
  10494. /* Directory.Delete(localDirectory, true);*/
  10495. }
  10496. catch { }
  10497. }
  10498. public void get_center_data()
  10499. {
  10500. int userId = CurrentUser.UserID;
  10501. string postCode = CurrentUser.UserPost.Post.Code;
  10502. List<string> lw = new List<string>();
  10503. List<string> ww = new List<string>();
  10504. DateTime currentTime = DateTime.Now;
  10505. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10506. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10507. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10508. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10509. string sql = " SELECT ";
  10510. string startTime = "2023-10-01 11:22:31";
  10511. //设计
  10512. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10513. {
  10514. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10515. 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));
  10516. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10517. 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));
  10518. }
  10519. //客服
  10520. else if (postCode == "CustomerService" || postCode == "Director")
  10521. {
  10522. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10523. 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));
  10524. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10525. 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));
  10526. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10527. 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));
  10528. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10529. 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));
  10530. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10531. 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));
  10532. }
  10533. //售后
  10534. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10535. {
  10536. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10537. 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));
  10538. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10539. 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));
  10540. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10541. 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));
  10542. }
  10543. //下单部
  10544. else if (postCode == "Place" || postCode == "PlaceMr")
  10545. {
  10546. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10547. 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));
  10548. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10549. 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));
  10550. }
  10551. //车间
  10552. else if (postCode == "Supplier")
  10553. {
  10554. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10555. 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));
  10556. }
  10557. DataTable dt = new DataTable();
  10558. if (lw.Count > 0)
  10559. {
  10560. sql += string.Join(" , ", lw);
  10561. sql += " FROM ";
  10562. sql += string.Join(" , ", ww);
  10563. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10564. }
  10565. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10566. }
  10567. public void get_center_data_list()
  10568. {
  10569. int userId = CurrentUser.UserID;
  10570. string postCode = CurrentUser.UserPost.Post.Code;
  10571. string shopIds = CurrentUser.User.pemShop;
  10572. DataStruct dStruct = GetPostStruct();
  10573. List<string> lw = new List<string>();
  10574. DateTime currentTime = DateTime.Now;
  10575. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10576. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10577. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10578. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10579. string startTime = "2023-10-01 11:22:31";
  10580. int order_type = GetPostInt("order_type");
  10581. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10582. {
  10583. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10584. if (order_type == 0)
  10585. {
  10586. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10587. }
  10588. else if (order_type == 3)
  10589. {
  10590. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10591. }
  10592. else
  10593. {
  10594. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10595. }
  10596. }
  10597. //客服
  10598. if (postCode == "CustomerService" || postCode == "Director")
  10599. {
  10600. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10601. if (order_type == 0)
  10602. {
  10603. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10604. }
  10605. else if (order_type == 1)
  10606. {
  10607. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10608. }
  10609. else if (order_type == 2)
  10610. {
  10611. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10612. }
  10613. else if (order_type == 3)
  10614. {
  10615. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10616. }
  10617. else if (order_type == 4)
  10618. {
  10619. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10620. }
  10621. else
  10622. {
  10623. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10624. }
  10625. }
  10626. //售后
  10627. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10628. {
  10629. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10630. if (shopIds != "")
  10631. {
  10632. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10633. }
  10634. if (order_type == 2)
  10635. {
  10636. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10637. }
  10638. else if (order_type == 4)
  10639. {
  10640. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10641. }
  10642. else if (order_type == 5)
  10643. {
  10644. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10645. }
  10646. else
  10647. {
  10648. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10649. }
  10650. }
  10651. //下单部
  10652. if (postCode == "Place" || postCode == "PlaceMr")
  10653. {
  10654. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10655. if (shopIds != "")
  10656. {
  10657. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10658. }
  10659. else if (order_type == 1)
  10660. {
  10661. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10662. }
  10663. else if (order_type == 2)
  10664. {
  10665. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10666. }
  10667. else
  10668. {
  10669. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10670. }
  10671. }
  10672. //车间
  10673. if (postCode == "Supplier")
  10674. {
  10675. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10676. if (order_type == 5)
  10677. {
  10678. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10679. }
  10680. else
  10681. {
  10682. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10683. }
  10684. }
  10685. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10686. dStruct.Fileds = "tid,ctid";
  10687. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10688. writeGridDataTableJson(dStruct.TotalCount, dt);
  10689. }
  10690. public void aftersale_audit_master()
  10691. {
  10692. if (UrlPostParmsCheck("ctid"))
  10693. {
  10694. string ctid = GetPostString("ctid");
  10695. if (ctid.Length > 0)
  10696. {
  10697. bool result = aftersale_data_change(ctid);
  10698. if (result)
  10699. {
  10700. returnSuccessMsg("修改成功!");
  10701. return;
  10702. }
  10703. }
  10704. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10705. }
  10706. }
  10707. public void aftersale_batch_audit_master()
  10708. {
  10709. if (UrlPostParmsCheck("ctids"))
  10710. {
  10711. string ctids = GetPostString("ctids");
  10712. if (ctids.Length > 0)
  10713. {
  10714. List<string> list = new List<string>();
  10715. string[] ctid_list = ctids.Split(',');
  10716. foreach (var item in ctid_list)
  10717. {
  10718. bool result = aftersale_data_change(item);
  10719. if (!result)
  10720. {
  10721. list.Add(item);
  10722. }
  10723. }
  10724. if (list.Count > 0)
  10725. {
  10726. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10727. return;
  10728. }
  10729. returnSuccessMsg("修改成功!");
  10730. return;
  10731. }
  10732. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10733. }
  10734. }
  10735. public bool aftersale_data_change(string ctid)
  10736. {
  10737. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10738. if (ceErpTradeCell != null)
  10739. {
  10740. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10741. ceErpTradeCell.AfterSaleSupplierState = 0;
  10742. StringBuilder sql = new StringBuilder();
  10743. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10744. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10745. CeErpTradeResponsible.DelByTid(ctid, 0);
  10746. 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 == "不理赔")
  10747. {
  10748. CeErpTradeResponsible.DelByTid(ctid, 1);
  10749. ceErpTradeCell.AfterSaleSupplierState = 1;
  10750. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10751. ceErpTradeCell.AfterSaleState = 4;
  10752. }
  10753. else
  10754. {
  10755. ceErpTradeCell.AfterSaleState = 3;
  10756. }
  10757. bool needCyt = false;
  10758. if (dt != null)
  10759. {
  10760. if (dt.Rows.Count == 1)
  10761. {
  10762. bool isEnd = false;
  10763. foreach (DataRow dr in dt.Rows)
  10764. {
  10765. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10766. {
  10767. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10768. isEnd = true;
  10769. }
  10770. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10771. {
  10772. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10773. isEnd = true;
  10774. }
  10775. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10776. {
  10777. needCyt = true;
  10778. }
  10779. }
  10780. if (isEnd)
  10781. {
  10782. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10783. ceErpTradeCell.AfterSaleState = 4;
  10784. ceErpTradeCell.AfterSaleSupplierState = 1;
  10785. }
  10786. }
  10787. else
  10788. {
  10789. bool isAll = true;
  10790. foreach (DataRow dr in dt.Rows)
  10791. {
  10792. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10793. {
  10794. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10795. continue;
  10796. }
  10797. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10798. {
  10799. string path = "";
  10800. int OrgID = 0;
  10801. if (!Convert.IsDBNull(dr["OrgPath"]))
  10802. {
  10803. path = dr["OrgPath"].ToString();
  10804. }
  10805. if (!Convert.IsDBNull(dr["OrgID"]))
  10806. {
  10807. OrgID = Convert.ToInt32(dr["OrgID"]);
  10808. }
  10809. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10810. {
  10811. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10812. continue;
  10813. }
  10814. }
  10815. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10816. {
  10817. needCyt = true;
  10818. }
  10819. isAll = false;
  10820. }
  10821. if (isAll)
  10822. {
  10823. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10824. ceErpTradeCell.AfterSaleState = 4;
  10825. ceErpTradeCell.AfterSaleSupplierState = 1;
  10826. }
  10827. }
  10828. }
  10829. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10830. {
  10831. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10832. }
  10833. if (ceErpTradeCell.AfterSaleState == 4)
  10834. {
  10835. ApiVo apiVo = new ApiVo();
  10836. apiVo.orderNumber = ceErpTradeCell.ctid;
  10837. apiVo.actionName = "afterOver";
  10838. designHelper.API_WorkCore(apiVo); //afterOver
  10839. }
  10840. ceErpTradeCell.Update();
  10841. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10842. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10843. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10844. return true;
  10845. }
  10846. return false;
  10847. }
  10848. public void get_erp_wechatorder()
  10849. {
  10850. DataStruct dStruct = GetPostStruct();
  10851. List<string> lw = new List<string>();
  10852. string tid = GetPostString("tid");
  10853. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10854. string shopname = GetPostString("shopname");
  10855. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10856. string buyernick = GetPostString("buyer_nick");
  10857. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10858. string customer = GetPostString("customer");
  10859. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10860. string returndate1 = GetPostString("returndate1");
  10861. string returndate2 = GetPostString("returndate2");
  10862. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10863. if (dw.Length > 0) lw.Add(dw);
  10864. string finishDate1 = GetPostString("finishdate1");
  10865. string finishDate2 = GetPostString("finishdate2");
  10866. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10867. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10868. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10869. dStruct.Order = "created desc";
  10870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10871. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10872. writeGridDataTableJson(dStruct.TotalCount, dt);
  10873. }
  10874. public void get_erp_wechatlist_sumprice()
  10875. {
  10876. DataStruct dStruct = GetPostStruct();
  10877. List<string> lw = new List<string>();
  10878. string tid = GetPostString("tid");
  10879. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10880. string shopname = GetPostString("shopname");
  10881. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10882. string buyernick = GetPostString("buyer_nick");
  10883. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10884. string customer = GetPostString("customer");
  10885. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10886. string returndate1 = GetPostString("returndate1");
  10887. string returndate2 = GetPostString("returndate2");
  10888. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10889. if (dw.Length > 0) lw.Add(dw);
  10890. string finishDate1 = GetPostString("finishdate1");
  10891. string finishDate2 = GetPostString("finishdate2");
  10892. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10893. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10894. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10895. string mainWhere = string.Join(" and ", lw.ToArray());
  10896. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10897. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10898. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10899. decimal total = 0;
  10900. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10901. {
  10902. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10903. }
  10904. var res = new
  10905. {
  10906. data = total
  10907. };
  10908. string ro_jsond = JsonConvert.SerializeObject(res);
  10909. returnSuccess(ro_jsond);
  10910. return;
  10911. }
  10912. public void get_erp_qr_waitdeliverylist()
  10913. {
  10914. DataStruct dStruct = GetPostStruct();
  10915. List<string> lw = new List<string>();
  10916. string tid = GetPostString("ctid");
  10917. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10918. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10919. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10920. var res_objz = new
  10921. {
  10922. restype = 1,
  10923. data = dt
  10924. };
  10925. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10926. returnSuccess(ro_jsonz);
  10927. }
  10928. public void get_erp_yield_list()
  10929. {
  10930. DataStruct dStruct = GetPostStruct();
  10931. List<string> lw = new List<string>();
  10932. string tid = GetPostString("ctid");
  10933. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10934. string shopname = GetPostString("shopname");
  10935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10936. string buyernick = GetPostString("buyer_nick");
  10937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10938. //if (tid.Length == 0 && buyernick.Length == 0)
  10939. //{
  10940. // lw.Add(string.Format("IsRefund<={0}", 1));
  10941. //}
  10942. string customer = GetPostString("customer");
  10943. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10944. string design = GetPostString("design");
  10945. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10946. string orderState = GetPostString("orderState");
  10947. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10948. string address = GetPostString("address");
  10949. 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));
  10950. string sellermemo = GetPostString("seller_memo");
  10951. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10952. string supplier = GetPostString("supplier");
  10953. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10954. string OrderArea = GetPostString("order_area");
  10955. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10956. string placedate1 = GetPostString("placedate1");
  10957. string placedate2 = GetPostString("placedate2");
  10958. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10959. if (fdw.Length > 0) lw.Add(fdw);
  10960. string price1 = GetPostString("price1");
  10961. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10962. string price2 = GetPostString("price2");
  10963. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10964. string unusualCon = GetPostString("unusualcon");
  10965. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10966. string posTag = CurrentUser.UserPost.Post.Code;
  10967. if (posTag == "Supplier")
  10968. {
  10969. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10970. }
  10971. lw.Add(string.Format("OrderState = 6 "));
  10972. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10973. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10974. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10975. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10976. writeGridDataTableJson(dStruct.TotalCount, dt);
  10977. }
  10978. public void change_erp_sup_state()
  10979. {
  10980. if (UrlPostParmsCheck("ctid"))
  10981. {
  10982. string ctid = GetPostString("ctid");
  10983. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10984. if (ceErpTradeCell != null)
  10985. {
  10986. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10987. if (ceErpTradeCellExtend == null)
  10988. {
  10989. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10990. ceErpTradeCellExtend.ctid = ctid;
  10991. ceErpTradeCellExtend.SupState = 1;
  10992. ceErpTradeCellExtend.Create();
  10993. }
  10994. else
  10995. {
  10996. ceErpTradeCellExtend.SupState = 1;
  10997. ceErpTradeCellExtend.Update();
  10998. }
  10999. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11000. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11001. return;
  11002. }
  11003. returnErrorMsg("找不到订单");
  11004. }
  11005. }
  11006. public void supplier_all_downs()
  11007. {
  11008. if (UrlPostParmsCheck("tids"))
  11009. {
  11010. string tids = GetPostString("tids");
  11011. if (tids != null && tids.Length > 0)
  11012. {
  11013. StringBuilder sql = new StringBuilder();
  11014. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11015. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11016. sql = new StringBuilder();
  11017. 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, "下载设计文件");
  11018. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11019. string[] list = tids.Split(',');
  11020. foreach (string ctid in list)
  11021. {
  11022. CeErpSukuraData.createInfo(ctid, 3);
  11023. }
  11024. designHelper.api_approveDesign(tids); //approveDesign
  11025. returnSuccessMsg("下载成功!");
  11026. return;
  11027. }
  11028. returnErrorMsg("下载订单更新失败");
  11029. }
  11030. }
  11031. public void uploaderFileSuccess()
  11032. {
  11033. if (UrlPostParmsCheck("fileName"))
  11034. {
  11035. string fileName = GetPostString("fileName");
  11036. ApiVo apiVo = new ApiVo();
  11037. apiVo.orderNumber = fileName;
  11038. apiVo.actionName = "finishDesign";
  11039. designHelper.API_WorkCore(apiVo);//finishDesign
  11040. returnSuccessMsg("");
  11041. }
  11042. }
  11043. public void get_sample2_order()
  11044. {
  11045. if (UrlPostParmsCheck("ctid"))
  11046. {
  11047. string ctid = GetPostString("ctid");
  11048. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11049. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11050. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11051. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11052. double total = 0.0;
  11053. double order_price = 0.0;
  11054. if (dt_bu.Rows.Count > 0)
  11055. {
  11056. foreach (DataRow dr in dt_bu.Rows)
  11057. {
  11058. total += Convert.ToDouble(dr["payment"]);
  11059. }
  11060. }
  11061. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11062. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11063. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11064. string tid = ctid.Replace("S_", "");
  11065. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11066. double paymant = 0.0;
  11067. if (entity != null)
  11068. {
  11069. paymant = entity.payment;
  11070. }
  11071. string return_reason = "";
  11072. if (dt_after != null && dt_after.Rows.Count > 0)
  11073. {
  11074. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11075. }
  11076. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11077. }
  11078. }
  11079. public void get_erp_design_status()
  11080. {
  11081. string designName = GetPostString("designName");
  11082. DataStruct dStruct = GetPostStruct();
  11083. if (designName.Length > 0)
  11084. {
  11085. 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";
  11086. sql_user += " and Name like '%" + designName + "%'";
  11087. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11088. List<string> ids_list = new List<string>();
  11089. if (user_table.Rows.Count > 0)
  11090. {
  11091. foreach (DataRow item in user_table.Rows)
  11092. {
  11093. ids_list.Add(item["id"].ToString());
  11094. string ids_s = item["TeamIds"].ToString();
  11095. if (ids_s.Length > 0)
  11096. {
  11097. ids_list.AddRange(ids_s.Split(','));
  11098. }
  11099. }
  11100. }
  11101. HashSet<string> set = new HashSet<string>(ids_list);
  11102. ids_list = set.ToList();
  11103. if (ids_list.Count > 0)
  11104. {
  11105. 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));
  11106. dStruct.MainWhere = sql;
  11107. DataTable dt = null;
  11108. dt = WebCache.GetData("view_ErpUser", dStruct);
  11109. writeGridDataTableJson(dStruct.TotalCount, dt);
  11110. }
  11111. }
  11112. }
  11113. public void change_erp_order_price()
  11114. {
  11115. string ctid = GetPostString("ctid");
  11116. double price = GetPostDouble("price");
  11117. if (ctid.Length > 0)
  11118. {
  11119. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11120. if (ceErpTradeCellExtend == null)
  11121. {
  11122. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11123. ceErpTradeCellExtend.ctid = ctid;
  11124. ceErpTradeCellExtend.payment_cyt = price;
  11125. ceErpTradeCellExtend.Create();
  11126. }
  11127. else
  11128. {
  11129. ceErpTradeCellExtend.payment_cyt = price;
  11130. ceErpTradeCellExtend.Update();
  11131. }
  11132. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11133. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11134. {
  11135. ceErpDataSendOrderInfo.isSync = false;
  11136. ceErpDataSendOrderInfo.Update();
  11137. }
  11138. if (ceErpDataSendOrderInfo == null)
  11139. {
  11140. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11141. ceErpDataSendOrderInfo.isSync = false;
  11142. ceErpDataSendOrderInfo.ctid = ctid;
  11143. ceErpDataSendOrderInfo.Create();
  11144. }
  11145. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11146. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11147. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11148. if (dth != null && dth.Rows.Count > 0)
  11149. {
  11150. dataSendOrderBean dataSendOrderBean = null;
  11151. foreach (DataRow item in dth.Rows)
  11152. {
  11153. try
  11154. {
  11155. dataSendOrderBean = new dataSendOrderBean();
  11156. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11157. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11158. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11159. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11160. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11161. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11162. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11163. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11164. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11165. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11166. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11167. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11168. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11169. if (result != null)
  11170. {
  11171. if ("0".Equals(result.errcode))
  11172. {
  11173. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11174. }
  11175. else
  11176. {
  11177. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11178. }
  11179. }
  11180. }
  11181. catch (Exception ex)
  11182. {
  11183. }
  11184. }
  11185. }
  11186. returnSuccessMsg("修改成功!");
  11187. return;
  11188. }
  11189. returnErrorMsg("找不到订单");
  11190. }
  11191. public void find_he_together()
  11192. {
  11193. string ctid = GetPostString("ctid");
  11194. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11195. List<string> list = new List<string>();
  11196. if (ceErpTradeCell != null)
  11197. {
  11198. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11199. {
  11200. 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);
  11201. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11202. if (table != null && table.Rows.Count > 0)
  11203. {
  11204. foreach (TableRow row in table.Rows)
  11205. {
  11206. }
  11207. }
  11208. }
  11209. }
  11210. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11211. }
  11212. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11213. {
  11214. //chy----19
  11215. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11216. //GD-CYT-----64
  11217. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11218. //ZHX----3
  11219. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11220. //JK----97
  11221. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11222. //ZT----70
  11223. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11224. //LHCY-----98
  11225. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11226. //XD-----90
  11227. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11228. //CYCY-----14
  11229. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11230. };
  11231. //其他改名
  11232. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11233. {
  11234. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11235. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11236. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11237. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11238. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11239. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11240. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11241. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11242. };
  11243. //不统计
  11244. List<int> no_suppliers = new List<int>()
  11245. {
  11246. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11247. };
  11248. //配件单
  11249. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11250. {
  11251. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11252. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11253. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11254. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11255. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11256. {"旗杆",new List<string>(){ "班旗" } },
  11257. {"牙签",new List<string>(){ "不干胶" } }
  11258. };
  11259. public void get_place_order_data()
  11260. {
  11261. string date1 = GetPostString("date1");
  11262. string date2 = GetPostString("date2");
  11263. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11264. DateTime start = DateTime.Parse(starttime);
  11265. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11266. DateTime end = DateTime.Parse(endtime);
  11267. if (date1 != null && date1.Length > 0)
  11268. {
  11269. DateTime dateTime = DateTime.Parse(date1);
  11270. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11271. start = DateTime.Parse(starttime);
  11272. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11273. end = DateTime.Parse(endtime);
  11274. }
  11275. if (date2 != null && date2.Length > 0)
  11276. {
  11277. DateTime dateTime = DateTime.Parse(date2);
  11278. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11279. end = DateTime.Parse(endtime);
  11280. }
  11281. 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);
  11282. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11283. //不干胶-----1,卡片-----29
  11284. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11285. foreach (DataRow row in data.Rows)
  11286. {
  11287. int productId = Convert.ToInt32(row["ProductId"]);
  11288. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11289. if (no_suppliers.Contains(supplierId))
  11290. {
  11291. continue;
  11292. }
  11293. string seller_memo = row["seller_memo"].ToString();
  11294. bool ispj = false;//是否配件单
  11295. bool isfirst = true;//第一个配
  11296. maps.Keys.ForEach(key =>
  11297. {
  11298. //备注包含配件
  11299. if (seller_memo.Contains(key) && isfirst)
  11300. {
  11301. List<string> list = maps[key];
  11302. ispj = true;
  11303. isfirst = false;
  11304. for (int i = 0; i < list.Count; i++)
  11305. {
  11306. if (seller_memo.Contains(list[i]))
  11307. {
  11308. ispj = false;
  11309. break;
  11310. }
  11311. }
  11312. }
  11313. });
  11314. if (ispj)
  11315. {
  11316. continue;
  11317. }
  11318. seller_memo = seller_memo.Replace("UV", "uv");
  11319. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11320. //吊牌归到卡片
  11321. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11322. seller_memo = seller_memo.Replace("卡套", "卡片");
  11323. seller_memo = seller_memo.Replace("封套", "卡片");
  11324. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11325. seller_memo = seller_memo.Replace("腰封", "卡片");
  11326. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11327. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11328. seller_memo = seller_memo.Replace("横幅", "条幅");
  11329. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11330. string map_key = "";
  11331. string type = "";
  11332. if (supplierMap.ContainsKey(supplierId))
  11333. {
  11334. foreach (var kvp in supplierMap[supplierId])
  11335. {
  11336. if (seller_memo.Contains(kvp.Key))
  11337. {
  11338. map_key = kvp.Value;
  11339. type = kvp.Value;
  11340. break;
  11341. }
  11342. }
  11343. }
  11344. if (map_key == "")
  11345. {
  11346. type = "其他";
  11347. map_key = "其他";
  11348. }
  11349. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11350. {
  11351. map_key = suppliers[supplierId];
  11352. }
  11353. if (supplierId == 70)
  11354. {
  11355. supplierId = 70;
  11356. }
  11357. map_key += "_" + row["SupplierName"].ToString();
  11358. Dictionary<string, int> map = null;
  11359. if (other_map.ContainsKey(map_key))
  11360. {
  11361. other_map.TryGetValue(map_key, out map);
  11362. }
  11363. else
  11364. {
  11365. map = new Dictionary<string, int>();
  11366. map.Add("dayDev", 0);//当天出货
  11367. map.Add("dayTotal", 0);//下单总数
  11368. map.Add("payTotal", 0);//500以上
  11369. map.Add("today", 0);//当天出货数量
  11370. map.Add("unusua", 0);//异常数
  11371. other_map.Add(map_key, map);
  11372. other_map.TryGetValue(map_key, out map);
  11373. }
  11374. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11375. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11376. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11377. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11378. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11379. {
  11380. map["dayTotal"]++;
  11381. if (supplierId == 97)
  11382. {
  11383. supplierId = 97;
  11384. }
  11385. }
  11386. if (Convert.ToDecimal(row["payment"]) >= 500)
  11387. {
  11388. map["payTotal"]++;
  11389. }
  11390. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11391. {
  11392. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11393. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11394. {
  11395. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11396. {
  11397. map["today"]++;
  11398. }
  11399. }
  11400. else
  11401. {
  11402. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11403. {
  11404. map["today"]++;
  11405. }
  11406. else
  11407. {
  11408. if (supplierId == 119)
  11409. {
  11410. Debug.WriteLine(row["seller_memo"].ToString());
  11411. }
  11412. }
  11413. }
  11414. }
  11415. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11416. {
  11417. map["unusua"]++;
  11418. }
  11419. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11420. //GD-CYT-----64
  11421. DateTime two = palceTimeStart.AddHours(14);
  11422. DateTime three = palceTimeStart.AddHours(15);
  11423. DateTime four = palceTimeStart.AddHours(16);
  11424. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11425. {
  11426. //下午四点前 500-1000
  11427. string count = row["ProductCount"].ToString();
  11428. if (count != null && count.Length > 0)
  11429. {
  11430. int productCount = commonHelper.getPlaceProductCount(count);
  11431. if (productCount >= 500 && productCount <= 1000)
  11432. {
  11433. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11434. {
  11435. map["dayDev"]++;
  11436. }
  11437. }
  11438. }
  11439. }
  11440. //UV
  11441. else if ("uv".Equals(type))
  11442. {
  11443. //ZT----70
  11444. //ZHX----3
  11445. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11446. {
  11447. map["dayDev"]++;
  11448. }
  11449. //JK----97
  11450. //HZX----105
  11451. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11452. {
  11453. map["dayDev"]++;
  11454. if (supplierId == 97)
  11455. {
  11456. supplierId = 97;
  11457. }
  11458. }
  11459. }
  11460. //帆布---52|条幅---27
  11461. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11462. {
  11463. //LHCY-----98
  11464. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11465. {
  11466. map["dayDev"]++;
  11467. }
  11468. }
  11469. //条幅
  11470. else if ("条幅".Equals(type))
  11471. {
  11472. //XD-----90
  11473. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11474. {
  11475. map["dayDev"]++;
  11476. }
  11477. }
  11478. //桌布
  11479. else if ("桌布".Equals(type))
  11480. {
  11481. //XD-----90
  11482. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11483. {
  11484. map["dayDev"]++;
  11485. }
  11486. }
  11487. //DL---10
  11488. //AYTW---119
  11489. //FS-CYT-DY ----80
  11490. //JK----97
  11491. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11492. {
  11493. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11494. {
  11495. map["dayDev"]++;
  11496. }
  11497. }
  11498. }
  11499. DataTable dt = new DataTable();
  11500. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11501. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11502. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11503. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11504. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11505. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11506. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11507. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11508. other_map.Keys.ForEach(key =>
  11509. {
  11510. DataRow dr = dt.NewRow();
  11511. Dictionary<string, int> map = other_map[key];
  11512. string[] key_list = key.Split('_');
  11513. dr[0] = key_list[0];
  11514. dr[1] = key_list[1];
  11515. if (key_list.Length > 2)
  11516. {
  11517. dr[1] += "(" + key_list[2] + ")";
  11518. }
  11519. dr[2] = map["dayTotal"];
  11520. dr[3] = map["payTotal"];
  11521. dr[4] = map["today"];
  11522. dr[5] = map["unusua"];
  11523. dr[6] = map["dayDev"];
  11524. double rate = 0.00;
  11525. if (map["dayDev"] > 0)
  11526. {
  11527. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11528. }
  11529. dr[7] = rate.ToString();
  11530. dt.Rows.Add(dr);
  11531. });
  11532. DataView dv = new DataView(dt);
  11533. dv.Sort = "SupplierName";
  11534. //dv.Sort = "AllOrder desc";
  11535. DataTable dtNew = dv.ToTable();
  11536. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11537. }
  11538. public void check_order_desing_info()
  11539. {
  11540. string ctid = GetPostString("ctid");
  11541. if (!string.IsNullOrEmpty(ctid))
  11542. {
  11543. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11544. if (ceErpTradeCell != null)
  11545. {
  11546. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11547. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11548. return;
  11549. }
  11550. returnErrorMsg("找不到订单");
  11551. return;
  11552. }
  11553. returnErrorMsg("找不到订单");
  11554. }
  11555. public void get_timeout_detail()
  11556. {
  11557. string poscode = CurrentUser.UserPost.Post.Code;
  11558. DataStruct dStruct = GetPostStruct();
  11559. List<string> lw = new List<string>();
  11560. string id = GetPostString("id");
  11561. string pay_date1 = GetPostString("pay_date1");
  11562. string pay_date2 = GetPostString("pay_date2");
  11563. int type = GetPostInt("type");
  11564. if (type == 0)
  11565. {
  11566. if (pay_date1.Length > 0)
  11567. {
  11568. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11569. }
  11570. if (pay_date2.Length > 0)
  11571. {
  11572. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11573. }
  11574. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11575. }
  11576. if (type == 1)
  11577. {
  11578. if (pay_date1.Length > 0)
  11579. {
  11580. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11581. }
  11582. if (pay_date2.Length > 0)
  11583. {
  11584. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11585. }
  11586. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11587. }
  11588. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11589. DataTable dt = null;
  11590. dt = WebCache.GetData("view_orderlist", dStruct);
  11591. writeGridDataTableJson(dStruct.TotalCount, dt);
  11592. }
  11593. public void saveUrgentChargePrice()
  11594. {
  11595. string ctid = GetPostString("ctid");
  11596. if (!string.IsNullOrEmpty(ctid))
  11597. {
  11598. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11599. if (ceErpTradeCell != null)
  11600. {
  11601. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11602. if (prices <= 100)
  11603. {
  11604. returnErrorMsg("此订单金额不足100元,无法加急。");
  11605. return;
  11606. }
  11607. double price = GetPostDouble("price");
  11608. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11609. if (ceErpTradeCellExtend == null)
  11610. {
  11611. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11612. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11613. }
  11614. ceErpTradeCellExtend.urgentCharge = price;
  11615. if (ceErpTradeCellExtend.ID > 0)
  11616. {
  11617. ceErpTradeCellExtend.Update();
  11618. }
  11619. else
  11620. {
  11621. ceErpTradeCellExtend.Save();
  11622. }
  11623. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11624. returnSuccessMsg("修改成功!");
  11625. return;
  11626. }
  11627. returnErrorMsg("找不到订单");
  11628. return;
  11629. }
  11630. returnErrorMsg("找不到订单");
  11631. }
  11632. public void finish_erp_order()
  11633. {
  11634. string ctid = GetPostString("ctid");
  11635. if (!string.IsNullOrEmpty(ctid))
  11636. {
  11637. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11638. {
  11639. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11640. if (ceErpTradeCell != null)
  11641. {
  11642. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11643. ceErpTradeCell.Update();
  11644. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11645. returnSuccessMsg("修改成功!");
  11646. return;
  11647. }
  11648. }
  11649. }
  11650. returnErrorMsg("找不到订单");
  11651. }
  11652. public void get_trade_order_list()
  11653. {
  11654. string tid = GetPostString("tid");
  11655. if (!string.IsNullOrEmpty(tid))
  11656. {
  11657. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11658. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11659. writeGridDataTableJson(data.Rows.Count, data);
  11660. return;
  11661. }
  11662. returnErrorMsg("找不到订单");
  11663. }
  11664. public void save_cell_spu()
  11665. {
  11666. string ctid = GetPostString("ctid");
  11667. string spu_id = GetPostString("spu_id");
  11668. if (!string.IsNullOrEmpty(ctid))
  11669. {
  11670. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11671. if (ceErpTradeCellExtend == null)
  11672. {
  11673. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11674. ceErpTradeCellExtend.ctid = ctid;
  11675. }
  11676. ceErpTradeCellExtend.spu_id = spu_id;
  11677. if (!string.IsNullOrEmpty(spu_id))
  11678. {
  11679. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11680. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11681. }
  11682. if (ceErpTradeCellExtend.ID == 0)
  11683. {
  11684. ceErpTradeCellExtend.Create();
  11685. }
  11686. else
  11687. {
  11688. ceErpTradeCellExtend.Update();
  11689. }
  11690. returnSuccessMsg("修改成功!");
  11691. return;
  11692. }
  11693. returnErrorMsg("找不到订单");
  11694. }
  11695. public void change_express_info()
  11696. {
  11697. string ctid = GetPostString("ctid");
  11698. string transNo = GetPostString("transNo");
  11699. string transCom = GetPostString("transCom");
  11700. if (!string.IsNullOrEmpty(ctid))
  11701. {
  11702. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11703. if (ceErpTradeCellExtend == null)
  11704. {
  11705. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11706. ceErpTradeCellExtend.ctid = ctid;
  11707. }
  11708. ceErpTradeCellExtend.modExpressNo = transNo;
  11709. ceErpTradeCellExtend.modExpressCom = transCom;
  11710. ceErpTradeCellExtend.readMod = 2;
  11711. if (ceErpTradeCellExtend.ID == 0)
  11712. {
  11713. ceErpTradeCellExtend.Create();
  11714. }
  11715. else
  11716. {
  11717. ceErpTradeCellExtend.Update();
  11718. }
  11719. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11720. returnSuccessMsg("修改成功!");
  11721. return;
  11722. }
  11723. returnErrorMsg("找不到订单");
  11724. }
  11725. public void get_change_express_list()
  11726. {
  11727. DataStruct dStruct = GetPostStruct();
  11728. List<string> lw = new List<string>();
  11729. int st = 2;
  11730. string tid = GetPostString("ctid");
  11731. if (tid.Length > 0)
  11732. {
  11733. string select_tid = getTidByCtid(tid);
  11734. lw.Add(string.Format("tid='{0}'", select_tid));
  11735. }
  11736. string shopname = GetPostString("shopname");
  11737. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11738. string buyernick = GetPostString("buyer_nick");
  11739. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11740. string sellermemo = GetPostString("seller_memo");
  11741. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11742. string supplier = GetPostString("supplier");
  11743. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11744. string customer = GetPostString("customer");
  11745. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11746. string design = GetPostString("design");
  11747. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11748. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11749. string poscode = CurrentUser.UserPost.Post.Code;
  11750. if (poscode != "SysAdmin")
  11751. {
  11752. string shopid = CurrentUser.User.pemShop;
  11753. lw.Add(string.Format("shopId in ({0})", shopid));
  11754. }
  11755. lw.Add("readMod = 2");
  11756. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11757. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11758. writeGridDataTableJson(dStruct.TotalCount, dt);
  11759. }
  11760. public void deal_express_complete()
  11761. {
  11762. string ctid = GetPostString("ctid");
  11763. if (!string.IsNullOrEmpty(ctid))
  11764. {
  11765. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11766. if (ceErpTradeCellExtend == null)
  11767. {
  11768. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11769. ceErpTradeCellExtend.ctid = ctid;
  11770. }
  11771. ceErpTradeCellExtend.readMod = 1;
  11772. if (ceErpTradeCellExtend.ID == 0)
  11773. {
  11774. ceErpTradeCellExtend.Create();
  11775. }
  11776. else
  11777. {
  11778. ceErpTradeCellExtend.Update();
  11779. }
  11780. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11781. returnSuccessMsg("修改成功!");
  11782. return;
  11783. }
  11784. returnErrorMsg("找不到订单");
  11785. }
  11786. public void aftersale_return_visit()
  11787. {
  11788. string ctid = GetPostString("ctid");
  11789. if (!string.IsNullOrEmpty(ctid))
  11790. {
  11791. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11792. if (ceErpTradeCellExtend == null)
  11793. {
  11794. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11795. ceErpTradeCellExtend.ctid = ctid;
  11796. }
  11797. ceErpTradeCellExtend.returnVisit = 1;
  11798. if (ceErpTradeCellExtend.ID == 0)
  11799. {
  11800. ceErpTradeCellExtend.Create();
  11801. }
  11802. else
  11803. {
  11804. ceErpTradeCellExtend.Update();
  11805. }
  11806. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11807. if (ceErpTradeAfterSaleExtend != null)
  11808. {
  11809. ceErpTradeAfterSaleExtend.TextResult = "";
  11810. ceErpTradeAfterSaleExtend.Update();
  11811. }
  11812. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11813. returnSuccessMsg("修改成功!");
  11814. return;
  11815. }
  11816. returnErrorMsg("找不到订单");
  11817. }
  11818. public void orderPlaceInfo()
  11819. {
  11820. string ctids = GetPostString("ctids");
  11821. string[] list = ctids.Split(',');
  11822. foreach (string ctid in list)
  11823. {
  11824. CeErpSukuraData.createInfo(ctid, 3);
  11825. }
  11826. StringBuilder sql = new StringBuilder();
  11827. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11828. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11829. designHelper.api_approveDesign(ctids); //approveDesign
  11830. returnSuccessMsg("");
  11831. }
  11832. public void get_issue_list()
  11833. {
  11834. DataStruct dStruct = GetPostStruct();
  11835. List<string> lw = new List<string>();
  11836. int st = 2;
  11837. string tid = GetPostString("ctid");
  11838. if (tid.Length > 0)
  11839. {
  11840. string select_tid = getTidByCtid(tid);
  11841. lw.Add(string.Format("tid='{0}'", select_tid));
  11842. }
  11843. string shopname = GetPostString("shopname");
  11844. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11845. string buyernick = GetPostString("buyer_nick");
  11846. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11847. string sellermemo = GetPostString("seller_memo");
  11848. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11849. string supplier = GetPostString("supplier");
  11850. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11851. string customer = GetPostString("customer");
  11852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11853. string design = GetPostString("design");
  11854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11855. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11856. string poscode = CurrentUser.UserPost.Post.Code;
  11857. if (poscode != "SysAdmin")
  11858. {
  11859. string shopid = CurrentUser.User.pemShop;
  11860. lw.Add(string.Format("shopId in ({0})", shopid));
  11861. }
  11862. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11863. {
  11864. lw.Add("IssueState = 1");
  11865. }
  11866. lw.Add("IssueState > 0");
  11867. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11868. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11869. writeGridDataTableJson(dStruct.TotalCount, dt);
  11870. }
  11871. public void saveIssueContent()
  11872. {
  11873. string ctid = GetPostString("ctid");
  11874. if (!string.IsNullOrEmpty(ctid))
  11875. {
  11876. string content = GetPostString("content");
  11877. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11878. if (ceErpTradeAfterSaleExtend == null)
  11879. {
  11880. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11881. ceErpTradeAfterSaleExtend.tid = ctid;
  11882. }
  11883. ceErpTradeAfterSaleExtend.IssueContent = content;
  11884. ceErpTradeAfterSaleExtend.IssueState = 1;
  11885. if (ceErpTradeAfterSaleExtend.ID > 0)
  11886. {
  11887. ceErpTradeAfterSaleExtend.Update();
  11888. }
  11889. else
  11890. {
  11891. ceErpTradeAfterSaleExtend.Create();
  11892. }
  11893. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11894. returnSuccessMsg("添加成功!");
  11895. return;
  11896. }
  11897. returnErrorMsg("找不到订单");
  11898. }
  11899. public void dealIssueContent()
  11900. {
  11901. string ctid = GetPostString("ctid");
  11902. if (!string.IsNullOrEmpty(ctid))
  11903. {
  11904. string content = GetPostString("content");
  11905. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11906. if (ceErpTradeAfterSaleExtend != null)
  11907. {
  11908. ceErpTradeAfterSaleExtend.IssueState = 2;
  11909. ceErpTradeAfterSaleExtend.Update();
  11910. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11911. returnSuccessMsg("修改完成!");
  11912. return;
  11913. }
  11914. }
  11915. returnErrorMsg("找不到订单");
  11916. }
  11917. public void set_tid_attachments()
  11918. {
  11919. string tid = GetPostString("tid");
  11920. string atta = GetPostString("atta");
  11921. if (!string.IsNullOrEmpty(tid))
  11922. {
  11923. if (string.IsNullOrEmpty(atta))
  11924. {
  11925. returnErrorMsg("文件地址为空");
  11926. return;
  11927. }
  11928. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11929. if (ceErpTradeCell != null)
  11930. {
  11931. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11932. if (ceErpTrade == null)
  11933. {
  11934. returnErrorMsg("找不到订单");
  11935. return;
  11936. }
  11937. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11938. bool isSend = false;
  11939. if (dt != null && dt.Rows.Count > 0)
  11940. {
  11941. foreach (DataRow row in dt.Rows)
  11942. {
  11943. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11944. {
  11945. isSend = true;
  11946. }
  11947. }
  11948. if (isSend)
  11949. {
  11950. returnErrorMsg("已发货无法修改");
  11951. return;
  11952. }
  11953. ceErpTrade.Attachments = atta;
  11954. ceErpTrade.Update();
  11955. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  11956. returnSuccessMsg("上传成功!");
  11957. return;
  11958. }
  11959. }
  11960. }
  11961. returnErrorMsg("找不到订单");
  11962. }
  11963. public void get_tid_attachments()
  11964. {
  11965. string tid = GetPostString("tid");
  11966. if (!string.IsNullOrEmpty(tid))
  11967. {
  11968. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11969. if (ceErpTradeCell != null)
  11970. {
  11971. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11972. if (ceErpTrade == null)
  11973. {
  11974. returnErrorMsg("找不到订单");
  11975. return;
  11976. }
  11977. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11978. return;
  11979. }
  11980. }
  11981. returnErrorMsg("找不到订单");
  11982. }
  11983. public void check_erp_sameorders()
  11984. {
  11985. if (UrlPostParmsCheck("ctid"))
  11986. {
  11987. string eid = GetPostString("ctid");
  11988. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11989. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11990. if (entity != null && ceErpTrade != null)
  11991. {
  11992. if (entity.OrderState > 6)
  11993. {
  11994. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11995. return;
  11996. }
  11997. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  11998. List<string> ids = new List<string>();
  11999. if (dt != null && dt.Rows.Count > 1)
  12000. {
  12001. bool needhe = true;
  12002. foreach (DataRow dr in dt.Rows)
  12003. {
  12004. ids.Add("'" + dr["ctid"] + "'");
  12005. /* //备注有合包
  12006. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12007. {
  12008. needhe = true;
  12009. }
  12010. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12011. {
  12012. needhe = true;
  12013. }
  12014. //顺丰快递
  12015. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12016. {
  12017. needhe = true;
  12018. }*/
  12019. }
  12020. if (!needhe)
  12021. {
  12022. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12023. return;
  12024. }
  12025. StringBuilder sql = new StringBuilder();
  12026. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12027. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12028. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12029. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12030. foreach (DataRow dr in dt.Rows)
  12031. {
  12032. dr["dstate"] = 0;
  12033. dr["dnumber"] = 0;
  12034. foreach (DataRow row in dt1.Rows)
  12035. {
  12036. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12037. {
  12038. dr["dstate"] = 2;
  12039. dr["default"] = 1;
  12040. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12041. }
  12042. }
  12043. if (eid.Equals(dr["ctid"].ToString()))
  12044. {
  12045. dr["dstate"] = 1;
  12046. dr["default"] = 1;
  12047. }
  12048. }
  12049. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12050. return;
  12051. }
  12052. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12053. return;
  12054. }
  12055. returnErrorMsg("未找到订单");
  12056. return;
  12057. }
  12058. returnErrorMsg("缺少必要的参数");
  12059. }
  12060. public void get_mark_number()
  12061. {
  12062. string eid = GetPostString("ctid");
  12063. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12064. if (entity != null)
  12065. {
  12066. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12067. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12068. int current = 1;
  12069. if (ceErpDeliverMark == null)
  12070. {
  12071. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12072. List<string> ids = new List<string>();
  12073. if (dt != null && dt.Rows.Count > 1)
  12074. {
  12075. foreach (DataRow dr in dt.Rows)
  12076. {
  12077. ids.Add("'" + dr["ctid"] + "'");
  12078. }
  12079. //查询已有的编号
  12080. StringBuilder sql = new StringBuilder();
  12081. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12082. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12083. if (dt1 == null || dt1.Rows.Count == 0)
  12084. {
  12085. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12086. List<int> list_number = new List<int>();
  12087. foreach (DataRow row in numbers.Rows)
  12088. {
  12089. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12090. }
  12091. //查询空余编号
  12092. for (int i = 0; i < list_number.Count + 2; i++)
  12093. {
  12094. if (!list_number.Contains(current))
  12095. {
  12096. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12097. //防止查询过程中有新数据生成
  12098. if (ceErpDeliverMark1 == null)
  12099. {
  12100. break;
  12101. }
  12102. }
  12103. current++;
  12104. }
  12105. }
  12106. else
  12107. {
  12108. foreach (DataRow row in dt1.Rows)
  12109. {
  12110. current = Convert.ToInt32(row["markNumber"]);
  12111. }
  12112. }
  12113. ceErpDeliverMark = new CeErpDeliverMark();
  12114. ceErpDeliverMark.ctid = eid;
  12115. ceErpDeliverMark.createtime = DateTime.Now;
  12116. if (ceErpTrade != null)
  12117. {
  12118. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12119. }
  12120. ceErpDeliverMark.markNumber = current;
  12121. ceErpDeliverMark.Create();
  12122. }
  12123. }
  12124. else
  12125. {
  12126. current = ceErpDeliverMark.markNumber;
  12127. }
  12128. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12129. return;
  12130. }
  12131. }
  12132. public void aftersaleCytSend()
  12133. {
  12134. string ctid = GetPostString("ctid");
  12135. if (!string.IsNullOrEmpty(ctid))
  12136. {
  12137. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12138. if (ceErpTradeCell != null)
  12139. {
  12140. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12141. }
  12142. returnSuccessMsg("推送成功");
  12143. return;
  12144. }
  12145. returnErrorMsg("缺少必要的参数");
  12146. }
  12147. public void packOrderInfo()
  12148. {
  12149. string ctids = GetPostString("ctids");
  12150. if (!string.IsNullOrEmpty(ctids))
  12151. {
  12152. string[] ctid_list = ctids.Split(',');
  12153. if (ctid_list.Length > 20)
  12154. {
  12155. returnErrorMsg("单次下载次数不能超过20个");
  12156. return;
  12157. }
  12158. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12159. StringBuilder sql = new StringBuilder();
  12160. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12161. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12162. int supplierId = 0;
  12163. StringBuilder insterSql = new StringBuilder();
  12164. for (int i = 0; i < dt.Rows.Count; i++)
  12165. {
  12166. DataRow row = dt.Rows[i];
  12167. if (i == 0)
  12168. {
  12169. supplierId = Convert.ToInt32(row["SupplierId"]);
  12170. }
  12171. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12172. {
  12173. returnErrorMsg("同车间的订单才能一起打包");
  12174. return;
  12175. }
  12176. int orderState = Convert.ToInt32(row["OrderState"]);
  12177. if (orderState != 5)
  12178. {
  12179. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12180. return;
  12181. }
  12182. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12183. }
  12184. CeErpPackData ceErpPackData = new CeErpPackData();
  12185. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12186. ceErpPackData.supplierId = supplierId;
  12187. ceErpPackData.createtime = DateTime.Now;
  12188. ceErpPackData.createBy = CurrentUser.UserID;
  12189. ceErpPackData.createName = CurrentUser.UserName;
  12190. ceErpPackData.Create();
  12191. if (ceErpPackData.ID > 0)
  12192. {
  12193. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12194. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12195. }
  12196. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12197. returnSuccessMsg("打包成功");
  12198. return;
  12199. }
  12200. returnErrorMsg("缺少必要的参数");
  12201. }
  12202. public void rePackOrderInfo()
  12203. {
  12204. string id = GetPostString("id");
  12205. if (!string.IsNullOrEmpty(id))
  12206. {
  12207. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12208. if (ceErpPackData == null)
  12209. {
  12210. returnSuccessMsg("查无数据");
  12211. return;
  12212. }
  12213. ceErpPackData.upStatus = 0;
  12214. ceErpPackData.message = "";
  12215. ceErpPackData.Update();
  12216. returnSuccessMsg("打包成功");
  12217. return;
  12218. }
  12219. returnErrorMsg("缺少必要的参数");
  12220. }
  12221. public void addPackDownNum()
  12222. {
  12223. string id = GetPostString("id");
  12224. if (!string.IsNullOrEmpty(id))
  12225. {
  12226. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12227. returnSuccessMsg("下载成功");
  12228. return;
  12229. }
  12230. returnErrorMsg("缺少必要的参数");
  12231. }
  12232. public void get_pack_list()
  12233. {
  12234. DataStruct dStruct = GetPostStruct();
  12235. List<string> lw = new List<string>();
  12236. string supplier = GetPostString("supplier");
  12237. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12238. string posTag = CurrentUser.UserPost.Post.Code;
  12239. if (posTag == "Supplier")
  12240. {
  12241. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12242. }
  12243. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12244. dStruct.Order = "createtime desc";
  12245. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12246. writeGridDataTableJson(dStruct.TotalCount, dt);
  12247. }
  12248. public void get_supplier_product_time_list()
  12249. {
  12250. DataStruct dStruct = GetPostStruct();
  12251. List<string> lw = new List<string>();
  12252. string supplier = GetPostString("supplier");
  12253. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12254. string posTag = CurrentUser.UserPost.Post.Code;
  12255. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12256. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12257. writeGridDataTableJson(dStruct.TotalCount, dt);
  12258. }
  12259. public void saveSupplierProductTime()
  12260. {
  12261. string productId = GetPostString("productId");
  12262. if (string.IsNullOrEmpty(productId))
  12263. {
  12264. returnErrorMsg("缺少必要的参数");
  12265. return;
  12266. }
  12267. string productName = GetPostString("productName");
  12268. int supplierId = GetPostInt("supplierId");
  12269. if (supplierId == 0)
  12270. {
  12271. returnErrorMsg("缺少必要的参数");
  12272. return;
  12273. }
  12274. int quantity = GetPostInt("quantity");
  12275. int sendDay = GetPostInt("sendTime");
  12276. string supplierName = GetPostString("supplierName");
  12277. string craft = GetPostString("craft");
  12278. string deadLine = GetPostString("deadLine");
  12279. string dayDeadLine = GetPostString("dayDeadLine");
  12280. try
  12281. {
  12282. int eid = GetPostInt("eid");
  12283. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12284. if (ceErpSupplierProductTime == null)
  12285. {
  12286. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12287. }
  12288. ceErpSupplierProductTime.productId = productId;
  12289. ceErpSupplierProductTime.productName = productName;
  12290. ceErpSupplierProductTime.supplierId = supplierId;
  12291. ceErpSupplierProductTime.supplierName = supplierName;
  12292. ceErpSupplierProductTime.craft = craft;
  12293. ceErpSupplierProductTime.sendDay = sendDay;
  12294. ceErpSupplierProductTime.quantity = quantity;
  12295. if (!string.IsNullOrEmpty(deadLine))
  12296. {
  12297. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12298. }
  12299. if (!string.IsNullOrEmpty(dayDeadLine))
  12300. {
  12301. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12302. }
  12303. if (ceErpSupplierProductTime.ID == 0)
  12304. {
  12305. ceErpSupplierProductTime.Save();
  12306. }
  12307. else
  12308. {
  12309. ceErpSupplierProductTime.Update();
  12310. }
  12311. }
  12312. catch (Exception e)
  12313. {
  12314. }
  12315. returnSuccessMsg("保存成功");
  12316. return;
  12317. }
  12318. public void delSupplierProductTime()
  12319. {
  12320. int eid = GetPostInt("eid");
  12321. if (eid > 0)
  12322. {
  12323. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12324. if (ceErpSupplierProductTime == null)
  12325. {
  12326. returnErrorMsg("查无数据");
  12327. return;
  12328. }
  12329. ceErpSupplierProductTime.Delete();
  12330. returnSuccessMsg("保存成功");
  12331. return;
  12332. }
  12333. returnErrorMsg("缺少必要的参数");
  12334. }
  12335. public void getExpressInfo()
  12336. {
  12337. string ctid = GetPostString("ctid");
  12338. if (!string.IsNullOrEmpty(ctid))
  12339. {
  12340. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12341. if (ceErpTradeCell != null)
  12342. {
  12343. string outSid = ceErpTradeCell.OutSid;
  12344. if (outSid.Length > 0)
  12345. {
  12346. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12347. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12348. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12349. return;
  12350. }
  12351. }
  12352. returnErrorMsg("查无记录");
  12353. return;
  12354. }
  12355. returnErrorMsg("缺少必要的参数");
  12356. }
  12357. public void getExpressPostData()
  12358. {
  12359. string express = GetPostString("express");
  12360. if (!string.IsNullOrEmpty(express))
  12361. {
  12362. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12363. if (ceErpExpressInfo != null)
  12364. {
  12365. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12366. return;
  12367. }
  12368. }
  12369. returnErrorMsg("缺少必要的参数");
  12370. }
  12371. }
  12372. }