sync.order.cs 635 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. namespace SiteCore.Handler
  49. {
  50. public partial class sync
  51. {
  52. public void get_erp_orderlist()
  53. {
  54. string poscode = CurrentUser.UserPost.Post.Code;
  55. DataStruct dStruct = GetPostStruct();
  56. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\扇子.xls");
  57. //apiHelper.Api_SyncOrderByTime("598825");
  58. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  59. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  60. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  61. //banniuApiHelper.sendLogisticsInfo(null);
  62. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  63. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  64. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  65. //int sid = commonHelper.autoDistributeToSupplier(entity);
  66. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  67. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1747793700000,\"deliveryType\":\"OFFLINE\",\"discountFee\":15.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1748015999000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":85.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2200806677467/O1CN01aEDI6s251wFlRwWHL_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4348532702415998633\",\"refSkuId\":\"0\",\"refSpuId\":\"620901028368\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":42.5,\"singleFee\":42.5,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【狂欢价】水晶标贴金属标签LOGO贴纸定制车热uv转印贴透明商标打印设备移丝印广告自粘刻字烫金定做公司防水不干胶印刷\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1747794079000,\"openBuyerId\":\"AAEmRHraABkUZRPgSx1NTPcZ\",\"openBuyerNick\":\"排**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1747793522000,\"payTime\":1747793695000,\"payment\":85.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"梅州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"梅江区\",\"receiverId\":\"c01bdfe140ea76155b427e6b00424547$\",\"receiverState\":\"广东省\",\"receiverTown\":\"三角镇\",\"refOid\":\"4348532702415998633\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"34.5x25.5mm-210个-UV转印贴-彩色-模切-排排坐唱山歌歌-小钰-()-老客户改稿\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":85.0,\"totalPrice\":100.0,\"totalSellPrice\":85.0,\"type\":\"SALE\"}}");
  68. //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}}");
  69. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  70. //commonHelper.loginGetOrder(2152);
  71. List<string> lw = new List<string>();
  72. string tid = GetPostString("ctid");
  73. string date1 = GetPostString("date1");
  74. //12-1 修改
  75. string urgent = GetPostString("urgent");
  76. string back = GetPostString("back");
  77. string offlineSearch = GetPostString("offlineSearch");
  78. int paramsCount = 0;
  79. if (!string.IsNullOrWhiteSpace(urgent))
  80. {
  81. if (urgent.Equals("true"))
  82. {
  83. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  84. }
  85. }
  86. if (!string.IsNullOrWhiteSpace(back))
  87. {
  88. if (back.Equals("true"))
  89. {
  90. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  91. }
  92. }
  93. if (!string.IsNullOrWhiteSpace(offlineSearch))
  94. {
  95. if (offlineSearch.Equals("true"))
  96. {
  97. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  98. }
  99. }
  100. //end
  101. string date2 = GetPostString("date2");
  102. string buyernick = GetPostString("buyer_nick");
  103. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  104. {
  105. if (tid.Length <= 0 && buyernick.Length <= 0)
  106. {
  107. return;
  108. }
  109. }
  110. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  111. {
  112. if (tid.Length > 0)
  113. {
  114. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  115. if (ceErpTradeCell != null)
  116. {
  117. tid = ceErpTradeCell.tid;
  118. }
  119. List<string> select_tid = getTidByCtidMore(tid);
  120. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  121. }
  122. if (buyernick.Length > 0)
  123. {
  124. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  125. }
  126. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  127. if (dw.Length > 0)
  128. {
  129. lw.Add(dw);
  130. }
  131. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  132. {
  133. string usershop = CurrentUser.User.pemShop;
  134. lw.Add(string.Format("ShopId in ({0})", usershop));
  135. }
  136. }
  137. else
  138. {
  139. if (ex_psize == 0)
  140. {
  141. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  142. }
  143. if (PKey != "admin")
  144. {
  145. string usershop = CurrentUser.User.pemShop;
  146. lw.Add(string.Format("ShopId in ({0})", usershop));
  147. paramsCount++;
  148. }
  149. }
  150. string uploaddate1 = GetPostString("uploaddate1");
  151. string uploaddate2 = GetPostString("uploaddate2");
  152. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  153. if (update.Length > 0) lw.Add(update);
  154. string deliverydate1 = GetPostString("deliverydate1");
  155. string deliverydate2 = GetPostString("deliverydate2");
  156. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  157. if (deliverydate.Length > 0)
  158. {
  159. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  160. };
  161. string shopname = GetPostString("shopname");
  162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  163. string addwechat = GetPostString("addwechat");
  164. if (addwechat.Length > 0)
  165. {
  166. int addWt = Convert.ToInt32(addwechat);
  167. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  168. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  169. }
  170. string customer = GetPostString("customer");
  171. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  172. string design = GetPostString("design");
  173. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  174. string orderState = GetPostString("orderState");
  175. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  176. string address = GetPostString("address");
  177. 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));
  178. string sellermemo = GetPostString("seller_memo");
  179. if (sellermemo.Length > 0)
  180. {
  181. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  182. }
  183. string backReason = GetPostString("backReason");
  184. if (backReason.Length > 0)
  185. {
  186. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  187. }
  188. string apdate1 = GetPostString("apdate1");
  189. string apdate2 = GetPostString("apdate2");
  190. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  191. if (dwap.Length > 0) lw.Add(dwap);
  192. string price1 = GetPostString("price1");
  193. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  194. string price2 = GetPostString("price2");
  195. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  196. string isoldcustomer = GetPostString("isoldcus");
  197. string spudata = GetPostString("spudata");
  198. if ("0".Equals(spudata))
  199. {
  200. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  201. }
  202. if ("1".Equals(spudata))
  203. {
  204. lw.Add(string.Format("spu_id <> ''"));
  205. }
  206. string finishdate1 = GetPostString("finishdate1");
  207. string finishdate2 = GetPostString("finishdate2");
  208. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  209. bool isFinish = false;
  210. if (finishdate.Length > 0)
  211. {
  212. lw.Add(finishdate);
  213. isFinish = true;
  214. paramsCount++;
  215. }
  216. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  217. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  218. if (ex_psize > 0)
  219. {
  220. int UserID = CurrentUser.UserID;
  221. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  222. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  223. {
  224. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  225. }
  226. dStruct.Order = "pay_time desc";
  227. }
  228. string isNew = GetPostString("isNew");
  229. if (isNew == "true")
  230. {
  231. lw.Add(string.Format("IsNew = {0}", 1));
  232. }
  233. string overtime = GetPostString("overtime");
  234. if (overtime == "1")
  235. {
  236. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  237. }
  238. String usePost = CurrentUser.UserPost.Post.Code;
  239. if (usePost.Equals("Operation") == true)
  240. {
  241. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  242. }
  243. else
  244. {
  245. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  246. }
  247. //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";
  248. if (dStruct.PageSize == 100000)
  249. {
  250. dStruct.Order = "";
  251. }
  252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  253. DataTable dt = null;
  254. string tablename = "view_orderlist";
  255. if (isFinish)
  256. {
  257. tablename = "view_orderlist_end";
  258. }
  259. dt = WebCache.GetData(tablename, dStruct);
  260. if (dt != null && dt.Rows.Count > 0)
  261. {
  262. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  263. foreach (DataRow dr in dt.Rows)
  264. {
  265. try
  266. {
  267. if (dr["refund_fees"] != null)
  268. {
  269. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  270. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  271. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  272. if (payment == refund_fees)
  273. {
  274. dr["refund_fees"] = Math.Round(refund_fees, 2);
  275. }
  276. else if (refund_fees == total_fee)
  277. {
  278. dr["refund_fees"] = payment;
  279. }
  280. else
  281. {
  282. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  283. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  284. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  285. }
  286. }
  287. // 对象操作
  288. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  289. ceErpTradeCell.ctid = dr["ctid"].ToString();
  290. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  291. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  292. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  293. if (dStruct.PageSize != 100000)
  294. {
  295. if (dr["DispatchSort"].ToString() == "2")
  296. {
  297. dr["gongchuang"] = 200;
  298. }
  299. else if ("外协".Equals(dr["ToType"].ToString()))
  300. {
  301. dr["gongchuang"] = 200;
  302. }
  303. else if ("内部".Equals(dr["ToType"].ToString()))
  304. {
  305. dr["gongchuang"] = -1;
  306. }
  307. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  308. {
  309. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  310. dr["gongchuang"] = response.code;
  311. }
  312. }
  313. }
  314. catch (NullReferenceException ex)
  315. {
  316. // 处理空引用异常
  317. dr["refund_fees"] = "0.00";
  318. }
  319. }
  320. }
  321. writeGridDataTableJson(dStruct.TotalCount, dt);
  322. }
  323. public void get_erp_orderlist_sumprice()
  324. {
  325. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  326. return;
  327. List<string> lw = new List<string>();
  328. string tid = GetPostString("ctid");
  329. string date1 = GetPostString("date1");
  330. string date2 = GetPostString("date2");
  331. if (tid.Length > 0 || date1.Length > 0)
  332. {
  333. lw.Add(string.Format("ctid like '%{0}%'", tid));
  334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  335. if (dw.Length > 0) lw.Add(dw);
  336. }
  337. else
  338. {
  339. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  340. }
  341. string shopname = GetPostString("shopname");
  342. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  343. string buyernick = GetPostString("buyer_nick");
  344. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  345. string customer = GetPostString("customer");
  346. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  347. string design = GetPostString("design");
  348. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  349. string orderState = GetPostString("orderState");
  350. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  351. string address = GetPostString("address");
  352. 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));
  353. string sellermemo = GetPostString("seller_memo");
  354. if (sellermemo.Length > 0)
  355. {
  356. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  357. }
  358. string apdate1 = GetPostString("apdate1");
  359. string apdate2 = GetPostString("apdate2");
  360. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  361. if (dwap.Length > 0) lw.Add(dwap);
  362. string price1 = GetPostString("price1");
  363. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  364. string price2 = GetPostString("price2");
  365. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  366. string isoldcustomer = GetPostString("isoldcus");
  367. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  368. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  369. if (PKey != "admin")
  370. {
  371. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  372. lw.Add(string.Format("shopId in ({0})", usershop));
  373. }
  374. //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";
  375. string mainWhere = string.Join(" and ", lw.ToArray());
  376. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  377. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  378. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  379. decimal total = 0;
  380. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  381. {
  382. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  383. }
  384. var res = new
  385. {
  386. data = total
  387. };
  388. string ro_jsond = JsonConvert.SerializeObject(res);
  389. returnSuccess(ro_jsond);
  390. return;
  391. }
  392. public void get_erp_CustomerServiceGather()
  393. {
  394. string userWhere = "", orderWhere = "";
  395. List<string> lw = new List<string>();
  396. string customer = GetPostString("customer");
  397. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  398. string shopname = GetPostString("shopname");
  399. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  400. string date1 = GetPostString("date1");
  401. string date2 = GetPostString("date2");
  402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  403. if (dw.Length > 0) lw.Add(dw);
  404. orderWhere = string.Join(" and ", lw.ToArray());
  405. 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 " +
  406. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  407. "left join " +
  408. "( " +
  409. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  410. ") as b on a.ID = b.CustomerUserId " +
  411. "left join " +
  412. "( " +
  413. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  414. ") as d on a.ID = d.CustomerUserId " +
  415. "left join " +
  416. "( " +
  417. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  418. ") as e on a.ID = e.CustomerUserId " +
  419. "left join " +
  420. "( " +
  421. " select CustomerUserId, RefundCount, RefundSum from " +
  422. " ( " +
  423. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  424. " from CE_ErpTradeRefund a " +
  425. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  426. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  427. " group by CustomerUserId " +
  428. " ) as a " +
  429. ") as f on a.ID = f.CustomerUserId " +
  430. "where a.PostCode = 'CustomerService'",
  431. userWhere, orderWhere);
  432. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  433. writeGridDataTableJson(dt.Rows.Count, dt);
  434. //writeGridDataTableJson(dt.Rows.Count, dt);
  435. }
  436. //设计汇总
  437. public void get_erp_DesignerGather()
  438. {
  439. string userWhere = "", orderWhere = "";
  440. List<string> lw = new List<string>();
  441. string Designer = GetPostString("designer");
  442. int org = GetPostInt("org");
  443. if (Designer.Length > 0)
  444. {
  445. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  446. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  447. }
  448. else if (org > 0)
  449. {
  450. userWhere = string.Format(" where OrgID ={0}", org);
  451. }
  452. string shopname = GetPostString("shopname");
  453. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  454. string state = GetPostString("state");
  455. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  456. string OrderArea = GetPostString("order_area");
  457. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  458. string date1 = GetPostString("date1");
  459. string date2 = GetPostString("date2");
  460. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  461. if (dw.Length > 0) lw.Add(dw);
  462. string UpDate1 = GetPostString("UpDate1");
  463. string UpDate2 = GetPostString("UpDate2");
  464. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  465. if (dw.Length > 0) lw.Add(dw);
  466. orderWhere = string.Join(" and ", lw.ToArray());
  467. 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 (" +
  468. "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 " +
  469. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  470. "left join " +
  471. "( " +
  472. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  473. ") as b on a.ID = b.DesignUserId " +
  474. "left join " +
  475. "( " +
  476. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  477. ") as d on a.ID = d.DesignUserId " +
  478. "left join " +
  479. "( " +
  480. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  481. ") as e on a.ID = e.DesignUserId " +
  482. "left join " +
  483. "( " +
  484. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  485. ") as g on a.ID = g.DesignUserId " +
  486. "left join " +
  487. "( " +
  488. " select CustomerUserId, RefundCount, RefundSum from " +
  489. " ( " +
  490. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  491. " from CE_ErpTradeRefund a " +
  492. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  493. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  494. " group by CustomerUserId " +
  495. " ) as a " +
  496. ") as f on a.ID = f.CustomerUserId " +
  497. "where a.PostCode = 'Designer') as z",
  498. userWhere, orderWhere);
  499. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  500. writeGridDataTableJson(dt.Rows.Count, dt);
  501. }
  502. //删除tradecell的订单
  503. public void del_erp_cellorder()
  504. {
  505. if (UrlPostParmsCheck("ctid"))
  506. {
  507. string eid = GetPostString("ctid");
  508. CeErpTradeCell.DelByCtid(eid);
  509. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  510. returnSuccessMsg("删除成功");
  511. }
  512. }
  513. public void clear_erp_refundstate()
  514. {
  515. if (UrlPostParmsCheck("ids"))
  516. {
  517. string eids = GetPostString("ids");
  518. string[] ctidList = eids.Split(',');
  519. foreach (string ctid in ctidList)
  520. {
  521. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  522. if (entity != null)
  523. {
  524. entity.IsRefund = 0;
  525. entity.Update();
  526. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  527. }
  528. else
  529. continue;
  530. }
  531. returnSuccessMsg("操作成功");
  532. return;
  533. }
  534. returnErrorMsg("缺少必要参数");
  535. }
  536. public void set_erp_urgency()
  537. {
  538. if (UrlPostParmsCheck("ctid"))
  539. {
  540. string eid = GetPostString("ctid");
  541. CeErpTradeCell entity = null;
  542. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  543. if (entity != null)
  544. {
  545. double prices = commonHelper.calculationPrice(entity);
  546. if (prices <= 100)
  547. {
  548. returnErrorMsg("此订单金额不足100元,无法加急。");
  549. return;
  550. }
  551. string utime = GetPostString("urgencytime");
  552. if (utime.Length > 0)
  553. {
  554. entity.UrgencyTime = Convert.ToDateTime(utime);
  555. }
  556. else
  557. {
  558. returnErrorMsg("请选择加急时间");
  559. return;
  560. }
  561. if (entity.OrderState <= 4)
  562. {
  563. //entity.seller_memo = entity.seller_memo + "-加急";
  564. string smemo = entity.seller_memo;
  565. int kindex = smemo.IndexOf(")");
  566. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  567. if (lastoneStr != "-")
  568. {
  569. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  570. }
  571. string prememo = smemo.Substring(0, kindex + 2);
  572. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  573. int lastkindex = lastmemo.IndexOf("(");
  574. DateTime urgtime = Convert.ToDateTime(utime);
  575. string newlastmemo = "";
  576. if (lastkindex == 0)
  577. {
  578. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  579. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  580. }
  581. else
  582. {
  583. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  584. }
  585. entity.seller_memo = prememo + newlastmemo;
  586. }
  587. entity.IsUrgency = true;
  588. entity.UpdateTime = DateTime.Now;
  589. entity.Update();
  590. ApiVo apiVo = new ApiVo();
  591. apiVo.orderNumber = entity.ctid;
  592. apiVo.actionName = "changeDesign";
  593. apiVo.orderRemarks = entity.seller_memo;
  594. apiVo.remarkSign = 3;
  595. designHelper.API_WorkCore(apiVo); //changeDesign
  596. CeErpSukuraData.createInfo(entity.ctid, 7);
  597. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  598. returnSuccessMsg("设置成功!");
  599. return;
  600. }
  601. returnErrorMsg("找不到记录");
  602. }
  603. }
  604. public void set_erp_reset()
  605. {
  606. if (UrlPostParmsCheck("ctid"))
  607. {
  608. string eid = GetPostString("ctid");
  609. CeErpTradeCell entity = null;
  610. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  611. if (entity != null)
  612. {
  613. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  614. {
  615. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  616. {
  617. returnErrorMsg("财务要求已下单已发货无法重置");
  618. return;
  619. }
  620. }
  621. entity.IsUrgency = false;
  622. entity.seller_memo = "";
  623. entity.OtherMemo = "";
  624. entity.OrderState = 0;
  625. entity.IsReturn = 0;
  626. //entity.IsRefund = 0;
  627. entity.MemoOpt = 0;
  628. entity.AfterSaleState = 0;
  629. entity.AfterSaleResponsible = "";
  630. entity.AfterSaleUserId = 0;
  631. entity.IsNeedBill = 0;
  632. entity.CustomerUserId = 0;
  633. entity.DesignUserId = 0;
  634. entity.SupplierId = 0;
  635. entity.PlaceUserId = 0;
  636. entity.ptid = "";
  637. entity.IsSample = 0;
  638. entity.IsXianHuo = 0;
  639. entity.isDianziOrder = 0;
  640. entity.DispatchSort = 0;
  641. entity.FinishPlaceTime = null;
  642. entity.Update();
  643. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  644. if (trade != null)
  645. {
  646. trade.seller_memo = "";
  647. trade.Update();
  648. }
  649. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  650. returnSuccessMsg("重置成功!");
  651. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  652. if (desginBill != null)
  653. {
  654. desginBill.isDel = 1;
  655. desginBill.Update();
  656. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  657. }
  658. ApiVo apiVo = new ApiVo();
  659. apiVo.orderNumber = entity.ctid;
  660. apiVo.actionName = "resetDesign";
  661. designHelper.API_WorkCore(apiVo);//resetDesign
  662. return;
  663. }
  664. returnErrorMsg("找不到记录");
  665. }
  666. }
  667. public void save_erp_sellermemo()
  668. {
  669. if (UrlPostParmsCheck("ctid"))
  670. {
  671. string ctid = GetPostString("ctid");
  672. CeErpTradeCell entity = null;
  673. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  674. if (entity != null)
  675. {
  676. string memo = GetPostString("seller_memo");
  677. memo = memo.Replace(" ", "");
  678. if (memo.Contains("补差"))
  679. {
  680. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  681. return;
  682. }
  683. List<string> bitList = new List<string>
  684. {
  685. "\\","/",":","*","?", "\"","<" ,">","|"
  686. };
  687. bool isIn = false;
  688. foreach (string bit in bitList)
  689. {
  690. if (memo.Contains(bit))
  691. {
  692. isIn = true;
  693. }
  694. }
  695. if (isIn)
  696. {
  697. returnErrorMsg("不能使用 一些符合作为文件名");
  698. return;
  699. }
  700. if (entity.seller_memo != memo)
  701. {
  702. if (entity.IsSample == 2)
  703. {
  704. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  705. return;
  706. }
  707. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  708. {
  709. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  710. {
  711. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  712. return;
  713. }
  714. /*if (CurrentUser.UserPost.Post.Code != "Place")
  715. {
  716. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  717. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  718. {
  719. returnErrorMsg("售前系统订单无法再此修改!");
  720. return;
  721. }
  722. }*/
  723. }
  724. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  725. }
  726. commonHelper.getCytPrice(entity);
  727. int memoopt = GetPostInt("MemoOpt");
  728. Boolean ismemoopt = false;
  729. if (memoopt > 0)
  730. {
  731. string stropt = "";
  732. if (memoopt == 1)
  733. {
  734. stropt = "“改稿”";
  735. ismemoopt = true;
  736. }
  737. else if (memoopt == 2)
  738. {
  739. stropt = "“定稿”";
  740. }
  741. else if (memoopt == 3)
  742. {
  743. stropt = "“查货”";
  744. CeErpSukuraData.createInfo(entity.ctid, 6);
  745. }
  746. entity.MemoOpt = Convert.ToInt32(memoopt);
  747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  748. }
  749. if (entity.OrderState < 5)
  750. {
  751. memo = memo.Replace("(", "(");
  752. memo = memo.Replace(")", ")");
  753. }
  754. if (entity.OrderState < 3)
  755. {
  756. entity.DispatchSort = 0;
  757. }
  758. entity.seller_memo = memo;
  759. entity.UpdateTime = DateTime.Now;
  760. entity.Update();
  761. ApiVo apiVo = new ApiVo();
  762. apiVo.orderNumber = entity.ctid;
  763. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  764. apiVo.orderRemarks = memo;
  765. apiVo.remarkSign = memoopt;
  766. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  767. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  768. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  769. {
  770. dataHelper.api_orderBack(entity.ctid, "0", "");
  771. }
  772. if (entity.seller_memo.Contains("改稿"))
  773. {
  774. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  775. }
  776. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  777. returnSuccessMsg("保存成功!");
  778. return;
  779. }
  780. returnErrorMsg("找不到记录");
  781. }
  782. }
  783. public void ins_erp_checkorder()
  784. {
  785. if (UrlPostParmsCheck("ctid"))
  786. {
  787. string ctid = GetPostString("ctid");
  788. CeErpTradeCell entity = null;
  789. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  790. if (entity != null)
  791. {
  792. if (entity.OrderState < 6)
  793. {
  794. returnErrorMsg("下单完成后才可查货");
  795. return;
  796. }
  797. /*if (entity.OrderState > 6)
  798. {
  799. returnErrorMsg("订单已发货");
  800. return;
  801. }*/
  802. if (entity.FinishPlaceTime != null)
  803. {
  804. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  805. {
  806. returnErrorMsg("下单时间不足,无法查货");
  807. return;
  808. }
  809. }
  810. entity.MemoOpt = 3;
  811. entity.CheckOrderTime = DateTime.Now;
  812. entity.UpdateTime = DateTime.Now;
  813. entity.Update();
  814. CeErpSukuraData.createInfo(entity.ctid, 6);
  815. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  816. returnSuccessMsg("操作成功!");
  817. return;
  818. }
  819. returnErrorMsg("找不到记录");
  820. }
  821. }
  822. public void save_erp_othermemo()
  823. {
  824. if (UrlPostParmsCheck("ctid"))
  825. {
  826. string ctid = GetPostString("ctid");
  827. CeErpTradeCell entity = null;
  828. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  829. if (entity != null)
  830. {
  831. entity.OtherMemo = GetPostString("otherMemo");
  832. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  833. {
  834. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  835. StringBuilder sql = new StringBuilder();
  836. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  837. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  838. if (dt != null && dt.Rows.Count > 0)
  839. {
  840. foreach (DataRow dr in dt.Rows)
  841. {
  842. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  843. {
  844. //品类一直
  845. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  846. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  847. if (ceErpSampleCustomer == null)
  848. {
  849. ceErpSampleCustomer = new CeErpSampleCustomer();
  850. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  851. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  852. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  853. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  854. ceErpSampleCustomer.shopId = entity.ShopId;
  855. }
  856. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  857. ceErpSampleCustomer.lastTid = entity.tid;
  858. if (ceErpSampleCustomer.ID > 0)
  859. {
  860. ceErpSampleCustomer.Update();
  861. }
  862. else
  863. {
  864. ceErpSampleCustomer.Create();
  865. }
  866. }
  867. }
  868. }
  869. }
  870. //if (entity.IsOldCustomer == 1)
  871. //{
  872. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  873. //{
  874. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  875. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  876. //}
  877. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  878. //{
  879. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  880. // {
  881. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  882. // {
  883. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  884. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  885. // }
  886. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  887. // {
  888. // entity.OrderState = 2;
  889. // entity.DesignUserId = 0;
  890. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  891. // }
  892. // else
  893. // {
  894. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  895. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  896. // }
  897. // }
  898. //}
  899. //}
  900. entity.UpdateTime = DateTime.Now;
  901. entity.Update();
  902. returnSuccessMsg("保存成功!");
  903. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  904. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  905. if (entity.OtherMemo.Contains("改稿"))
  906. {
  907. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  908. }
  909. return;
  910. }
  911. returnErrorMsg("找不到记录");
  912. }
  913. }
  914. public void save_erp_customermemo()
  915. {
  916. if (UrlPostParmsCheck("ctid"))
  917. {
  918. string ctid = GetPostString("ctid");
  919. CeErpTradeCell entity = null;
  920. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  921. if (entity != null)
  922. {
  923. entity.UpdateTime = DateTime.Now;
  924. entity.CustomerMemo = GetPostString("CustomerMemo");
  925. entity.Update();
  926. ApiVo apiVo = new ApiVo();
  927. apiVo.orderNumber = entity.ctid;
  928. apiVo.actionName = "followRemarks";
  929. apiVo.orderRemarks = entity.CustomerMemo;
  930. designHelper.API_WorkCore(apiVo);//followRemarks
  931. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  932. returnSuccessMsg("保存成功!");
  933. return;
  934. }
  935. returnErrorMsg("找不到记录");
  936. }
  937. }
  938. public void upd_erp_addmemotag()
  939. {
  940. if (UrlPostParmsCheck("ctid"))
  941. {
  942. ;
  943. string eid = GetPostString("ctid");
  944. string sfTagstr = GetPostString("memotag");
  945. CeErpTradeCell entity = null;
  946. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  947. if (entity != null)
  948. {
  949. ApiVo apiVo = new ApiVo();
  950. if (entity.OrderState == 0)
  951. {
  952. returnErrorMsg("请先领单");
  953. return;
  954. }
  955. //撤销顺丰
  956. if (sfTagstr == "撤销顺丰")
  957. {
  958. entity.IsSF = 0;
  959. string reMsg = "";
  960. string oldmemo = entity.seller_memo;
  961. if (entity.OrderState < 5)
  962. {
  963. oldmemo = oldmemo.Replace("顺丰到付", "");
  964. oldmemo = oldmemo.Replace("顺丰寄付", "");
  965. entity.seller_memo = oldmemo;
  966. }
  967. else
  968. {
  969. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  970. {
  971. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  972. }
  973. }
  974. entity.Update();
  975. apiVo.orderNumber = entity.ctid;
  976. apiVo.actionName = "orderRemarks";
  977. apiVo.orderRemarks = entity.seller_memo;
  978. apiVo.isSf = entity.IsSF.ToString();
  979. designHelper.API_WorkCore(apiVo);//orderRemarks
  980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  981. returnSuccessMsg("撤销成功!" + reMsg);
  982. return;
  983. }
  984. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  985. {
  986. //string oldmemo = entity.seller_memo;
  987. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  988. string sfStr = GetPostString("memotag");
  989. string smemo = entity.seller_memo;
  990. int kindex = smemo.IndexOf(")");
  991. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  992. if (lastoneStr != "-")
  993. {
  994. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  995. }
  996. string prememo = smemo.Substring(0, kindex + 2);
  997. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  998. int lastkindex = lastmemo.IndexOf("(");
  999. string newlastmemo = "";
  1000. if (lastkindex == 0)
  1001. {
  1002. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1003. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1004. }
  1005. else
  1006. {
  1007. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1008. }
  1009. entity.seller_memo = prememo + newlastmemo;
  1010. }
  1011. string sfTagMSg = "";
  1012. if (sfTagstr == "顺丰寄付")
  1013. {
  1014. entity.IsSF = 1;
  1015. sfTagMSg = "顺丰寄付";
  1016. }
  1017. else if (sfTagstr == "顺丰到付")
  1018. {
  1019. entity.IsSF = 2;
  1020. sfTagMSg = "顺丰到付";
  1021. }
  1022. entity.Update();
  1023. apiVo = new ApiVo();
  1024. apiVo.orderNumber = entity.ctid;
  1025. apiVo.actionName = "orderRemarks";
  1026. apiVo.orderRemarks = entity.seller_memo;
  1027. apiVo.isSf = entity.IsSF.ToString();
  1028. designHelper.API_WorkCore(apiVo);//orderRemarks
  1029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1030. returnSuccessMsg("标记成功!");
  1031. return;
  1032. }
  1033. returnErrorMsg("找不到记录");
  1034. }
  1035. }
  1036. public void upd_erp_ordertag()
  1037. {
  1038. if (UrlPostParmsCheck("ctid"))
  1039. {
  1040. string eid = GetPostString("ctid");
  1041. CeErpTradeCell entity = null;
  1042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1043. if (entity != null)
  1044. {
  1045. int tag = GetPostInt("wechattag");
  1046. //if(tag==4 && entity.IsSample == 2)
  1047. //{
  1048. // returnErrorMsg("补差价单不能标记微信单");
  1049. // return;
  1050. //}
  1051. entity.wechatTag = tag;
  1052. entity.Update();
  1053. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1054. if (tag == 1)
  1055. {
  1056. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1057. if (cash == null)
  1058. {
  1059. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1060. cash = new CeErpReturnCash();
  1061. cash.tid = entity.tid;
  1062. cash.seller_nick = main.seller_nick;
  1063. cash.payment = trade.payment;
  1064. cash.buyer_nick = main.buyer_nick;
  1065. cash.cashstate = 0;
  1066. cash.rtype = "微信返现";
  1067. cash.returnprice = 0;
  1068. cash.created = DateTime.Now;
  1069. cash.con = "订单标记微信单";
  1070. cash.img = "";
  1071. cash.applyuserid = CurrentUser.UserID;
  1072. cash.Create();
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1074. }
  1075. else
  1076. {
  1077. cash.cashstate = 0;
  1078. cash.Update();
  1079. }
  1080. CeErpSukuraData.createInfo(entity.ctid, 9);
  1081. }
  1082. else if (tag == 2)
  1083. {
  1084. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1085. if (cash == null)
  1086. {
  1087. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1088. cash = new CeErpReturnCash();
  1089. cash.tid = entity.tid;
  1090. cash.seller_nick = main.seller_nick;
  1091. cash.payment = trade.payment;
  1092. cash.buyer_nick = main.buyer_nick;
  1093. cash.cashstate = 0;
  1094. cash.rtype = "推购返现";
  1095. cash.returnprice = 5;
  1096. cash.created = DateTime.Now;
  1097. cash.con = "订单标记推购单";
  1098. cash.img = "";
  1099. cash.applyuserid = CurrentUser.UserID;
  1100. cash.Create();
  1101. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1102. }
  1103. else
  1104. {
  1105. cash.cashstate = 0;
  1106. cash.Update();
  1107. }
  1108. CeErpSukuraData.createInfo(entity.ctid, 9);
  1109. }
  1110. else if (tag == 3)
  1111. {
  1112. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1113. if (pers == null)
  1114. {
  1115. pers = new CeErpPersuade();
  1116. pers.ctid = entity.ctid;
  1117. pers.pstate = 0;
  1118. pers.created = DateTime.Now;
  1119. pers.applyuserid = CurrentUser.UserID;
  1120. pers.Create();
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1122. }
  1123. else
  1124. {
  1125. pers.pstate = 0;
  1126. pers.Update();
  1127. }
  1128. }
  1129. else if (tag == 4 || tag == 5)
  1130. {
  1131. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1132. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1133. if (pers == null)
  1134. {
  1135. pers = new CeErpStayGoods();
  1136. pers.t_id = entity.tid;
  1137. pers.status = "待审核";
  1138. pers.audit_type = 0;
  1139. if (tag == 4)
  1140. {
  1141. pers.stay_type = "微信推购";
  1142. }
  1143. else
  1144. {
  1145. pers.stay_type = "旺旺推购";
  1146. }
  1147. if (entity.IsXianHuo == 0)
  1148. {
  1149. pers.product_id = entity.ProductId;
  1150. }
  1151. pers.wangwang = main.buyer_nick;
  1152. pers.shop_name = main.seller_nick;
  1153. pers.creata_time = DateTime.Now;
  1154. pers.create_u_id = CurrentUser.UserID;
  1155. pers.create_u_name = CurrentUser.UserName;
  1156. pers.Create();
  1157. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1158. }
  1159. else
  1160. {
  1161. pers.audit_type = 0;
  1162. pers.Update();
  1163. }
  1164. CeErpSukuraData.createInfo(entity.ctid, 10);
  1165. }
  1166. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1167. returnSuccessMsg("标记成功!");
  1168. return;
  1169. }
  1170. returnErrorMsg("找不到记录");
  1171. }
  1172. }
  1173. public void upd_erp_ordertag_cancel()
  1174. {
  1175. if (UrlPostParmsCheck("ctid"))
  1176. {
  1177. string eid = GetPostString("ctid");
  1178. CeErpTradeCell entity = null;
  1179. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1180. if (entity != null)
  1181. {
  1182. entity.wechatTag = 0;
  1183. entity.Update();
  1184. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1185. if (pers != null)
  1186. {
  1187. pers.status = "取消推购";
  1188. pers.audit_type = 3;
  1189. pers.Update();
  1190. }
  1191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1192. returnSuccessMsg("标记成功!");
  1193. return;
  1194. }
  1195. returnErrorMsg("找不到记录");
  1196. }
  1197. }
  1198. public void upd_erp_addweichattag()
  1199. {
  1200. if (UrlPostParmsCheck("ctid"))
  1201. {
  1202. ;
  1203. string eid = GetPostString("ctid");
  1204. CeErpTradeCell entity = null;
  1205. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1206. if (entity != null)
  1207. {
  1208. if (entity.IsAddWechat > 0)
  1209. {
  1210. returnErrorMsg("此单已经标记过了");
  1211. return;
  1212. }
  1213. 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);
  1214. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1215. if (dt.Rows.Count > 0)
  1216. {
  1217. entity.IsAddWechat = 2;
  1218. }
  1219. else
  1220. {
  1221. entity.IsAddWechat = 1;
  1222. }
  1223. entity.Update();
  1224. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1225. returnSuccessMsg("标记成功!");
  1226. return;
  1227. }
  1228. returnErrorMsg("找不到记录");
  1229. }
  1230. }
  1231. public void upd_erp_getmyorder()
  1232. {
  1233. if (UrlPostParmsCheck("ctid"))
  1234. {
  1235. ;
  1236. string eid = GetPostString("ctid");
  1237. CeErpTradeCell entity = null;
  1238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1239. if (entity != null)
  1240. {
  1241. if (entity.ctid.IndexOf("C") != -1)
  1242. {
  1243. StringBuilder sql = new StringBuilder();
  1244. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1245. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1246. if (dt.Rows.Count > 0)
  1247. {
  1248. decimal total = 0;
  1249. foreach (DataRow dr in dt.Rows)
  1250. {
  1251. total += Convert.ToDecimal(dr["payment"]);
  1252. }
  1253. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1254. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1255. {
  1256. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1257. return;
  1258. }
  1259. }
  1260. }
  1261. if (entity.OrderState == -1)
  1262. {
  1263. returnErrorMsg("待审核订单无法领取!");
  1264. return;
  1265. }
  1266. entity.CustomerUserId = CurrentUser.UserID;
  1267. if (entity.OrderState < 2)
  1268. {
  1269. entity.OrderState = 2;
  1270. if (entity.ShopId != 0)
  1271. {
  1272. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1273. }
  1274. }
  1275. entity.UpdateTime = DateTime.Now;
  1276. entity.Update();
  1277. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1278. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1279. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1280. {
  1281. dataHelper.api_orderBack(entity.ctid, "0", "");
  1282. }
  1283. returnSuccessMsg("领单成功!");
  1284. return;
  1285. }
  1286. returnErrorMsg("找不到记录");
  1287. }
  1288. }
  1289. public void getmyorder_from_init()
  1290. {
  1291. if (UrlPostParmsCheck("ctid"))
  1292. {
  1293. string eid = GetPostString("ctid");
  1294. CeErpTradeCell entity = null;
  1295. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1296. if (entity != null)
  1297. {
  1298. string sellerMemo = GetPostString("sellerMemo");
  1299. if (sellerMemo.Length > 0)
  1300. {
  1301. entity.seller_memo = sellerMemo;
  1302. }
  1303. string oterhMemo = GetPostString("otherMemo");
  1304. if (oterhMemo.Length > 0)
  1305. {
  1306. entity.OtherMemo = oterhMemo;
  1307. }
  1308. int urg = GetPostInt("urgency");
  1309. entity.IsUrgency = (urg == 1 ? true : false);
  1310. int wechat = GetPostInt("wechat");
  1311. int command = GetPostInt("command");
  1312. if (wechat == 1)
  1313. {
  1314. entity.wechatTag = 1;
  1315. }
  1316. if (command == 1)
  1317. {
  1318. entity.wechatTag = 2;
  1319. }
  1320. string pPro = GetPostString("pprofession");
  1321. if (pPro.Length > 0)
  1322. {
  1323. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1324. string spro = GetPostString("profession");
  1325. if (spro.Length > 0)
  1326. {
  1327. entity.ProfessionId = Convert.ToInt32(spro);
  1328. }
  1329. }
  1330. string proId = GetPostString("productId");
  1331. if (proId.Length > 0)
  1332. {
  1333. entity.ProductId = Convert.ToInt32(proId);
  1334. }
  1335. entity.Material = GetPostString("material");
  1336. entity.Craft = GetPostString("craft");
  1337. entity.CustomerUserId = CurrentUser.UserID;
  1338. if (entity.OrderState < 2)
  1339. {
  1340. entity.OrderState = 2;
  1341. if (entity.ShopId != 0)
  1342. {
  1343. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1344. }
  1345. }
  1346. entity.Update();
  1347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1348. returnSuccessMsg("领单成功!");
  1349. return;
  1350. }
  1351. returnErrorMsg("找不到记录");
  1352. }
  1353. }
  1354. public void upd_erp_setrelationorder()
  1355. {
  1356. if (UrlPostParmsCheck("ctid"))
  1357. {
  1358. ;
  1359. string eid = GetPostString("ctid");
  1360. string ftid = GetPostString("ftid");
  1361. CeErpTradeCell entity = null;
  1362. CeErpTradeCell fentity = null;
  1363. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1364. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1365. if (fentity == null)
  1366. {
  1367. returnErrorMsg("找不到关联的主订单");
  1368. return;
  1369. }
  1370. if (entity != null)
  1371. {
  1372. if (entity.OrderState >= 5)
  1373. {
  1374. returnErrorMsg("本单已经设计完成无法关联");
  1375. return;
  1376. }
  1377. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1378. {
  1379. returnErrorMsg("线下单续审核后才能关联!");
  1380. return;
  1381. }
  1382. entity.ptid = ftid;
  1383. entity.OrderState = fentity.OrderState;
  1384. //entity.status = fentity.status;
  1385. entity.CustomerUserId = fentity.CustomerUserId;
  1386. entity.DesignUserId = fentity.DesignUserId;
  1387. entity.seller_memo = "补差价单:" + ftid;
  1388. entity.IsSample = 2;
  1389. entity.Update();
  1390. ApiVo apiVo = new ApiVo();
  1391. apiVo.orderNumber = ftid;
  1392. apiVo.payment = entity.payment;
  1393. apiVo.actionName = "repairDesign";
  1394. designHelper.API_WorkCore(apiVo);//repairDesign
  1395. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1396. returnSuccessMsg("关联成功!");
  1397. return;
  1398. }
  1399. else
  1400. returnErrorMsg("找不到记录");
  1401. }
  1402. }
  1403. public void download_erp_neworder()
  1404. {
  1405. string seller = GetPostString("seller_nick");
  1406. string tid = GetPostString("tid");
  1407. if (seller.Length <= 0 || tid.Length <= 0)
  1408. {
  1409. returnErrorMsg("数据错误");
  1410. }
  1411. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1412. //{
  1413. // returnErrorMsg("找不到店铺Sessionkey");
  1414. //}
  1415. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1416. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1417. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1418. if (res.IndexOf("refOid") == -1)
  1419. {
  1420. returnErrorMsg("下载订单数据失败");
  1421. return;
  1422. }
  1423. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1424. returnSuccessMsg("下载完成");
  1425. //tmcHelper.createNewOrder(res);
  1426. //CeErpTrade entr = null;
  1427. //entr = CeErpTrade.Get(tid);
  1428. //if (entr != null)
  1429. //{
  1430. // returnSuccess("下载成功");
  1431. // //下载成功之后,Cell表生成对应的订单;
  1432. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1433. //}
  1434. //else
  1435. //{
  1436. // returnErrorMsg("下载失败或者创建订单失败");
  1437. //}
  1438. }
  1439. public void set_erp_atersale()
  1440. {
  1441. if (UrlPostParmsCheck("ctid"))
  1442. {
  1443. string eid = GetPostString("ctid");
  1444. string reason = GetPostString("AfterSaleReason");
  1445. CeErpTradeCell entity = null;
  1446. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1447. if (entity != null)
  1448. {
  1449. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1450. {
  1451. returnErrorMsg("此订单已经在售后");
  1452. return;
  1453. }
  1454. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1455. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1456. entity.AfterSaleTime = DateTime.Now;
  1457. entity.Update();
  1458. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1459. returnSuccessMsg("转售后成功!");
  1460. return;
  1461. }
  1462. returnErrorMsg("找不到记录");
  1463. }
  1464. }
  1465. public void set_erp_withdraw()
  1466. {
  1467. if (UrlPostParmsCheck("ctid"))
  1468. {
  1469. try
  1470. {
  1471. string eid = GetPostString("ctid");//商品id
  1472. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1473. CeWithdraw ceWithdrawSelect = null;
  1474. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1475. if (ceWithdrawSelect != null)
  1476. {
  1477. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1478. {
  1479. ceWithdrawSelect.status = -1;
  1480. ceWithdrawSelect.Update();
  1481. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1482. returnSuccessMsg("重新发起审核成功");
  1483. return;
  1484. }
  1485. else
  1486. {
  1487. returnSuccessMsg("请勿重复申请!");
  1488. return;
  1489. }
  1490. }
  1491. else
  1492. {
  1493. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1494. if (string.IsNullOrEmpty(CustomerUserId))
  1495. {
  1496. CustomerUserId = "-1";
  1497. }
  1498. int Userid = CurrentUser.UserID;//用户id
  1499. CeWithdraw ceWithdraw = new CeWithdraw();
  1500. ceWithdraw.tid = eid;
  1501. ceWithdraw.userid = Userid;
  1502. ceWithdraw.providerid = CustomerUserId;
  1503. ceWithdraw.status = 3;
  1504. ceWithdraw.creationtime = DateTime.Now;
  1505. ceWithdraw.Create();
  1506. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1507. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1508. return;
  1509. }
  1510. }
  1511. catch
  1512. {
  1513. returnErrorMsg("申请撤回订单失败");
  1514. return;
  1515. }
  1516. }
  1517. }
  1518. public void ins_erp_billinfo()
  1519. {
  1520. if (UrlPostParmsCheck("ctid"))
  1521. {
  1522. string eid = GetPostString("ctid");
  1523. CeErpTradeCell entity = null;
  1524. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1525. if (entity != null)
  1526. {
  1527. CeErpBill bill = CeErpBill.GetByTid(eid);
  1528. bool isHave = false;
  1529. if (bill != null)
  1530. {
  1531. isHave = true;
  1532. if (bill.state != 4)
  1533. {
  1534. returnErrorMsg("此单已经申请过发票了");
  1535. return;
  1536. }
  1537. }
  1538. if (entity.IsNeedBill == 0)
  1539. {
  1540. entity.IsNeedBill = 1;
  1541. }
  1542. entity.Update();
  1543. string errjson = "";
  1544. try
  1545. {
  1546. CeErpBill bill_entity = new CeErpBill();
  1547. bill_entity.tid = entity.tid;
  1548. bill_entity.title = GetPostString("title");
  1549. string taxstr = GetPostString("tax");
  1550. taxstr = taxstr.Replace(" ", "");
  1551. bill_entity.tax = taxstr;
  1552. bill_entity.bank = GetPostString("bank");
  1553. string bankacstr = GetPostString("bankac");
  1554. bankacstr = bankacstr.Replace(" ", "");
  1555. bill_entity.bankac = bankacstr;
  1556. bill_entity.address = GetPostString("address");
  1557. bill_entity.phone = GetPostString("phone");
  1558. bill_entity.price = GetPostString("price");
  1559. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1560. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1561. {
  1562. billCount += 1;
  1563. }
  1564. string prebill = "ltb";
  1565. for (int idx = 1; idx <= billCount; idx++)
  1566. {
  1567. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1568. string billoid = prebill + idx + dtstr;
  1569. bill_entity.billOrderId += billoid;
  1570. if (idx < billCount)
  1571. {
  1572. bill_entity.billOrderId += ",";
  1573. }
  1574. }
  1575. bill_entity.productId = GetPostInt("ProductName");
  1576. bill_entity.num = GetPostInt("num");
  1577. bill_entity.unit = GetPostString("unit");
  1578. bill_entity.type = GetPostString("type");
  1579. bill_entity.sendType = GetPostString("SendType");
  1580. bill_entity.email = GetPostString("email");
  1581. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1582. bill_entity.shopName = GetPostString("ShopName");
  1583. bill_entity.applymemo = GetPostString("applyMemo");
  1584. bill_entity.createTime = DateTime.Now;
  1585. bill_entity.state = 0;
  1586. bill_entity.userId = CurrentUser.UserID;
  1587. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1588. bill_entity.Create();
  1589. }
  1590. catch (Exception ex)
  1591. {
  1592. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1593. returnErrorMsg("创建发票出错!");
  1594. return;
  1595. }
  1596. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1597. returnSuccessMsg("发票申请成功!");
  1598. return;
  1599. }
  1600. returnErrorMsg("找不到记录");
  1601. }
  1602. }
  1603. public void ins_erp_neworder()
  1604. {
  1605. if (UrlPostParmsCheck("receiver_name"))
  1606. {
  1607. CeErpTrade entity = new CeErpTrade();
  1608. string plat_form = GetPostString("platform");
  1609. string preStr = "N_";
  1610. if (plat_form == "拼多多")
  1611. {
  1612. preStr = "P_";
  1613. }
  1614. else if (plat_form == "阿里巴巴")
  1615. {
  1616. preStr = "A_";
  1617. }
  1618. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1619. entity.seller_nick = GetPostString("seller_nick");
  1620. entity.buyer_nick = GetPostString("buyer_nick");
  1621. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1622. entity.total_fee = entity.payment;
  1623. entity.pay_time = DateTime.Now;
  1624. entity.status = "NOT_SHIPPED";
  1625. entity.receiver_name = GetPostString("receiver_name");
  1626. entity.receiver_mobile = GetPostString("receiver_mobile");
  1627. entity.receiver_state = GetPostString("receiver_state");
  1628. entity.receiver_city = GetPostString("receiver_city");
  1629. entity.receiver_district = GetPostString("receiver_district");
  1630. entity.receiver_address = GetPostString("receiver_address");
  1631. if (entity.receiver_state == "" || entity.receiver_city == "")
  1632. {
  1633. returnErrorMsg("收件地址不能为空");
  1634. return;
  1635. }
  1636. int shopId = 0;
  1637. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1638. if (nShop != null)
  1639. {
  1640. shopId = nShop.ID;
  1641. }
  1642. if (shopId != 34 && entity.payment == 0)
  1643. {
  1644. returnErrorMsg("公司自用的单金额才能为0");
  1645. return;
  1646. }
  1647. entity.Create();
  1648. CeErpTradeCell entitycell = new CeErpTradeCell();
  1649. entitycell.ctid = entity.tid;
  1650. entitycell.tid = entity.tid;
  1651. entitycell.ShopId = shopId;
  1652. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1653. entitycell.OrderState = 0;
  1654. entitycell.pay_time = entity.pay_time;
  1655. entitycell.IsOffLineOrder = 1;
  1656. entitycell.Create();
  1657. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1658. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1659. return;
  1660. }
  1661. }
  1662. public void ins_erp_neworder2()
  1663. {
  1664. if (UrlPostParmsCheck("receiver_name"))
  1665. {
  1666. //string plat_form = GetPostString("platform");
  1667. string preStr = "X_";
  1668. string memo = GetPostString("memo");
  1669. string productId = GetPostString("productId");
  1670. string primg = GetPostString("proofimg");
  1671. string sellerNick = GetPostString("seller_nick");
  1672. string addFrom = GetPostString("addfrom");
  1673. if (addFrom == "1")
  1674. {
  1675. preStr = "N_";
  1676. }
  1677. int shopId = 0;
  1678. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1679. if (nShop != null)
  1680. {
  1681. shopId = nShop.ID;
  1682. }
  1683. else
  1684. {
  1685. returnErrorMsg("找不到对应店铺");
  1686. return;
  1687. }
  1688. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1689. {
  1690. returnErrorMsg("必须上传付款凭证");
  1691. return;
  1692. }
  1693. CeErpTrade entity = new CeErpTrade();
  1694. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1695. entity.seller_nick = sellerNick;
  1696. entity.buyer_nick = GetPostString("buyer_nick");
  1697. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1698. entity.total_fee = entity.payment;
  1699. entity.pay_time = DateTime.Now;
  1700. entity.status = "NOT_SHIPPED";
  1701. entity.receiver_name = GetPostString("receiver_name");
  1702. entity.receiver_mobile = GetPostString("receiver_mobile");
  1703. entity.receiver_state = GetPostString("receiver_state");
  1704. entity.receiver_city = GetPostString("receiver_city");
  1705. entity.receiver_district = GetPostString("receiver_district");
  1706. entity.receiver_address = GetPostString("receiver_address");
  1707. entity.seller_memo = memo;
  1708. entity.orderFrom = 20;
  1709. entity.orderType = 15;
  1710. if (entity.receiver_state == "" || entity.receiver_city == "")
  1711. {
  1712. returnErrorMsg("收件地址不能为空");
  1713. return;
  1714. }
  1715. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1716. {
  1717. returnErrorMsg("公司自用的单金额才能为0");
  1718. return;
  1719. }
  1720. entity.Create();
  1721. string toWhere = GetPostString("towhere");
  1722. CeErpTradeCell entitycell = new CeErpTradeCell();
  1723. entitycell.ctid = entity.tid;
  1724. //唯一标识
  1725. entitycell.OrderSn = entity.tid;
  1726. string orderSn = dataHelper.getSaleOrderSn();
  1727. if (orderSn != "")
  1728. {
  1729. entitycell.OrderSn = orderSn;
  1730. }
  1731. entitycell.tid = entity.tid;
  1732. //if (preStr == "X_")
  1733. //{
  1734. entitycell.IsOffLineOrder = 1;
  1735. //}
  1736. entitycell.CustomerUserId = CurrentUser.UserID;
  1737. entitycell.PayProofImg = primg;
  1738. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1739. entitycell.ProductId = Convert.ToInt32(productId);
  1740. entitycell.ShopId = shopId;
  1741. entitycell.UpdateTime = DateTime.Now;
  1742. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1743. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1744. {
  1745. entitycell.IsXianHuo = 1;
  1746. }
  1747. entitycell.pay_time = entity.pay_time;
  1748. if (toWhere == "1")
  1749. {
  1750. entitycell.OrderState = 2;
  1751. }
  1752. else
  1753. {
  1754. entitycell.OrderState = 6;
  1755. entitycell.FinishPlaceTime = entitycell.pay_time;
  1756. }
  1757. if (shopId == 94)
  1758. {
  1759. entitycell.OrderState = 4;
  1760. entitycell.WaitDesignTime = entitycell.pay_time;
  1761. entitycell.StartDesignTime = entitycell.pay_time;
  1762. entitycell.DesignUserId = 218;
  1763. }
  1764. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1765. {
  1766. entitycell.OrderState = -1;//修改12-5
  1767. CeWithdraw ceWithdraw = new CeWithdraw();
  1768. ceWithdraw.tid = entity.tid;
  1769. ceWithdraw.providerid = "-1";
  1770. ceWithdraw.status = -1;
  1771. ceWithdraw.creationtime = DateTime.Now;
  1772. ceWithdraw.userid = 1337;
  1773. ceWithdraw.Create();
  1774. }
  1775. entitycell.Create();
  1776. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1777. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1778. {
  1779. addPlaceRegist(entitycell, CurrentUser.UserID);
  1780. }
  1781. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1782. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1783. return;
  1784. }
  1785. }
  1786. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1787. {
  1788. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1789. entity.PlactTime = tradecell.pay_time;
  1790. entity.AddUserId = userid;
  1791. entity.FileName = tradecell.seller_memo;
  1792. entity.Supplier = 24;
  1793. entity.CreateTime = DateTime.Now;
  1794. entity.Did = tradecell.ctid;
  1795. entity.tid = tradecell.tid;
  1796. entity.splitTag = tradecell.SplitTag;
  1797. entity.CurState = "未完成";
  1798. entity.Create();
  1799. }
  1800. public void get_erp_offlinelist()
  1801. {
  1802. DataStruct dStruct = GetPostStruct();
  1803. List<string> lw = new List<string>();
  1804. string tid = GetPostString("ctid");
  1805. string date1 = GetPostString("date1");
  1806. string date2 = GetPostString("date2");
  1807. if (tid.Length > 0 || date1.Length > 0)
  1808. {
  1809. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1810. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1811. if (dw.Length > 0) lw.Add(dw);
  1812. }
  1813. else
  1814. {
  1815. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1816. }
  1817. string shopname = GetPostString("shopname");
  1818. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1819. string buyernick = GetPostString("buyer_nick");
  1820. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1821. string customer = GetPostString("customer");
  1822. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1823. string design = GetPostString("design");
  1824. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1825. string orderState = GetPostString("orderState");
  1826. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1827. string address = GetPostString("address");
  1828. 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));
  1829. string sellermemo = GetPostString("seller_memo");
  1830. if (sellermemo.Length > 0)
  1831. {
  1832. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1833. }
  1834. string price1 = GetPostString("price1");
  1835. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1836. string price2 = GetPostString("price2");
  1837. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1838. //if (PKey != "admin")
  1839. //{
  1840. // string usershop = CurrentUser.User.pemShop;
  1841. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1842. //}
  1843. //if (ex_psize > 0)
  1844. //{
  1845. dStruct.Order = "pay_time desc";
  1846. //}
  1847. //else
  1848. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1849. lw.Add(string.Format("IsOffLineOrder=1"));
  1850. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1851. DataTable dt = null;
  1852. dt = WebCache.GetData("view_erptradecell", dStruct);
  1853. writeGridDataTableJson(dStruct.TotalCount, dt);
  1854. }
  1855. public void get_erp_returncashrecord()
  1856. {
  1857. DataStruct dStruct = GetPostStruct();
  1858. List<string> lw = new List<string>();
  1859. string tid = GetPostString("ctid");
  1860. if (tid.Length > 0)
  1861. {
  1862. lw.Add(string.Format("tid like '%{0}%'", tid));
  1863. dStruct.Order = "id desc";
  1864. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1865. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1866. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1867. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1868. return;
  1869. }
  1870. returnErrorMsg("id数据错误!");
  1871. }
  1872. public void ins_erp_returncashrecord()
  1873. {
  1874. if (UrlPostParmsCheck("tid"))
  1875. {
  1876. string tid = GetPostString("tid");
  1877. string retype = GetPostString("type");
  1878. StringBuilder sql = new StringBuilder();
  1879. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1880. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1881. if (dt.Rows.Count > 0)
  1882. {
  1883. returnErrorMsg("相同返现类型记录已存在");
  1884. return;
  1885. }
  1886. CeErpReturnCash entity = new CeErpReturnCash();
  1887. entity.tid = tid;
  1888. entity.seller_nick = GetPostString("seller_nick");
  1889. string pment = GetPostString("payment");
  1890. if (pment.Length > 0)
  1891. {
  1892. entity.payment = Convert.ToDouble(pment);
  1893. }
  1894. entity.buyer_nick = GetPostString("buyer_nick");
  1895. entity.cashstate = 0;
  1896. entity.rtype = retype;
  1897. string rPrice = GetPostString("returnprice");
  1898. if (rPrice.Length > 0)
  1899. {
  1900. entity.returnprice = Convert.ToDouble(rPrice);
  1901. }
  1902. entity.created = DateTime.Now;
  1903. entity.con = GetPostString("con");
  1904. entity.img = GetPostString("img");
  1905. entity.applyuserid = CurrentUser.UserID;
  1906. entity.Create();
  1907. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1908. returnSuccessMsg("操作成功!");
  1909. return;
  1910. }
  1911. }
  1912. public void set_erp_predelivery()
  1913. {
  1914. if (UrlPostParmsCheck("ctid"))
  1915. {
  1916. string eid = GetPostString("ctid");
  1917. CeErpTradeCell entity = null;
  1918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1919. if (entity != null)
  1920. {
  1921. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1922. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1923. //{
  1924. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1925. // return;
  1926. //}
  1927. entity.IsPreDelivery = 1;
  1928. entity.Update();
  1929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1930. returnSuccessMsg("预发货成功!");
  1931. return;
  1932. //string shop = GetPostString("seller_nick");
  1933. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1934. //string comName = GetPostString("comName");
  1935. //string comCode = GetPostString("comCode");
  1936. //string outSid = GetPostString("outSid");//运单号
  1937. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1938. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1939. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1940. //string apires = "";
  1941. //if (deliveryType == "虚拟发货")
  1942. //{
  1943. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1944. //}
  1945. //else
  1946. //{
  1947. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1948. //}
  1949. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1950. ////{
  1951. //if (apires.IndexOf("发货成功") != -1)
  1952. //{
  1953. // if (deliveryType != "虚拟发货")
  1954. // {
  1955. // //还要插入快递信息到 快递信息表
  1956. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1957. // exinfo.tid = eid;
  1958. // exinfo.out_sid = outSid;
  1959. // exinfo.company_code = comCode;
  1960. // exinfo.company_name = comName;
  1961. // exinfo.delivery_memo = deliveryMemo;
  1962. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1963. // exinfo.deliveryType = deliveryType;
  1964. // exinfo.Create();
  1965. // }
  1966. // returnSuccessMsg("发货成功!");
  1967. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1968. //}
  1969. //else
  1970. //{
  1971. // returnErrorMsg("淘宝发货失败!!");
  1972. //}
  1973. //return;
  1974. }
  1975. returnErrorMsg("找不到订单记录");
  1976. }
  1977. }
  1978. public void get_erp_unusuallist()
  1979. {
  1980. DataStruct dStruct = GetPostStruct();
  1981. List<string> lw = new List<string>();
  1982. string tid = GetPostString("ctid");
  1983. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1984. string shopname = GetPostString("shopname");
  1985. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1986. string buyernick = GetPostString("buyer_nick");
  1987. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1988. string ResponsibleMan = GetPostString("responsible");
  1989. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1990. string date1 = GetPostString("date1");
  1991. string date2 = GetPostString("date2");
  1992. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1993. if (dw.Length > 0) lw.Add(dw);
  1994. string price1 = GetPostString("price1");
  1995. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1996. string price2 = GetPostString("price2");
  1997. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1998. string orderState = GetPostString("orderState");
  1999. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2000. string sellermemo = GetPostString("seller_memo");
  2001. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2002. lw.Add(string.Format("UnusualTag > 0"));
  2003. lw.Add(string.Format("IsRefund<={0}", 1));
  2004. dStruct.Order = "pay_time desc";
  2005. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2006. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2007. writeGridDataTableJson(dStruct.TotalCount, dt);
  2008. }
  2009. public void set_erp_unusualtonomal()
  2010. {
  2011. if (UrlPostParmsCheck("ctid"))
  2012. {
  2013. string eid = GetPostString("ctid");
  2014. CeErpTradeCell entity = null;
  2015. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2016. if (entity != null)
  2017. {
  2018. entity.UnusualTag = -1;
  2019. entity.Update();
  2020. returnSuccessMsg("忽略成功!");
  2021. return;
  2022. }
  2023. returnErrorMsg("找不到记录");
  2024. }
  2025. }
  2026. public void ins_erp_unusualreason()
  2027. {
  2028. if (UrlPostParmsCheck("ctid"))
  2029. {
  2030. string eid = GetPostString("ctid");
  2031. CeErpTradeCell entity = null;
  2032. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2033. if (entity != null)
  2034. {
  2035. entity.MemoOpt = 4;
  2036. entity.UnusualCon = GetPostString("con");
  2037. entity.Update();
  2038. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2039. if (trade != null)
  2040. {
  2041. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2042. }
  2043. //查货是否超时
  2044. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2045. if (ceErpTradeCellExtend == null)
  2046. {
  2047. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2048. ceErpTradeCellExtend.ctid = entity.ctid;
  2049. }
  2050. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2051. {
  2052. ceErpTradeCellExtend.CheckOut += 1;
  2053. }
  2054. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2055. if (ceErpTradeCellExtend.ID > 0)
  2056. {
  2057. ceErpTradeCellExtend.Update();
  2058. }
  2059. else
  2060. {
  2061. ceErpTradeCellExtend.Create();
  2062. }
  2063. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2064. returnSuccessMsg("操作成功!");
  2065. return;
  2066. }
  2067. returnErrorMsg("找不到记录");
  2068. }
  2069. }
  2070. public void upd_erp_sampleorder()
  2071. {
  2072. if (UrlPostParmsCheck("ctid"))
  2073. {
  2074. string eid = GetPostString("ctid");
  2075. string[] eArr = eid.Split(',');
  2076. if (eArr.Length > 1)
  2077. {
  2078. List<string> eLst = new List<string>();
  2079. for (int i = 0; i < eArr.Length; i++)
  2080. {
  2081. eLst.Add("'" + eArr[i] + "'");
  2082. }
  2083. eid = string.Join(",", eLst.ToArray());
  2084. }
  2085. else
  2086. {
  2087. eid = "'" + eid + "'";
  2088. }
  2089. StringBuilder sql = new StringBuilder();
  2090. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2091. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2092. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2093. if (dt.Rows.Count > 0)
  2094. {
  2095. string errmsg = "";
  2096. foreach (DataRow dr in dt.Rows)
  2097. {
  2098. StringBuilder sqlsb = new StringBuilder();
  2099. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2100. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2101. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2102. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2103. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2104. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2105. {
  2106. continue;
  2107. }
  2108. else
  2109. {
  2110. string emsg = commonHelper.KeepChinese(apires);
  2111. errmsg += emsg;
  2112. }
  2113. }
  2114. if (errmsg.Length > 0)
  2115. {
  2116. returnErrorMsg(errmsg);
  2117. return;
  2118. }
  2119. returnSuccessMsg("操作成功");
  2120. return;
  2121. }
  2122. returnErrorMsg("找不到记录");
  2123. }
  2124. }
  2125. public void upd_erp_transcustomer()
  2126. {
  2127. if (UrlPostParmsCheck("ctid"))
  2128. {
  2129. string eid = GetPostString("ctid");
  2130. int userid = GetPostInt("CustomerUserId");
  2131. CeErpTradeCell entity = null;
  2132. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2133. if (entity != null)
  2134. {
  2135. //string[] mlist = entity.seller_memo.Split('-');
  2136. //string sql = "select * from view_erpuser where id=" + userid;
  2137. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2138. //if (dt != null && dt.Rows.Count > 0)
  2139. //{
  2140. // string nmemo = "";
  2141. // for(int i = 0; i < mlist.Length - 1; i++)
  2142. // {
  2143. // nmemo += mlist[i];
  2144. // nmemo += "-";
  2145. // }
  2146. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2147. // entity.seller_memo = nmemo;
  2148. //}
  2149. entity.CustomerUserId = userid;
  2150. entity.Update();
  2151. returnSuccessMsg("操作成功!");
  2152. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2153. return;
  2154. }
  2155. returnErrorMsg("找不到记录");
  2156. }
  2157. }
  2158. public void upd_erp_transdesigner()
  2159. {
  2160. if (UrlPostParmsCheck("ctid"))
  2161. {
  2162. string eids = GetPostString("ctid");
  2163. string[] ctidList = eids.Split(',');
  2164. int userid = GetPostInt("DesignUserId");
  2165. foreach (string ctid in ctidList)
  2166. {
  2167. CeErpTradeCell entity = null;
  2168. CeErpDesignerBill entitys = null;
  2169. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2170. entitys = CeErpDesignerBill.GetByTid(ctid);
  2171. if (entity != null)
  2172. {
  2173. if (entity.OrderState > 4)
  2174. {
  2175. continue;
  2176. }
  2177. //存在退款不能流转
  2178. if (entity.IsRefund > 0)
  2179. {
  2180. continue;
  2181. }
  2182. entity.DesignUserId = userid;
  2183. entity.WaitDesignTime = DateTime.Now;
  2184. entity.Update();
  2185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2186. }
  2187. }
  2188. returnSuccessMsg("操作成功!");
  2189. }
  2190. }
  2191. public void upd_erp_distributedesigner()
  2192. {
  2193. if (UrlPostParmsCheck("ctid"))
  2194. {
  2195. string eid = GetPostString("ctid");
  2196. int userid = GetPostInt("DesignUserId");
  2197. string[] idlist = eid.Split(',');
  2198. if (idlist.Length <= 0)
  2199. {
  2200. returnErrorMsg("订单不能为空");
  2201. return;
  2202. }
  2203. foreach (string ctid in idlist)
  2204. {
  2205. CeErpTradeCell entity = null;
  2206. CeErpDesignerBill entitys = null;
  2207. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2208. else continue;
  2209. if (entity != null)
  2210. {
  2211. if (userid == 2125 || userid == 3542)
  2212. { }
  2213. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2214. {
  2215. returnErrorMsg("金额错误的订单无法指派");
  2216. return;
  2217. }
  2218. if (entity.OrderState >= 5)
  2219. {
  2220. returnErrorMsg("已经设计完成无法指派");
  2221. return;
  2222. }
  2223. if (entity.OrderState == -1)
  2224. {
  2225. returnErrorMsg("审核中的订单无法指派");
  2226. return;
  2227. }
  2228. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2229. {
  2230. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2231. return;
  2232. }
  2233. //157赖橙帆 159林晨 73 静之颖
  2234. 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)
  2235. {
  2236. returnErrorMsg("指派设计共创无法再次指派!");
  2237. return;
  2238. }
  2239. entity.OrderState = 3;
  2240. if (entity.SupplierId == 0)
  2241. {
  2242. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2243. entity.SupplierId = suid;
  2244. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2245. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2246. }
  2247. if (userid == 2125 && entity.seller_memo != "")
  2248. {
  2249. apiDesign.API_GetPrintData_CreateOrder(entity);
  2250. }
  2251. if (userid == 3542 && entity.seller_memo != "")
  2252. {
  2253. string userPost = CurrentUser.UserPost.Post.Code;
  2254. if (CurrentUser.UserID == 73)
  2255. {
  2256. userPost = "SysAdmin";
  2257. }
  2258. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2259. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2260. if (response.msg != "设计共创:成功")
  2261. {
  2262. returnErrorMsg(response.msg);
  2263. return;
  2264. }
  2265. entity.DispatchSort = 2;
  2266. }
  2267. else
  2268. {
  2269. if (entity.DispatchSort == 2)
  2270. {
  2271. ApiVo apiVo = new ApiVo();
  2272. apiVo.actionName = "closeDesign";
  2273. apiVo.orderNumber = entity.ctid;
  2274. designHelper.API_WorkCore(apiVo);//closeDesign
  2275. }
  2276. entity.DispatchSort = 0;
  2277. }
  2278. entity.DesignUserId = userid;
  2279. entity.WaitDesignTime = DateTime.Now;
  2280. entity.UpdateTime = DateTime.Now;
  2281. entity.Update();
  2282. string name = commonHelper.getUserNameById(userid);
  2283. commonHelper.UpdateRelationOrder(entity.ctid);
  2284. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2285. }
  2286. }
  2287. returnSuccessMsg("操作成功!");
  2288. return;
  2289. }
  2290. }
  2291. public string getTidByCtid(string ctid)
  2292. {
  2293. string tid = "";
  2294. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2295. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2296. if (dataTable != null && dataTable.Rows.Count > 0)
  2297. {
  2298. tid = dataTable.Rows[0]["tid"].ToString();
  2299. }
  2300. return tid;
  2301. }
  2302. public List<string> getTidByCtidMore(string ctid)
  2303. {
  2304. 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);
  2305. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2306. List<string> list = new List<string>();
  2307. if (dataTable != null && dataTable.Rows.Count > 0)
  2308. {
  2309. foreach (DataRow item in dataTable.Rows)
  2310. {
  2311. list.Add("'" + item["tid"].ToString() + "'");
  2312. }
  2313. }
  2314. return list;
  2315. }
  2316. public List<string> getTidByCtidLike(string ctid)
  2317. {
  2318. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2319. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2320. List<string> list = new List<string>();
  2321. if (dataTable != null && dataTable.Rows.Count > 0)
  2322. {
  2323. foreach (DataRow item in dataTable.Rows)
  2324. {
  2325. list.Add("'" + item["tid"].ToString() + "'");
  2326. }
  2327. }
  2328. return list;
  2329. }
  2330. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2331. {
  2332. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2333. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2334. List<string> list = new List<string>();
  2335. if (dataTable != null && dataTable.Rows.Count > 0)
  2336. {
  2337. foreach (DataRow item in dataTable.Rows)
  2338. {
  2339. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2340. {
  2341. continue;
  2342. }
  2343. list.Add("'" + item["receiverId"].ToString() + "'");
  2344. }
  2345. }
  2346. return list;
  2347. }
  2348. public void get_erp_myorderlist()
  2349. {
  2350. DataStruct dStruct = GetPostStruct();
  2351. List<string> lw = new List<string>();
  2352. string tid = GetPostString("ctid");
  2353. if (tid.Length > 0)
  2354. {
  2355. string select_tid = getTidByCtid(tid);
  2356. lw.Add(string.Format("tid='{0}'", select_tid));
  2357. }
  2358. else
  2359. {
  2360. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2361. }
  2362. //12-1 修改
  2363. string urgent = GetPostString("urgent");
  2364. string back = GetPostString("back");
  2365. string offlineSearch = GetPostString("offlineSearch");
  2366. if (!string.IsNullOrWhiteSpace(urgent))
  2367. {
  2368. if (urgent.Equals("true"))
  2369. {
  2370. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2371. }
  2372. }
  2373. if (!string.IsNullOrWhiteSpace(back))
  2374. {
  2375. if (back.Equals("true"))
  2376. {
  2377. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2378. }
  2379. }
  2380. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2381. {
  2382. if (offlineSearch.Equals("true"))
  2383. {
  2384. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2385. }
  2386. }
  2387. //end
  2388. string shopname = GetPostString("shopname");
  2389. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2390. string buyernick = GetPostString("buyer_nick");
  2391. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2392. string design = GetPostString("design");
  2393. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2394. string orderState = GetPostString("orderState");
  2395. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2396. string sellermemo = GetPostString("seller_memo");
  2397. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2398. string date1 = GetPostString("date1");
  2399. string date2 = GetPostString("date2");
  2400. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2401. if (dw.Length > 0) lw.Add(dw);
  2402. string price1 = GetPostString("price1");
  2403. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2404. string price2 = GetPostString("price2");
  2405. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2406. string urgency = GetPostString("urgency");
  2407. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2408. string after = GetPostString("after");
  2409. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2410. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2411. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2412. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2414. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2415. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2416. if (dt != null && dt.Rows.Count > 0)
  2417. {
  2418. foreach (DataRow dr in dt.Rows)
  2419. {
  2420. try
  2421. {
  2422. // 对象操作
  2423. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2424. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2425. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2426. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2427. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2428. if (dStruct.PageSize != 100000)
  2429. {
  2430. if (dr["DispatchSort"].ToString() == "2")
  2431. {
  2432. dr["gongchuang"] = 200;
  2433. }
  2434. else if ("外协".Equals(dr["ToType"].ToString()))
  2435. {
  2436. dr["gongchuang"] = 200;
  2437. }
  2438. else if ("内部".Equals(dr["ToType"].ToString()))
  2439. {
  2440. dr["gongchuang"] = -1;
  2441. }
  2442. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2443. {
  2444. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2445. dr["gongchuang"] = response.code;
  2446. }
  2447. }
  2448. }
  2449. catch (NullReferenceException ex)
  2450. {
  2451. }
  2452. }
  2453. }
  2454. writeGridDataTableJson(dStruct.TotalCount, dt);
  2455. }
  2456. public void get_erp_myreturnorderlist()
  2457. {
  2458. DataStruct dStruct = GetPostStruct();
  2459. List<string> lw = new List<string>();
  2460. string tid = GetPostString("ctid");
  2461. if (tid.Length > 0)
  2462. {
  2463. string select_tid = getTidByCtid(tid);
  2464. lw.Add(string.Format("tid='{0}'", select_tid));
  2465. }
  2466. else
  2467. {
  2468. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2469. }
  2470. string shopname = GetPostString("shopname");
  2471. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2472. string buyernick = GetPostString("buyer_nick");
  2473. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2474. string design = GetPostString("design");
  2475. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2476. string orderState = GetPostString("orderState");
  2477. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2478. string sellermemo = GetPostString("seller_memo");
  2479. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2480. string date1 = GetPostString("date1");
  2481. string date2 = GetPostString("date2");
  2482. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2483. if (dw.Length > 0) lw.Add(dw);
  2484. string price1 = GetPostString("price1");
  2485. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2486. string price2 = GetPostString("price2");
  2487. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2488. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2489. {
  2490. lw.Add(string.Format("CusOrgID = 94"));
  2491. }
  2492. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2493. {
  2494. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2495. }
  2496. else
  2497. {
  2498. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2499. }
  2500. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2501. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2502. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2503. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2504. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2505. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2506. if (dt != null && dt.Rows.Count > 0)
  2507. {
  2508. foreach (DataRow dr in dt.Rows)
  2509. {
  2510. try
  2511. {
  2512. // 对象操作
  2513. if (dStruct.PageSize != 100000)
  2514. {
  2515. if (dr["DispatchSort"].ToString() == "2")
  2516. {
  2517. dr["gongchuang"] = 200;
  2518. }
  2519. else if ("外协".Equals(dr["ToType"].ToString()))
  2520. {
  2521. dr["gongchuang"] = 200;
  2522. }
  2523. else if ("内部".Equals(dr["ToType"].ToString()))
  2524. {
  2525. dr["gongchuang"] = -1;
  2526. }
  2527. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2528. {
  2529. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2530. dr["gongchuang"] = response.code;
  2531. }
  2532. }
  2533. }
  2534. catch (NullReferenceException ex)
  2535. {
  2536. // 处理空引用异常
  2537. }
  2538. }
  2539. }
  2540. writeGridDataTableJson(dStruct.TotalCount, dt);
  2541. }
  2542. public void get_erp_myorderlist_pregather()
  2543. {
  2544. string date1 = GetPostString("date1");
  2545. string date2 = GetPostString("date2");
  2546. int userId = CurrentUser.UserID; //客服id
  2547. string orderWhere = "";
  2548. List<string> lw = new List<string>();
  2549. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2550. if (dw.Length > 0) lw.Add(dw);
  2551. lw.Add(string.Format("CustomerUserId={0}", userId));
  2552. lw.Add(string.Format("OrderState<9"));
  2553. orderWhere = string.Join(" and ", lw.ToArray());
  2554. string orderWhere2 = "";
  2555. List<string> lw2 = new List<string>();
  2556. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2557. if (dw2.Length > 0) lw2.Add(dw2);
  2558. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2559. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2560. string sql = string.Format("select *" +
  2561. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2562. "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 " +
  2563. "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 " +
  2564. "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");
  2565. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2566. //writeGridDataTableJson(dt.Rows.Count, dt);
  2567. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2568. }
  2569. public void upd_erp_publishorder()
  2570. {
  2571. if (UrlPostParmsCheck("ctid"))
  2572. {
  2573. string eid = GetPostString("ctid");
  2574. CeErpTradeCell entity = null;
  2575. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2576. if (entity != null)
  2577. {
  2578. entity.OrderState = 0; //发布后,变为待抢单
  2579. entity.Update();
  2580. commonHelper.UpdateRelationOrder(entity.ctid);
  2581. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2582. returnSuccessMsg("发布成功!");
  2583. return;
  2584. }
  2585. returnErrorMsg("找不到记录");
  2586. }
  2587. }
  2588. public void get_erp_my_tiporder()
  2589. {
  2590. StringBuilder sql = new StringBuilder();
  2591. int userId = 0;
  2592. if (CurrentUser != null) userId = CurrentUser.UserID;
  2593. string posCode = CurrentUser.UserPost.Post.Code;
  2594. string isTipedAfterSaleVerify = GetPostString("af");
  2595. DataTable dt = new DataTable();
  2596. if (posCode != "Supplier")
  2597. {
  2598. if (posCode == "CustomerService" || posCode == "Director")
  2599. {
  2600. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2601. }
  2602. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2603. {
  2604. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2605. }
  2606. else
  2607. {
  2608. string teamIds = CurrentUser.User.TeamIds;
  2609. if (teamIds == "")
  2610. {
  2611. teamIds = "0";
  2612. }
  2613. 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);
  2614. }
  2615. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2616. }
  2617. if (dt.Rows.Count <= 0)
  2618. {
  2619. string key = "aftersale_order_" + userId;
  2620. if (RedisHelper.HasKey(key))
  2621. {
  2622. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2623. dt.Columns.Add("ctid", typeof(string));
  2624. dt.Columns.Add("IsReadTag", typeof(int));
  2625. foreach (var i in list)
  2626. {
  2627. DataRow data = dt.NewRow();
  2628. data["ctid"] = i;
  2629. data["IsReadTag"] = 4;
  2630. dt.Rows.Add(data);
  2631. }
  2632. RedisHelper.StringDelete(key);
  2633. }
  2634. }
  2635. if (dt.Rows.Count <= 0)
  2636. {
  2637. sql = new StringBuilder();
  2638. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2639. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2640. }
  2641. if (posCode == "Supplier")
  2642. {
  2643. string ids = CurrentUser.User.pemVend;
  2644. if (ids != null && ids.Length > 0)
  2645. {
  2646. string[] ids_list = ids.Split(',');
  2647. foreach (var item in ids_list)
  2648. {
  2649. string key = "return_order_" + item;
  2650. if (RedisHelper.HasKey(key))
  2651. {
  2652. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2653. dt.Columns.Add("ctid", typeof(string));
  2654. dt.Columns.Add("IsReadTag", typeof(int));
  2655. foreach (var i in list)
  2656. {
  2657. DataRow data = dt.NewRow();
  2658. data["ctid"] = i;
  2659. data["IsReadTag"] = 1;
  2660. dt.Rows.Add(data);
  2661. }
  2662. RedisHelper.StringDelete(key);
  2663. }
  2664. }
  2665. }
  2666. if (dt.Rows.Count <= 0)
  2667. {
  2668. sql = new StringBuilder();
  2669. 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);
  2670. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2671. }
  2672. }
  2673. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2674. }
  2675. public void reset_erp_tiporder()
  2676. {
  2677. string ids = GetPostString("ids");
  2678. string[] ctidList = ids.Split(',');
  2679. foreach (string ctid in ctidList)
  2680. {
  2681. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2682. if (enty != null)
  2683. {
  2684. enty.IsReadTag = 0;
  2685. enty.Update();
  2686. }
  2687. }
  2688. returnSuccessMsg("成功!");
  2689. return;
  2690. }
  2691. public void get_erp_designlist()
  2692. {
  2693. DataStruct dStruct = GetPostStruct();
  2694. List<string> lw = new List<string>();
  2695. string tid = GetPostString("ctid");
  2696. if (tid.Length > 0)
  2697. {
  2698. string select_tid = getTidByCtid(tid);
  2699. lw.Add(string.Format("tid='{0}'", select_tid));
  2700. }
  2701. string shopname = GetPostString("shopname");
  2702. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2703. string buyernick = GetPostString("buyer_nick");
  2704. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2705. string customer = GetPostString("customer");
  2706. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2707. string design = GetPostString("design");
  2708. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2709. string orderState = GetPostString("orderState");
  2710. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2711. lw.Add(string.Format("OrderState<6"));
  2712. string address = GetPostString("address");
  2713. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2714. string sellermemo = GetPostString("seller_memo");
  2715. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2716. string date1 = GetPostString("date1");
  2717. string date2 = GetPostString("date2");
  2718. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2719. if (dw.Length > 0) lw.Add(dw);
  2720. string apdate1 = GetPostString("apdate1");
  2721. string apdate2 = GetPostString("apdate2");
  2722. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2723. if (dwap.Length > 0) lw.Add(dwap);
  2724. string price1 = GetPostString("price1");
  2725. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2726. string price2 = GetPostString("price2");
  2727. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2728. string designTime = GetPostString("designtime");
  2729. if (designTime.Length > 0)
  2730. {
  2731. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2732. }
  2733. string usershop = CurrentUser.User.pemShop;
  2734. if (usershop.Length > 0)
  2735. {
  2736. lw.Add(string.Format("shopId in ({0})", usershop));
  2737. }
  2738. int myOrgid = CurrentUser.UserPost.OrgID;
  2739. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2740. if (myOrgCode.IndexOf("Designer") != -1)
  2741. {
  2742. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2743. {
  2744. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2745. }
  2746. else
  2747. {
  2748. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2749. }
  2750. }
  2751. else
  2752. {
  2753. string orgId = GetPostString("designerhd");
  2754. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2755. }
  2756. if (tid.Length > 0 || buyernick.Length > 0)
  2757. {
  2758. lw.Add(string.Format("OrderState >= 3"));
  2759. }
  2760. else
  2761. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2762. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2763. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2764. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2765. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2766. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2767. if (dt != null && dt.Rows.Count > 0)
  2768. {
  2769. foreach (DataRow dr in dt.Rows)
  2770. {
  2771. try
  2772. {
  2773. // 对象操作
  2774. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2775. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2776. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2777. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2778. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2779. if (dStruct.PageSize != 100000)
  2780. {
  2781. if (dr["DispatchSort"].ToString() == "2")
  2782. {
  2783. dr["gongchuang"] = 200;
  2784. }
  2785. else if ("外协".Equals(dr["ToType"].ToString()))
  2786. {
  2787. dr["gongchuang"] = 200;
  2788. }
  2789. else if ("内部".Equals(dr["ToType"].ToString()))
  2790. {
  2791. dr["gongchuang"] = -1;
  2792. }
  2793. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2794. {
  2795. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2796. dr["gongchuang"] = response.code;
  2797. }
  2798. }
  2799. }
  2800. catch (NullReferenceException ex)
  2801. {
  2802. }
  2803. }
  2804. }
  2805. writeGridDataTableJson(dStruct.TotalCount, dt);
  2806. }
  2807. public void get_erp_mydesignlist()
  2808. {
  2809. DataStruct dStruct = GetPostStruct();
  2810. List<string> lw = new List<string>();
  2811. string tid = GetPostString("ctid");
  2812. if (tid.Length > 0)
  2813. {
  2814. string select_tid = getTidByCtid(tid);
  2815. lw.Add(string.Format("tid='{0}'", select_tid));
  2816. }
  2817. string shopname = GetPostString("shopname");
  2818. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2819. string buyernick = GetPostString("buyer_nick");
  2820. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2821. string customer = GetPostString("customer");
  2822. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2823. string orderState = GetPostString("orderState");
  2824. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2825. //lw.Add(string.Format("OrderState<6"));
  2826. string date1 = GetPostString("date1");
  2827. string date2 = GetPostString("date2");
  2828. string dw = GetDateWhere("pay_time", date1, date2);
  2829. if (dw.Length > 0) lw.Add(dw);
  2830. string apdate1 = GetPostString("apdate1");
  2831. string apdate2 = GetPostString("apdate2");
  2832. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2833. if (dwap.Length > 0) lw.Add(dwap);
  2834. string price1 = GetPostString("price1");
  2835. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2836. string price2 = GetPostString("price2");
  2837. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2838. string olddownload = GetPostString("olddown");
  2839. if (olddownload == "1")
  2840. {
  2841. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2842. }
  2843. else if (olddownload == "2")
  2844. {
  2845. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2846. }
  2847. string sellermemo = GetPostString("seller_memo");
  2848. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2849. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2850. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2851. {
  2852. if (CurrentUser.User.TeamIds.Length > 0)
  2853. {
  2854. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2855. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2856. else
  2857. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2858. }
  2859. else
  2860. {
  2861. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2862. }
  2863. }
  2864. if (tid.Length <= 0)
  2865. {
  2866. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2867. }
  2868. lw.Add(string.Format("IsReturn!=3"));
  2869. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2871. string teamids = CurrentUser.User.TeamIds.ToString();
  2872. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2873. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2874. if (dt != null && dt.Rows.Count > 0)
  2875. {
  2876. foreach (DataRow dr in dt.Rows)
  2877. {
  2878. try
  2879. {
  2880. // 对象操作
  2881. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2882. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2883. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2884. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2885. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2886. if (dStruct.PageSize != 100000)
  2887. {
  2888. if (dr["DispatchSort"].ToString() == "2")
  2889. {
  2890. dr["gongchuang"] = 200;
  2891. }
  2892. else if ("外协".Equals(dr["ToType"].ToString()))
  2893. {
  2894. dr["gongchuang"] = 200;
  2895. }
  2896. else if ("内部".Equals(dr["ToType"].ToString()))
  2897. {
  2898. dr["gongchuang"] = -1;
  2899. }
  2900. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2901. {
  2902. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2903. dr["gongchuang"] = response.code;
  2904. }
  2905. }
  2906. }
  2907. catch (NullReferenceException ex)
  2908. {
  2909. }
  2910. }
  2911. }
  2912. writeGridDataTableJson(dStruct.TotalCount, dt);
  2913. }
  2914. public void set_erp_startdesign()
  2915. {
  2916. if (UrlPostParmsCheck("ctid"))
  2917. {
  2918. string eid = GetPostString("ctid");
  2919. CeErpTradeCell entity = null;
  2920. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2921. if (entity != null)
  2922. {
  2923. if (entity.OrderState != 3)
  2924. {
  2925. returnErrorMsg("请刷新,订单已经设计了");
  2926. return;
  2927. }
  2928. entity.StartDesignTime = DateTime.Now;
  2929. entity.OrderState = 4;
  2930. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2931. {
  2932. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2933. entity.SupplierId = suid;
  2934. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2935. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2936. }
  2937. entity.UpdateTime = DateTime.Now;
  2938. //entity.MakeSupplier = suname;
  2939. entity.Update();
  2940. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2941. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2942. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2943. commonHelper.getCytPrice(entity);
  2944. returnSuccessMsg("操作成功!");
  2945. return;
  2946. }
  2947. returnErrorMsg("找不到记录");
  2948. }
  2949. }
  2950. public void ins_erp_designselfmemo()
  2951. {
  2952. if (UrlPostParmsCheck("ctid"))
  2953. {
  2954. string eid = GetPostString("ctid");
  2955. string con = GetPostString("con");
  2956. CeErpTradeCell entity = null;
  2957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2958. if (entity != null)
  2959. {
  2960. entity.DesignSelfMemo = con;
  2961. entity.Update();
  2962. returnSuccessMsg("操作成功!");
  2963. return;
  2964. }
  2965. returnErrorMsg("找不到记录");
  2966. }
  2967. }
  2968. public void ins_erp_designprice()
  2969. {
  2970. if (UrlPostParmsCheck("ctid"))
  2971. {
  2972. string eid = GetPostString("ctid");
  2973. int uid = CurrentUser.UserID;
  2974. string userName = CurrentUser.UserName;
  2975. CeErpTradeCell entity = null;
  2976. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2977. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2978. if (entitys == null)
  2979. {
  2980. entitys = new CeErpDesignerBill();
  2981. }
  2982. if (entity != null)
  2983. {
  2984. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2985. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2986. entity.StartDesignTime = DateTime.Now;
  2987. entity.OrderState = 4;
  2988. string suname = "";
  2989. if (entity.SupplierId == 0)
  2990. {
  2991. int sid = commonHelper.autoDistributeToSupplier(entity);
  2992. entity.SupplierId = sid;
  2993. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2994. }
  2995. entity.Update();
  2996. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2997. if (ceErpUserPost != null)
  2998. {
  2999. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3000. if (ceErpPost != null)
  3001. {
  3002. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3003. {
  3004. entitys.tid = entity.ctid;
  3005. entitys.oid = entity.tid;
  3006. entitys.uid = uid;
  3007. entitys.userName = userName;
  3008. entitys.designerType = 1;
  3009. entitys.designerTypeText = "内部设计师";
  3010. entitys.price = Convert.ToDouble(GetPostString("price"));
  3011. entitys.designNum = GetPostInt("designNum");
  3012. entitys.modifyNum = GetPostInt("modifyNum");
  3013. entitys.designSize = GetPostString("designSize");
  3014. entitys.modifySize = GetPostString("modifySize");
  3015. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3016. {
  3017. entitys.create_time = DateTime.Now;
  3018. entitys.create_u_id = uid;
  3019. entitys.create_u_name = userName;
  3020. entitys.Save();
  3021. }
  3022. else
  3023. {
  3024. entitys.update_time = DateTime.Now;
  3025. entitys.update_u_id = uid;
  3026. entitys.update_u_name = userName;
  3027. entitys.Update();
  3028. }
  3029. }
  3030. }
  3031. }
  3032. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3033. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3034. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3035. if (suname != "")
  3036. {
  3037. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3038. }
  3039. commonHelper.getCytPrice(entity);
  3040. returnSuccessMsg("操作成功!");
  3041. return;
  3042. }
  3043. returnErrorMsg("找不到记录");
  3044. }
  3045. }
  3046. public void upload_erp_filecomplete()
  3047. {
  3048. if (UrlPostParmsCheck("ctid"))
  3049. {
  3050. string eid = GetPostString("ctid");
  3051. CeErpTradeCell entity = null;
  3052. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3053. if (entity != null)
  3054. {
  3055. entity.OrderState = 5; //设计完成
  3056. entity.Update();
  3057. returnSuccessMsg(eid + "上传成功,设计完成!");
  3058. return;
  3059. }
  3060. returnErrorMsg("找不到订单记录");
  3061. }
  3062. }
  3063. public void get_erp_designovertimelist()
  3064. {
  3065. DataStruct dStruct = GetPostStruct();
  3066. List<string> lw = new List<string>();
  3067. string tid = GetPostString("ctid");
  3068. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3069. string shopname = GetPostString("shopname");
  3070. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3071. string buyernick = GetPostString("buyer_nick");
  3072. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3073. string ResponsibleMan = GetPostString("responsible");
  3074. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3075. string date1 = GetPostString("date1");
  3076. string date2 = GetPostString("date2");
  3077. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3078. if (dw.Length > 0) lw.Add(dw);
  3079. string price1 = GetPostString("price1");
  3080. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3081. string price2 = GetPostString("price2");
  3082. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3083. string orderState = GetPostString("orderState");
  3084. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3085. string sellermemo = GetPostString("seller_memo");
  3086. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3087. lw.Add(string.Format("UnusualTag=3"));
  3088. lw.Add(string.Format("IsRefund<={0}", 1));
  3089. dStruct.Order = "WaitDesignTime desc";
  3090. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3091. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3092. writeGridDataTableJson(dStruct.TotalCount, dt);
  3093. }
  3094. //设计管理 获取抢单大厅列表
  3095. public void get_erp_grabinglist()
  3096. {
  3097. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3098. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3099. bool oldOrder = false;
  3100. if (org != null)
  3101. {
  3102. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3103. }
  3104. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3105. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3106. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3107. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3108. //先处理订单数据
  3109. if (dt.Rows.Count > 0)
  3110. {
  3111. Dictionary<string, int> design = null;
  3112. int count = 0;
  3113. foreach (DataRow row in dt.Rows)
  3114. {
  3115. if (map.ContainsKey(row["ShopId"].ToString()))
  3116. {
  3117. map.TryGetValue(row["ShopId"].ToString(), out design);
  3118. }
  3119. else
  3120. {
  3121. design = new Dictionary<string, int>();
  3122. }
  3123. if (design.ContainsKey(row["ProductId"].ToString()))
  3124. {
  3125. design.TryGetValue(row["ProductId"].ToString(), out count);
  3126. }
  3127. count++;
  3128. design[row["ProductId"].ToString()] = count;
  3129. map[row["ShopId"].ToString()] = design;
  3130. }
  3131. }
  3132. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3133. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3134. //把店铺排序和技能排序分类
  3135. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3136. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3137. if (design_dt.Rows.Count > 0)
  3138. {
  3139. Dictionary<string, string> design = null;
  3140. List<string> shopIds = null;
  3141. foreach (DataRow row in design_dt.Rows)
  3142. {
  3143. if ("0".Equals(row["designId"].ToString()))
  3144. {
  3145. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3146. {
  3147. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3148. }
  3149. else
  3150. {
  3151. shopIds = new List<string>();
  3152. }
  3153. shopIds.Add(row["shopId"].ToString());
  3154. shop_orders[row["orders"].ToString()] = shopIds;
  3155. }
  3156. else
  3157. {
  3158. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3159. {
  3160. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3161. }
  3162. else
  3163. {
  3164. design = new Dictionary<string, string>();
  3165. }
  3166. design[row["orders"].ToString()] = row["designId"].ToString();
  3167. design_orders[row["shopId"].ToString()] = design;
  3168. }
  3169. }
  3170. //处理成key value后根据key排序
  3171. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3172. foreach (List<string> val in shop_orders.Values)
  3173. {
  3174. if (val != null)
  3175. {
  3176. foreach (string key in val)
  3177. {
  3178. if (design_orders.ContainsKey(key.ToString()))
  3179. {
  3180. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3181. }
  3182. }
  3183. }
  3184. }
  3185. }
  3186. //校验哪个优先级有订单
  3187. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3188. foreach (string key in shop_orders.Keys)
  3189. {
  3190. List<string> ids = null;
  3191. shop_orders.TryGetValue(key, out ids);
  3192. //id为shopid
  3193. foreach (string id in ids)
  3194. {
  3195. Dictionary<string, int> list = null;
  3196. Dictionary<string, string> desing = null;
  3197. map.TryGetValue(id, out list);
  3198. design_orders.TryGetValue(id, out desing);
  3199. if (list != null && desing != null)
  3200. {
  3201. foreach (var item in desing)
  3202. {
  3203. int count = 0;
  3204. if (list.ContainsKey(item.Value))
  3205. {
  3206. list.TryGetValue(item.Value, out count);
  3207. if (count > 0)
  3208. {
  3209. designIds[id] = item.Value;
  3210. break;
  3211. }
  3212. }
  3213. }
  3214. }
  3215. }
  3216. if (designIds.Count > 0)
  3217. {
  3218. break;
  3219. }
  3220. }
  3221. DataTable table = new DataTable();
  3222. table.Columns.Add("tid", typeof(string));
  3223. table.Columns.Add("ctid", typeof(string));
  3224. table.Columns.Add("seller_nick", typeof(string));
  3225. table.Columns.Add("productName", typeof(string));
  3226. table.Columns.Add("pay_time", typeof(string));
  3227. table.Columns.Add("seller_memo", typeof(string));
  3228. if (designIds.Count > 0)
  3229. {
  3230. string shopId = "";
  3231. string productId = "";
  3232. foreach (var designInfo in designIds)
  3233. {
  3234. shopId = designInfo.Key;
  3235. productId = designInfo.Value;
  3236. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3237. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3238. if (dt.Rows.Count > 0)
  3239. {
  3240. foreach (DataRow row in dt.Rows)
  3241. {
  3242. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3243. {
  3244. DataRow data = table.NewRow();
  3245. data["ctid"] = row["ctid"].ToString();
  3246. data["tid"] = row["tid"].ToString();
  3247. data["seller_nick"] = ceErpShop.ShopName;
  3248. data["pay_time"] = row["pay_time"].ToString();
  3249. data["seller_memo"] = row["seller_memo"].ToString();
  3250. data["productName"] = ceErpProduct.PType;
  3251. table.Rows.Add(data);
  3252. }
  3253. }
  3254. }
  3255. }
  3256. }
  3257. writeGridDataTableJson(table.Rows.Count, table);
  3258. }
  3259. private object rushLockObject = new object();
  3260. public void set_erp_grabingorder()
  3261. {
  3262. if (UrlPostParmsCheck("ctid"))
  3263. {
  3264. int total = CurrentUser.User.Person.Total;
  3265. int userId = CurrentUser.User.ID;
  3266. int noFinish = CurrentUser.User.Person.NoFinish;
  3267. int finalization = CurrentUser.User.Person.Finalization;
  3268. string eids = GetPostString("ctid");
  3269. string key = "RushKey_" + userId;
  3270. int count = 0;
  3271. if (erpRedis.RedisHelper.KeyExists(key))
  3272. {
  3273. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3274. if (redisCount != null)
  3275. {
  3276. count = Convert.ToInt32(redisCount);
  3277. }
  3278. }
  3279. if (count >= total)
  3280. {
  3281. returnErrorMsg("半小时内已经抢" + total + "单");
  3282. return;
  3283. }
  3284. string[] ctidlist = eids.Split(',');
  3285. if (count + ctidlist.Length > total)
  3286. {
  3287. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3288. return;
  3289. }
  3290. int itag = 0;
  3291. lock (rushLockObject)
  3292. {
  3293. if (ctidlist.Length > 0)
  3294. {
  3295. string[] dtList = new string[ctidlist.Length];
  3296. for (int i = 0; i < ctidlist.Length; i++)
  3297. {
  3298. dtList[i] = "'" + ctidlist[i] + "'";
  3299. }
  3300. 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"));
  3301. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3302. if (dt_user.Rows.Count > 0)
  3303. {
  3304. int doing = 0;//未定稿
  3305. int finish = 0;//已完成
  3306. foreach (DataRow dr in dt_user.Rows)
  3307. {
  3308. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3309. {
  3310. doing++;
  3311. }
  3312. else
  3313. {
  3314. finish++;
  3315. }
  3316. }
  3317. if (doing >= noFinish)
  3318. {
  3319. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3320. return;
  3321. }
  3322. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3323. {
  3324. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3325. return;
  3326. }
  3327. }
  3328. //校验选择单子状态
  3329. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3330. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3331. if (dt.Rows.Count > 0)
  3332. {
  3333. List<string> list = new List<string>();
  3334. foreach (DataRow dr in dt.Rows)
  3335. {
  3336. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3337. {
  3338. list.Add(dr["ctid"].ToString());
  3339. }
  3340. }
  3341. if (list.Count > 0)
  3342. {
  3343. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3344. return;
  3345. }
  3346. }
  3347. foreach (string ctid in ctidlist)
  3348. {
  3349. CeErpTradeCell entity = null;
  3350. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3351. if (entity != null)
  3352. {
  3353. entity.OrderState = 3;
  3354. entity.DesignUserId = CurrentUser.UserID;
  3355. entity.WaitDesignTime = DateTime.Now;
  3356. entity.StartDesignTime = DateTime.Now;
  3357. entity.Update();
  3358. commonHelper.UpdateRelationOrder(entity.ctid);
  3359. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3360. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3361. itag++;
  3362. }
  3363. }
  3364. }
  3365. }
  3366. count += ctidlist.Length;
  3367. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3368. if (itag == 0)
  3369. returnErrorMsg("没有找到相关订单");
  3370. else
  3371. returnSuccessMsg("抢单成功!");
  3372. return;
  3373. }
  3374. }
  3375. public void get_erp_waitorderlist()
  3376. {
  3377. DataStruct dStruct = GetPostStruct();
  3378. List<string> lw = new List<string>();
  3379. string tid = GetPostString("ctid");
  3380. if (tid.Length > 0)
  3381. {
  3382. string select_tid = getTidByCtid(tid);
  3383. lw.Add(string.Format("tid='{0}'", select_tid));
  3384. }
  3385. string shopname = GetPostString("shopname");
  3386. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3387. string buyernick = GetPostString("buyer_nick");
  3388. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3389. string customer = GetPostString("customer");
  3390. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3391. string design = GetPostString("design");
  3392. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3393. string orderState = GetPostString("orderState");
  3394. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3395. string supplier = GetPostString("supplier");
  3396. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3397. string sellermemo = GetPostString("seller_memo");
  3398. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3399. string otherMemo = GetPostString("otherMemo");
  3400. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3401. string address = GetPostString("address");
  3402. 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));
  3403. string date1 = GetPostString("date1");
  3404. string date2 = GetPostString("date2");
  3405. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3406. if (dw.Length > 0) lw.Add(dw);
  3407. string price1 = GetPostString("price1");
  3408. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3409. string price2 = GetPostString("price2");
  3410. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3411. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3412. lw.Add(string.Format("IsSample != 2 "));
  3413. lw.Add(string.Format("OrderState = 5 "));
  3414. lw.Add(string.Format("IsRefund<={0}", 1));
  3415. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3416. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3417. string pagesize = GetPostString("pagesize");
  3418. if (pagesize != null)
  3419. {
  3420. dStruct.PageSize = 200;
  3421. }
  3422. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3423. List<string> tids = new List<string>();
  3424. if (dt != null)
  3425. {
  3426. dt.Columns.Add("compenPrice", typeof(double));
  3427. foreach (DataRow dr in dt.Rows)
  3428. {
  3429. if (Convert.IsDBNull(dr["compenPrice"]))
  3430. {
  3431. dr["compenPrice"] = 0;
  3432. }
  3433. tids.Add("'" + dr["tid"].ToString() + "'");
  3434. 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();
  3435. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3436. {
  3437. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3438. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3439. entity.SupplierId = suid;
  3440. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3441. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3442. entity.Update();
  3443. }
  3444. }
  3445. }
  3446. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3447. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3448. if (dt_price != null && dt_price.Rows.Count > 0)
  3449. {
  3450. foreach (DataRow dr in dt_price.Rows)
  3451. {
  3452. foreach (DataRow row in dt.Rows)
  3453. {
  3454. if (row["tid"].Equals(dr["ptid"]))
  3455. {
  3456. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3457. break;
  3458. }
  3459. }
  3460. }
  3461. }
  3462. writeGridDataTableJson(dStruct.TotalCount, dt);
  3463. }
  3464. public void get_erp_supplierwaitorderlist()
  3465. {
  3466. DataStruct dStruct = GetPostStruct();
  3467. List<string> lw = new List<string>();
  3468. string tid = GetPostString("ctid");
  3469. if (tid.Length > 0)
  3470. {
  3471. string select_tid = getTidByCtid(tid);
  3472. lw.Add(string.Format("tid='{0}'", select_tid));
  3473. }
  3474. string shopname = GetPostString("shopname");
  3475. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3476. string sellermemo = GetPostString("seller_memo");
  3477. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3478. string date1 = GetPostString("date1");
  3479. string date2 = GetPostString("date2");
  3480. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3481. if (dw.Length > 0) lw.Add(dw);
  3482. lw.Add(string.Format("OrderState = 5 "));
  3483. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3484. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3485. {
  3486. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3487. }
  3488. string supplier = GetPostString("supplier");
  3489. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3490. {
  3491. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3492. }
  3493. lw.Add(string.Format("IsRefund<={0}", 1));
  3494. dStruct.Order = "FinishDesignTime desc";
  3495. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3496. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3497. if (dt != null)
  3498. {
  3499. foreach (DataRow dr in dt.Rows)
  3500. {
  3501. 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();
  3502. }
  3503. }
  3504. writeGridDataTableJson(dStruct.TotalCount, dt);
  3505. }
  3506. public void upd_erp_verifytosupplier()
  3507. {
  3508. if (UrlPostParmsCheck("ctid"))
  3509. {
  3510. string eids = GetPostString("ctid");
  3511. CeErpTradeCell entity = null;
  3512. string[] eidsList = eids.Split(',');
  3513. if (eidsList.Length <= 0)
  3514. {
  3515. returnErrorMsg("订单号不能空");
  3516. return;
  3517. }
  3518. List<string> tLst = new List<string>();
  3519. foreach (string ctidstr in eidsList)
  3520. {
  3521. tLst.Add("'" + ctidstr + "'");
  3522. CeErpDataSendOrderInfo.createObject(ctidstr);
  3523. }
  3524. string needtids = string.Join(",", tLst.ToArray());
  3525. StringBuilder sql = new StringBuilder();
  3526. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3527. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3528. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3529. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3530. returnSuccessMsg("操作成功!");
  3531. return;
  3532. /**foreach (string ctidstr in eidsList)
  3533. {
  3534. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3535. if (entity != null)
  3536. {
  3537. if (entity.SupplierId == 0)
  3538. {
  3539. continue;
  3540. }
  3541. entity.IsVerifyToSupplier = true;
  3542. if (entity.IsReturn == 1) //1是供应商打回
  3543. {
  3544. entity.IsReturn = 0;
  3545. }
  3546. entity.FinishPlaceTime = DateTime.Now;
  3547. entity.PlaceUserId = CurrentUser.UserID;
  3548. entity.Update();
  3549. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3550. }
  3551. }
  3552. returnSuccessMsg("操作成功!");
  3553. return;**/
  3554. }
  3555. }
  3556. public void upd_erp_supplierback()
  3557. {
  3558. if (UrlPostParmsCheck("ctid"))
  3559. {
  3560. string eid = GetPostString("ctid");
  3561. string reason = GetPostString("returnreason");
  3562. CeErpTradeCell entity = null;
  3563. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3564. if (entity != null)
  3565. {
  3566. /*if (entity.IsHaveNewOrder == 2 && CurrentUser.UserPost.Post.Code != "SysAdmin")
  3567. {
  3568. returnErrorMsg("订单正在下载中无法退回!");
  3569. return;
  3570. }*/
  3571. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3572. {
  3573. string key = "return_order_" + entity.SupplierId;
  3574. List<string> list = new List<string>();
  3575. if (RedisHelper.HasKey(key))
  3576. {
  3577. object data = RedisHelper.StringGet(key);
  3578. list = Convert.ToString(data).Split(',').ToList();
  3579. }
  3580. list.Add(eid);
  3581. RedisHelper.StringSet(key, string.Join(",", list));
  3582. }
  3583. entity.IsVerifyToSupplier = false;
  3584. entity.IsReturn = 1;
  3585. entity.ReturnTime = DateTime.Now;
  3586. entity.ReturnReason = reason;
  3587. if (entity.OrderState == 6)
  3588. {
  3589. entity.OrderState = 5;
  3590. }
  3591. entity.Update();
  3592. CeErpSukuraData.createInfo(entity.ctid, 5);
  3593. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3594. returnSuccessMsg("操作成功!");
  3595. return;
  3596. }
  3597. returnErrorMsg("找不到订单记录");
  3598. }
  3599. }
  3600. public void upd_erp_toaftersaleorder()
  3601. {
  3602. if (UrlPostParmsCheck("ctid"))
  3603. {
  3604. string eid = GetPostString("ctid");
  3605. string reason = GetPostString("returnreason");
  3606. CeErpTradeCell entity = null;
  3607. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3608. if (entity != null)
  3609. {
  3610. if (entity.isAfterSaleOrder != 1)
  3611. {
  3612. returnErrorMsg("带S的售后单才能打回给售后");
  3613. return;
  3614. }
  3615. if (entity.OrderState >= 5)
  3616. {
  3617. returnErrorMsg("已经设计完成了不能打回给售后");
  3618. return;
  3619. }
  3620. entity.OrderState = 0;
  3621. entity.IsReturn = 3;
  3622. entity.ReturnTime = DateTime.Now;
  3623. entity.UpdateTime = DateTime.Now;
  3624. entity.ReturnReason = reason;
  3625. entity.Update();
  3626. CeErpSukuraData.createInfo(entity.ctid, 5);
  3627. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3628. returnSuccessMsg("操作成功!");
  3629. return;
  3630. }
  3631. returnErrorMsg("找不到订单记录");
  3632. }
  3633. }
  3634. public void upd_erp_aftersaletodesign()
  3635. {
  3636. if (UrlPostParmsCheck("ctid"))
  3637. {
  3638. string eid = GetPostString("ctid");
  3639. CeErpTradeCell entity = null;
  3640. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3641. if (entity != null)
  3642. {
  3643. entity.OrderState = 3;
  3644. entity.IsReturn = 0;
  3645. entity.UpdateTime = DateTime.Now;
  3646. entity.Update();
  3647. CeErpSukuraData.createInfo(entity.ctid, 5);
  3648. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3649. returnSuccessMsg("操作成功!");
  3650. return;
  3651. }
  3652. returnErrorMsg("找不到订单记录");
  3653. }
  3654. }
  3655. public void assign_erp_supplier()
  3656. {
  3657. if (UrlPostParmsCheck("ctid"))
  3658. {
  3659. string eids = GetPostString("ctid");
  3660. int sid = GetPostInt("SupplierName");
  3661. string fromTag = GetPostString("tag");
  3662. string[] eidList = eids.Split(',');
  3663. if (eidList.Length <= 0)
  3664. {
  3665. returnErrorMsg("指派不能为空");
  3666. return;
  3667. }
  3668. string errMsg = "";
  3669. string suname = commonHelper.getSupplierNameById(sid);
  3670. foreach (string ctid in eidList)
  3671. {
  3672. CeErpTradeCell entity = null;
  3673. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3674. if (entity != null)
  3675. {
  3676. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3677. {
  3678. errMsg += (ctid + "指派失败!!!");
  3679. continue;
  3680. }
  3681. entity.SupplierId = sid;
  3682. entity.Update();
  3683. commonHelper.UpdateRelationOrder(entity.ctid);
  3684. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3685. if (entity.OrderState >= 6)
  3686. {
  3687. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3688. //{
  3689. // string msl = entity.MakeSupplier;
  3690. // string[] mslist = msl.Split(',');
  3691. // 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);
  3692. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3693. //}
  3694. //else
  3695. //{
  3696. StringBuilder sql = new StringBuilder();
  3697. 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);
  3698. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3699. //}
  3700. }
  3701. }
  3702. else
  3703. {
  3704. continue;
  3705. }
  3706. }
  3707. if (errMsg.Length > 0)
  3708. {
  3709. returnErrorMsg(errMsg);
  3710. return;
  3711. }
  3712. returnSuccessMsg("操作成功!");
  3713. return;
  3714. }
  3715. }
  3716. public void assign_erp_makesupplier()
  3717. {
  3718. if (UrlPostParmsCheck("ctid"))
  3719. {
  3720. string eids = GetPostString("ctid");
  3721. string sname = GetPostString("SupplierName");
  3722. string[] eidList = eids.Split(',');
  3723. if (eidList.Length <= 0)
  3724. {
  3725. returnErrorMsg("指派不能为空");
  3726. return;
  3727. }
  3728. List<string> tLst = new List<string>();
  3729. foreach (string ctid in eidList)
  3730. {
  3731. CeErpTradeCell entity = null;
  3732. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3733. if (entity != null)
  3734. {
  3735. entity.MakeSupplier = sname;
  3736. entity.Update();
  3737. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3738. tLst.Add("'" + ctid + "'");
  3739. }
  3740. else
  3741. {
  3742. continue;
  3743. }
  3744. }
  3745. string ctids = string.Join(",", tLst.ToArray());
  3746. StringBuilder sql2 = new StringBuilder();
  3747. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3748. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3749. returnSuccessMsg("操作成功!");
  3750. return;
  3751. }
  3752. }
  3753. public void ins_erp_returnreason()
  3754. {
  3755. if (UrlPostParmsCheck("ctid"))
  3756. {
  3757. string eid = GetPostString("ctid");
  3758. CeErpTradeCell entity = null;
  3759. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3760. string userpost = CurrentUser.UserPost.Post.Code;
  3761. if (entity != null)
  3762. {
  3763. bool isPlace = false;
  3764. if (entity.OrderState > 6)
  3765. {
  3766. returnErrorMsg("已发货无法打回!");
  3767. return;
  3768. }
  3769. if (entity.OrderState == 6)
  3770. {
  3771. isPlace = true;
  3772. }
  3773. bool isNeedUpdateCell2 = false;
  3774. if (entity.OrderState >= 6)
  3775. {
  3776. isNeedUpdateCell2 = true;
  3777. }
  3778. int returnTag = 2;
  3779. if (userpost == "Supplier")
  3780. {
  3781. returnTag = 1;
  3782. }
  3783. int toType = GetPostInt("totype");
  3784. string fromType = "3";
  3785. if (entity.OrderState < 5)
  3786. {
  3787. fromType = "3";
  3788. }
  3789. else
  3790. {
  3791. fromType = "4";
  3792. }
  3793. if (entity.IsXianHuo == 0)
  3794. {
  3795. if (returnTag == 2)
  3796. {
  3797. if (toType == 1)
  3798. {
  3799. entity.OrderState = 0;
  3800. entity.ReturnUserType = 1;
  3801. string clearman = GetPostString("clearman");
  3802. if (!string.IsNullOrEmpty(clearman))
  3803. {
  3804. entity.DesignUserId = 0;
  3805. }
  3806. }
  3807. else
  3808. {
  3809. entity.OrderState = 3;
  3810. entity.ReturnUserType = 2;
  3811. }
  3812. entity.IsReadTag = 1;
  3813. }
  3814. else if (returnTag == 1)
  3815. {
  3816. entity.OrderState = 5;
  3817. }
  3818. entity.IsVerifyToSupplier = false;
  3819. }
  3820. if (entity.IsXianHuo == 1)
  3821. {
  3822. entity.OrderState = 5;
  3823. }
  3824. entity.UnusualTag = 0;
  3825. entity.UnusualTime = null;
  3826. entity.UnusualCon = "";
  3827. entity.IsReturn = returnTag;
  3828. entity.ReturnTime = DateTime.Now;
  3829. entity.UpdateTime = DateTime.Now;
  3830. entity.ReturnReason = GetPostString("returnreason");
  3831. entity.Update();
  3832. if (entity.OrderState == 3)
  3833. {
  3834. ApiVo apiVo = new ApiVo();
  3835. apiVo.orderNumber = entity.ctid;
  3836. apiVo.actionName = "rebutDesign";
  3837. apiVo.orderRemarks = entity.ReturnReason;
  3838. designHelper.API_WorkCore(apiVo);//rebutDesign
  3839. }
  3840. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3841. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3842. {
  3843. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3844. }
  3845. CeErpSukuraData.createInfo(entity.ctid, 5);
  3846. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3847. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3848. if (isPlace)
  3849. {
  3850. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3851. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3852. if (dth != null && dth.Rows.Count > 0)
  3853. {
  3854. dataSendOrderBean dataSendOrderBean = null;
  3855. foreach (DataRow item in dth.Rows)
  3856. {
  3857. try
  3858. {
  3859. dataSendOrderBean = new dataSendOrderBean();
  3860. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3861. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3862. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3863. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3864. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3865. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3866. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3867. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3868. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3869. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3870. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3871. dataSendOrderBean.Radio1723534706288 = "打回";
  3872. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3873. if (result != null)
  3874. {
  3875. if ("0".Equals(result.errcode))
  3876. {
  3877. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3878. }
  3879. else
  3880. {
  3881. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3882. }
  3883. }
  3884. }
  3885. catch (Exception ex)
  3886. {
  3887. }
  3888. }
  3889. }
  3890. }
  3891. if (isNeedUpdateCell2)
  3892. {
  3893. if (entity.MakeSupplier.IndexOf(",") != -1)
  3894. {
  3895. StringBuilder sql2 = new StringBuilder();
  3896. 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);
  3897. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3898. }
  3899. else
  3900. {
  3901. StringBuilder sql2 = new StringBuilder();
  3902. 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);
  3903. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3904. }
  3905. }
  3906. returnSuccessMsg("操作成功!");
  3907. return;
  3908. }
  3909. returnErrorMsg("找不到订单记录");
  3910. }
  3911. }
  3912. public void cyt_erp_returnreason()
  3913. {
  3914. if (UrlPostParmsCheck("ctid"))
  3915. {
  3916. string eid = GetPostString("ctid");
  3917. CeErpTradeCell entity = null;
  3918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3919. string userpost = CurrentUser.UserPost.Post.Code;
  3920. if (entity != null)
  3921. {
  3922. if (entity.OrderState > 6)
  3923. {
  3924. returnErrorMsg("已发货无法打回!");
  3925. return;
  3926. }
  3927. JObject jsonObject = new JObject
  3928. {
  3929. { "Userid", "77886" },
  3930. { "Pwd", "lt666888" },
  3931. { "LTOrderId",eid }
  3932. };
  3933. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3934. JObject jsonObjects = JObject.Parse(response);
  3935. string msg = (string)jsonObjects["msg"];
  3936. if (msg != "取消成功")
  3937. {
  3938. returnErrorMsg(msg);
  3939. return;
  3940. }
  3941. bool isNeedUpdateCell2 = false;
  3942. if (entity.OrderState >= 6)
  3943. {
  3944. isNeedUpdateCell2 = true;
  3945. }
  3946. int returnTag = 2;
  3947. if (userpost == "Supplier")
  3948. {
  3949. returnTag = 1;
  3950. }
  3951. if (entity.IsXianHuo == 0)
  3952. {
  3953. if (returnTag == 2)
  3954. {
  3955. int toType = GetPostInt("totype");
  3956. if (toType == 1)
  3957. {
  3958. entity.OrderState = 0;
  3959. entity.ReturnUserType = 1;
  3960. }
  3961. else
  3962. {
  3963. entity.OrderState = 4;
  3964. entity.ReturnUserType = 2;
  3965. }
  3966. entity.IsReadTag = 1;
  3967. }
  3968. else if (returnTag == 1)
  3969. {
  3970. entity.OrderState = 5;
  3971. }
  3972. entity.IsVerifyToSupplier = false;
  3973. }
  3974. entity.UnusualTag = 0;
  3975. entity.UnusualTime = null;
  3976. entity.UnusualCon = "";
  3977. entity.IsReturn = returnTag;
  3978. entity.ReturnTime = DateTime.Now;
  3979. entity.ReturnReason = GetPostString("returnreason");
  3980. entity.Update();
  3981. if (entity.OrderState == 4)
  3982. {
  3983. ApiVo apiVo = new ApiVo();
  3984. apiVo.orderNumber = entity.ctid;
  3985. apiVo.actionName = "rebutDesign";
  3986. apiVo.orderRemarks = entity.ReturnReason;
  3987. designHelper.API_WorkCore(apiVo);//rebutDesign
  3988. }
  3989. CeErpSukuraData.createInfo(entity.ctid, 5);
  3990. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3991. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3992. if (isNeedUpdateCell2)
  3993. {
  3994. if (entity.MakeSupplier.IndexOf(",") != -1)
  3995. {
  3996. StringBuilder sql2 = new StringBuilder();
  3997. 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);
  3998. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3999. }
  4000. else
  4001. {
  4002. StringBuilder sql2 = new StringBuilder();
  4003. 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);
  4004. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4005. }
  4006. }
  4007. returnSuccessMsg("操作成功!");
  4008. return;
  4009. }
  4010. returnErrorMsg("找不到订单记录");
  4011. }
  4012. }
  4013. public void upd_erp_xianhuoreturntag()
  4014. {
  4015. if (UrlPostParmsCheck("ctid"))
  4016. {
  4017. string eids = GetPostString("ctid");
  4018. string[] ctids = eids.Split(',');
  4019. foreach (string ctid in ctids)
  4020. {
  4021. CeErpTradeCell entity = null;
  4022. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4023. if (entity != null)
  4024. {
  4025. entity.IsReturn = 0;
  4026. entity.Update();
  4027. CeErpSukuraData.createInfo(entity.ctid, 5);
  4028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4029. }
  4030. }
  4031. returnSuccessMsg("操作成功!");
  4032. return;
  4033. }
  4034. }
  4035. public void get_erp_waitdeliverylist()
  4036. {
  4037. DataStruct dStruct = GetPostStruct();
  4038. List<string> lw = new List<string>();
  4039. string tid = GetPostString("ctid");
  4040. if (tid.Length > 0)
  4041. {
  4042. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4043. if (tid.Length > 5)
  4044. {
  4045. List<string> tids = getTidByCtidLike(tid);
  4046. if (tids.Count > 0 && tids.Count < 10)
  4047. {
  4048. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4049. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4050. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4051. {
  4052. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4053. }*/
  4054. }
  4055. }
  4056. lw.Add(tid_sql);
  4057. }
  4058. string shopname = GetPostString("shopname");
  4059. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4060. string buyernick = GetPostString("buyer_nick");
  4061. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4062. //if (tid.Length == 0 && buyernick.Length == 0)
  4063. //{
  4064. // lw.Add(string.Format("IsRefund<={0}", 1));
  4065. //}
  4066. string customer = GetPostString("customer");
  4067. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4068. string design = GetPostString("design");
  4069. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4070. string orderState = GetPostString("orderState");
  4071. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4072. string address = GetPostString("address");
  4073. 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));
  4074. string sellermemo = GetPostString("seller_memo");
  4075. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4076. string supplier = GetPostString("supplier");
  4077. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4078. string OrderArea = GetPostString("order_area");
  4079. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4080. string placedate1 = GetPostString("placedate1");
  4081. string placedate2 = GetPostString("placedate2");
  4082. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4083. if (fdw.Length > 0) lw.Add(fdw);
  4084. string price1 = GetPostString("price1");
  4085. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4086. string price2 = GetPostString("price2");
  4087. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4088. string unusualCon = GetPostString("unusualcon");
  4089. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4090. string otherMemo = GetPostString("otherMemo");
  4091. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4092. string posTag = CurrentUser.UserPost.Post.Code;
  4093. if (posTag == "Supplier")
  4094. {
  4095. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4096. }
  4097. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4098. lw.Add(string.Format("type != 'PDD' "));
  4099. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4100. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4101. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4102. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4103. writeGridDataTableJson(dStruct.TotalCount, dt);
  4104. }
  4105. public void get_erp_changedeliverylist()
  4106. {
  4107. DataStruct dStruct = GetPostStruct();
  4108. List<string> lw = new List<string>();
  4109. string tid = GetPostString("ctid");
  4110. if (tid.Length > 0)
  4111. {
  4112. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4113. if (tid.Length > 5)
  4114. {
  4115. List<string> tids = getTidByCtidLike(tid);
  4116. if (tids.Count > 0 && tids.Count < 10)
  4117. {
  4118. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4119. }
  4120. }
  4121. lw.Add(tid_sql);
  4122. }
  4123. string shopname = GetPostString("shopname");
  4124. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4125. string buyernick = GetPostString("buyer_nick");
  4126. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4127. //if (tid.Length == 0 && buyernick.Length == 0)
  4128. //{
  4129. // lw.Add(string.Format("IsRefund<={0}", 1));
  4130. //}
  4131. string customer = GetPostString("customer");
  4132. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4133. string design = GetPostString("design");
  4134. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4135. string orderState = GetPostString("orderState");
  4136. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4137. string address = GetPostString("address");
  4138. 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));
  4139. string sellermemo = GetPostString("seller_memo");
  4140. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4141. string supplier = GetPostString("supplier");
  4142. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4143. string OrderArea = GetPostString("order_area");
  4144. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4145. string placedate1 = GetPostString("placedate1");
  4146. string placedate2 = GetPostString("placedate2");
  4147. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4148. if (fdw.Length > 0) lw.Add(fdw);
  4149. string price1 = GetPostString("price1");
  4150. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4151. string price2 = GetPostString("price2");
  4152. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4153. string unusualCon = GetPostString("unusualcon");
  4154. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4155. string otherMemo = GetPostString("otherMemo");
  4156. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4157. string posTag = CurrentUser.UserPost.Post.Code;
  4158. if (posTag == "Supplier")
  4159. {
  4160. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4161. }
  4162. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4163. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4164. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4165. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4166. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4167. /*if (tid.Length > 0)
  4168. {
  4169. List<string> tids = new List<string>();
  4170. if (dt != null && dt.Rows.Count > 0)
  4171. {
  4172. foreach (DataRow item in dt.Rows)
  4173. {
  4174. tids.Add("'" + item["tid"] + "'");
  4175. }
  4176. }
  4177. if (tids.Count > 0)
  4178. {
  4179. lw.RemoveAt(0);
  4180. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4182. dt = WebCache.GetData("view_erptradecell", dStruct);
  4183. }
  4184. }*/
  4185. writeGridDataTableJson(dStruct.TotalCount, dt);
  4186. }
  4187. public void get_erp_pddderiving()
  4188. {
  4189. DataStruct dStruct = GetPostStruct();
  4190. List<string> lw = new List<string>();
  4191. string tid = GetPostString("ctid");
  4192. if (tid.Length > 0)
  4193. {
  4194. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4195. if (tid.Length > 5)
  4196. {
  4197. List<string> tids = getTidByCtidLike(tid);
  4198. if (tids.Count > 0 && tids.Count < 10)
  4199. {
  4200. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4201. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4202. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4203. {
  4204. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4205. }*/
  4206. }
  4207. }
  4208. lw.Add(tid_sql);
  4209. }
  4210. string shopname = GetPostString("shopname");
  4211. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4212. string buyernick = GetPostString("buyer_nick");
  4213. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4214. //if (tid.Length == 0 && buyernick.Length == 0)
  4215. //{
  4216. // lw.Add(string.Format("IsRefund<={0}", 1));
  4217. //}
  4218. string customer = GetPostString("customer");
  4219. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4220. string design = GetPostString("design");
  4221. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4222. string orderState = GetPostString("orderState");
  4223. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4224. string address = GetPostString("address");
  4225. 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));
  4226. string sellermemo = GetPostString("seller_memo");
  4227. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4228. string supplier = GetPostString("supplier");
  4229. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4230. string OrderArea = GetPostString("order_area");
  4231. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4232. string placedate1 = GetPostString("placedate1");
  4233. string placedate2 = GetPostString("placedate2");
  4234. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4235. if (fdw.Length > 0) lw.Add(fdw);
  4236. string price1 = GetPostString("price1");
  4237. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4238. string price2 = GetPostString("price2");
  4239. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4240. string unusualCon = GetPostString("unusualcon");
  4241. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4242. string posTag = CurrentUser.UserPost.Post.Code;
  4243. if (posTag == "Supplier")
  4244. {
  4245. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4246. }
  4247. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4248. lw.Add(string.Format("type = 'PDD' "));
  4249. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4250. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4251. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4252. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4253. /*if (tid.Length > 0)
  4254. {
  4255. List<string> tids = new List<string>();
  4256. if (dt != null && dt.Rows.Count > 0)
  4257. {
  4258. foreach (DataRow item in dt.Rows)
  4259. {
  4260. tids.Add("'" + item["tid"] + "'");
  4261. }
  4262. }
  4263. if (tids.Count > 0)
  4264. {
  4265. lw.RemoveAt(0);
  4266. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4267. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4268. dt = WebCache.GetData("view_erptradecell", dStruct);
  4269. }
  4270. }*/
  4271. writeGridDataTableJson(dStruct.TotalCount, dt);
  4272. }
  4273. public void get_erp_jdderiving()
  4274. {
  4275. DataStruct dStruct = GetPostStruct();
  4276. List<string> lw = new List<string>();
  4277. string tid = GetPostString("ctid");
  4278. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4279. string shopname = GetPostString("shopname");
  4280. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4281. string buyernick = GetPostString("buyer_nick");
  4282. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4283. //if (tid.Length == 0 && buyernick.Length == 0)
  4284. //{
  4285. // lw.Add(string.Format("IsRefund<={0}", 1));
  4286. //}
  4287. string customer = GetPostString("customer");
  4288. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4289. string design = GetPostString("design");
  4290. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4291. string orderState = GetPostString("orderState");
  4292. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4293. string address = GetPostString("address");
  4294. 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));
  4295. string sellermemo = GetPostString("seller_memo");
  4296. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4297. string supplier = GetPostString("supplier");
  4298. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4299. string OrderArea = GetPostString("order_area");
  4300. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4301. string placedate1 = GetPostString("placedate1");
  4302. string placedate2 = GetPostString("placedate2");
  4303. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4304. if (fdw.Length > 0) lw.Add(fdw);
  4305. string price1 = GetPostString("price1");
  4306. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4307. string price2 = GetPostString("price2");
  4308. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4309. string unusualCon = GetPostString("unusualcon");
  4310. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4311. string posTag = CurrentUser.UserPost.Post.Code;
  4312. if (posTag == "Supplier")
  4313. {
  4314. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4315. }
  4316. lw.Add(string.Format("OrderState = 6 "));
  4317. lw.Add(string.Format("type = 'JD' "));
  4318. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4319. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4320. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4321. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4322. writeGridDataTableJson(dStruct.TotalCount, dt);
  4323. }
  4324. public void get_erp_demoorderlist()
  4325. {
  4326. DataStruct dStruct = GetPostStruct();
  4327. List<string> lw = new List<string>();
  4328. string tid = GetPostString("ctid");
  4329. if (tid.Length > 0)
  4330. {
  4331. string select_tid = getTidByCtid(tid);
  4332. lw.Add(string.Format("tid='{0}'", select_tid));
  4333. }
  4334. string shopname = GetPostString("shopname");
  4335. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4336. string buyernick = GetPostString("buyer_nick");
  4337. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4338. string customer = GetPostString("customer");
  4339. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4340. string design = GetPostString("design");
  4341. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4342. string orderState = GetPostString("orderState");
  4343. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4344. string address = GetPostString("address");
  4345. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4346. string sellermemo = GetPostString("seller_memo");
  4347. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4348. string supplier = GetPostString("supplier");
  4349. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4350. string OrderArea = GetPostString("order_area");
  4351. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4352. string date1 = GetPostString("date1");
  4353. string date2 = GetPostString("date2");
  4354. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4355. if (dw.Length > 0) lw.Add(dw);
  4356. string price1 = GetPostString("price1");
  4357. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4358. string price2 = GetPostString("price2");
  4359. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4360. string posTag = CurrentUser.UserPost.Post.Code;
  4361. if (posTag == "Supplier")
  4362. {
  4363. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4364. }
  4365. //lw.Add(string.Format("OrderState = 6 "));
  4366. lw.Add(string.Format("IsSample={0}", 3));
  4367. lw.Add(string.Format("IsRefund<={0}", 1));
  4368. dStruct.Order = "pay_time desc";
  4369. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4370. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4371. writeGridDataTableJson(dStruct.TotalCount, dt);
  4372. }
  4373. public void save_erp_checkmemo()
  4374. {
  4375. if (UrlPostParmsCheck("ctid"))
  4376. {
  4377. string ctid = GetPostString("ctid");
  4378. CeErpTradeCell entity = null;
  4379. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4380. if (entity != null)
  4381. {
  4382. entity.CheckMemo = GetPostString("CheckMemo");
  4383. entity.Update();
  4384. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4385. if (trade != null)
  4386. {
  4387. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4388. }
  4389. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4390. returnSuccessMsg("保存成功!");
  4391. return;
  4392. }
  4393. returnErrorMsg("找不到记录");
  4394. }
  4395. }
  4396. public void get_erp_returnlist()
  4397. {
  4398. DataStruct dStruct = GetPostStruct();
  4399. List<string> lw = new List<string>();
  4400. string tid = GetPostString("ctid");
  4401. if (tid.Length > 0)
  4402. {
  4403. string select_tid = getTidByCtid(tid);
  4404. lw.Add(string.Format("tid='{0}'", select_tid));
  4405. }
  4406. string shopname = GetPostString("shopname");
  4407. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4408. string buyernick = GetPostString("buyer_nick");
  4409. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4410. string customer = GetPostString("customer");
  4411. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4412. string design = GetPostString("design");
  4413. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4414. string orderState = GetPostString("orderState");
  4415. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4416. string address = GetPostString("address");
  4417. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4418. string sellermemo = GetPostString("seller_memo");
  4419. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4420. string supplier = GetPostString("supplier");
  4421. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4422. string date1 = GetPostString("date1");
  4423. string date2 = GetPostString("date2");
  4424. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4425. if (dw.Length > 0) lw.Add(dw);
  4426. string bdate1 = GetPostString("backdate1");
  4427. string bdate2 = GetPostString("backdate2");
  4428. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4429. if (dw_back.Length > 0) lw.Add(dw_back);
  4430. string price1 = GetPostString("price1");
  4431. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4432. string price2 = GetPostString("price2");
  4433. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4434. lw.Add(string.Format("IsReturn>0"));
  4435. lw.Add(string.Format("IsXianHuo=0"));
  4436. lw.Add(string.Format("IsReturn!=3"));
  4437. string backtype = GetPostString("backtype");
  4438. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4439. dStruct.Order = "FinishDesignTime desc";
  4440. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4441. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4442. writeGridDataTableJson(dStruct.TotalCount, dt);
  4443. }
  4444. public void get_erp_today_sumreturn()
  4445. {
  4446. DataStruct dStruct = GetPostStruct();
  4447. List<string> lw = new List<string>();
  4448. string bdate1 = GetPostString("returnTimeS");
  4449. string bdate2 = GetPostString("returnTimeE");
  4450. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4451. if (dw_back.Length > 0) lw.Add(dw_back);
  4452. lw.Add(string.Format("IsReturn=0"));
  4453. lw.Add(string.Format("IsXianHuo=0"));
  4454. string mainWhere = string.Join(" and ", lw.ToArray());
  4455. string sql = "";
  4456. if (dw_back.Length > 0)
  4457. {
  4458. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4459. }
  4460. else
  4461. {
  4462. 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 + "'";
  4463. }
  4464. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4465. decimal total = 0, today_finish = 0;
  4466. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4467. {
  4468. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4469. }
  4470. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4471. {
  4472. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4473. }
  4474. var res = new
  4475. {
  4476. data = total,
  4477. data1 = today_finish,
  4478. };
  4479. string ro_jsond = JsonConvert.SerializeObject(res);
  4480. returnSuccess(ro_jsond);
  4481. return;
  4482. }
  4483. public void get_erp_allreturnlist()
  4484. {
  4485. DataStruct dStruct = GetPostStruct();
  4486. List<string> lw = new List<string>();
  4487. string tid = GetPostString("ctid");
  4488. if (tid.Length > 0)
  4489. {
  4490. string select_tid = getTidByCtid(tid);
  4491. lw.Add(string.Format("tid='{0}'", select_tid));
  4492. }
  4493. string shopname = GetPostString("shopname");
  4494. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4495. string buyernick = GetPostString("buyer_nick");
  4496. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4497. string customer = GetPostString("customer");
  4498. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4499. string design = GetPostString("design");
  4500. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4501. string orderState = GetPostString("orderState");
  4502. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4503. string address = GetPostString("address");
  4504. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4505. string sellermemo = GetPostString("seller_memo");
  4506. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4507. string supplier = GetPostString("supplier");
  4508. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4509. string date1 = GetPostString("date1");
  4510. string date2 = GetPostString("date2");
  4511. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4512. if (dw.Length > 0) lw.Add(dw);
  4513. string bdate1 = GetPostString("backdate1");
  4514. string bdate2 = GetPostString("backdate2");
  4515. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4516. if (dw_back.Length > 0) lw.Add(dw_back);
  4517. string price1 = GetPostString("price1");
  4518. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4519. string price2 = GetPostString("price2");
  4520. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4521. string backreason = GetPostString("backreason");
  4522. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4523. lw.Add(string.Format("IsXianHuo=0"));
  4524. lw.Add(string.Format("ReturnTime != ''"));
  4525. string backtype = GetPostString("backtype");
  4526. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4527. dStruct.Order = "FinishDesignTime desc";
  4528. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4529. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4530. writeGridDataTableJson(dStruct.TotalCount, dt);
  4531. }
  4532. public void get_erp_aftersalereturnlist()
  4533. {
  4534. DataStruct dStruct = GetPostStruct();
  4535. List<string> lw = new List<string>();
  4536. string tid = GetPostString("ctid");
  4537. if (tid.Length > 0)
  4538. {
  4539. string select_tid = getTidByCtid(tid);
  4540. lw.Add(string.Format("tid='{0}'", select_tid));
  4541. }
  4542. string shopname = GetPostString("shopname");
  4543. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4544. string buyernick = GetPostString("buyer_nick");
  4545. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4546. string customer = GetPostString("customer");
  4547. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4548. string design = GetPostString("design");
  4549. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4550. string orderState = GetPostString("orderState");
  4551. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4552. string address = GetPostString("address");
  4553. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4554. string sellermemo = GetPostString("seller_memo");
  4555. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4556. string supplier = GetPostString("supplier");
  4557. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4558. string date1 = GetPostString("date1");
  4559. string date2 = GetPostString("date2");
  4560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4561. if (dw.Length > 0) lw.Add(dw);
  4562. string bdate1 = GetPostString("backdate1");
  4563. string bdate2 = GetPostString("backdate2");
  4564. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4565. if (dw_back.Length > 0) lw.Add(dw_back);
  4566. string price1 = GetPostString("price1");
  4567. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4568. string price2 = GetPostString("price2");
  4569. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4570. lw.Add(string.Format("IsReturn=3"));
  4571. string backtype = GetPostString("backtype");
  4572. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4573. string backreason = GetPostString("backreason");
  4574. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4575. dStruct.Order = "ReturnTime desc";
  4576. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4577. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4578. writeGridDataTableJson(dStruct.TotalCount, dt);
  4579. }
  4580. public void get_erp_xianhuoreturnlist()
  4581. {
  4582. DataStruct dStruct = GetPostStruct();
  4583. List<string> lw = new List<string>();
  4584. string tid = GetPostString("ctid");
  4585. if (tid.Length > 0)
  4586. {
  4587. string select_tid = getTidByCtid(tid);
  4588. lw.Add(string.Format("tid='{0}'", select_tid));
  4589. }
  4590. string shopname = GetPostString("shopname");
  4591. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4592. string buyernick = GetPostString("buyer_nick");
  4593. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4594. string customer = GetPostString("customer");
  4595. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4596. string design = GetPostString("design");
  4597. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4598. string orderState = GetPostString("orderState");
  4599. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4600. string address = GetPostString("address");
  4601. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4602. string sellermemo = GetPostString("seller_memo");
  4603. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4604. string supplier = GetPostString("supplier");
  4605. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4606. string OrderArea = GetPostString("order_area");
  4607. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4608. string date1 = GetPostString("date1");
  4609. string date2 = GetPostString("date2");
  4610. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4611. if (dw.Length > 0) lw.Add(dw);
  4612. string price1 = GetPostString("price1");
  4613. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4614. string price2 = GetPostString("price2");
  4615. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4616. string posTag = CurrentUser.UserPost.Post.Code;
  4617. if (posTag == "Supplier")
  4618. {
  4619. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4620. }
  4621. lw.Add(string.Format("OrderState=6 "));
  4622. lw.Add(string.Format("IsXianHuo=1 "));
  4623. lw.Add(string.Format("IsReturn>0 "));
  4624. lw.Add(string.Format("IsReturn!=3"));
  4625. lw.Add(string.Format("IsRefund<={0}", 1));
  4626. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4627. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4628. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4629. writeGridDataTableJson(dStruct.TotalCount, dt);
  4630. }
  4631. public void set_erp_orderdelivery()
  4632. {
  4633. if (UrlPostParmsCheck("ctid"))
  4634. {
  4635. string eid = GetPostString("ctid");
  4636. CeErpTradeCell entity = null;
  4637. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4638. if (entity != null)
  4639. {
  4640. if (entity.OrderState >= 7)
  4641. {
  4642. returnErrorMsg("此单已发货,无需重复发货");
  4643. return;
  4644. }
  4645. if (entity.OrderState != 6)
  4646. {
  4647. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4648. return;
  4649. }
  4650. string shop = GetPostString("seller_nick");
  4651. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4652. string comName = GetPostString("comName");
  4653. string comCode = GetPostString("comCode");
  4654. string outSid = GetPostString("outSid");
  4655. string deliveryType = GetPostString("deliveryType");
  4656. string deliveryMemo = GetPostString("deliveryMemo");
  4657. outSid = outSid.Trim();
  4658. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4659. if (mainEn == null)
  4660. {
  4661. returnErrorMsg("找不到原始订单记录");
  4662. return;
  4663. }
  4664. bool isInitOrderDeliv = false;
  4665. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4666. {
  4667. isInitOrderDeliv = true;
  4668. }
  4669. string apires = "";
  4670. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4671. 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)
  4672. {
  4673. apires = "发货成功true";
  4674. }
  4675. else
  4676. {
  4677. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4678. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4679. }
  4680. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4681. {
  4682. entity.OrderState = 7;//发货后订单已发货
  4683. entity.OutSid = outSid;
  4684. entity.MemoOpt = 0;
  4685. entity.UpdateTime = DateTime.Now;
  4686. entity.FinishDeliveryTime = DateTime.Now;
  4687. entity.Update();
  4688. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4689. commonHelper.UpdateRelationOrder(entity.ctid);
  4690. //还要插入快递信息到 快递信息表
  4691. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4692. exinfo.tid = eid;
  4693. exinfo.out_sid = outSid;
  4694. exinfo.company_code = comCode;
  4695. exinfo.company_name = comName;
  4696. exinfo.delivery_memo = deliveryMemo;
  4697. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4698. exinfo.deliveryType = deliveryType;
  4699. exinfo.Create();
  4700. returnSuccessMsg("发货操作成功!");
  4701. commonHelper.UpdateRelationOrder(entity.ctid);
  4702. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4703. CeErpSukuraData.createInfo(entity.ctid, 4);
  4704. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4705. {
  4706. commonHelper.sendCytExpress(exinfo);
  4707. }
  4708. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4709. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4710. }
  4711. else
  4712. {
  4713. string errmsg = commonHelper.KeepChinese(apires);
  4714. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4715. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4716. }
  4717. return;
  4718. }
  4719. returnErrorMsg("找不到订单记录");
  4720. }
  4721. }
  4722. public void set_erp_multidelivery()
  4723. {
  4724. string eids = GetPostString("tids");
  4725. string[] eidList = eids.Split(',');
  4726. if (eidList.Length <= 0)
  4727. {
  4728. returnErrorMsg("发货不能为空");
  4729. return;
  4730. }
  4731. foreach (string ctid in eidList)
  4732. {
  4733. if (ctid.Length <= 0) continue;
  4734. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4735. if (expInfo != null)
  4736. {
  4737. StringBuilder sql = new StringBuilder();
  4738. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4739. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4740. if (dt.Rows.Count > 0)
  4741. {
  4742. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4743. {
  4744. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4745. expInfo.state = "异常";
  4746. expInfo.isMultiDelivery = 1;
  4747. expInfo.Update();
  4748. continue;
  4749. }
  4750. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4751. {
  4752. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4753. expInfo.state = "异常";
  4754. expInfo.Update();
  4755. continue;
  4756. }
  4757. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4758. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4759. bool isInitOrderDeliv = false;
  4760. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4761. {
  4762. isInitOrderDeliv = true;
  4763. expInfo.isMultiDelivery = 1;
  4764. }
  4765. if (ctid.IndexOf("N") != -1)
  4766. {
  4767. StringBuilder sqlbucha = new StringBuilder();
  4768. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4769. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4770. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4771. commonHelper.UpdateRelationOrder(ctid);
  4772. expInfo.delivery_memo = "发货成功";
  4773. expInfo.state = "发货成功";
  4774. expInfo.isMultiDelivery = 1;
  4775. expInfo.Update();
  4776. }
  4777. else
  4778. {
  4779. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4780. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4781. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4782. {
  4783. expInfo.delivery_memo = "发货成功";
  4784. expInfo.state = "发货成功";
  4785. expInfo.isMultiDelivery = 1;
  4786. expInfo.Update();
  4787. commonHelper.UpdateRelationOrder(ctid);
  4788. CeErpSukuraData.createInfo(ctid, 4);
  4789. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4790. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4791. }
  4792. else
  4793. {
  4794. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4795. expInfo.state = "异常";
  4796. expInfo.Update();
  4797. }
  4798. }
  4799. }
  4800. }
  4801. }
  4802. returnSuccessMsg("操作完成");
  4803. }
  4804. public void reset_erp_memoopt()
  4805. {
  4806. if (UrlPostParmsCheck("ctid"))
  4807. {
  4808. string eid = GetPostString("ctid");
  4809. CeErpTradeCell entity = null;
  4810. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4811. if (entity != null)
  4812. {
  4813. string stropt = "";
  4814. if (entity.MemoOpt == 1)
  4815. {
  4816. stropt = "“改稿”";
  4817. }
  4818. else if (entity.MemoOpt == 2)
  4819. {
  4820. stropt = "“定稿”";
  4821. }
  4822. else if (entity.MemoOpt == 3)
  4823. {
  4824. stropt = "“完成查货”";
  4825. CeErpSukuraData.createInfo(entity.ctid, 6);
  4826. }
  4827. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4828. entity.UpdateTime = DateTime.Now;
  4829. entity.MemoOpt = 0;
  4830. entity.Update();
  4831. returnSuccessMsg("操作成功!");
  4832. return;
  4833. }
  4834. returnErrorMsg("找不到记录");
  4835. }
  4836. }
  4837. public void get_erp_deliveryunusual()
  4838. {
  4839. DataStruct dStruct = GetPostStruct();
  4840. List<string> lw = new List<string>();
  4841. string tid = GetPostString("ctid");
  4842. if (tid.Length > 0)
  4843. {
  4844. string select_tid = getTidByCtid(tid);
  4845. lw.Add(string.Format("tid='{0}'", select_tid));
  4846. }
  4847. string shopname = GetPostString("shopname");
  4848. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4849. string buyernick = GetPostString("buyer_nick");
  4850. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4851. string customer = GetPostString("customer");
  4852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4853. string design = GetPostString("design");
  4854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4855. string sellermemo = GetPostString("seller_memo");
  4856. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4857. string supplier = GetPostString("supplier");
  4858. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4859. string date1 = GetPostString("date1");
  4860. string date2 = GetPostString("date2");
  4861. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4862. if (dw.Length > 0) lw.Add(dw);
  4863. string placedate1 = GetPostString("placedate1");
  4864. string placedate2 = GetPostString("placedate2");
  4865. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4866. if (dw_place.Length > 0) lw.Add(dw_place);
  4867. string price1 = GetPostString("price1");
  4868. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4869. string price2 = GetPostString("price2");
  4870. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4871. string unusualCon = GetPostString("unusualcon");
  4872. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4873. string posTag = CurrentUser.UserPost.Post.Code;
  4874. if (posTag == "Supplier")
  4875. {
  4876. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4877. }
  4878. lw.Add(string.Format("OrderState = 6"));
  4879. lw.Add(string.Format("UnusualTag = 5"));
  4880. lw.Add(string.Format("IsRefund<={0}", 1));
  4881. dStruct.Order = "FinishPlaceTime desc";
  4882. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4883. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4884. writeGridDataTableJson(dStruct.TotalCount, dt);
  4885. }
  4886. public void get_erp_deliveryedlist()
  4887. {
  4888. DataStruct dStruct = GetPostStruct();
  4889. List<string> lw = new List<string>();
  4890. string tid = GetPostString("ctid");
  4891. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4892. string shopname = GetPostString("shopname");
  4893. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4894. string buyernick = GetPostString("buyer_nick");
  4895. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4896. string customer = GetPostString("customer");
  4897. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4898. string design = GetPostString("design");
  4899. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4900. string sellermemo = GetPostString("seller_memo");
  4901. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4902. string logistics = GetPostString("logistics");
  4903. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4904. string date1 = GetPostString("date1");
  4905. string date2 = GetPostString("date2");
  4906. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4907. //if (dw.Length > 0) lw.Add(dw);
  4908. string placedate1 = GetPostString("placedate1");
  4909. string placedate2 = GetPostString("placedate2");
  4910. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4911. if (fdw.Length > 0) lw.Add(fdw);
  4912. string devdate1 = GetPostString("deliverydate1");
  4913. string devdate2 = GetPostString("deliverydate2");
  4914. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4915. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4916. string price1 = GetPostString("price1");
  4917. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4918. string price2 = GetPostString("price2");
  4919. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4920. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4921. {
  4922. if (tid.Length > 0)
  4923. {
  4924. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4925. if (tid.Length > 5)
  4926. {
  4927. List<string> tids = getTidByCtidLike(tid);
  4928. if (tids.Count > 0 && tids.Count < 10)
  4929. {
  4930. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4931. }
  4932. }
  4933. lw.Add(tid_sql);
  4934. }
  4935. if (buyernick.Length > 0)
  4936. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4937. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4938. if (dw.Length > 0) lw.Add(dw);
  4939. }
  4940. else
  4941. {
  4942. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4943. }
  4944. string posTag = CurrentUser.UserPost.Post.Code;
  4945. if (posTag == "Supplier")
  4946. {
  4947. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4948. }
  4949. else
  4950. {
  4951. string supplier = GetPostString("supplier");
  4952. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4953. }
  4954. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4955. lw.Add(string.Format("type != 'PDD' "));
  4956. lw.Add(string.Format("IsRefund!={0}", 2));
  4957. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4958. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4959. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4960. /*if (tid.Length > 0)
  4961. {
  4962. List<string> tids = new List<string>();
  4963. if (dt != null && dt.Rows.Count > 0)
  4964. {
  4965. foreach (DataRow item in dt.Rows)
  4966. {
  4967. tids.Add("'" + item["tid"] + "'");
  4968. }
  4969. }
  4970. if (tids.Count > 0)
  4971. {
  4972. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4973. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4974. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4975. dt = WebCache.GetData("view_erptradecell", dStruct);
  4976. }
  4977. }*/
  4978. if (dt != null)
  4979. {
  4980. foreach (DataRow dr in dt.Rows)
  4981. {
  4982. 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();
  4983. }
  4984. }
  4985. writeGridDataTableJson(dStruct.TotalCount, dt);
  4986. }
  4987. public void get_erp_pdddeliveryed()
  4988. {
  4989. DataStruct dStruct = GetPostStruct();
  4990. List<string> lw = new List<string>();
  4991. string tid = GetPostString("ctid");
  4992. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4993. string shopname = GetPostString("shopname");
  4994. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4995. string buyernick = GetPostString("buyer_nick");
  4996. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4997. string customer = GetPostString("customer");
  4998. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4999. string design = GetPostString("design");
  5000. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5001. string sellermemo = GetPostString("seller_memo");
  5002. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5003. string logistics = GetPostString("logistics");
  5004. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5005. string date1 = GetPostString("date1");
  5006. string date2 = GetPostString("date2");
  5007. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5008. //if (dw.Length > 0) lw.Add(dw);
  5009. string placedate1 = GetPostString("placedate1");
  5010. string placedate2 = GetPostString("placedate2");
  5011. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5012. if (fdw.Length > 0) lw.Add(fdw);
  5013. string devdate1 = GetPostString("deliverydate1");
  5014. string devdate2 = GetPostString("deliverydate2");
  5015. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5016. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5017. string price1 = GetPostString("price1");
  5018. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5019. string price2 = GetPostString("price2");
  5020. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5021. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5022. {
  5023. if (tid.Length > 0)
  5024. {
  5025. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5026. if (tid.Length > 5)
  5027. {
  5028. List<string> tids = getTidByCtidLike(tid);
  5029. if (tids.Count > 0 && tids.Count < 10)
  5030. {
  5031. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5032. }
  5033. }
  5034. lw.Add(tid_sql);
  5035. }
  5036. if (buyernick.Length > 0)
  5037. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5038. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5039. if (dw.Length > 0) lw.Add(dw);
  5040. }
  5041. else
  5042. {
  5043. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5044. }
  5045. string posTag = CurrentUser.UserPost.Post.Code;
  5046. if (posTag == "Supplier")
  5047. {
  5048. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5049. }
  5050. else
  5051. {
  5052. string supplier = GetPostString("supplier");
  5053. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5054. }
  5055. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5056. lw.Add(string.Format("type = 'PDD' "));
  5057. lw.Add(string.Format("IsRefund!={0}", 2));
  5058. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5059. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5060. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5061. /* if (tid.Length > 0)
  5062. {
  5063. List<string> tids = new List<string>();
  5064. if (dt != null && dt.Rows.Count > 0)
  5065. {
  5066. foreach (DataRow item in dt.Rows)
  5067. {
  5068. tids.Add("'" + item["tid"] + "'");
  5069. }
  5070. }
  5071. if (tids.Count > 0)
  5072. {
  5073. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5074. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5075. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5076. dt = WebCache.GetData("view_erptradecell", dStruct);
  5077. }
  5078. }*/
  5079. foreach (DataRow dr in dt.Rows)
  5080. {
  5081. 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();
  5082. }
  5083. writeGridDataTableJson(dStruct.TotalCount, dt);
  5084. }
  5085. public void get_erp_jddeliveryed()
  5086. {
  5087. DataStruct dStruct = GetPostStruct();
  5088. List<string> lw = new List<string>();
  5089. string tid = GetPostString("ctid");
  5090. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5091. string shopname = GetPostString("shopname");
  5092. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5093. string buyernick = GetPostString("buyer_nick");
  5094. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5095. string customer = GetPostString("customer");
  5096. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5097. string design = GetPostString("design");
  5098. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5099. string sellermemo = GetPostString("seller_memo");
  5100. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5101. string date1 = GetPostString("date1");
  5102. string date2 = GetPostString("date2");
  5103. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5104. //if (dw.Length > 0) lw.Add(dw);
  5105. string placedate1 = GetPostString("placedate1");
  5106. string placedate2 = GetPostString("placedate2");
  5107. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5108. if (fdw.Length > 0) lw.Add(fdw);
  5109. string devdate1 = GetPostString("deliverydate1");
  5110. string devdate2 = GetPostString("deliverydate2");
  5111. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5112. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5113. string price1 = GetPostString("price1");
  5114. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5115. string price2 = GetPostString("price2");
  5116. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5117. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5118. {
  5119. if (tid.Length > 0)
  5120. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5121. if (buyernick.Length > 0)
  5122. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5123. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5124. if (dw.Length > 0) lw.Add(dw);
  5125. }
  5126. else
  5127. {
  5128. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5129. }
  5130. string posTag = CurrentUser.UserPost.Post.Code;
  5131. if (posTag == "Supplier")
  5132. {
  5133. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5134. }
  5135. else
  5136. {
  5137. string supplier = GetPostString("supplier");
  5138. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5139. }
  5140. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5141. lw.Add(string.Format("type = 'JD' "));
  5142. lw.Add(string.Format("IsRefund!={0}", 2));
  5143. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5144. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5145. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5146. foreach (DataRow dr in dt.Rows)
  5147. {
  5148. 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();
  5149. }
  5150. writeGridDataTableJson(dStruct.TotalCount, dt);
  5151. }
  5152. public void get_erp_allplacelist()
  5153. {
  5154. DataStruct dStruct = GetPostStruct();
  5155. List<string> lw = new List<string>();
  5156. string tid = GetPostString("ctid");
  5157. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5158. string shopname = GetPostString("shopname");
  5159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5160. string buyernick = GetPostString("buyer_nick");
  5161. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5162. string customer = GetPostString("customer");
  5163. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5164. string design = GetPostString("design");
  5165. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5166. string sellermemo = GetPostString("seller_memo");
  5167. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5168. string supplier = GetPostString("supplier");
  5169. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5170. string date1 = GetPostString("date1");
  5171. string date2 = GetPostString("date2");
  5172. string pldate1 = GetPostString("placedate1");
  5173. string pldate2 = GetPostString("placedate2");
  5174. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5175. //if (dw.Length > 0) lw.Add(dw);
  5176. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5177. {
  5178. if (tid.Length > 0)
  5179. {
  5180. string select_tid = getTidByCtid(tid);
  5181. lw.Add(string.Format("tid='{0}'", select_tid));
  5182. }
  5183. if (buyernick.Length > 0)
  5184. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5185. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5186. if (dw.Length > 0) lw.Add(dw);
  5187. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5188. if (dw_place.Length > 0) lw.Add(dw_place);
  5189. }
  5190. else
  5191. {
  5192. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5193. {
  5194. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5195. }
  5196. }
  5197. string price1 = GetPostString("price1");
  5198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5199. string price2 = GetPostString("price2");
  5200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5201. string posTag = CurrentUser.UserPost.Post.Code;
  5202. if (posTag == "Supplier")
  5203. {
  5204. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5205. }
  5206. lw.Add(string.Format("OrderState >= 6"));
  5207. lw.Add(string.Format("IsSample != 2 "));
  5208. //lw.Add(string.Format("isDianziOrder = 0 "));
  5209. lw.Add(string.Format("SupplierId > 0 "));
  5210. //lw.Add(string.Format("IsRefund<={0}", 1));
  5211. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5212. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5213. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5214. foreach (DataRow dr in dt.Rows)
  5215. {
  5216. 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();
  5217. }
  5218. writeGridDataTableJson(dStruct.TotalCount, dt);
  5219. }
  5220. public void get_erp_financeallplacelist()
  5221. {
  5222. DataStruct dStruct = GetPostStruct();
  5223. List<string> lw = new List<string>();
  5224. string tid = GetPostString("ctid");
  5225. string shopname = GetPostString("shopname");
  5226. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5227. string buyernick = GetPostString("buyer_nick");
  5228. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5229. string customer = GetPostString("customer");
  5230. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5231. string design = GetPostString("design");
  5232. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5233. string sellermemo = GetPostString("seller_memo");
  5234. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5235. string supplier = GetPostString("supplier");
  5236. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5237. string date1 = GetPostString("date1");
  5238. string date2 = GetPostString("date2");
  5239. string pldate1 = GetPostString("placedate1");
  5240. string pldate2 = GetPostString("placedate2");
  5241. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5242. {
  5243. if (tid.Length > 0)
  5244. {
  5245. string select_tid = getTidByCtid(tid);
  5246. lw.Add(string.Format("tid='{0}'", select_tid));
  5247. }
  5248. if (buyernick.Length > 0)
  5249. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5250. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5251. if (dw.Length > 0) lw.Add(dw);
  5252. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5253. if (dw_place.Length > 0) lw.Add(dw_place);
  5254. }
  5255. else
  5256. {
  5257. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5258. {
  5259. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5260. }
  5261. }
  5262. string price1 = GetPostString("price1");
  5263. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5264. string price2 = GetPostString("price2");
  5265. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5266. string posTag = CurrentUser.UserPost.Post.Code;
  5267. if (posTag == "Supplier")
  5268. {
  5269. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5270. }
  5271. //lw.Add(string.Format("OrderState >= 6"));
  5272. lw.Add(string.Format("IsSample != 2 "));
  5273. lw.Add(string.Format("isDianziOrder = 0 "));
  5274. //lw.Add(string.Format("IsRefund<={0}", 1));
  5275. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5277. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5278. foreach (DataRow dr in dt.Rows)
  5279. {
  5280. 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();
  5281. }
  5282. writeGridDataTableJson(dStruct.TotalCount, dt);
  5283. }
  5284. public void get_erp_expresslist()
  5285. {
  5286. int listtype = GetInt("ltype");
  5287. DataStruct dStruct = GetPostStruct();
  5288. List<string> lw = new List<string>();
  5289. string tid = GetPostString("tid");
  5290. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5291. string outsid = GetPostString("out_sid");
  5292. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5293. string importer = GetPostString("ImportUserName");
  5294. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5295. string file = GetPostString("import_file");
  5296. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5297. string printman = GetPostString("printman");
  5298. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5299. string date1 = GetPostString("date1");
  5300. string date2 = GetPostString("date2");
  5301. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5302. if (dw.Length > 0) lw.Add(dw);
  5303. string fdate1 = GetPostString("finishdate1");
  5304. string fdate2 = GetPostString("finishdate2");
  5305. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5306. if (fdw.Length > 0) lw.Add(fdw);
  5307. string supplierId = GetPostString("supplierId");
  5308. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5309. if (listtype == 1)
  5310. {
  5311. lw.Add(string.Format("importUserId !=0"));
  5312. }
  5313. string posTag = CurrentUser.UserPost.Post.Code;
  5314. if (posTag == "Supplier")
  5315. {
  5316. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5317. }
  5318. if (dStruct.PageSize != 100000)
  5319. {
  5320. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5321. }
  5322. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5323. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5324. writeGridDataTableJson(dStruct.TotalCount, dt);
  5325. }
  5326. public void set_erp_buchaorderdelivery()
  5327. {
  5328. if (UrlPostParmsCheck("ctid"))
  5329. {
  5330. string eid = GetPostString("ctid");
  5331. CeErpTradeCell entity = null;
  5332. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5333. if (entity != null)
  5334. {
  5335. if (entity.IsSample != 2)
  5336. {
  5337. returnErrorMsg("补差价单才能标记为已发货");
  5338. return;
  5339. }
  5340. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5341. entity.OrderState = 7;
  5342. entity.Update();
  5343. returnSuccessMsg("操作成功!");
  5344. return;
  5345. }
  5346. returnErrorMsg("找不到记录");
  5347. }
  5348. }
  5349. public void get_stdtemplates()
  5350. {
  5351. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5352. //string res = taobaoHelper.test();
  5353. string res = apiHelper.API_PrintTemplate();
  5354. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5355. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5356. {
  5357. int sidx = res.IndexOf("error_code");
  5358. int eidx = res.IndexOf("success");
  5359. string msg = res.Substring(sidx, eidx - sidx);
  5360. returnErrorMsg(msg);
  5361. return;
  5362. }
  5363. if (res.Length <= 0)
  5364. {
  5365. returnErrorMsg("模板数据为空!");
  5366. return;
  5367. }
  5368. ReturnSuccess(res);
  5369. }
  5370. public void cancel_print_order()
  5371. {
  5372. if (UrlPostParmsCheck("ctid"))
  5373. {
  5374. string ctid = GetPostString("ctid");
  5375. CeErpTradeCell entity = null;
  5376. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5377. if (entity != null)
  5378. {
  5379. string res = "";
  5380. string code = entity.LastBillWaybillCode;
  5381. if (code == "")
  5382. {
  5383. code = entity.OutSid;
  5384. }
  5385. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5386. XLog.SaveLog(0, "取消面单" + res);
  5387. }
  5388. }
  5389. }
  5390. public void set_erp_printwaybill()
  5391. {
  5392. if (UrlPostParmsCheck("ctid"))
  5393. {
  5394. string ctid = GetPostString("ctid");
  5395. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5396. string cpName = GetPostString("cpname");
  5397. string isTogether = GetPostString("together");
  5398. string printType = GetPostString("printType");
  5399. //var res_obj = new
  5400. //{
  5401. // restype = 1,
  5402. // 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\"}"
  5403. //};
  5404. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5405. //ReturnSuccess(ro_json);
  5406. //return;
  5407. bool isUseLastWayBillCode = false;
  5408. CeErpTradeCell entity = null;
  5409. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5410. if (entity != null)
  5411. {
  5412. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5413. {
  5414. isUseLastWayBillCode = true;
  5415. }
  5416. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5417. {
  5418. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5419. return;
  5420. }
  5421. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5422. {
  5423. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5424. return;
  5425. }
  5426. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5427. {
  5428. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5429. return;
  5430. }
  5431. }
  5432. string res = "";
  5433. Api_waybill_code_response_Obj fullObj = null;
  5434. string pData_str = "";
  5435. string curUseWayBillCode = "";
  5436. if (isUseLastWayBillCode == false)
  5437. {
  5438. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5439. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5440. if (res.IndexOf("failure") != -1)
  5441. {
  5442. //int idx = res.IndexOf("sub_message");
  5443. //int idx2 = res.IndexOf("flag");
  5444. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5445. string errMsgNeed = commonHelper.KeepChinese(res);
  5446. var res_objd = new
  5447. {
  5448. restype = 0,
  5449. data = "获取面单失败" + errMsgNeed
  5450. };
  5451. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5452. returnSuccess(ro_jsond);
  5453. if (res.IndexOf("停发") != -1)
  5454. {
  5455. entity.UnusualCon = "物流停发";
  5456. entity.Update();
  5457. }
  5458. //returnErrorMsg("获取面单失败,"+emsg);
  5459. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5460. return;
  5461. }
  5462. else if (res.IndexOf("errorMsg") != -1)
  5463. {
  5464. //int idx = res.IndexOf("errorMsg");
  5465. //int idx2 = res.IndexOf("}]}");
  5466. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5467. string errMsgNeed = commonHelper.KeepChinese(res);
  5468. var res_objf = new
  5469. {
  5470. restype = 0,
  5471. data = "获取面单失败2" + errMsgNeed
  5472. };
  5473. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5474. if (res.IndexOf("停发") != -1)
  5475. {
  5476. entity.UnusualCon = "物流停发";
  5477. entity.Update();
  5478. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5479. if (trade != null)
  5480. {
  5481. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5482. }
  5483. }
  5484. returnSuccess(ro_jsonf);
  5485. //returnErrorMsg("获取面单失败," + emsg);
  5486. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5487. return;
  5488. }
  5489. try
  5490. {
  5491. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5492. //res = res.Replace(" ", "");
  5493. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5494. }
  5495. catch (Exception ex)
  5496. {
  5497. XLog.SaveLog(0, "生成fullObj" + res);
  5498. var res_objf = new
  5499. {
  5500. restype = 0,
  5501. data = "生成fullObj发生错误" + ex.Message
  5502. };
  5503. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5504. returnSuccess(ro_jsonf);
  5505. return;
  5506. }
  5507. if (fullObj.response.data.content.Count > 0)
  5508. {
  5509. ContentItem codeObj = fullObj.response.data.content[0];
  5510. if (cpCode.IndexOf("SFFQ-") != -1)
  5511. {
  5512. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5513. }
  5514. else
  5515. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5516. curUseWayBillCode = codeObj.waybillCode;
  5517. }
  5518. else
  5519. {
  5520. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5521. var res_objf = new
  5522. {
  5523. restype = 0,
  5524. data = "生成fullObj找不到快递单号waybillCode"
  5525. };
  5526. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5527. returnSuccess(ro_jsonf);
  5528. return;
  5529. }
  5530. }
  5531. else
  5532. {
  5533. //使用上次打印的快递单号
  5534. if (cpCode == "SFFQ-LY")
  5535. {
  5536. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5537. }
  5538. else
  5539. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5540. curUseWayBillCode = entity.LastBillWaybillCode;
  5541. }
  5542. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5543. {
  5544. var res_obje = new
  5545. {
  5546. restype = 0,
  5547. data = "获取加密打印数据失败"
  5548. };
  5549. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5550. returnSuccess(ro_jsone);
  5551. entity.LastBillCpCode = cpCode;
  5552. entity.LastBillWaybillCode = curUseWayBillCode;
  5553. entity.Update();
  5554. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5555. //returnErrorMsg("获取加密打印数据失败");
  5556. return;
  5557. }
  5558. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5559. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5560. string btnType = "";
  5561. string errorMsg = "";
  5562. if (entity != null)
  5563. {
  5564. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5565. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5566. //cpcode是 YTO-CAINIAO
  5567. //string comCode = cpCode.Split('-')[0].ToString();
  5568. string apires = "";
  5569. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5570. //isTogether=2是新的合包弹窗
  5571. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5572. {
  5573. if (ctid.IndexOf("N") != -1)
  5574. {
  5575. apires = "发货成功";
  5576. }
  5577. else
  5578. {
  5579. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5580. }
  5581. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5582. //打单后发货
  5583. StringBuilder sql = new StringBuilder();
  5584. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5585. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5586. {
  5587. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5588. }
  5589. else
  5590. {
  5591. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5592. }
  5593. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5594. foreach (DataRow row in dt.Rows)
  5595. {
  5596. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5597. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5598. {
  5599. try
  5600. {
  5601. btnType = "待发货";
  5602. entity.OutSid = curUseWayBillCode;
  5603. entity.OrderState = 7;
  5604. entity.IsUrgency = false;
  5605. entity.LastBillCpCode = "";
  5606. entity.LastBillWaybillCode = "";
  5607. entity.FinishDeliveryTime = DateTime.Now;
  5608. entity.IsReturn = 0;
  5609. entity.MemoOpt = 0;
  5610. entity.UpdateTime = DateTime.Now;
  5611. entity.Update();
  5612. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5613. //还要插入快递信息到 快递信息表
  5614. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5615. exinfo.tid = entity.ctid;
  5616. exinfo.out_sid = curUseWayBillCode;
  5617. exinfo.company_code = cpCode;
  5618. exinfo.company_name = cpName;
  5619. exinfo.supplierUserName = supplierName;
  5620. exinfo.deliveryType = "发货成功";
  5621. exinfo.print_time = DateTime.Now;
  5622. exinfo.printUser = CurrentUser.UserName;
  5623. exinfo.postData = pData_str;
  5624. exinfo.Create();
  5625. commonHelper.UpdateRelationOrder(entity.ctid);
  5626. CeErpSukuraData.createInfo(ctid, 4);
  5627. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5628. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5629. {
  5630. commonHelper.sendCytExpress(exinfo);
  5631. }
  5632. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5633. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5634. }
  5635. catch (Exception ex)
  5636. {
  5637. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5638. }
  5639. }
  5640. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5641. {
  5642. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5643. if (entity.OrderState == 6)
  5644. {
  5645. entity.OrderState = 7;
  5646. }
  5647. entity.UpdateTime = DateTime.Now;
  5648. entity.FinishDeliveryTime = DateTime.Now;
  5649. btnType = "已发货";
  5650. entity.Update();
  5651. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5652. exinfo.tid = entity.ctid;
  5653. exinfo.out_sid = curUseWayBillCode;
  5654. exinfo.company_code = cpCode;
  5655. exinfo.company_name = cpName;
  5656. exinfo.supplierUserName = supplierName;
  5657. exinfo.deliveryType = "发货成功";
  5658. exinfo.print_time = DateTime.Now;
  5659. exinfo.printUser = CurrentUser.UserName;
  5660. exinfo.postData = pData_str;
  5661. exinfo.Create();
  5662. commonHelper.UpdateRelationOrder(entity.ctid);
  5663. CeErpSukuraData.createInfo(entity.ctid, 4);
  5664. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5665. {
  5666. commonHelper.sendCytExpress(exinfo);
  5667. }
  5668. //不处理
  5669. }
  5670. else
  5671. {
  5672. entity.UpdateTime = DateTime.Now;
  5673. entity.LastBillCpCode = cpCode;
  5674. entity.LastBillWaybillCode = curUseWayBillCode;
  5675. entity.Update();
  5676. string errmsg = commonHelper.KeepChinese(apires);
  5677. var res_objz = new
  5678. {
  5679. restype = 0,
  5680. data = "打单后发货失败"
  5681. };
  5682. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5683. returnSuccess(ro_jsonz);
  5684. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5685. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5686. return;
  5687. }
  5688. }
  5689. }
  5690. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5691. {
  5692. string ctids = GetPostString("ctids");
  5693. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5694. List<string> list = new List<string>();
  5695. List<string> send_list = new List<string>();
  5696. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5697. CeErpTrade ceErpTrade = new CeErpTrade();
  5698. //可合包的合并一起发货
  5699. if (dt == null && string.IsNullOrEmpty(ctids))
  5700. {
  5701. var res_objz = new
  5702. {
  5703. restype = 0,
  5704. data = "打单后发货失败"
  5705. };
  5706. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5707. returnSuccess(ro_jsonz);
  5708. return;
  5709. }
  5710. if (!string.IsNullOrEmpty(ctids))
  5711. {
  5712. StringBuilder sql = new StringBuilder();
  5713. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5714. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5715. }
  5716. foreach (DataRow row in dt.Rows)
  5717. {
  5718. list.Add("'" + row["ctid"] + "'");
  5719. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5720. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5721. if (ctid.IndexOf("N") != -1)
  5722. {
  5723. apires = "发货成功";
  5724. }
  5725. else
  5726. {
  5727. if (!send_list.Contains(ceErpTrade.tid))
  5728. {
  5729. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5730. }
  5731. else
  5732. {
  5733. apires = "发货成功";
  5734. }
  5735. }
  5736. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5737. {
  5738. send_list.Add(ceErpTrade.tid);
  5739. try
  5740. {
  5741. btnType = "待发货";
  5742. ceErpTradeCell.OutSid = curUseWayBillCode;
  5743. ceErpTradeCell.OrderState = 7;
  5744. ceErpTradeCell.IsUrgency = false;
  5745. ceErpTradeCell.LastBillCpCode = "";
  5746. ceErpTradeCell.LastBillWaybillCode = "";
  5747. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5748. ceErpTradeCell.IsReturn = 0;
  5749. ceErpTradeCell.MemoOpt = 0;
  5750. ceErpTradeCell.UpdateTime = DateTime.Now;
  5751. ceErpTradeCell.Update();
  5752. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5753. //还要插入快递信息到 快递信息表
  5754. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5755. exinfo.tid = ceErpTradeCell.ctid;
  5756. exinfo.out_sid = curUseWayBillCode;
  5757. exinfo.company_code = cpCode;
  5758. exinfo.company_name = cpName;
  5759. exinfo.supplierUserName = supplierName;
  5760. exinfo.deliveryType = "发货成功";
  5761. exinfo.print_time = DateTime.Now;
  5762. exinfo.printUser = CurrentUser.UserName;
  5763. exinfo.postData = pData_str;
  5764. exinfo.Create();
  5765. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5766. CeErpSukuraData.createInfo(ctid, 4);
  5767. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5768. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5769. {
  5770. commonHelper.sendCytExpress(exinfo);
  5771. }
  5772. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5773. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5774. }
  5775. catch (Exception ex)
  5776. {
  5777. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5778. }
  5779. }
  5780. else
  5781. {
  5782. ceErpTradeCell.UpdateTime = DateTime.Now;
  5783. ceErpTradeCell.LastBillCpCode = cpCode;
  5784. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5785. ceErpTradeCell.Update();
  5786. string errmsg = commonHelper.KeepChinese(apires);
  5787. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5788. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5789. }
  5790. }
  5791. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5792. }
  5793. }
  5794. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5795. var res_obj = new
  5796. {
  5797. restype = 1,
  5798. data = pData_str,
  5799. errorMsg
  5800. };
  5801. string ro_json = JsonConvert.SerializeObject(res_obj);
  5802. ReturnSuccess(ro_json);
  5803. return;
  5804. }
  5805. }
  5806. private string GetUTF8String(byte[] vs)
  5807. {
  5808. throw new NotImplementedException();
  5809. }
  5810. public void set_erp_printwaybill_cn()
  5811. {
  5812. if (UrlPostParmsCheck("ctid"))
  5813. {
  5814. string ctid = GetPostString("ctid");
  5815. string cpCode = GetPostString("cpcode");
  5816. string cpName = GetPostString("cpname");
  5817. string tempUrl = GetPostString("tempurl");
  5818. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5819. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5820. //string res = taobaoHelper.test();
  5821. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5822. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5823. {
  5824. int sidx = res.IndexOf("errorMsg");
  5825. int eidx = res.IndexOf("}");
  5826. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5827. var res_objzxx = new
  5828. {
  5829. restype = 0,
  5830. data = msg
  5831. };
  5832. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5833. returnSuccess(ro_jsonzxx);
  5834. //returnErrorMsg(msg);
  5835. return;
  5836. }
  5837. int idx = res.IndexOf("waybillCode");
  5838. int idx2 = res.IndexOf("printData");
  5839. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5840. string eid = GetPostString("ctid");
  5841. CeErpTradeCell entity = null;
  5842. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5843. if (entity != null)
  5844. {
  5845. string osid = entity.OutSid;
  5846. entity.OutSid = osid + "," + outsid;
  5847. entity.FinishDeliveryTime = DateTime.Now;
  5848. entity.OrderState = 7;
  5849. entity.UpdateTime = DateTime.Now;
  5850. entity.IsReturn = 0;
  5851. entity.Update();
  5852. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5853. exinfo.tid = entity.ctid;
  5854. exinfo.out_sid = outsid;
  5855. exinfo.company_code = cpCode;
  5856. exinfo.company_name = cpName;
  5857. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5858. exinfo.deliveryType = "发货成功";
  5859. exinfo.print_time = DateTime.Now;
  5860. exinfo.printUser = CurrentUser.UserName;
  5861. exinfo.Create();
  5862. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5863. {
  5864. commonHelper.sendCytExpress(exinfo);
  5865. }
  5866. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5867. }
  5868. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5869. var res_objz = new
  5870. {
  5871. restype = 1,
  5872. data = res
  5873. };
  5874. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5875. returnSuccess(ro_jsonz);
  5876. //ReturnSuccess(res);
  5877. }
  5878. }
  5879. ////打单,打印面单 获取面单号
  5880. //public void set_erp_printwaybill()
  5881. //{
  5882. // if (UrlPostParmsCheck("ctid"))
  5883. // {
  5884. // string ctid = GetPostString("ctid");
  5885. // string cpCode = GetPostString("cpcode");
  5886. // string tempUrl = GetPostString("tempurl");
  5887. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5888. // //string res = taobaoHelper.test();
  5889. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5890. // if (res.IndexOf("error_response") != -1)
  5891. // {
  5892. // int sidx = res.IndexOf("sub_msg");
  5893. // int eidx = res.IndexOf("request_id");
  5894. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5895. // returnErrorMsg(msg);
  5896. // return;
  5897. // }
  5898. // int idx = res.IndexOf("waybill_code");
  5899. // int idx2 = res.IndexOf("}]}");
  5900. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5901. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5902. // ReturnSuccess(res);
  5903. // }
  5904. //}
  5905. public void cancel_erp_aftersale()
  5906. {
  5907. if (UrlPostParmsCheck("ctid"))
  5908. {
  5909. string eid = GetPostString("ctid");
  5910. CeErpTradeCell entity = null;
  5911. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5912. if (entity != null)
  5913. {
  5914. //有过处理的售后,取消也不能删除 售 字,保留
  5915. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5916. {
  5917. entity.AfterSaleState = 4;
  5918. }
  5919. else
  5920. entity.AfterSaleState = 0;
  5921. entity.UpdateTime = DateTime.Now;
  5922. entity.Update();
  5923. returnSuccessMsg("操作成功!");
  5924. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5925. return;
  5926. }
  5927. returnErrorMsg("找不到订单记录");
  5928. }
  5929. }
  5930. public void get_erp_aftersalelist()
  5931. {
  5932. DataStruct dStruct = GetPostStruct();
  5933. List<string> lw = new List<string>();
  5934. int st = GetInt("st");
  5935. string tid = GetPostString("ctid");
  5936. if (st == 3)
  5937. {
  5938. if (tid.Length > 0)
  5939. {
  5940. string select_tid = getTidByCtid(tid);
  5941. lw.Add(string.Format("tid='{0}'", select_tid));
  5942. }
  5943. }
  5944. else
  5945. {
  5946. if (tid.Length > 0)
  5947. {
  5948. string select_tid = getTidByCtid(tid);
  5949. lw.Add(string.Format("tid='{0}'", select_tid));
  5950. }
  5951. }
  5952. string shopname = GetPostString("shopname");
  5953. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5954. string buyernick = GetPostString("buyer_nick");
  5955. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5956. string sellermemo = GetPostString("seller_memo");
  5957. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5958. string orderState = GetPostString("orderState");
  5959. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5960. string afterState = GetPostString("afterstate");
  5961. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5962. string date1 = GetPostString("date1");
  5963. string date2 = GetPostString("date2");
  5964. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5965. if (dw.Length > 0) lw.Add(dw);
  5966. string price1 = GetPostString("price1");
  5967. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5968. string price2 = GetPostString("price2");
  5969. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5970. //lw.Add(string.Format("IsRefund!={0}", 1));
  5971. string reason = GetPostString("reason");
  5972. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5973. string method = GetPostString("method");
  5974. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5975. string handler = GetPostString("handler");
  5976. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5977. string handledate1 = GetPostString("handledate1");
  5978. string handledate2 = GetPostString("handledate2");
  5979. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5980. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5981. string finish1 = GetPostString("finishdate1");
  5982. string finish2 = GetPostString("finishdate2");
  5983. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5984. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5985. string afterdate1 = GetPostString("afterdate1");
  5986. string afterdate2 = GetPostString("afterdate2");
  5987. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5988. if (afterDate.Length > 0) lw.Add(afterDate);
  5989. string supplier = GetPostString("supplier");
  5990. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5991. string responsible = GetPostString("responsibleman");
  5992. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5993. string customer = GetPostString("customer");
  5994. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5995. string design = GetPostString("design");
  5996. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5997. string afterMemoType = GetPostString("aftermemotype");
  5998. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5999. string posCode = CurrentUser.UserPost.Post.Code;
  6000. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6001. //{
  6002. // string vstate = GetPostString("vstate");
  6003. // if (vstate.Length > 0)
  6004. // {
  6005. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6006. // }
  6007. // if (posCode == "Supplier")
  6008. // {
  6009. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6010. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6011. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6012. // }
  6013. // else
  6014. // {
  6015. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6016. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6017. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6018. // {
  6019. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6020. // }
  6021. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6022. // {
  6023. // int orgid = CurrentUser.UserPost.OrgID;
  6024. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6025. // }
  6026. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6027. // {
  6028. // string shopid = CurrentUser.User.pemShop;
  6029. // lw.Add(string.Format("shopId in ({0})", shopid));
  6030. // }
  6031. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6032. // //{
  6033. // // int org_id = CurrentUser.UserPost.OrgID;
  6034. // // lw.Add(string.Format("OrgID={0}", org_id));
  6035. // //}
  6036. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6037. // }
  6038. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6039. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6040. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6041. //}
  6042. if (st == 5)
  6043. {
  6044. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6045. {
  6046. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6047. {
  6048. string shopid = CurrentUser.User.pemShop;
  6049. lw.Add(string.Format("shopId in ({0})", shopid));
  6050. }
  6051. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6052. {
  6053. int mrOrgid = CurrentUser.UserPost.OrgID;
  6054. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6055. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6056. }
  6057. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6058. //{
  6059. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6060. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6061. //}
  6062. else
  6063. {
  6064. string userIdStr = "";
  6065. if (posCode == "CustomerService")
  6066. {
  6067. userIdStr = CurrentUser.UserID + "_k";
  6068. }
  6069. else if (posCode == "Designer" || posCode == "wxDesigner")
  6070. {
  6071. userIdStr = CurrentUser.UserID + "_s";
  6072. }
  6073. else if (posCode == "Place")
  6074. {
  6075. userIdStr = CurrentUser.UserID + "_x";
  6076. }
  6077. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6078. }
  6079. }
  6080. string placedate1 = GetPostString("placedate1");
  6081. string placedate2 = GetPostString("placedate2");
  6082. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6083. if (dwplace.Length > 0) lw.Add(dwplace);
  6084. string supState = GetPostString("supState");
  6085. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6086. string searchType = GetPostString("searchType");
  6087. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6088. {
  6089. lw.Add(string.Format("BackNum>1"));
  6090. }
  6091. lw.Add(string.Format("AfterSaleState>0"));
  6092. if (ex_psize > 0)
  6093. {
  6094. if (CurrentUser.UserPost.Post.Code == "Finance")
  6095. dStruct.Order = "pay_time desc";
  6096. else
  6097. dStruct.Order = "HandleTime desc";
  6098. }
  6099. else
  6100. dStruct.Order = "HandleTime desc";
  6101. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6102. DataTable dt = WebCache.GetData("view_test", dStruct);
  6103. writeGridDataTableJson(dStruct.TotalCount, dt);
  6104. }
  6105. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6106. //{
  6107. // lw.Add(string.Format("AfterSaleState=4"));
  6108. // string code = CurrentUser.UserPost.Post.Code;
  6109. // if (code == "CustomerService")
  6110. // {
  6111. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6112. // }
  6113. // else if (code == "Designer" || code == "DesignerMr")
  6114. // {
  6115. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6116. // }
  6117. // else if (code == "Place" || code == "PlaceMr")
  6118. // {
  6119. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6120. // }
  6121. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6122. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6123. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6124. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6125. //}
  6126. //else //处理中的售后,待处理和处理中合并
  6127. //{
  6128. // if (afterState.Length <= 0)
  6129. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6130. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6131. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6132. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6133. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6134. //}
  6135. }
  6136. public void get_erp_disagreeftersalelist()
  6137. {
  6138. DataStruct dStruct = GetPostStruct();
  6139. List<string> lw = new List<string>();
  6140. int st = 2;
  6141. string tid = GetPostString("ctid");
  6142. if (tid.Length > 0)
  6143. {
  6144. string select_tid = getTidByCtid(tid);
  6145. lw.Add(string.Format("tid='{0}'", select_tid));
  6146. }
  6147. string shopname = GetPostString("shopname");
  6148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6149. string buyernick = GetPostString("buyer_nick");
  6150. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6151. string sellermemo = GetPostString("seller_memo");
  6152. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6153. string orderState = GetPostString("orderState");
  6154. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6155. string afterState = GetPostString("afterstate");
  6156. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6157. string date1 = GetPostString("date1");
  6158. string date2 = GetPostString("date2");
  6159. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6160. if (dw.Length > 0) lw.Add(dw);
  6161. string price1 = GetPostString("price1");
  6162. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6163. string price2 = GetPostString("price2");
  6164. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6165. //lw.Add(string.Format("IsRefund!={0}", 1));
  6166. string reason = GetPostString("reason");
  6167. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6168. string method = GetPostString("method");
  6169. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6170. string handler = GetPostString("handler");
  6171. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6172. string handledate1 = GetPostString("handledate1");
  6173. string handledate2 = GetPostString("handledate2");
  6174. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6175. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6176. string afterdate1 = GetPostString("afterdate1");
  6177. string afterdate2 = GetPostString("afterdate2");
  6178. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6179. if (afterDate.Length > 0) lw.Add(afterDate);
  6180. string backdate1 = GetPostString("backdate1");
  6181. string backdate2 = GetPostString("backdate2");
  6182. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6183. if (backDate.Length > 0) lw.Add(backDate);
  6184. string supplier = GetPostString("supplier");
  6185. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6186. string responsible = GetPostString("responsibleman");
  6187. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6188. string customer = GetPostString("customer");
  6189. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6190. string design = GetPostString("design");
  6191. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6192. string afterSaleMemo = GetPostString("afterSaleMemo");
  6193. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6194. string afterMemoType = GetPostString("aftermemotype");
  6195. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6196. string aftersakereason = GetPostString("aftersakereason");
  6197. if (aftersakereason.Length > 0)
  6198. {
  6199. if (aftersakereason == "1")
  6200. {
  6201. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6202. }
  6203. if (aftersakereason == "2")
  6204. {
  6205. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6206. }
  6207. }
  6208. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6209. string poscode = CurrentUser.UserPost.Post.Code;
  6210. if (poscode != "SysAdmin")
  6211. {
  6212. string shopid = CurrentUser.User.pemShop;
  6213. lw.Add(string.Format("shopId in ({0})", shopid));
  6214. }
  6215. string searchType = GetPostString("searchType");
  6216. if (searchType == "wait")
  6217. {
  6218. lw.Add(string.Format("HandleTime is null"));
  6219. }
  6220. if (searchType == "handling")
  6221. {
  6222. lw.Add(string.Format("HandleTime is not null "));
  6223. }
  6224. if (searchType == "back" || searchType == "puBack")
  6225. {
  6226. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6227. }
  6228. if (searchType == "reBack")
  6229. {
  6230. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6231. }
  6232. if (searchType == "moreBack")
  6233. {
  6234. lw.Add(string.Format("backNum > 1"));
  6235. }
  6236. lw.Add(string.Format("(AfterSaleState=5)"));
  6237. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6239. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6240. writeGridDataTableJson(dStruct.TotalCount, dt);
  6241. }
  6242. public void get_erp_handlingaftersalelist()
  6243. {
  6244. DataStruct dStruct = GetPostStruct();
  6245. List<string> lw = new List<string>();
  6246. int st = 2;
  6247. string tid = GetPostString("ctid");
  6248. if (tid.Length > 0)
  6249. {
  6250. string select_tid = getTidByCtid(tid);
  6251. lw.Add(string.Format("tid='{0}'", select_tid));
  6252. }
  6253. string shopname = GetPostString("shopname");
  6254. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6255. string buyernick = GetPostString("buyer_nick");
  6256. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6257. string sellermemo = GetPostString("seller_memo");
  6258. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6259. string orderState = GetPostString("orderState");
  6260. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6261. string afterState = GetPostString("afterstate");
  6262. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6263. string date1 = GetPostString("date1");
  6264. string date2 = GetPostString("date2");
  6265. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6266. if (dw.Length > 0) lw.Add(dw);
  6267. string price1 = GetPostString("price1");
  6268. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6269. string price2 = GetPostString("price2");
  6270. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6271. //lw.Add(string.Format("IsRefund!={0}", 1));
  6272. string reason = GetPostString("reason");
  6273. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6274. string method = GetPostString("method");
  6275. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6276. string handler = GetPostString("handler");
  6277. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6278. string handledate1 = GetPostString("handledate1");
  6279. string handledate2 = GetPostString("handledate2");
  6280. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6281. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6282. string afterdate1 = GetPostString("afterdate1");
  6283. string afterdate2 = GetPostString("afterdate2");
  6284. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6285. if (afterDate.Length > 0) lw.Add(afterDate);
  6286. string supplier = GetPostString("supplier");
  6287. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6288. string responsible = GetPostString("responsibleman");
  6289. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6290. string customer = GetPostString("customer");
  6291. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6292. string design = GetPostString("design");
  6293. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6294. string afterSaleMemo = GetPostString("afterSaleMemo");
  6295. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6296. string afterMemoType = GetPostString("aftermemotype");
  6297. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6298. string afterresult = GetPostString("afterresult");
  6299. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6300. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6301. string poscode = CurrentUser.UserPost.Post.Code;
  6302. if (poscode != "SysAdmin")
  6303. {
  6304. string shopid = CurrentUser.User.pemShop;
  6305. lw.Add(string.Format("shopId in ({0})", shopid));
  6306. }
  6307. string searchType = GetPostString("searchType");
  6308. if (searchType == "wait")
  6309. {
  6310. lw.Add(string.Format("HandleTime is null"));
  6311. }
  6312. if (searchType == "documentary")
  6313. {
  6314. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6315. }
  6316. if (searchType == "handling")
  6317. {
  6318. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6319. }
  6320. if (searchType == "back" || searchType == "puBack")
  6321. {
  6322. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6323. }
  6324. if (searchType == "reBack")
  6325. {
  6326. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6327. }
  6328. if (afterState.Length <= 0)
  6329. {
  6330. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6331. }
  6332. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6334. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6335. writeGridDataTableJson(dStruct.TotalCount, dt);
  6336. }
  6337. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6338. //public void get_erp_back_handlingaftersalelist()
  6339. //{
  6340. // DataStruct dStruct = GetPostStruct();
  6341. // List<string> lw = new List<string>();
  6342. // string tid = GetPostString("ctid");
  6343. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6344. // string shopname = GetPostString("shopname");
  6345. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6346. // string buyernick = GetPostString("buyer_nick");
  6347. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6348. // string sellermemo = GetPostString("seller_memo");
  6349. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6350. // string orderState = GetPostString("orderState");
  6351. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6352. // string afterState = GetPostString("afterstate");
  6353. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6354. // string date1 = GetPostString("date1");
  6355. // string date2 = GetPostString("date2");
  6356. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6357. // if (dw.Length > 0) lw.Add(dw);
  6358. // string price1 = GetPostString("price1");
  6359. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6360. // string price2 = GetPostString("price2");
  6361. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6362. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6363. // string reason = GetPostString("reason");
  6364. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6365. // string method = GetPostString("method");
  6366. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6367. // string handler = GetPostString("handler");
  6368. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6369. // string handledate1 = GetPostString("handledate1");
  6370. // string handledate2 = GetPostString("handledate2");
  6371. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6372. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6373. // string afterdate1 = GetPostString("afterdate1");
  6374. // string afterdate2 = GetPostString("afterdate2");
  6375. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6376. // if (afterDate.Length > 0) lw.Add(afterDate);
  6377. // string supplier = GetPostString("supplier");
  6378. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6379. // string responsible = GetPostString("responsibleman");
  6380. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6381. // string customer = GetPostString("customer");
  6382. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6383. // string design = GetPostString("design");
  6384. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6385. // string afterMemoType = GetPostString("aftermemotype");
  6386. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6387. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6388. // if (afterState.Length <= 0)
  6389. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6390. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6391. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6392. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6393. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6394. //}
  6395. public void get_erp_aftersaleverifylist()
  6396. {
  6397. DataStruct dStruct = GetPostStruct();
  6398. List<string> lw = new List<string>();
  6399. string tid = GetPostString("ctid");
  6400. if (tid.Length > 0)
  6401. {
  6402. string select_tid = getTidByCtid(tid);
  6403. lw.Add(string.Format("otid='{0}'", select_tid));
  6404. }
  6405. string shopname = GetPostString("shopname");
  6406. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6407. string buyernick = GetPostString("buyer_nick");
  6408. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6409. string sellermemo = GetPostString("seller_memo");
  6410. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6411. string orderState = GetPostString("orderState");
  6412. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6413. //lw.Add(string.Format("IsRefund!={0}", 1));
  6414. string reason = GetPostString("reason");
  6415. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6416. string method = GetPostString("method");
  6417. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6418. string handler = GetPostString("handler");
  6419. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6420. string handledate1 = GetPostString("handledate1");
  6421. string handledate2 = GetPostString("handledate2");
  6422. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6423. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6424. string finish1 = GetPostString("finishdate1");
  6425. string finish2 = GetPostString("finishdate2");
  6426. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6427. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6428. string supplier = GetPostString("supplier");
  6429. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6430. string responsible = GetPostString("responsibleman");
  6431. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6432. string posCode = CurrentUser.UserPost.Post.Code;
  6433. string vstate = GetPostString("vstate");
  6434. if (vstate.Length > 0)
  6435. {
  6436. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6437. }
  6438. if (posCode == "Supplier")
  6439. {
  6440. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6441. lw.Add(string.Format("VerifyState = 0"));
  6442. lw.Add("type = 1");
  6443. lw.Add(string.Format("AfterSaleState={0}", 3));
  6444. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6445. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6446. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6447. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6448. writeGridDataTableJson(dStruct.TotalCount, dt);
  6449. }
  6450. else if (posCode == "logistics")
  6451. {
  6452. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6453. lw.Add(string.Format("VerifyState = 0"));
  6454. lw.Add("type = 2");
  6455. lw.Add(string.Format("AfterSaleState={0}", 3));
  6456. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6457. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6458. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6459. writeGridDataTableJson(dStruct.TotalCount, dt);
  6460. }
  6461. else
  6462. {
  6463. lw.Add(string.Format("(AfterSaleState = 3)"));
  6464. string reasonState = GetPostString("reasonState");
  6465. lw.Add("type = 0");
  6466. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6467. || posCode == "Summarize" || posCode == "Finance")
  6468. {
  6469. if (reasonState == "2")
  6470. {
  6471. lw.Add("VerifyState = 3");
  6472. }
  6473. else if (reasonState == "1")
  6474. {
  6475. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6476. }
  6477. else
  6478. {
  6479. lw.Add("VerifyState in (0,3)");
  6480. }
  6481. //不加条件,可以看全部
  6482. }
  6483. 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")
  6484. {
  6485. int orgid = CurrentUser.UserPost.OrgID;
  6486. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6487. if (string.IsNullOrEmpty(manageOrgId))
  6488. {
  6489. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6490. }
  6491. else
  6492. {
  6493. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6494. }
  6495. if (reasonState == "1")
  6496. {
  6497. lw.Add("VerifyState = 3");
  6498. }
  6499. else if (reasonState == "2")
  6500. {
  6501. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6502. }
  6503. else
  6504. {
  6505. }
  6506. }
  6507. else
  6508. {
  6509. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6510. }
  6511. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6512. //{
  6513. // int org_id = CurrentUser.UserPost.OrgID;
  6514. // lw.Add(string.Format("OrgID={0}", org_id));
  6515. //}
  6516. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6517. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6518. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6519. writeGridDataTableJson(dStruct.TotalCount, dt);
  6520. }
  6521. }
  6522. public void get_erp_finishaftersalelist()
  6523. {
  6524. DataStruct dStruct = GetPostStruct();
  6525. List<string> lw = new List<string>();
  6526. int st = 4;
  6527. string tid = GetPostString("ctid");
  6528. if (tid.Length > 0)
  6529. {
  6530. string select_tid = getTidByCtid(tid);
  6531. lw.Add(string.Format("otid='{0}'", select_tid));
  6532. }
  6533. string shopname = GetPostString("shopname");
  6534. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6535. //lw.Add(string.Format("IsRefund!={0}", 1));
  6536. string reason = GetPostString("reason");
  6537. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6538. string method = GetPostString("method");
  6539. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6540. string buyernick = GetPostString("buyer_nick");
  6541. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6542. string handler = GetPostString("handler");
  6543. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6544. string handledate1 = GetPostString("handledate1");
  6545. string handledate2 = GetPostString("handledate2");
  6546. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6547. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6548. string finish1 = GetPostString("finishdate1");
  6549. string finish2 = GetPostString("finishdate2");
  6550. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6551. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6552. string supplier = GetPostString("supplier");
  6553. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6554. string responsible = GetPostString("responsibleman");
  6555. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6556. string vstate = GetPostString("vstate");
  6557. if (vstate.Length > 0)
  6558. {
  6559. if ("3".Equals(vstate))
  6560. {
  6561. lw.Add(string.Format("IsTem=1"));
  6562. }
  6563. else
  6564. {
  6565. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6566. }
  6567. }
  6568. lw.Add(string.Format("AfterSaleState=4"));
  6569. string code = CurrentUser.UserPost.Post.Code;
  6570. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6571. {
  6572. //不加条件,可以看全部
  6573. }
  6574. else if (code == "Supplier")
  6575. {
  6576. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6577. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6578. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6579. }
  6580. else if (code == "logistics")
  6581. {
  6582. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6583. lw.Add("type = 2");
  6584. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6585. }
  6586. 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")
  6587. {
  6588. int orgid = CurrentUser.UserPost.OrgID;
  6589. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6590. if (string.IsNullOrEmpty(manageOrgIds))
  6591. {
  6592. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6593. }
  6594. else
  6595. {
  6596. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6597. }
  6598. }
  6599. else
  6600. {
  6601. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6602. }
  6603. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6604. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6605. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6606. writeGridDataTableJson(dStruct.TotalCount, dt);
  6607. }
  6608. public void handle_erp_aftersale()
  6609. {
  6610. if (UrlPostParmsCheck("ctid"))
  6611. {
  6612. string eid = GetPostString("ctid");
  6613. string responStr = GetPostString("AfterSaleResponsible");
  6614. if (responStr.Length <= 0)
  6615. {
  6616. returnErrorMsg("售后责任人不能为空");
  6617. return;
  6618. }
  6619. bool isDesign = false;
  6620. double designFree = 0.00;
  6621. int responsibleId = 0;
  6622. CeErpTradeCell entity = null;
  6623. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6624. if (entity != null)
  6625. {
  6626. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6627. string afterMethod = GetPostString("AfterSaleMethod");
  6628. if (isNeedNewOrder == 1)
  6629. {
  6630. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6631. bool ishav = true;
  6632. if (newentity == null)
  6633. {
  6634. newentity = entity.Clone() as CeErpTradeCell;
  6635. ishav = false;
  6636. newentity.ctid = "S_" + entity.ctid;
  6637. newentity.OrderState = 0;
  6638. //唯一标识
  6639. newentity.OrderSn = newentity.ctid;
  6640. string orderSn = dataHelper.getSaleOrderSn();
  6641. if (orderSn != "")
  6642. {
  6643. newentity.OrderSn = orderSn;
  6644. }
  6645. }
  6646. newentity.UpdateTime = DateTime.Now;
  6647. newentity.AfterSaleState = 0;
  6648. newentity.AfterSaleMethod = afterMethod;
  6649. if (!ishav)
  6650. {
  6651. string memo_str = newentity.seller_memo;
  6652. memo_str = memo_str.Replace("(", "(");
  6653. memo_str = memo_str.Replace(")", ")");
  6654. int sIndex = memo_str.IndexOf("(");
  6655. int eIndex = memo_str.IndexOf(")");
  6656. if (sIndex == -1 || eIndex == -1)
  6657. {
  6658. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6659. return;
  6660. }
  6661. string first = memo_str.Substring(0, sIndex + 1);
  6662. string memoCtid = newentity.OrderSn;
  6663. //if (memoCtid.IndexOf("C") != -1)
  6664. //{
  6665. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6666. //if (CIdx.IndexOf("+") != -1)
  6667. //{
  6668. //CIdx = "C" + CIdx.Split('+')[1];
  6669. //}
  6670. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6671. //}
  6672. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6673. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6674. string newMemo = first + memoCtid + last;
  6675. newentity.seller_memo = newMemo;
  6676. newentity.FinishPlaceTime = null;
  6677. newentity.UnusualTag = 0;
  6678. newentity.UnusualCon = "";
  6679. newentity.UnusualTime = null;
  6680. newentity.AfterSaleMemo = "";
  6681. newentity.AfterSaleMethod = afterMethod;
  6682. newentity.AfterSalePreTime = null;
  6683. newentity.AfterSaleReason = "";
  6684. newentity.AfterSaleResponsible = "";
  6685. newentity.AfterSaleState = 0;
  6686. newentity.AfterSaleTime = null;
  6687. newentity.AfterSaleUserId = 0;
  6688. newentity.AfterSaleSupplierState = 0;
  6689. newentity.LastBillWaybillCode = "";
  6690. newentity.LastBillCpCode = "";
  6691. newentity.FinishAfterSaleTime = null;
  6692. newentity.HandleTime = null;
  6693. newentity.IsSF = 0;
  6694. newentity.IsOldCustomer = 0;
  6695. newentity.UrgencyTime = null;
  6696. newentity.ResponsibleUserId = "";
  6697. newentity.IsVerifyToSupplier = false;
  6698. newentity.payment = 0;
  6699. newentity.CheckMemo = "";
  6700. newentity.OutSid = "";
  6701. newentity.CheckOrderTime = null;
  6702. newentity.MemoOpt = 0;
  6703. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6704. }
  6705. newentity.isAfterSaleOrder = 1;
  6706. newentity.IsRefund = 0;
  6707. string receiveMobile = GetPostString("receiver_mobile");
  6708. if (receiveMobile.Length > 0)
  6709. {
  6710. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6711. if (trade != null)
  6712. {
  6713. trade.receiver_name = GetPostString("receiver_name");
  6714. trade.receiver_mobile = receiveMobile;
  6715. trade.receiver_state = GetPostString("receiver_state");
  6716. trade.receiver_city = GetPostString("receiver_city");
  6717. trade.receiver_district = GetPostString("receiver_district");
  6718. trade.receiver_address = GetPostString("receiver_address");
  6719. newentity.IsOffLineOrder = 1;
  6720. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6721. }
  6722. }
  6723. string st = GetPostString("ToState");
  6724. if (st.Length > 0)
  6725. {
  6726. if (newentity.OrderState <= 3)
  6727. {
  6728. newentity.WaitDesignTime = DateTime.Now;
  6729. newentity.StartDesignTime = null;
  6730. newentity.FinishDesignTime = null;
  6731. newentity.OrderState = 3;
  6732. if (st == "下单员")
  6733. {
  6734. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6735. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6736. {
  6737. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6738. }
  6739. }
  6740. else
  6741. {
  6742. newentity.WaitDesignTime = DateTime.Now;
  6743. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6744. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6745. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6746. {
  6747. DataRow user = dt1.Rows[0];
  6748. //找主管
  6749. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6750. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6751. if (dt != null && dt.Rows.Count > 0)
  6752. {
  6753. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6754. newentity.DesignUserId = designMr;
  6755. string key = "aftersale_order_" + designMr;
  6756. if (RedisHelper.HasKey(key))
  6757. {
  6758. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6759. list.Add(newentity.ctid);
  6760. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6761. }
  6762. }
  6763. //账号正常
  6764. if (user["State"].ToString() == "0")
  6765. {
  6766. newentity.DesignUserId = entity.DesignUserId;
  6767. string key = "aftersale_order_" + entity.DesignUserId;
  6768. if (RedisHelper.HasKey(key))
  6769. {
  6770. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6771. list.Add(newentity.ctid);
  6772. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6773. }
  6774. }
  6775. }
  6776. }
  6777. }
  6778. if (entity.IsXianHuo == 1)
  6779. {
  6780. newentity.OrderState = 6;
  6781. entity.FinishPlaceTime = DateTime.Now;
  6782. }
  6783. }
  6784. if (ishav)
  6785. {
  6786. newentity.Update();
  6787. }
  6788. else
  6789. {
  6790. newentity.Create();
  6791. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6792. newCellExtend.ctid = newentity.ctid;
  6793. newCellExtend.orderFrom = 20;
  6794. newCellExtend.orderType = 30;
  6795. if (st == "下单员")
  6796. {
  6797. }
  6798. else
  6799. {
  6800. newCellExtend.ReprintTime = DateTime.Now;
  6801. }
  6802. newCellExtend.Create();
  6803. }
  6804. if (st != "下单员")
  6805. {
  6806. if (entity.DispatchSort == 2)
  6807. {
  6808. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6809. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6810. }
  6811. }
  6812. }
  6813. //处理售后扩展
  6814. string resIdStr = GetPostString("ResponsibleUserId");
  6815. string refundFees = GetPostString("refundFrees");
  6816. int IsComplain = GetPostInt("isComplain");
  6817. int IsBad = GetPostInt("isBad");
  6818. string IsOriginal = GetPostString("isOriginal");
  6819. double diffResultPrice = GetPostDouble("diffResultPrice");
  6820. string textResult = GetPostString("textResult");
  6821. string supplierResponsible = GetPostString("supplierResponsible");
  6822. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6823. if (ceErpTradeAfterSaleExtend == null)
  6824. {
  6825. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6826. ceErpTradeAfterSaleExtend.tid = eid;
  6827. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6828. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6829. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6830. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6831. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6832. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6833. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6834. ceErpTradeAfterSaleExtend.Create();
  6835. }
  6836. else
  6837. {
  6838. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6839. {
  6840. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6841. }
  6842. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6843. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6844. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6845. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6846. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6847. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6848. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6849. ceErpTradeAfterSaleExtend.Update();
  6850. }
  6851. int gysid = GetPostInt("ResponsibleSupId");
  6852. if (entity.AfterSaleUserId == 0)
  6853. {
  6854. entity.AfterSaleUserId = CurrentUser.UserID;
  6855. }
  6856. entity.ResponsibleUserId = resIdStr;
  6857. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6858. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6859. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6860. {
  6861. CeErpTradeResponsible.DelByTid(eid, -1);
  6862. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6863. int backNum = 0;
  6864. if (number != null)
  6865. {
  6866. backNum = number.BackNum;
  6867. }
  6868. char[] separator = { ',' };
  6869. string[] sArray = resIdStr.Split(separator);
  6870. string[] refundFreeList = { };
  6871. if (refundFees.Length > 0)
  6872. {
  6873. refundFreeList = refundFees.Split(separator);
  6874. }
  6875. int index = -1;
  6876. foreach (string i in sArray)
  6877. {
  6878. index++;
  6879. if (i.Length <= 0) continue;
  6880. char[] separator2 = { '_' };
  6881. string idstr = i.Split(separator2)[0];
  6882. string idtype = i.Split(separator2)[1];
  6883. double refudFree = 0;
  6884. if (refundFreeList.Length > 0)
  6885. {
  6886. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6887. }
  6888. if (idtype == "s")
  6889. {
  6890. isDesign = true;
  6891. designFree = refudFree;
  6892. }
  6893. int userId = Convert.ToInt32(idstr);
  6894. int type = 0;
  6895. if (idtype == "g")
  6896. {
  6897. type = 1;
  6898. }
  6899. if (idtype == "w")
  6900. {
  6901. type = 2;
  6902. }
  6903. if (idtype == "t")
  6904. {
  6905. type = 3;
  6906. }
  6907. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6908. if (ceErpTradeResponsible == null)
  6909. {
  6910. ceErpTradeResponsible = new CeErpTradeResponsible();
  6911. ceErpTradeResponsible.tid = eid;
  6912. ceErpTradeResponsible.UserId = userId;
  6913. ceErpTradeResponsible.createdTime = DateTime.Now;
  6914. ceErpTradeResponsible.type = type;
  6915. if (type == 1)
  6916. {
  6917. ceErpTradeResponsible.IsSup = 1;
  6918. }
  6919. if (type == 2)
  6920. {
  6921. ceErpTradeResponsible.IsFlow = 1;
  6922. }
  6923. }
  6924. ceErpTradeResponsible.RefundFee = refudFree;
  6925. ceErpTradeResponsible.VerifyState = 0;
  6926. if (userId == 2125 || idtype == "w")
  6927. {
  6928. ceErpTradeResponsible.VerifyState = 1;
  6929. }
  6930. if (idtype == "w" && userId == 101)
  6931. {
  6932. ceErpTradeResponsible.VerifyState = 0;
  6933. }
  6934. if (ceErpTradeResponsible.ID > 0)
  6935. {
  6936. ceErpTradeResponsible.Update();
  6937. }
  6938. else
  6939. {
  6940. ceErpTradeResponsible.Create();
  6941. }
  6942. if (isDesign)
  6943. {
  6944. responsibleId = ceErpTradeResponsible.ID;
  6945. }
  6946. }
  6947. CeErpTradeResponsible.NumByTid(backNum, eid);
  6948. }
  6949. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6950. if (ceErpTradeCellExtend != null)
  6951. {
  6952. ceErpTradeCellExtend.returnVisit = 0;
  6953. ceErpTradeCellExtend.Update();
  6954. }
  6955. if (entity.HandleTime != null)
  6956. {
  6957. if (entity.AfterSaleState == 1)
  6958. {
  6959. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6960. }
  6961. else
  6962. {
  6963. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6964. }
  6965. }
  6966. else
  6967. {
  6968. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6969. entity.HandleTime = DateTime.Now;
  6970. }
  6971. bool isCompale = false;
  6972. if (entity.AfterSaleState == 5)
  6973. {
  6974. isCompale = true;
  6975. entity.AfterSaleState = 3;
  6976. }
  6977. entity.AfterSaleSupplierState = 0;
  6978. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6979. {
  6980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6981. }
  6982. string sImgs = GetPostString("img");
  6983. entity.AfterSaleSupplierImg = sImgs;
  6984. entity.supRefundType = GetPostString("supRefundType");
  6985. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6986. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6987. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6988. entity.AfterSaleMemoType = GetPostString("MemoType");
  6989. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6990. {
  6991. //entity.AfterSaleSupplierState = 2;
  6992. }
  6993. string df = GetPostString("DeductFee");
  6994. if (df == "")
  6995. {
  6996. df = "0";
  6997. }
  6998. string rf = GetPostString("RefundFee");
  6999. if (rf == "")
  7000. {
  7001. rf = "0";
  7002. }
  7003. string pm = GetPostString("AfterSalePayment");
  7004. if (pm == "")
  7005. {
  7006. pm = "0";
  7007. }
  7008. entity.AfterSalePayment = Convert.ToDouble(pm);
  7009. entity.DeductFee = Convert.ToDouble(df);
  7010. entity.RefundFee = Convert.ToDouble(rf);
  7011. entity.UpdateTime = DateTime.Now;
  7012. entity.Update();
  7013. string toState = GetPostString("ToState");
  7014. string original = GetPostString("isOriginal");
  7015. ApiVo apiVo = new ApiVo();
  7016. apiVo.orderNumber = entity.ctid;
  7017. apiVo.actionName = "afterDesign";
  7018. apiVo.orderRemarks = entity.AfterSaleMethod;
  7019. apiVo.reasonRemarks = entity.AfterSaleReason;
  7020. apiVo.isDesign = isDesign;
  7021. apiVo.designFree = designFree;
  7022. apiVo.responsibleId = responsibleId;
  7023. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7024. if (toState == "设计师")
  7025. {
  7026. apiVo.isOriginal = Convert.ToBoolean(original);
  7027. }
  7028. designHelper.API_WorkCore(apiVo);//afterDesign
  7029. CeErpMethod methodSql = new CeErpMethod();
  7030. methodSql.con = entity.AfterSaleMethod;
  7031. methodSql.addTime = DateTime.Now;
  7032. methodSql.Create();
  7033. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7034. CeErpMethod.ExecuteNonQuery(delsql);
  7035. if (isCompale)
  7036. {
  7037. aftersale_data_change(entity.ctid);
  7038. }
  7039. returnSuccessMsg("操作成功!");
  7040. return;
  7041. }
  7042. returnErrorMsg("找不到订单记录");
  7043. }
  7044. }
  7045. public void ins_erp_toresponsible()
  7046. {
  7047. if (UrlPostParmsCheck("ctid"))
  7048. {
  7049. string eid = GetPostString("ctid");
  7050. CeErpTradeCell entity = null;
  7051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7052. if (entity != null)
  7053. {
  7054. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7055. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7056. {
  7057. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7058. return;
  7059. }
  7060. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7061. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7062. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7063. if (entity.AfterSalePreTime == null)
  7064. {
  7065. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7066. {
  7067. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7068. }
  7069. }
  7070. entity.AfterSalePreTime = DateTime.Now;
  7071. //预完成给售后主管审核客户问题直接完成
  7072. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7073. {
  7074. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7075. {
  7076. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7077. }
  7078. }
  7079. ceErpTradeAfterSaleExtend.Update();
  7080. entity.AfterSaleState = 2;
  7081. entity.UpdateTime = DateTime.Now;
  7082. entity.Update();
  7083. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7084. aftersale_data_change(entity.ctid);
  7085. returnSuccessMsg("操作成功!");
  7086. return;
  7087. }
  7088. returnErrorMsg("找不到订单记录");
  7089. }
  7090. }
  7091. public void cancel_erp_aftersaleanddelnew()
  7092. {
  7093. if (UrlPostParmsCheck("ctid"))
  7094. {
  7095. string eid = GetPostString("ctid");
  7096. CeErpTradeCell entity = null;
  7097. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7098. if (entity != null)
  7099. {
  7100. entity.AfterSaleState = 0;
  7101. entity.AfterSaleReason = "";
  7102. entity.AfterSaleMethod = "";
  7103. entity.AfterSaleMemo = "";
  7104. entity.AfterSaleResponsible = "";
  7105. entity.ResponsibleUserId = "";
  7106. entity.DeductFee = 0;
  7107. entity.RefundFee = 0;
  7108. entity.IsArbitrate = 0;
  7109. CeErpTradeResponsible.DelByTid(eid, -1);
  7110. entity.Update();
  7111. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7112. if (after != null)
  7113. {
  7114. if (after.OrderState < 5)
  7115. CeErpTradeCell.DelByCtid("S_" + eid);
  7116. }
  7117. returnSuccessMsg("操作成功!");
  7118. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7119. return;
  7120. }
  7121. returnErrorMsg("找不到订单记录");
  7122. }
  7123. }
  7124. public void get_erp_aftersale_pregather()
  7125. {
  7126. List<string> lw = new List<string>();
  7127. int st = GetInt("st");
  7128. string tid = GetPostString("ctid");
  7129. if (tid.Length > 0)
  7130. {
  7131. string select_tid = getTidByCtid(tid);
  7132. lw.Add(string.Format("tid='{0}'", select_tid));
  7133. }
  7134. string shopname = GetPostString("shopname");
  7135. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7136. string buyernick = GetPostString("buyer_nick");
  7137. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7138. string sellermemo = GetPostString("seller_memo");
  7139. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7140. string orderState = GetPostString("orderState");
  7141. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7142. string reason = GetPostString("reason");
  7143. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7144. string method = GetPostString("method");
  7145. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7146. string handler = GetPostString("handler");
  7147. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7148. string handledate1 = GetPostString("handledate1");
  7149. string handledate2 = GetPostString("handledate2");
  7150. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7151. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7152. string supplier = GetPostString("supplier");
  7153. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7154. string responsible = GetPostString("responsibleman");
  7155. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7156. string customer = GetPostString("customer");
  7157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7158. string design = GetPostString("design");
  7159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7160. string afterMemoType = GetPostString("aftermemotype");
  7161. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7162. string afterSaleMemo = GetPostString("afterSaleMemo");
  7163. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7164. string afterresult = GetPostString("afterresult");
  7165. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7166. string poscode = CurrentUser.UserPost.Post.Code;
  7167. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7168. {
  7169. string shopid = CurrentUser.User.pemShop;
  7170. lw.Add(string.Format("shopId in ({0})", shopid));
  7171. }
  7172. var mainwhere = string.Join(" and ", lw.ToArray());
  7173. string ro_json = "";
  7174. string type = GetPostString("gather_type");
  7175. int number = 0;
  7176. if (poscode == "AfterSale")
  7177. {
  7178. //处理中
  7179. if (type == "Handling")
  7180. {
  7181. 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) : ""));
  7182. DataTable dt = null;
  7183. try
  7184. {
  7185. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7186. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7187. }
  7188. catch (Exception e)
  7189. {
  7190. dt = new DataTable();
  7191. }
  7192. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7193. return;
  7194. }
  7195. if (type == "Wait")
  7196. {
  7197. //待处理
  7198. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7199. DataTable dt1 = null;
  7200. try
  7201. {
  7202. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7203. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7204. }
  7205. catch (Exception e)
  7206. {
  7207. dt1 = new DataTable();
  7208. }
  7209. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7210. return;
  7211. }
  7212. if (type == "back")
  7213. {
  7214. //打回
  7215. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7216. DataTable dt2 = null;
  7217. try
  7218. {
  7219. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7220. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7221. }
  7222. catch (Exception e)
  7223. {
  7224. dt2 = new DataTable();
  7225. }
  7226. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7227. return;
  7228. }
  7229. if (type == "preCompletion")
  7230. {
  7231. //预完成
  7232. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7233. DataTable dt3 = null;
  7234. try
  7235. {
  7236. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7237. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7238. }
  7239. catch (Exception e)
  7240. {
  7241. dt3 = new DataTable();
  7242. }
  7243. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7244. return;
  7245. }
  7246. if (type == "documentary")
  7247. {
  7248. //跟单中
  7249. 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) : ""));
  7250. DataTable dt4 = null;
  7251. try
  7252. {
  7253. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7254. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7255. }
  7256. catch (Exception e)
  7257. {
  7258. dt4 = new DataTable();
  7259. }
  7260. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7261. return;
  7262. }
  7263. if (type == "reBack")
  7264. {
  7265. //被打回
  7266. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7267. DataTable dt1 = null;
  7268. try
  7269. {
  7270. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7271. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7272. }
  7273. catch (Exception e)
  7274. {
  7275. dt1 = new DataTable();
  7276. }
  7277. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7278. return;
  7279. }
  7280. }
  7281. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7282. {
  7283. if (type == "puBack")
  7284. {
  7285. //退回
  7286. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7287. DataTable dt = null;
  7288. try
  7289. {
  7290. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7291. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7292. }
  7293. catch (Exception e)
  7294. {
  7295. dt = new DataTable();
  7296. }
  7297. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7298. return;
  7299. }
  7300. if (type == "reBack")
  7301. {
  7302. //打回
  7303. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7304. DataTable dt1 = null;
  7305. try
  7306. {
  7307. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7308. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7309. }
  7310. catch (Exception e)
  7311. {
  7312. dt1 = new DataTable();
  7313. }
  7314. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7315. return;
  7316. }
  7317. if (type == "examEd")
  7318. {
  7319. //已审核
  7320. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7321. DataTable dt2 = null;
  7322. try
  7323. {
  7324. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7325. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7326. }
  7327. catch (Exception e)
  7328. {
  7329. dt2 = new DataTable();
  7330. }
  7331. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7332. return;
  7333. }
  7334. if (type == "waitExam")
  7335. {
  7336. //待审核
  7337. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7338. DataTable dt3 = null;
  7339. try
  7340. {
  7341. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7342. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7343. }
  7344. catch (Exception e)
  7345. {
  7346. dt3 = new DataTable();
  7347. }
  7348. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7349. return;
  7350. }
  7351. if (type == "Handling")
  7352. {
  7353. //处理中
  7354. 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) : ""));
  7355. DataTable dt4 = null;
  7356. try
  7357. {
  7358. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7359. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7360. }
  7361. catch (Exception e)
  7362. {
  7363. dt4 = new DataTable();
  7364. }
  7365. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7366. return;
  7367. }
  7368. if (type == "Wait")
  7369. {
  7370. //待处理
  7371. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7372. DataTable dt5 = null;
  7373. try
  7374. {
  7375. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7376. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7377. }
  7378. catch (Exception e)
  7379. {
  7380. dt5 = new DataTable();
  7381. }
  7382. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7383. return;
  7384. }
  7385. if (type == "documentary")
  7386. {
  7387. //跟单中
  7388. 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) : ""));
  7389. DataTable dt6 = null;
  7390. try
  7391. {
  7392. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7393. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7394. }
  7395. catch (Exception e)
  7396. {
  7397. dt6 = new DataTable();
  7398. }
  7399. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7400. return;
  7401. }
  7402. }
  7403. returnSuccess(ro_json);
  7404. }
  7405. public void end_erp_aftersale()
  7406. {
  7407. if (UrlPostParmsCheck("ctid"))
  7408. {
  7409. string eid = GetPostString("ctid");
  7410. CeErpTradeCell entity = null;
  7411. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7412. if (entity != null)
  7413. {
  7414. string stype = GetPostString("stype");
  7415. string typeStr = stype;
  7416. entity.AfterSaleState = 4;
  7417. entity.FinishAfterSaleTime = DateTime.Now;
  7418. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7419. entity.Update();
  7420. ApiVo apiVo = new ApiVo();
  7421. apiVo.orderNumber = entity.ctid;
  7422. apiVo.actionName = "afterOver";
  7423. designHelper.API_WorkCore(apiVo); //afterOver
  7424. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7425. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7426. CeErpSukuraData.createInfo(entity.ctid, 8);
  7427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7428. returnSuccessMsg("操作成功!");
  7429. return;
  7430. }
  7431. returnErrorMsg("找不到订单记录");
  7432. }
  7433. }
  7434. public void ins_erp_finishaftersale()
  7435. {
  7436. if (UrlPostParmsCheck("id"))
  7437. {
  7438. string eid = GetPostString("id");
  7439. CeErpTradeResponsible entity = null;
  7440. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7441. if (entity != null)
  7442. {
  7443. entity.VerifyState = 1;
  7444. entity.VerifyTime = DateTime.Now;
  7445. entity.Update();
  7446. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7447. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7448. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7449. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7450. if (dt.Rows.Count <= 0)
  7451. {
  7452. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7453. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7454. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7455. CeErpSukuraData.createInfo(entity.tid, 8);
  7456. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7457. {
  7458. CeErpDesignerBill.Del(entity.tid);
  7459. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7460. }
  7461. }
  7462. returnSuccessMsg("操作成功!");
  7463. return;
  7464. }
  7465. returnErrorMsg("找不到订单记录");
  7466. }
  7467. }
  7468. public void upd_erp_arbitrateaftersale()
  7469. {
  7470. if (UrlPostParmsCheck("id"))
  7471. {
  7472. string eid = GetPostString("id");
  7473. CeErpTradeResponsible entity = null;
  7474. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7475. if (entity != null)
  7476. {
  7477. entity.IsArbitrate = 1;
  7478. entity.ArbitradeMemo = GetPostString("reason");
  7479. entity.VerifyState = 2;
  7480. entity.Update();
  7481. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7482. if (tradecell != null)
  7483. {
  7484. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7485. tradecell.IsArbitrate = 1;
  7486. tradecell.Update();
  7487. }
  7488. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7489. returnSuccessMsg("操作成功!");
  7490. return;
  7491. }
  7492. returnErrorMsg("找不到订单记录");
  7493. }
  7494. }
  7495. public void upd_erp_backaftersale()
  7496. {
  7497. if (UrlPostParmsCheck("tid"))
  7498. {
  7499. string eid = GetPostString("tid");
  7500. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7501. int backNum = 0;
  7502. if (number != null)
  7503. {
  7504. backNum = number.BackNum;
  7505. }
  7506. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7507. CeErpTradeCell entity = null;
  7508. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7509. if (entity != null)
  7510. {
  7511. entity.AfterSaleBackReason = GetPostString("backreason");
  7512. entity.AfterSaleState = 1;
  7513. entity.AfterSaleSupplierState = 0;
  7514. entity.UpdateTime = DateTime.Now;
  7515. entity.Update();
  7516. returnSuccessMsg("操作成功!");
  7517. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7518. return;
  7519. }
  7520. returnErrorMsg("找不到订单记录");
  7521. }
  7522. }
  7523. public void get_erp_supplieraftersalelist()
  7524. {
  7525. DataStruct dStruct = GetPostStruct();
  7526. List<string> lw = new List<string>();
  7527. string tid = GetPostString("ctid");
  7528. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7529. string shopname = GetPostString("shopname");
  7530. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7531. string buyernick = GetPostString("buyer_nick");
  7532. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7533. string sellermemo = GetPostString("seller_memo");
  7534. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7535. string orderState = GetPostString("orderState");
  7536. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7537. string afterState = GetPostString("afterstate");
  7538. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7539. string date1 = GetPostString("date1");
  7540. string date2 = GetPostString("date2");
  7541. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7542. if (dw.Length > 0) lw.Add(dw);
  7543. string price1 = GetPostString("price1");
  7544. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7545. string price2 = GetPostString("price2");
  7546. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7547. string reason = GetPostString("reason");
  7548. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7549. string method = GetPostString("method");
  7550. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7551. string handledate1 = GetPostString("handledate1");
  7552. string handledate2 = GetPostString("handledate2");
  7553. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7554. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7555. string handler = GetPostString("handler");
  7556. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7557. string afterdate1 = GetPostString("afterdate1");
  7558. string afterdate2 = GetPostString("afterdate2");
  7559. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7560. if (afterDate.Length > 0) lw.Add(afterDate);
  7561. string customer = GetPostString("customer");
  7562. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7563. string design = GetPostString("design");
  7564. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7565. string afterMemoType = GetPostString("aftermemotype");
  7566. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7567. string vstate = GetPostString("vstate");
  7568. if (vstate.Length > 0)
  7569. {
  7570. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7571. }
  7572. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7573. string supplier = GetPostString("supplier");
  7574. int supid = commonHelper.getSupplierIDByName(supplier);
  7575. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7576. string posCode = CurrentUser.UserPost.Post.Code;
  7577. if (posCode == "Supplier")
  7578. {
  7579. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7580. }
  7581. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7582. {
  7583. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7584. }
  7585. else
  7586. {
  7587. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7588. }
  7589. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7590. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7591. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7592. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7593. writeGridDataTableJson(dStruct.TotalCount, dt);
  7594. }
  7595. public void upd_erp_supverifyaftersale()
  7596. {
  7597. if (UrlPostParmsCheck("id"))
  7598. {
  7599. string id = GetPostString("id");
  7600. int st = GetPostInt("afterstate");
  7601. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7602. CeErpTradeCell entity = null;
  7603. if (ceErpTradeResponsible != null)
  7604. {
  7605. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7606. }
  7607. string afmemo = GetPostString("supmemo");
  7608. string image = GetPostString("image");
  7609. if (entity != null)
  7610. {
  7611. entity.AfterSaleSupplierState = st;
  7612. entity.AfterSaleSupplierMemo = afmemo;
  7613. if (st == 1)
  7614. {
  7615. ceErpTradeResponsible.VerifyState = 1;
  7616. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7617. ceErpTradeResponsible.Update();
  7618. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7619. if (isAll)
  7620. {
  7621. entity.AfterSaleState = 4;
  7622. entity.FinishAfterSaleTime = DateTime.Now;
  7623. }
  7624. }
  7625. else
  7626. {
  7627. CeErpTradeResponsible.dateByTid(entity.ctid);
  7628. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7629. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7630. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7631. if (num <= 1)
  7632. {
  7633. entity.AfterSaleState = 1;
  7634. }
  7635. else
  7636. {
  7637. entity.AfterSaleState = 5;
  7638. }
  7639. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7640. if (ceErpTradeAfterSaleExtend != null)
  7641. {
  7642. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7643. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7644. ceErpTradeAfterSaleExtend.Update();
  7645. }
  7646. else
  7647. {
  7648. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7649. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7650. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7651. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7652. ceErpTradeAfterSaleExtend.Create();
  7653. }
  7654. }
  7655. if (entity.AfterSaleState == 4)
  7656. {
  7657. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7658. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7659. {
  7660. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7661. }
  7662. ApiVo apiVo = new ApiVo();
  7663. apiVo.orderNumber = entity.ctid;
  7664. apiVo.actionName = "afterOver";
  7665. designHelper.API_WorkCore(apiVo); //afterOver
  7666. }
  7667. entity.UpdateTime = DateTime.Now;
  7668. entity.Update();
  7669. returnSuccessMsg("操作成功!");
  7670. CeErpSukuraData.createInfo(entity.ctid, 8);
  7671. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7672. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7673. return;
  7674. }
  7675. returnErrorMsg("找不到订单记录");
  7676. }
  7677. }
  7678. public void upd_erp_masteraftersale()
  7679. {
  7680. if (UrlPostParmsCheck("id"))
  7681. {
  7682. string id = GetPostString("id");
  7683. int st = GetPostInt("afterstate");
  7684. string afmemo = GetPostString("supmemo");
  7685. string image = GetPostString("image");
  7686. string textResult = GetPostString("textResult");
  7687. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7688. if (ceErpTradeResponsible != null)
  7689. {
  7690. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7691. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7692. ceErpTradeResponsible.Update();
  7693. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7694. if (entity != null)
  7695. {
  7696. entity.AfterSaleSupplierState = st;
  7697. entity.AfterSaleSupplierMemo = afmemo;
  7698. if (st == 1)
  7699. {
  7700. }
  7701. else
  7702. {
  7703. CeErpTradeResponsible.dateByTid(entity.ctid);
  7704. //退回到售后
  7705. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7706. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7707. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7708. if (num <= 1)
  7709. {
  7710. entity.AfterSaleState = 1;
  7711. }
  7712. else
  7713. {
  7714. entity.AfterSaleState = 5;
  7715. }
  7716. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7717. if (ceErpTradeAfterSaleExtend != null)
  7718. {
  7719. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7720. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7721. ceErpTradeAfterSaleExtend.Update();
  7722. }
  7723. else
  7724. {
  7725. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7726. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7727. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7728. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7729. ceErpTradeAfterSaleExtend.Create();
  7730. }
  7731. }
  7732. entity.UpdateTime = DateTime.Now;
  7733. entity.Update();
  7734. returnSuccessMsg("操作成功!");
  7735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7736. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7737. return;
  7738. }
  7739. }
  7740. returnErrorMsg("找不到订单记录");
  7741. }
  7742. }
  7743. public void upd_erp_personaftersale()
  7744. {
  7745. if (UrlPostParmsCheck("id"))
  7746. {
  7747. //林小连
  7748. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7749. {
  7750. upd_erp_masteraftersale();
  7751. return;
  7752. }
  7753. string id = GetPostString("id");
  7754. int st = GetPostInt("afterstate");
  7755. string afmemo = GetPostString("supmemo");
  7756. string image = GetPostString("image");
  7757. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7758. if (ceErpTradeResponsible != null)
  7759. {
  7760. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7761. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7762. ceErpTradeResponsible.Update();
  7763. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7764. if (entity != null)
  7765. {
  7766. entity.AfterSaleSupplierMemo = afmemo;
  7767. entity.AfterSaleSupplierState = st;
  7768. if (st == 1)
  7769. {
  7770. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7771. if (isAll)
  7772. {
  7773. entity.AfterSaleState = 4;
  7774. entity.FinishAfterSaleTime = DateTime.Now;
  7775. }
  7776. }
  7777. else
  7778. {
  7779. CeErpTradeResponsible.dateByTid(entity.ctid);
  7780. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7781. if (ceErpTradeAfterSaleExtend != null)
  7782. {
  7783. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7784. ceErpTradeAfterSaleExtend.Update();
  7785. }
  7786. else
  7787. {
  7788. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7789. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7790. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7791. ceErpTradeAfterSaleExtend.Create();
  7792. }
  7793. //退回到主管
  7794. //entity.AfterSaleState = 2;
  7795. }
  7796. if (entity.AfterSaleState == 4)
  7797. {
  7798. ApiVo apiVo = new ApiVo();
  7799. apiVo.orderNumber = entity.ctid;
  7800. apiVo.actionName = "afterOver";
  7801. designHelper.API_WorkCore(apiVo); //afterOver
  7802. }
  7803. entity.UpdateTime = DateTime.Now;
  7804. entity.Update();
  7805. returnSuccessMsg("操作成功!");
  7806. CeErpSukuraData.createInfo(entity.ctid, 8);
  7807. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7808. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7809. return;
  7810. }
  7811. }
  7812. returnErrorMsg("找不到订单记录");
  7813. }
  7814. }
  7815. public void set_erp_supplierrefundtag()
  7816. {
  7817. if (UrlPostParmsCheck("ctid"))
  7818. {
  7819. string eid = GetPostString("ctid");
  7820. CeErpTradeCell entity = null;
  7821. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7822. if (entity != null)
  7823. {
  7824. entity.IsSupplierRefund = GetPostInt("tag");
  7825. entity.Update();
  7826. returnSuccessMsg("操作成功!");
  7827. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7828. return;
  7829. }
  7830. returnErrorMsg("找不到订单记录");
  7831. }
  7832. }
  7833. public void get_erp_refundlist()
  7834. {
  7835. DataStruct dStruct = GetPostStruct();
  7836. List<string> lw = new List<string>();
  7837. string tid = GetPostString("tid");
  7838. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7839. //string rid = GetPostString("refund_id");
  7840. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7841. string shopname = GetPostString("shopname");
  7842. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7843. string buyernick = GetPostString("buyer_nick");
  7844. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7845. string customer = GetPostString("customer");
  7846. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7847. string design = GetPostString("design");
  7848. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7849. string sellermemo = GetPostString("seller_memo");
  7850. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7851. //string date1 = GetPostString("date1");
  7852. //string date2 = GetPostString("date2");
  7853. //string dateType = GetPostString("dateType");
  7854. //if (dateType.Length > 0)
  7855. //{
  7856. // if (dateType == "1001") dateType = "0";
  7857. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7858. // if (searchDT.Count == 2)
  7859. // {
  7860. // date1 = searchDT[0].ToString();
  7861. // date2 = searchDT[1].ToString();
  7862. // }
  7863. //}
  7864. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7865. //if (dw.Length > 0) lw.Add(dw);
  7866. string redate1 = GetPostString("refunddate1");
  7867. string redate2 = GetPostString("refunddate2");
  7868. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7869. if (dwdate.Length > 0) lw.Add(dwdate);
  7870. string price1 = GetPostString("price1");
  7871. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7872. string price2 = GetPostString("price2");
  7873. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7874. string ispartrefund = GetPostString("ispartrefund");
  7875. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7876. string refundState = GetPostString("refundvstate");
  7877. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7878. int st = GetInt("st");
  7879. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7880. {
  7881. string responsible = GetPostString("responsibleman");
  7882. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7883. lw.Add(string.Format("RefundState>={0}", st));
  7884. string code = CurrentUser.UserPost.Post.Code;
  7885. if (code == "CustomerService")
  7886. {
  7887. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7888. }
  7889. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7890. {
  7891. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7892. }
  7893. else if (code == "Place" || code == "PlaceMr")
  7894. {
  7895. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7896. }
  7897. dStruct.Order = "RefundState asc,created desc";
  7898. }
  7899. else if (st == 10)
  7900. {
  7901. string responsible = GetPostString("responsibleman");
  7902. if (responsible == "空白")
  7903. {
  7904. lw.Add(string.Format("ResponsibleUserName = ''"));
  7905. }
  7906. else if (responsible.Length > 0)
  7907. {
  7908. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7909. }
  7910. lw.Add(string.Format("RefundState>=0"));
  7911. dStruct.Order = "created desc";
  7912. }
  7913. else
  7914. {
  7915. string responsible = GetPostString("responsibleman");
  7916. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7917. lw.Add(string.Format("RefundState={0}", st));
  7918. dStruct.Order = "created desc";
  7919. }
  7920. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7921. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7922. dt.Columns.Add("refund_fees");
  7923. foreach (DataRow dr in dt.Rows)
  7924. {
  7925. String status = dr["status"].ToString();
  7926. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7927. {
  7928. dr["refund_fees"] = dr["refund_fee"];
  7929. }
  7930. else
  7931. {
  7932. dr["refund_fees"] = "0.0";
  7933. }
  7934. }
  7935. writeGridDataTableJson(dStruct.TotalCount, dt);
  7936. }
  7937. public void get_erp_refunddesignlist()
  7938. {
  7939. DataStruct dStruct = GetPostStruct();
  7940. List<string> lw = new List<string>();
  7941. string tid = GetPostString("tid");
  7942. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7943. string shopname = GetPostString("shopname");
  7944. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7945. string buyernick = GetPostString("buyer_nick");
  7946. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7947. string customer = GetPostString("customer");
  7948. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7949. string design = GetPostString("design");
  7950. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7951. string sellermemo = GetPostString("seller_memo");
  7952. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7953. string redate1 = GetPostString("refunddate1");
  7954. string redate2 = GetPostString("refunddate2");
  7955. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7956. if (dwdate.Length > 0) lw.Add(dwdate);
  7957. string price1 = GetPostString("price1");
  7958. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7959. string price2 = GetPostString("price2");
  7960. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7961. string ispartrefund = GetPostString("ispartrefund");
  7962. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7963. string designerorg = GetPostString("designerorg");
  7964. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7965. string refundState = GetPostString("refundState");
  7966. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7967. int myOrgid = CurrentUser.UserPost.OrgID;
  7968. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7969. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7970. {
  7971. if (CurrentUser.User.TeamIds.Length > 0)
  7972. {
  7973. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7974. }
  7975. else
  7976. {
  7977. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7978. }
  7979. }
  7980. else if ("SysAdmin".Equals(myOrgCode))
  7981. {
  7982. }
  7983. else
  7984. {
  7985. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7986. {
  7987. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7988. }
  7989. else
  7990. {
  7991. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7992. }
  7993. }
  7994. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7995. dStruct.Order = "created desc";
  7996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7997. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7998. dt.Columns.Add("refund_fees");
  7999. foreach (DataRow dr in dt.Rows)
  8000. {
  8001. String status = dr["status"].ToString();
  8002. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8003. {
  8004. dr["refund_fees"] = dr["refund_fee"];
  8005. }
  8006. else
  8007. {
  8008. dr["refund_fees"] = "0.0";
  8009. }
  8010. }
  8011. writeGridDataTableJson(dStruct.TotalCount, dt);
  8012. }
  8013. public void handle_erp_refundtag()
  8014. {
  8015. if (UrlPostParmsCheck("refund_id"))
  8016. {
  8017. string eid = GetPostString("refund_id");
  8018. string respMan = GetPostString("ResponsibleName");
  8019. if (respMan.Length <= 0)
  8020. {
  8021. returnErrorMsg("责任人不能为空");
  8022. return;
  8023. }
  8024. CeErpTradeRefund entity = null;
  8025. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8026. if (entity != null)
  8027. {
  8028. entity.ResponsibleUserName = respMan;
  8029. string userid = GetPostString("ResponsibleUserId");
  8030. if (userid.Length > 0)
  8031. {
  8032. entity.ResponsibleUserId = userid;
  8033. }
  8034. entity.Memo = GetPostString("Memo");
  8035. if (respMan.IndexOf("客服") != -1 ||
  8036. respMan.IndexOf("设计师") != -1 ||
  8037. respMan.IndexOf("下单员") != -1)
  8038. {
  8039. entity.RefundState = 2;
  8040. }
  8041. else
  8042. {
  8043. entity.RefundState = 3;
  8044. }
  8045. entity.modified = DateTime.Now;
  8046. entity.Update();
  8047. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8048. returnSuccessMsg("操作成功!");
  8049. return;
  8050. }
  8051. returnErrorMsg("找不到订单记录");
  8052. }
  8053. }
  8054. public void handle_erp_designrefundtag()
  8055. {
  8056. if (UrlPostParmsCheck("refund_id"))
  8057. {
  8058. string eid = GetPostString("refund_id");
  8059. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8060. if (ceErpTradeCellExtend == null)
  8061. {
  8062. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8063. ceErpTradeCellExtend.ctid = eid;
  8064. }
  8065. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8066. if (ceErpTradeCellExtend.ID > 0)
  8067. {
  8068. ceErpTradeCellExtend.Update();
  8069. }
  8070. else
  8071. {
  8072. ceErpTradeCellExtend.Create();
  8073. }
  8074. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8075. returnSuccessMsg("操作成功!");
  8076. return;
  8077. }
  8078. returnErrorMsg("找不到订单记录");
  8079. }
  8080. public void upd_erp_refundverify()
  8081. {
  8082. if (UrlPostParmsCheck("refund_id"))
  8083. {
  8084. string eid = GetPostString("refund_id");
  8085. CeErpTradeRefund entity = null;
  8086. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8087. if (entity != null)
  8088. {
  8089. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8090. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8091. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8092. {
  8093. entity.RefundState = 2;
  8094. }
  8095. else
  8096. {
  8097. entity.RefundState = 3;
  8098. }
  8099. entity.Update();
  8100. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8101. returnSuccessMsg("操作成功!");
  8102. return;
  8103. }
  8104. returnErrorMsg("找不到订单记录");
  8105. }
  8106. }
  8107. public void upd_erp_refundapprove()
  8108. {
  8109. if (UrlPostParmsCheck("refund_id"))
  8110. {
  8111. string eid = GetPostString("refund_id");
  8112. CeErpTradeRefund entity = null;
  8113. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8114. if (entity != null)
  8115. {
  8116. int apr = GetPostInt("approve");
  8117. if (apr == 0)
  8118. {
  8119. entity.RefundState = 1;
  8120. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8121. }
  8122. else if (apr == 1)
  8123. {
  8124. entity.RefundState = 3;
  8125. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8126. }
  8127. entity.modified = DateTime.Now;
  8128. entity.Update();
  8129. returnSuccessMsg("操作成功!");
  8130. return;
  8131. }
  8132. returnErrorMsg("找不到订单记录");
  8133. }
  8134. }
  8135. public void get_erp_billlist()
  8136. {
  8137. DataStruct dStruct = GetPostStruct();
  8138. List<string> lw = new List<string>();
  8139. string title = GetPostString("title");
  8140. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8141. string tid = GetPostString("tid");
  8142. string tids = GetPostString("tids");
  8143. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8144. if (tids.Length > 0)
  8145. {
  8146. tids = "'" + tids + "'";
  8147. tids = tids.Replace(",", "','");
  8148. lw.Add(string.Format("tid in ({0})", tids));
  8149. }
  8150. string shopname = GetPostString("shopname");
  8151. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8152. string buyernick = GetPostString("buyer_nick");
  8153. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8154. string customer = GetPostString("customer");
  8155. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8156. string date1 = GetPostString("date1");
  8157. string date2 = GetPostString("date2");
  8158. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8159. if (dw.Length > 0) lw.Add(dw);
  8160. string price1 = GetPostString("price1");
  8161. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8162. string price2 = GetPostString("price2");
  8163. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8164. string returndate1 = GetPostString("returndate1");
  8165. string returndate2 = GetPostString("returndate2");
  8166. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8167. if (dw1.Length > 0) lw.Add(dw1);
  8168. string billtype = GetPostString("billtype");
  8169. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8170. string billstate = GetPostString("billstate");
  8171. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8172. string usershop = CurrentUser.User.pemShop;
  8173. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8174. dStruct.Order = "createTime desc";
  8175. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8176. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8177. //foreach (DataRow dr in dt.Rows)
  8178. //{
  8179. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8180. //}
  8181. writeGridDataTableJson(dStruct.TotalCount, dt);
  8182. }
  8183. public void modify_erp_billinfo()
  8184. {
  8185. if (UrlPostParmsCheck("ID"))
  8186. {
  8187. string eid = GetPostString("ID");
  8188. CeErpBill bill_entity = null;
  8189. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8190. if (bill_entity != null)
  8191. {
  8192. bill_entity.tid = GetPostString("tid");
  8193. bill_entity.title = GetPostString("title");
  8194. bill_entity.tax = GetPostString("tax");
  8195. bill_entity.bank = GetPostString("bank");
  8196. bill_entity.bankac = GetPostString("bankac");
  8197. bill_entity.address = GetPostString("address");
  8198. bill_entity.phone = GetPostString("phone");
  8199. bill_entity.price = GetPostString("price");
  8200. bill_entity.productId = GetPostInt("ProductName");
  8201. bill_entity.num = GetPostInt("num");
  8202. bill_entity.unit = GetPostString("unit");
  8203. bill_entity.type = GetPostString("type");
  8204. bill_entity.sendType = GetPostString("SendType");
  8205. bill_entity.email = GetPostString("email");
  8206. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8207. bill_entity.shopName = GetPostString("ShopName");
  8208. bill_entity.applymemo = GetPostString("applymemo");
  8209. bill_entity.modifyTime = DateTime.Now;
  8210. bill_entity.createTime = DateTime.Now;
  8211. bill_entity.state = 0;
  8212. bill_entity.Update();
  8213. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8214. returnSuccessMsg("发票修改成功!");
  8215. return;
  8216. }
  8217. returnErrorMsg("找不到对应记录");
  8218. }
  8219. }
  8220. public void set_erp_invoicing()
  8221. {
  8222. if (UrlPostParmsCheck("id"))
  8223. {
  8224. try
  8225. {
  8226. string eid = GetPostString("id");
  8227. CeErpBill bill_entity = null;
  8228. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8229. if (bill_entity != null)
  8230. {
  8231. int ComId = GetPostInt("ComId");
  8232. //string memo = GetPostString("Memo");
  8233. int allInfo = GetPostInt("allinfo");
  8234. string clert = CurrentUser.User.Name;
  8235. //string detailValue = GetPostString("detailvalue");
  8236. string billId = bill_entity.billOrderId;
  8237. string[] billIdList = billId.Split(',');
  8238. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8239. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8240. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8241. {
  8242. billCount += 1;
  8243. }
  8244. if (billId.Length <= 0 || billIdList.Length != billCount)
  8245. {
  8246. bill_entity.billOrderId = "";
  8247. string prebill = "ltb";
  8248. for (int idx = 1; idx <= billCount; idx++)
  8249. {
  8250. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8251. string billoid = prebill + idx + dtstr;
  8252. bill_entity.billOrderId += billoid;
  8253. if (idx < billCount)
  8254. {
  8255. bill_entity.billOrderId += ",";
  8256. }
  8257. }
  8258. }
  8259. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8260. if (bill_entity.state == 5)
  8261. {
  8262. string errMsg = bill_entity.failerror;
  8263. string[] errlist = errMsg.Split('|');
  8264. string[] errTags = new string[errlist.Length];
  8265. for (int itag = 0; itag < errlist.Length; itag++)
  8266. {
  8267. if (errlist[itag].Length <= 0) continue;
  8268. errTags[itag] = errlist[itag].Split('&')[0];
  8269. }
  8270. for (int iii = 0; iii < errTags.Length; iii++)
  8271. {
  8272. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8273. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8274. if (billOrderList.Length >= erroBillOrderTag)
  8275. {
  8276. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8277. if (needModifyBillId.Length <= 19)
  8278. {
  8279. needModifyBillId = needModifyBillId + "1";
  8280. }
  8281. else
  8282. {
  8283. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8284. last = last + 1;
  8285. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8286. }
  8287. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8288. }
  8289. }
  8290. }
  8291. bool isHaveBillSucces = false;
  8292. string totalRes = "";
  8293. bill_entity.failerror = "";
  8294. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8295. {
  8296. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8297. totalRes += res;
  8298. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8299. {
  8300. isHaveBillSucces = true;
  8301. bill_entity.comId = ComId;
  8302. bill_entity.state = 1;
  8303. bill_entity.executeTime = DateTime.Now;
  8304. bill_entity.executeUser = clert;
  8305. }
  8306. else
  8307. {
  8308. bill_entity.state = 5;
  8309. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8310. }
  8311. }
  8312. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8313. bill_entity.Update();
  8314. if (isHaveBillSucces)
  8315. {
  8316. StringBuilder sql = new StringBuilder();
  8317. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8318. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8319. }
  8320. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8321. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8322. {
  8323. returnErrorMsg("开票失败");
  8324. }
  8325. else
  8326. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8327. return;
  8328. }
  8329. returnErrorMsg("找不到对应记录");
  8330. }
  8331. catch (Exception ex)
  8332. {
  8333. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8334. returnErrorMsg("操作失败");
  8335. }
  8336. }
  8337. }
  8338. public void get_erp_invoicing_back()
  8339. {
  8340. if (UrlPostParmsCheck("id"))
  8341. {
  8342. try
  8343. {
  8344. string id = GetPostString("id");
  8345. CeErpBill entiy = CeErpBill.Get(id);
  8346. if (entiy != null)
  8347. {
  8348. if (entiy.state == 0)
  8349. {
  8350. returnErrorMsg("发票还未开具");
  8351. return;
  8352. }
  8353. string[] billOrderList = entiy.billOrderId.Split(',');
  8354. int iTag = 0;
  8355. entiy.fplsh = "";
  8356. entiy.fpdm = "";
  8357. entiy.fphm = "";
  8358. foreach (string billOrderId in billOrderList)
  8359. {
  8360. iTag++;
  8361. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8362. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8363. {
  8364. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8365. try
  8366. {
  8367. Invoicing_get_response_Obj iObj = null;
  8368. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8369. if (iObj != null)
  8370. {
  8371. entiy.state = 2;
  8372. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8373. entiy.fpdm += iObj.list[0].c_fpdm;
  8374. entiy.fphm += iObj.list[0].c_fphm;
  8375. if (iTag < billOrderList.Length)
  8376. {
  8377. entiy.fplsh += ",";
  8378. entiy.fpdm += ",";
  8379. entiy.fphm += ",";
  8380. }
  8381. entiy.Update();
  8382. }
  8383. StringBuilder sql = new StringBuilder();
  8384. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8385. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8386. returnSuccessMsg("开票成功");
  8387. }
  8388. catch (Exception ex)
  8389. {
  8390. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8391. }
  8392. return;
  8393. }
  8394. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8395. {
  8396. var res_obj = new
  8397. {
  8398. data = "开票中"
  8399. };
  8400. string ro_json = JsonConvert.SerializeObject(res_obj);
  8401. returnSuccess(ro_json);
  8402. return;
  8403. }
  8404. else
  8405. {
  8406. int eidx = res.IndexOf("c_resultmsg");
  8407. int lidx = res.IndexOf("c_status");
  8408. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8409. entiy.state = 5;
  8410. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8411. entiy.Update();
  8412. returnErrorMsg("开票失败");
  8413. return;
  8414. }
  8415. }
  8416. }
  8417. }
  8418. catch (Exception ex)
  8419. {
  8420. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8421. }
  8422. return;
  8423. }
  8424. }
  8425. public void get_erp_invoicing()
  8426. {
  8427. if (UrlPostParmsCheck("id"))
  8428. {
  8429. try
  8430. {
  8431. string id = GetPostString("id");
  8432. CeErpBill entiy = CeErpBill.Get(id);
  8433. if (entiy != null)
  8434. {
  8435. if (entiy.state == 0)
  8436. {
  8437. returnErrorMsg("发票还未开具");
  8438. return;
  8439. }
  8440. if (entiy.sendType == "纸质发票")
  8441. {
  8442. if (entiy.img.Length <= 0)
  8443. {
  8444. returnErrorMsg("查无纸质发票");
  8445. return;
  8446. }
  8447. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8448. returnSuccess(returnres);
  8449. return;
  8450. }
  8451. string[] billOrderList = entiy.billOrderId.Split(',');
  8452. int iTag = 0;
  8453. string fpUrl = "";
  8454. entiy.fplsh = "";
  8455. entiy.fpdm = "";
  8456. entiy.fphm = "";
  8457. foreach (string billOrderId in billOrderList)
  8458. {
  8459. iTag++;
  8460. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8461. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8462. {
  8463. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8464. Invoicing_get_response_Obj iObj = null;
  8465. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8466. if (iObj != null)
  8467. {
  8468. //entiy.state = 2;
  8469. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8470. entiy.fpdm += iObj.list[0].c_fpdm;
  8471. entiy.fphm += iObj.list[0].c_fphm;
  8472. if (iTag < billOrderList.Length)
  8473. {
  8474. entiy.fplsh += ",";
  8475. entiy.fpdm += ",";
  8476. entiy.fphm += ",";
  8477. }
  8478. entiy.Update();
  8479. fpUrl += iObj.list[0].c_url + ",";
  8480. }
  8481. //returnSuccess(res);
  8482. StringBuilder sql = new StringBuilder();
  8483. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8484. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8485. }
  8486. else
  8487. {
  8488. int eidx = res.IndexOf("c_resultmsg");
  8489. //int lidx = res.IndexOf("c_status");
  8490. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8491. //开票失败
  8492. entiy.state = 5;
  8493. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8494. entiy.Update();
  8495. returnErrorMsg("开票失败");
  8496. return;
  8497. }
  8498. }
  8499. var returnObj = new
  8500. {
  8501. data = fpUrl
  8502. };
  8503. string ro_json = JsonConvert.SerializeObject(returnObj);
  8504. returnSuccess(ro_json);
  8505. }
  8506. }
  8507. catch (Exception ex)
  8508. {
  8509. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8510. }
  8511. return;
  8512. }
  8513. }
  8514. public void save_erp_billimg()
  8515. {
  8516. if (UrlPostParmsCheck("id"))
  8517. {
  8518. string eid = GetPostString("id");
  8519. CeErpBill bill_entity = null;
  8520. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8521. if (bill_entity != null)
  8522. {
  8523. bill_entity.img = GetPostString("img");
  8524. bill_entity.executeTime = DateTime.Now;
  8525. bill_entity.state = 2;
  8526. bill_entity.Update();
  8527. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8528. returnSuccessMsg("保存成功");
  8529. }
  8530. return;
  8531. }
  8532. }
  8533. public void upd_erp_billreturnback()
  8534. {
  8535. if (UrlPostParmsCheck("id"))
  8536. {
  8537. int eid = GetPostInt("id");
  8538. CeErpBill bill_entity = null;
  8539. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8540. if (bill_entity != null)
  8541. {
  8542. bill_entity.state = 3;
  8543. bill_entity.returnReason = GetPostString("reason");
  8544. bill_entity.Update();
  8545. returnSuccessMsg("驳回成功!");
  8546. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8547. }
  8548. return;
  8549. }
  8550. }
  8551. public void cancel_erp_bill()
  8552. {
  8553. if (UrlPostParmsCheck("id"))
  8554. {
  8555. int eid = GetPostInt("id");
  8556. int detailValue = GetPostInt("detailvalue");
  8557. CeErpBill bill_entity = null;
  8558. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8559. string cres = "";
  8560. string gres = "";
  8561. if (bill_entity != null)
  8562. {
  8563. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8564. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8565. {
  8566. int iTag = 0;
  8567. bill_entity.fplsh = "";
  8568. bill_entity.fpdm = "";
  8569. bill_entity.fphm = "";
  8570. foreach (string billOrderId in billOrderList)
  8571. {
  8572. iTag++;
  8573. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8574. if (gres.IndexOf("success") != -1)
  8575. {
  8576. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8577. Invoicing_get_response_Obj iObj = null;
  8578. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8579. if (iObj != null)
  8580. {
  8581. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8582. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8583. bill_entity.fphm += iObj.list[0].c_fphm;
  8584. if (iTag < billOrderList.Length)
  8585. {
  8586. bill_entity.fplsh += ",";
  8587. bill_entity.fpdm += ",";
  8588. bill_entity.fphm += ",";
  8589. }
  8590. bill_entity.Update();
  8591. }
  8592. }
  8593. else
  8594. {
  8595. returnErrorMsg(gres);
  8596. return;
  8597. }
  8598. }
  8599. }
  8600. if (bill_entity.sendType == "纸质发票")
  8601. {
  8602. //作废
  8603. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8604. //if (DateTime.Now.Month == extime.Month)
  8605. //{
  8606. //cres = taobaoHelper.cancel_invoicing(eid);
  8607. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8608. //{
  8609. bill_entity.state = 4;//已作废
  8610. bill_entity.Update();
  8611. returnSuccessMsg("发票已作废");
  8612. return;
  8613. //}
  8614. //else
  8615. //{
  8616. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8617. // bill_entity.Update();
  8618. // returnErrorMsg(cres);
  8619. // return;
  8620. //}
  8621. //}
  8622. //else
  8623. //{
  8624. // returnErrorMsg("纸质发票只能作废本月的发票");
  8625. // return;
  8626. //}
  8627. }
  8628. //红冲
  8629. int redTag = 0;
  8630. string[] fpdmList = bill_entity.fpdm.Split(',');
  8631. string[] fphmList = bill_entity.fphm.Split(',');
  8632. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8633. {
  8634. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8635. return;
  8636. }
  8637. foreach (string billOrderId in billOrderList)
  8638. {
  8639. redTag++;
  8640. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8641. cres += onecres;
  8642. cres += ",";
  8643. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8644. {
  8645. bill_entity.state = 4;//已作废
  8646. //bill_entity.Update();
  8647. //returnSuccessMsg("发票已红冲");
  8648. }
  8649. else if (onecres.IndexOf("重复冲红") != -1)
  8650. {
  8651. bill_entity.state = 4;//已作废
  8652. //bill_entity.Update();
  8653. //returnSuccessMsg("发票已红冲");
  8654. }
  8655. else
  8656. {
  8657. string errmsg = commonHelper.KeepChinese(onecres);
  8658. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8659. }
  8660. }
  8661. bill_entity.Update();
  8662. if (cres.IndexOf("失败") != -1)
  8663. returnErrorMsg("红冲失败");
  8664. else
  8665. returnSuccessMsg("发票已红冲");
  8666. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8667. return;
  8668. }
  8669. return;
  8670. }
  8671. }
  8672. public void del_erp_billorder()
  8673. {
  8674. if (UrlPostParmsCheck("id"))
  8675. {
  8676. string eid = GetPostString("id");
  8677. CeErpBill.Del(eid);
  8678. CeErpBill bill = CeErpBill.Get(eid);
  8679. if (bill != null)
  8680. {
  8681. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8682. }
  8683. returnSuccessMsg("删除成功");
  8684. }
  8685. }
  8686. public void finish_erp_bill()
  8687. {
  8688. if (UrlPostParmsCheck("ids"))
  8689. {
  8690. string eids = GetPostString("ids");
  8691. string[] list = eids.Split(',');
  8692. foreach (string eid in list)
  8693. {
  8694. CeErpBill bill = CeErpBill.Get(eid);
  8695. if (bill != null)
  8696. {
  8697. bill.state = 2;
  8698. bill.Update();
  8699. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8700. }
  8701. }
  8702. returnSuccessMsg("操作成功");
  8703. }
  8704. }
  8705. public void get_erp_returncash()
  8706. {
  8707. DataStruct dStruct = GetPostStruct();
  8708. List<string> lw = new List<string>();
  8709. string tid = GetPostString("tid");
  8710. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8711. string shopname = GetPostString("shopname");
  8712. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8713. string buyernick = GetPostString("buyer_nick");
  8714. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8715. string customer = GetPostString("customer");
  8716. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8717. string returndate1 = GetPostString("returndate1");
  8718. string returndate2 = GetPostString("returndate2");
  8719. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8720. if (dw.Length > 0) lw.Add(dw);
  8721. string finishDate1 = GetPostString("finishdate1");
  8722. string finishDate2 = GetPostString("finishdate2");
  8723. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8724. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8725. string returntype = GetPostString("returntype");
  8726. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8727. string returnvstate = GetPostString("returnvstate");
  8728. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8729. dStruct.Order = "created desc";
  8730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8731. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8732. writeGridDataTableJson(dStruct.TotalCount, dt);
  8733. }
  8734. public void get_erp_staygoods()
  8735. {
  8736. DataStruct dStruct = GetPostStruct();
  8737. List<string> lw = new List<string>();
  8738. string tid = GetPostString("tid");
  8739. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8740. string shopname = GetPostString("shopname");
  8741. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8742. string wangwang = GetPostString("wangwang");
  8743. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8744. string customer = GetPostString("customer");
  8745. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8746. string returndate1 = GetPostString("returndate1");
  8747. string returndate2 = GetPostString("returndate2");
  8748. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8749. if (dw.Length > 0) lw.Add(dw);
  8750. string finishDate1 = GetPostString("finishdate1");
  8751. string finishDate2 = GetPostString("finishdate2");
  8752. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8753. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8754. string returnvstate = GetPostString("returnvstate");
  8755. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8756. string persuadetype = GetPostString("persuadetype");
  8757. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8758. string customerOrg = GetPostString("customerOrg");
  8759. if (customerOrg.Length > 0)
  8760. {
  8761. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8762. }
  8763. dStruct.Order = "creata_time desc";
  8764. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8765. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8766. writeGridDataTableJson(dStruct.TotalCount, dt);
  8767. }
  8768. public void upd_erp_staygoods()
  8769. {
  8770. if (UrlPostParmsCheck("id"))
  8771. {
  8772. int eid = GetPostInt("id");
  8773. CeErpStayGoods entity = null;
  8774. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8775. if (entity != null)
  8776. {
  8777. entity.audit_type = 1;
  8778. entity.audit_time = DateTime.Now;
  8779. entity.audit_u_id = CurrentUser.UserID;
  8780. entity.audit_u_name = CurrentUser.UserName;
  8781. entity.Update();
  8782. returnSuccessMsg("审核成功!");
  8783. return;
  8784. }
  8785. returnErrorMsg("找不到订单记录");
  8786. }
  8787. }
  8788. public void upd_erp_stayGoodsback()
  8789. {
  8790. if (UrlPostParmsCheck("id"))
  8791. {
  8792. int eid = GetPostInt("id");
  8793. CeErpStayGoods entity = null;
  8794. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8795. if (entity != null)
  8796. {
  8797. entity.audit_text = GetPostString("reason");
  8798. entity.audit_type = 2;
  8799. entity.audit_time = DateTime.Now;
  8800. entity.audit_u_id = CurrentUser.UserID;
  8801. entity.audit_u_name = CurrentUser.UserName;
  8802. entity.Update();
  8803. returnSuccessMsg("退回成功!");
  8804. return;
  8805. }
  8806. returnErrorMsg("找不到订单记录");
  8807. }
  8808. }
  8809. public void upd_erp_returncashverify()
  8810. {
  8811. if (UrlPostParmsCheck("ID"))
  8812. {
  8813. int eid = GetPostInt("ID");
  8814. CeErpReturnCash entity = null;
  8815. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8816. if (entity != null)
  8817. {
  8818. entity.cashstate = 1;
  8819. entity.verifytime = DateTime.Now;
  8820. entity.verifyuserid = CurrentUser.UserID;
  8821. entity.Update();
  8822. returnSuccessMsg("审核成功!");
  8823. return;
  8824. }
  8825. returnErrorMsg("找不到订单记录");
  8826. }
  8827. }
  8828. public void upd_all_erp_returncashverify()
  8829. {
  8830. if (UrlPostParmsCheck("ID"))
  8831. {
  8832. String[] list = GetPostString("ID").Split(',');
  8833. CeErpReturnCash entity = null;
  8834. for (int i = 0; i < list.Length; i++)
  8835. {
  8836. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8837. if (entity != null)
  8838. {
  8839. if (entity.cashstate == 1)
  8840. {
  8841. returnErrorMsg("已审核过的订单不需要在审核!");
  8842. return;
  8843. }
  8844. entity.cashstate = 1;
  8845. entity.verifytime = DateTime.Now;
  8846. entity.verifyuserid = CurrentUser.UserID;
  8847. entity.Update();
  8848. }
  8849. }
  8850. returnSuccessMsg("审核成功!");
  8851. return;
  8852. }
  8853. }
  8854. public void upd_erp_returncashback()
  8855. {
  8856. if (UrlPostParmsCheck("ID"))
  8857. {
  8858. int eid = GetPostInt("ID");
  8859. CeErpReturnCash entity = null;
  8860. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8861. if (entity != null)
  8862. {
  8863. entity.backreason = GetPostString("reason");
  8864. entity.cashstate = 2;
  8865. entity.verifytime = DateTime.Now;
  8866. entity.verifyuserid = CurrentUser.UserID;
  8867. entity.Update();
  8868. returnSuccessMsg("退回成功!");
  8869. return;
  8870. }
  8871. returnErrorMsg("找不到订单记录");
  8872. }
  8873. }
  8874. public void upd_erp_returnprice()
  8875. {
  8876. if (UrlPostParmsCheck("ID"))
  8877. {
  8878. int eid = GetPostInt("ID");
  8879. CeErpReturnCash entity = null;
  8880. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8881. if (entity != null)
  8882. {
  8883. if (entity.cashstate == 1)
  8884. {
  8885. returnErrorMsg("审核通过了不能改");
  8886. return;
  8887. }
  8888. entity.returnprice = GetPostDouble("returnprice");
  8889. entity.Update();
  8890. returnSuccessMsg("修改成功!");
  8891. return;
  8892. }
  8893. returnErrorMsg("找不到订单记录");
  8894. }
  8895. }
  8896. public void del_erp_returncash()
  8897. {
  8898. if (UrlPostParmsCheck("ID"))
  8899. {
  8900. int eid = GetPostInt("ID");
  8901. CeErpReturnCash.Del(eid);
  8902. returnSuccessMsg("操作成功");
  8903. return;
  8904. }
  8905. }
  8906. public void test_for_do_sql()
  8907. {
  8908. string sql = GetPostString("sqlstr");
  8909. if (sql.Length > 0)
  8910. {
  8911. try
  8912. {
  8913. DbHelper.DbConn.ExecuteNonQuery(sql);
  8914. var res_obj = new
  8915. {
  8916. data = "成功",
  8917. };
  8918. string ro_json = JsonConvert.SerializeObject(res_obj);
  8919. returnSuccess(ro_json);
  8920. }
  8921. catch (Exception ex)
  8922. {
  8923. var res_obj = new
  8924. {
  8925. data = ex.Message,
  8926. };
  8927. string ro_json = JsonConvert.SerializeObject(res_obj);
  8928. returnSuccess(ro_json);
  8929. }
  8930. }
  8931. }
  8932. public void get_user_info()
  8933. {
  8934. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8935. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8936. }
  8937. public void get_total_data()
  8938. {
  8939. int userId = CurrentUser.UserID;
  8940. string sql = "";
  8941. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8942. {
  8943. 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);
  8944. }
  8945. else
  8946. {
  8947. 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 " +
  8948. "(select ID from CE_ErpUser where ID = {0}) d " +
  8949. "left join " +
  8950. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8951. ") a on d.ID = a.id left join " +
  8952. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8953. ") b on a.id = b.id1 left join" +
  8954. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8955. ") c on a.id = c.id2;", userId);
  8956. }
  8957. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8958. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8959. }
  8960. public void get_date_area_total_data2()
  8961. {
  8962. int userId = CurrentUser.UserID;
  8963. string date_type = GetPostString("timetype");
  8964. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8965. string sql = "";
  8966. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8967. {
  8968. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8969. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8970. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8971. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8972. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8973. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8974. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8975. ") a on e.ID = a.id left join " +
  8976. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8977. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8978. ") b on a.id = b.id1 " +
  8979. "left join " +
  8980. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8981. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8982. ") c on a.id = c.id2 " +
  8983. "left join " +
  8984. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8985. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8986. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8987. }
  8988. else
  8989. {
  8990. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8991. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8992. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8993. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8994. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8995. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8996. ") a on e.ID = a.id left join " +
  8997. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8998. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8999. ") c on a.id = c.id2 " +
  9000. "left join " +
  9001. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9002. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9003. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9004. }
  9005. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9006. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9007. }
  9008. public void get_date_area_total_data()
  9009. {
  9010. int userId = CurrentUser.UserID;
  9011. string date_type = GetPostString("timetype");
  9012. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9013. string date1 = searchDT[0].ToString();
  9014. string date2 = searchDT[1].ToString();
  9015. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9016. {
  9017. SqlParameter[] sqlParameter ={
  9018. new SqlParameter("@userId", SqlDbType.Int,4),
  9019. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9020. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9021. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9022. };
  9023. sqlParameter[0].Value = userId;
  9024. sqlParameter[1].Value = date1;
  9025. sqlParameter[2].Value = date2;
  9026. sqlParameter[3].Direction = ParameterDirection.Output;
  9027. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9028. string res = sqlParameter[3].Value.ToString();
  9029. var res_obj = new
  9030. {
  9031. data = res
  9032. };
  9033. string ro_json = JsonConvert.SerializeObject(res_obj);
  9034. returnSuccess(ro_json);
  9035. }
  9036. else
  9037. {
  9038. SqlParameter[] sqlParameter ={
  9039. new SqlParameter("@userId", SqlDbType.Int,4),
  9040. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9041. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9042. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9043. };
  9044. sqlParameter[0].Value = userId;
  9045. sqlParameter[1].Value = date1;
  9046. sqlParameter[2].Value = date2;
  9047. sqlParameter[3].Direction = ParameterDirection.Output;
  9048. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9049. string res = sqlParameter[3].Value.ToString();
  9050. var res_obj = new
  9051. {
  9052. data = res
  9053. };
  9054. string ro_json = JsonConvert.SerializeObject(res_obj);
  9055. returnSuccess(ro_json);
  9056. }
  9057. //writeGridDataViewJson(dt.Rows.Count, dv);
  9058. }
  9059. public void get_order_list()
  9060. {
  9061. string strFields = GetPostString("paraFields");
  9062. string strOrder = GetPostString("paraOrder");
  9063. string strWhere = GetPostString("paraWhere");
  9064. string strPageSize = GetPostString("paraPageSize");
  9065. DataStruct dStruct = GetPostStruct();
  9066. dStruct.PageSize = int.Parse(strPageSize);
  9067. dStruct.Fileds = strFields;
  9068. dStruct.Order = strOrder;
  9069. dStruct.MainWhere = strWhere;
  9070. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9071. writeGridDataTableJson(dStruct.TotalCount, dt);
  9072. }
  9073. ////获取待开始订单列表
  9074. //public void get_wait_design_order_list()
  9075. //{
  9076. // string date_type = GetPostString("date_type");
  9077. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9078. // DataStruct dStruct = GetPostStruct();
  9079. // dStruct.PageSize = 1000;
  9080. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9081. // List<string> lw = new List<string>();
  9082. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9083. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9084. // dStruct.Order = "WaitDesignTime asc";
  9085. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9086. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9087. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9088. //}
  9089. //获取完成单量排名
  9090. public void get_finish_order_count_ranking()
  9091. {
  9092. /* string date_type = GetPostString("date_type");
  9093. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9094. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9095. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9096. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9097. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9098. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9099. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9100. writeGridDataTableJson(0, new DataTable());
  9101. }
  9102. public void get_finish_order_amount_ranking()
  9103. {
  9104. /*string date_type = GetPostString("date_type");
  9105. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9106. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9107. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9108. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9109. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9110. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9111. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9112. writeGridDataTableJson(0, new DataTable());
  9113. }
  9114. public void get_finish_refund_count_ranking()
  9115. {
  9116. string date_type = GetPostString("date_type");
  9117. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9118. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9119. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9120. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9121. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9122. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9123. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9124. writeGridDataTableJson(dt.Rows.Count, dt);
  9125. }
  9126. public void get_finish_refund_amount_ranking()
  9127. {
  9128. string date_type = GetPostString("date_type");
  9129. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9130. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9131. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9132. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9133. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9134. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9136. writeGridDataTableJson(dt.Rows.Count, dt);
  9137. }
  9138. public void set_erp_finishorder_director()
  9139. {
  9140. if (UrlPostParmsCheck("ctid"))
  9141. {
  9142. string eid = GetPostString("ctid");
  9143. CeErpTradeCell entity = null;
  9144. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9145. if (entity != null)
  9146. {
  9147. entity.OrderState = 8;
  9148. entity.Update();
  9149. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9150. returnSuccessMsg("操作成功!");
  9151. return;
  9152. }
  9153. returnErrorMsg("找不到记录");
  9154. }
  9155. }
  9156. public void get_erp_placeregistlist()
  9157. {
  9158. DataStruct dStruct = GetPostStruct();
  9159. List<string> lw = new List<string>();
  9160. string outsid = GetPostString("outsid");
  9161. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9162. string memo = GetPostString("memo");
  9163. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9164. string filename = GetPostString("filename");
  9165. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9166. string islate = GetPostString("islate");
  9167. if (islate.Length > 0)
  9168. {
  9169. if (islate == "1")
  9170. lw.Add(string.Format("OutLate>0"));
  9171. else
  9172. lw.Add(string.Format("OutLate=0"));
  9173. }
  9174. string placedate1 = GetPostString("placedate1");
  9175. string placedate2 = GetPostString("placedate2");
  9176. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9177. if (dw.Length > 0) lw.Add(dw);
  9178. string deliveryDate1 = GetPostString("deliverydate1");
  9179. string deliveryDate2 = GetPostString("deliverydate2");
  9180. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9181. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9182. dStruct.Order = "ID desc";
  9183. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9184. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9185. writeGridDataTableJson(dStruct.TotalCount, dt);
  9186. }
  9187. public void ins_erp_placeregist()
  9188. {
  9189. if (UrlPostParmsCheck("id"))
  9190. {
  9191. string eid = GetPostString("id");
  9192. CeErpPlaceRegister entity = null;
  9193. if (eid == "0")//新增
  9194. {
  9195. entity = new CeErpPlaceRegister();
  9196. string xdTime = GetPostString("placeTime");
  9197. if (xdTime.Length > 0)
  9198. {
  9199. entity.PlactTime = Convert.ToDateTime(xdTime);
  9200. }
  9201. string fhTime = GetPostString("deliveryTime");
  9202. if (fhTime.Length > 0)
  9203. {
  9204. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9205. }
  9206. string preTime = GetPostString("preOutTime");
  9207. if (preTime.Length > 0)
  9208. {
  9209. entity.PreOutTime = Convert.ToDateTime(preTime);
  9210. }
  9211. entity.DeliveryCount = GetPostInt("deliveryCount");
  9212. entity.ReceiveCount = GetPostInt("receiveCount");
  9213. entity.OutSid = GetPostString("outSid");
  9214. entity.FileName = GetPostString("fileName");
  9215. entity.Memo = GetPostString("memo");
  9216. entity.AddUserId = CurrentUser.UserID;
  9217. entity.CreateTime = DateTime.Now;
  9218. entity.Img = GetPostString("img");
  9219. entity.Supplier = GetPostInt("supplier");
  9220. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9221. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9222. {
  9223. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9224. DateTime dt2 = (DateTime)entity.PreOutTime;
  9225. TimeSpan span = dt1.Subtract(dt2);
  9226. if (span.Days > 0)
  9227. {
  9228. entity.OutLate = span.Days;
  9229. }
  9230. }
  9231. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9232. entity.Create();
  9233. returnSuccessMsg("添加成功!");
  9234. return;
  9235. }
  9236. else //修改
  9237. {
  9238. entity = CeErpPlaceRegister.Get(eid);
  9239. if (entity != null)
  9240. {
  9241. string xdTime = GetPostString("placeTime");
  9242. if (xdTime.Length > 0)
  9243. {
  9244. entity.PlactTime = Convert.ToDateTime(xdTime);
  9245. }
  9246. string fhTime = GetPostString("deliveryTime");
  9247. if (fhTime.Length > 0)
  9248. {
  9249. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9250. }
  9251. string preTime = GetPostString("preOutTime");
  9252. if (preTime.Length > 0)
  9253. {
  9254. entity.PreOutTime = Convert.ToDateTime(preTime);
  9255. }
  9256. entity.DeliveryCount = GetPostInt("deliveryCount");
  9257. entity.ReceiveCount = GetPostInt("receiveCount");
  9258. if (entity.DeliveryCount == entity.ReceiveCount)
  9259. {
  9260. entity.CurState = "已完成";
  9261. }
  9262. else
  9263. {
  9264. entity.CurState = "未完成";
  9265. }
  9266. entity.OutSid = GetPostString("outSid");
  9267. entity.FileName = GetPostString("fileName");
  9268. entity.Memo = GetPostString("memo");
  9269. entity.Img = GetPostString("img");
  9270. entity.Supplier = GetPostInt("supplier");
  9271. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9272. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9273. {
  9274. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9275. DateTime dt2 = (DateTime)entity.PreOutTime;
  9276. TimeSpan span = dt1.Subtract(dt2);
  9277. if (span.Days > 0)
  9278. {
  9279. entity.OutLate = span.Days;
  9280. }
  9281. }
  9282. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9283. entity.Update();
  9284. returnSuccessMsg("修改成功");
  9285. return;
  9286. }
  9287. returnErrorMsg("找不到对应的记录");
  9288. return;
  9289. }
  9290. }
  9291. returnErrorMsg("缺少必要参数");
  9292. }
  9293. public void del_erp_placeregist()
  9294. {
  9295. string eid = GetPostString("id");
  9296. CeErpPlaceRegister.Del(eid);
  9297. returnSuccessMsg("删除成功!");
  9298. return;
  9299. }
  9300. public void ins_erp_placeregistbyorder()
  9301. {
  9302. string ctid = GetPostString("ctid");
  9303. if (ctid.Length > 0)
  9304. {
  9305. StringBuilder sql = new StringBuilder();
  9306. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9307. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9308. if (dt.Rows.Count > 0)
  9309. {
  9310. foreach (DataRow dr in dt.Rows)
  9311. {
  9312. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9313. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9314. entity.AddUserId = CurrentUser.UserID;
  9315. entity.tid = dr["tid"].ToString();
  9316. entity.Did = Convert.ToString(dr["ctid"]);
  9317. entity.splitTag = dr["SplitTag"].ToString();
  9318. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9319. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9320. if (pre_ctid.Length > 0)
  9321. {
  9322. sellmemo = sellmemo.Replace(pre_ctid, "");
  9323. }
  9324. sellmemo = sellmemo.Replace("[", "");
  9325. sellmemo = sellmemo.Replace("]", "");
  9326. entity.FileName = sellmemo;
  9327. string count = dr["ProductCount"].ToString();
  9328. int usecount = commonHelper.getIntCountFromString(count);
  9329. entity.DeliveryCount = usecount;
  9330. entity.CurState = "未完成";
  9331. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9332. {
  9333. entity.Supplier = 24;//dl手提袋定制
  9334. }
  9335. else
  9336. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9337. entity.CreateTime = DateTime.Now;
  9338. entity.Create();
  9339. }
  9340. returnSuccessMsg("操作成功");
  9341. return;
  9342. }
  9343. returnErrorMsg("没有找到对应订单");
  9344. return;
  9345. }
  9346. returnErrorMsg("缺少订单编号");
  9347. return;
  9348. }
  9349. public void get_erp_persuadelist()
  9350. {
  9351. DataStruct dStruct = GetPostStruct();
  9352. List<string> lw = new List<string>();
  9353. string ctid = GetPostString("ctid");
  9354. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9355. string shopname = GetPostString("shopname");
  9356. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9357. string buyernick = GetPostString("buyer_nick");
  9358. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9359. string customer = GetPostString("customer");
  9360. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9361. string returndate1 = GetPostString("returndate1");
  9362. string returndate2 = GetPostString("returndate2");
  9363. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9364. if (dw.Length > 0) lw.Add(dw);
  9365. string finishDate1 = GetPostString("finishdate1");
  9366. string finishDate2 = GetPostString("finishdate2");
  9367. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9368. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9369. string persuadetype = GetPostString("persuadetype");
  9370. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9371. string returnvstate = GetPostString("returnvstate");
  9372. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9373. dStruct.Order = "created desc";
  9374. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9375. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9376. writeGridDataTableJson(dStruct.TotalCount, dt);
  9377. }
  9378. public void upd_erp_returnpersuadeback()
  9379. {
  9380. if (UrlPostParmsCheck("ID"))
  9381. {
  9382. int eid = GetPostInt("ID");
  9383. CeErpPersuade entity = null;
  9384. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9385. if (entity != null)
  9386. {
  9387. entity.backreason = GetPostString("reason");
  9388. entity.pstate = 2;
  9389. entity.verifytime = DateTime.Now;
  9390. entity.verifyuserid = CurrentUser.UserID;
  9391. entity.Update();
  9392. returnSuccessMsg("退回成功!");
  9393. return;
  9394. }
  9395. returnErrorMsg("找不到订单记录");
  9396. }
  9397. }
  9398. public void upd_erp_returnpersuadeverify()
  9399. {
  9400. if (UrlPostParmsCheck("ID"))
  9401. {
  9402. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9403. {
  9404. returnErrorMsg("暂无权限审核");
  9405. return;
  9406. }
  9407. int eid = GetPostInt("ID");
  9408. CeErpPersuade entity = null;
  9409. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9410. if (entity != null)
  9411. {
  9412. entity.pstate = 1;
  9413. entity.verifytime = DateTime.Now;
  9414. entity.verifyuserid = CurrentUser.UserID;
  9415. entity.Update();
  9416. returnSuccessMsg("审核成功!");
  9417. return;
  9418. }
  9419. returnErrorMsg("找不到订单记录");
  9420. }
  9421. }
  9422. public void del_erp_persuade()
  9423. {
  9424. if (UrlPostParmsCheck("ID"))
  9425. {
  9426. int eid = GetPostInt("ID");
  9427. CeErpPersuade.Del(eid);
  9428. returnSuccessMsg("操作成功");
  9429. return;
  9430. }
  9431. }
  9432. public void get_erp_oldcustoupload()
  9433. {
  9434. DataStruct dStruct = GetPostStruct();
  9435. List<string> lw = new List<string>();
  9436. string buyernick = GetPostString("buyer_nick");
  9437. if (buyernick.Length > 0)
  9438. {
  9439. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9440. }
  9441. else
  9442. return;
  9443. dStruct.Order = "pay_time desc";
  9444. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9445. DataTable dt = null;
  9446. dt = WebCache.GetData("view_erptradecell", dStruct);
  9447. writeGridDataTableJson(dStruct.TotalCount, dt);
  9448. }
  9449. public void get_erp_checkorderlist()
  9450. {
  9451. DataStruct dStruct = GetPostStruct();
  9452. List<string> lw = new List<string>();
  9453. string tid = GetPostString("ctid");
  9454. if (tid.Length > 0)
  9455. {
  9456. string select_tid = getTidByCtid(tid);
  9457. lw.Add(string.Format("tid='{0}'", select_tid));
  9458. }
  9459. string shopname = GetPostString("shopname");
  9460. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9461. string buyernick = GetPostString("buyer_nick");
  9462. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9463. string customer = GetPostString("customer");
  9464. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9465. string design = GetPostString("design");
  9466. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9467. string orderState = GetPostString("orderState");
  9468. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9469. string address = GetPostString("address");
  9470. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9471. string sellermemo = GetPostString("seller_memo");
  9472. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9473. string supplier = GetPostString("supplier");
  9474. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9475. {
  9476. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9477. }
  9478. else
  9479. {
  9480. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9481. }
  9482. string date1 = GetPostString("date1");
  9483. string date2 = GetPostString("date2");
  9484. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9485. if (dw.Length > 0) lw.Add(dw);
  9486. string placedate1 = GetPostString("placedate1");
  9487. string placedate2 = GetPostString("placedate2");
  9488. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9489. if (fdw.Length > 0) lw.Add(fdw);
  9490. string price1 = GetPostString("price1");
  9491. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9492. string price2 = GetPostString("price2");
  9493. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9494. string checkst = GetPostString("checkstate");
  9495. if (checkst.Length > 0 && "10".Equals(checkst))
  9496. {
  9497. lw.Add(string.Format("CheckOut>0"));
  9498. }
  9499. else
  9500. {
  9501. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9502. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9503. }
  9504. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9505. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9506. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9507. writeGridDataTableJson(dStruct.TotalCount, dt);
  9508. }
  9509. public void ins_erp_startCheck()
  9510. {
  9511. if (UrlPostParmsCheck("ctid"))
  9512. {
  9513. string eid = GetPostString("ctid");
  9514. CeErpTradeCell entity = null;
  9515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9516. if (entity != null)
  9517. {
  9518. entity.MemoOpt = 4;
  9519. entity.UpdateTime = DateTime.Now;
  9520. entity.Update();
  9521. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9522. CeErpSukuraData.createInfo(entity.ctid, 6);
  9523. returnSuccessMsg("操作成功!");
  9524. return;
  9525. }
  9526. returnErrorMsg("找不到记录");
  9527. }
  9528. }
  9529. public void upd_erp_sendXlw()
  9530. {
  9531. if (UrlPostParmsCheck("ctid"))
  9532. {
  9533. string eid = GetPostString("ctid");
  9534. CeErpTradeCell entity = null;
  9535. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9536. if (entity != null)
  9537. {
  9538. if (entity.IsSendGift == 1)
  9539. {
  9540. returnErrorMsg("请勿重复标记");
  9541. return;
  9542. }
  9543. entity.IsSendGift = 1;
  9544. entity.Update();
  9545. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9546. returnSuccessMsg("操作成功!");
  9547. return;
  9548. }
  9549. returnErrorMsg("找不到记录");
  9550. }
  9551. }
  9552. public void cancel_sendXlw()
  9553. {
  9554. if (UrlPostParmsCheck("ctid"))
  9555. {
  9556. string eid = GetPostString("ctid");
  9557. CeErpTradeCell entity = null;
  9558. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9559. if (entity != null)
  9560. {
  9561. if (entity.IsSendGift == 0)
  9562. {
  9563. returnErrorMsg("未标记小礼物");
  9564. return;
  9565. }
  9566. entity.IsSendGift = 0;
  9567. entity.Update();
  9568. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9569. returnSuccessMsg("操作成功!");
  9570. return;
  9571. }
  9572. returnErrorMsg("找不到记录");
  9573. }
  9574. }
  9575. public void get_erp_designbill()
  9576. {
  9577. DataStruct dStruct = GetPostStruct();
  9578. List<string> lw = new List<string>();
  9579. int isMy = GetInt("my");
  9580. if (isMy == 1)
  9581. {
  9582. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9583. }
  9584. string tid = GetPostString("tid");
  9585. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9586. string userName = GetPostString("design");
  9587. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9588. string price1 = GetPostString("price1");
  9589. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9590. string price2 = GetPostString("price2");
  9591. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9592. string rePrice1 = GetPostString("rePrice1");
  9593. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9594. string rePrice2 = GetPostString("rePrice2");
  9595. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9596. string designerType = GetPostString("designerType");
  9597. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9598. string orderState = GetPostString("orderState");
  9599. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9600. string endTime1 = GetPostString("endTime1");
  9601. string endTime2 = GetPostString("endTime2");
  9602. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9603. if (dw.Length > 0) lw.Add(dw);
  9604. string isDk = GetPostString("isDk");
  9605. if (isDk == "1")
  9606. {
  9607. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9608. }
  9609. else if (isDk == "0")
  9610. {
  9611. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9612. }
  9613. dStruct.Order = "oid, create_time desc";
  9614. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9615. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9616. writeGridDataTableJson(dStruct.TotalCount, dt);
  9617. }
  9618. public void upd_erp_designerbill()
  9619. {
  9620. if (UrlPostParmsCheck("ID"))
  9621. {
  9622. string eid = GetPostString("ID");
  9623. CeErpDesignerBill entity = null;
  9624. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9625. if (entity != null)
  9626. {
  9627. if (GetPostDouble("designerpirce") > 0)
  9628. {
  9629. entity.realPrice = GetPostDouble("designerpirce");
  9630. entity.update_time = DateTime.Now;
  9631. entity.update_u_id = CurrentUser.UserID;
  9632. entity.update_u_name = CurrentUser.UserName;
  9633. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9634. entity.Update();
  9635. returnSuccessMsg("操作成功!");
  9636. return;
  9637. }
  9638. else
  9639. {
  9640. entity.price = GetPostDouble("price");
  9641. entity.update_time = DateTime.Now;
  9642. entity.update_u_id = CurrentUser.UserID;
  9643. entity.update_u_name = CurrentUser.UserName;
  9644. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9645. entity.Update();
  9646. returnSuccessMsg("操作成功!");
  9647. return;
  9648. }
  9649. }
  9650. returnErrorMsg("找不到记录");
  9651. }
  9652. }
  9653. public void audit_erp_designerbill()
  9654. {
  9655. if (UrlPostParmsCheck("ID"))
  9656. {
  9657. string eid = GetPostString("ID");
  9658. CeErpDesignerBill entity = null;
  9659. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9660. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9661. if (entity != null)
  9662. {
  9663. entity.realPrice = GetPostDouble("designerpirce");
  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. if (orderEntity != null)
  9671. {
  9672. orderEntity.IsReadTag = 3;
  9673. orderEntity.Update();
  9674. }
  9675. returnSuccessMsg("操作成功!");
  9676. return;
  9677. }
  9678. returnErrorMsg("找不到记录");
  9679. }
  9680. }
  9681. public void all_audit_erp_designerbill()
  9682. {
  9683. if (UrlPostParmsCheck("idList"))
  9684. {
  9685. string[] list = GetPostString("idList").Split(',');
  9686. CeErpDesignerBill entity = null;
  9687. for (int i = 0; i < list.Length; i++)
  9688. {
  9689. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9690. if (entity == null) return;
  9691. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9692. if (orderEntity == null) return;
  9693. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9694. entity.update_time = DateTime.Now;
  9695. entity.update_u_id = CurrentUser.UserID;
  9696. entity.update_u_name = CurrentUser.UserName;
  9697. entity.isAudit = 1;
  9698. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9699. entity.Update();
  9700. orderEntity.IsReadTag = 3;
  9701. orderEntity.Update();
  9702. }
  9703. returnSuccessMsg("操作成功!");
  9704. return;
  9705. }
  9706. }
  9707. public void get_erp_sameorders()
  9708. {
  9709. if (UrlPostParmsCheck("ctid"))
  9710. {
  9711. string eid = GetPostString("ctid");
  9712. CeErpTradeCell entity = null;
  9713. entity = CeErpTradeCell.GetByCtid(eid);
  9714. if (entity != null)
  9715. {
  9716. StringBuilder sql = new StringBuilder();
  9717. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9718. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9719. var res = new
  9720. {
  9721. data = dt.Rows.Count
  9722. };
  9723. string ro_jsond = JsonConvert.SerializeObject(res);
  9724. returnSuccess(ro_jsond);
  9725. return;
  9726. }
  9727. returnErrorMsg("未找到订单");
  9728. return;
  9729. }
  9730. returnErrorMsg("缺少必要的参数");
  9731. }
  9732. public void get_erp_islasthavesameorder()
  9733. {
  9734. if (UrlPostParmsCheck("ctid"))
  9735. {
  9736. string eid = GetPostString("ctid");
  9737. string[] ctidList = eid.Split(',');
  9738. StringBuilder sql = new StringBuilder();
  9739. string tisCtid = "";
  9740. foreach (string ctid in ctidList)
  9741. {
  9742. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9743. if (entity != null)
  9744. {
  9745. sql = new StringBuilder();
  9746. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9747. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9748. if (dth.Rows.Count > 0)
  9749. {
  9750. tisCtid += entity.ctid;
  9751. tisCtid += ",";
  9752. }
  9753. }
  9754. }
  9755. if (tisCtid.Length > 0)
  9756. {
  9757. var res = new
  9758. {
  9759. data = tisCtid
  9760. };
  9761. string ro_jsond = JsonConvert.SerializeObject(res);
  9762. returnSuccess(ro_jsond);
  9763. }
  9764. else
  9765. {
  9766. var res = new
  9767. {
  9768. data = ""
  9769. };
  9770. string ro_jsond = JsonConvert.SerializeObject(res);
  9771. returnSuccess(ro_jsond);
  9772. }
  9773. return;
  9774. }
  9775. returnErrorMsg("缺少必要的参数");
  9776. }
  9777. public void file_client_down_url()
  9778. {
  9779. if (!UrlPostParmsCheck("userId"))
  9780. {
  9781. returnErrorMsg("缺少必要的参数");
  9782. }
  9783. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9784. }
  9785. public void checkout_form_data()
  9786. {
  9787. if (!UrlPostParmsCheck("tid"))
  9788. {
  9789. returnErrorMsg("缺少必要的参数");
  9790. }
  9791. string tid = GetPostString("tid");
  9792. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9793. if (ceErpOrderFormData != null)
  9794. {
  9795. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9796. returnSuccess(ro_jsond);
  9797. return;
  9798. }
  9799. returnErrorMsg("尚未有文件!");
  9800. }
  9801. public void back_supplier_audit()
  9802. {
  9803. int userId = CurrentUser.UserID;
  9804. StringBuilder sql = new StringBuilder();
  9805. 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);
  9806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9807. if (dt.Rows.Count > 0)
  9808. {
  9809. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9810. }
  9811. else
  9812. {
  9813. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9814. }
  9815. }
  9816. public void back_supplier_query()
  9817. {
  9818. string eid = GetPostString("ctid");
  9819. if (eid != "")
  9820. {
  9821. StringBuilder sql = new StringBuilder();
  9822. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9823. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9824. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9825. }
  9826. else
  9827. {
  9828. returnErrorMsg("找不到订单记录");
  9829. return;
  9830. }
  9831. }
  9832. public void verified_to_order()
  9833. {
  9834. int userId = CurrentUser.UserID;
  9835. StringBuilder sql = new StringBuilder();
  9836. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9837. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9838. if (dt.Rows.Count > 0)
  9839. {
  9840. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9841. }
  9842. else
  9843. {
  9844. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9845. }
  9846. }
  9847. public void upd_supplier_audit()
  9848. {
  9849. if (UrlPostParmsCheck("ctid"))
  9850. {
  9851. string eid = GetPostString("ctid");
  9852. string reason = GetPostString("returnreason");
  9853. CeErpTradeCell entity = null;
  9854. CeWithdraw withdraw = null;
  9855. withdraw = CeWithdraw.GetByTid(eid);
  9856. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9857. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9858. {
  9859. if (withdraw != null)
  9860. {
  9861. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9862. {
  9863. returnSuccessMsg("您没有权限操作!");
  9864. return;
  9865. }
  9866. else
  9867. {
  9868. if (reason.Equals("1"))
  9869. {
  9870. if (entity.OrderState == -1)
  9871. {
  9872. if (entity.FinishPlaceTime == null)
  9873. {
  9874. entity.OrderState = 2;
  9875. }
  9876. else
  9877. {
  9878. entity.OrderState = 6;
  9879. }
  9880. }
  9881. entity.Update();
  9882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9883. if (withdraw != null)
  9884. {
  9885. withdraw.status = int.Parse(reason);
  9886. withdraw.Update();
  9887. }
  9888. returnSuccessMsg("操作成功!");
  9889. return;
  9890. }
  9891. else
  9892. {
  9893. withdraw.status = int.Parse(reason);
  9894. withdraw.acknowledgingtime = DateTime.Now;
  9895. withdraw.Update();
  9896. returnSuccessMsg("查看详细请点击线下订单查询");
  9897. return;
  9898. }
  9899. }
  9900. }
  9901. // 第一个字符是 'N'
  9902. }
  9903. if (eid[0] != 'N')
  9904. {
  9905. }
  9906. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9907. {
  9908. entity.IsVerifyToSupplier = false;
  9909. entity.IsReturn = 1;
  9910. entity.ReturnTime = DateTime.Now;
  9911. entity.ReturnReason = reason;
  9912. if (entity.OrderState == 6)
  9913. {
  9914. entity.OrderState = 5;
  9915. }
  9916. entity.Update();
  9917. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9918. if (withdraw != null)
  9919. {
  9920. withdraw.status = int.Parse(reason);
  9921. withdraw.Update();
  9922. }
  9923. returnSuccessMsg("操作成功!");
  9924. return;
  9925. }
  9926. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9927. {
  9928. ;
  9929. if (withdraw != null)
  9930. {
  9931. withdraw.status = int.Parse(reason);
  9932. withdraw.acknowledgingtime = DateTime.Now;
  9933. withdraw.Update();
  9934. returnSuccessMsg("供应商取消撤回!");
  9935. return;
  9936. }
  9937. }
  9938. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9939. {
  9940. if (entity.OrderState == -1)
  9941. {
  9942. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9943. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9944. {
  9945. returnErrorMsg("订单spu没有确认无法通过审核!");
  9946. return;
  9947. }
  9948. if (entity.FinishPlaceTime == null)
  9949. {
  9950. entity.OrderState = 2;
  9951. }
  9952. else
  9953. {
  9954. entity.OrderState = 3;
  9955. }
  9956. commonHelper.getCytPrice(entity);
  9957. }
  9958. entity.Update();
  9959. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9960. if (withdraw != null)
  9961. {
  9962. withdraw.status = int.Parse(reason);
  9963. withdraw.Update();
  9964. }
  9965. returnSuccessMsg("操作成功!");
  9966. return;
  9967. }
  9968. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9969. {
  9970. if (withdraw == null)
  9971. {
  9972. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9973. return;
  9974. }
  9975. }
  9976. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9977. {
  9978. if (withdraw != null)
  9979. {
  9980. withdraw.status = int.Parse(reason);
  9981. withdraw.acknowledgingtime = DateTime.Now;
  9982. withdraw.Update();
  9983. returnSuccessMsg("查看详细请点击线下订单查询");
  9984. return;
  9985. }
  9986. }
  9987. return;
  9988. }
  9989. }
  9990. //校验报价
  9991. public void refund_order_tip()
  9992. {
  9993. int userid = CurrentUser.UserID;
  9994. int sectionId = CurrentUser.UserPost.OrgID;
  9995. StringBuilder sql = new StringBuilder();
  9996. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9997. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9998. List<string> ids = new List<string>();
  9999. if (dth.Rows.Count > 0)
  10000. {
  10001. foreach (DataRow dr in dth.Rows)
  10002. {
  10003. ids.Add(dr["ID"].ToString());
  10004. }
  10005. try
  10006. {
  10007. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10008. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10009. }
  10010. catch (Exception ex)
  10011. {
  10012. }
  10013. }
  10014. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10015. }
  10016. public void refund_order_Design()
  10017. {
  10018. int userid = CurrentUser.UserID;
  10019. int sectionId = CurrentUser.UserPost.OrgID;
  10020. StringBuilder sql = new StringBuilder();
  10021. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10022. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10023. List<string> ids = new List<string>();
  10024. if (dth.Rows.Count > 0)
  10025. {
  10026. foreach (DataRow dr in dth.Rows)
  10027. {
  10028. ids.Add(dr["ID"].ToString());
  10029. }
  10030. try
  10031. {
  10032. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10033. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10034. }
  10035. catch (Exception ex)
  10036. {
  10037. }
  10038. }
  10039. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10040. }
  10041. public void change_order_info()
  10042. {
  10043. int userid = CurrentUser.UserID;
  10044. StringBuilder sql = new StringBuilder();
  10045. 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);
  10046. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10047. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10048. }
  10049. public void change_win_mome()
  10050. {
  10051. if (UrlPostParmsCheck("id,ctid"))
  10052. {
  10053. string id = GetPostString("id");
  10054. string ctid = GetPostString("ctid");
  10055. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10056. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10057. if (ce == null || ceErpMessageTip == null)
  10058. {
  10059. returnSuccessMsg("未找到对应的订单!");
  10060. return;
  10061. }
  10062. if (ce.OrderState >= 5)
  10063. {
  10064. returnSuccessMsg("已上传文件无法修改!");
  10065. return;
  10066. }
  10067. int type = GetPostInt("type");
  10068. string content = GetPostString("content");
  10069. if (type == 0)
  10070. {
  10071. content = content.Replace("(", "(");
  10072. content = content.Replace(")", ")");
  10073. string check = MidStrEx(content, "(", ")").Trim();
  10074. if (string.IsNullOrEmpty(check))
  10075. {
  10076. returnSuccessMsg("文件名格式不正确");
  10077. return;
  10078. }
  10079. }
  10080. ce.seller_memo = content;
  10081. ce.Update();
  10082. ceErpMessageTip.isVisit = true;
  10083. ceErpMessageTip.Update();
  10084. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10085. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10086. ApiVo apiVo = new ApiVo();
  10087. apiVo.orderNumber = ce.ctid;
  10088. apiVo.actionName = "demandDesign";
  10089. apiVo.orderRemarks = content;
  10090. apiVo.demandExamine = type + 1;
  10091. designHelper.API_WorkCore(apiVo);//demandDesign
  10092. returnSuccessMsg("修改成功!");
  10093. }
  10094. }
  10095. public static string MidStrEx(string sourse, string startstr, string endstr)
  10096. {
  10097. string result = string.Empty;
  10098. int startindex, endindex;
  10099. try
  10100. {
  10101. startindex = sourse.IndexOf(startstr);
  10102. if (startindex == -1)
  10103. return result;
  10104. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10105. endindex = tmpstr.IndexOf(endstr);
  10106. if (endindex == -1)
  10107. return result;
  10108. result = tmpstr.Remove(endindex);
  10109. }
  10110. catch (Exception ex)
  10111. {
  10112. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10113. }
  10114. return result;
  10115. }
  10116. public void refund_order_list()
  10117. {
  10118. int userid = CurrentUser.UserID;
  10119. int sectionId = CurrentUser.UserPost.OrgID;
  10120. StringBuilder sql = new StringBuilder();
  10121. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10122. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10123. DataStruct dStruct = GetPostStruct();
  10124. DataTable dt = null;
  10125. List<string> ids = new List<string>();
  10126. List<string> tids = new List<string>();
  10127. if (dth.Rows.Count > 0)
  10128. {
  10129. foreach (DataRow dr in dth.Rows)
  10130. {
  10131. tids.Add("'" + dr["tid"].ToString() + "'");
  10132. ids.Add(dr["id"].ToString());
  10133. }
  10134. try
  10135. {
  10136. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10137. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10138. List<string> lw = new List<string>();
  10139. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10140. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10141. dt = WebCache.GetData("view_orderlist", dStruct);
  10142. }
  10143. catch (Exception ex)
  10144. {
  10145. }
  10146. }
  10147. writeGridDataTableJson(dStruct.TotalCount, dt);
  10148. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10149. }
  10150. //新增
  10151. public void order_batch_downloads()
  10152. {
  10153. string ceid = GetPostString("tid");
  10154. String[] tid = ceid.Split(',');
  10155. order_batch_caiyingtong(tid);
  10156. /* (string success, string errors) = UploadFiles(tid);
  10157. returnSuccessMsg(success + errors);*/
  10158. return;
  10159. }
  10160. //报价接口
  10161. public void Get_To_Quote()
  10162. {
  10163. string ceid = GetPostString("ctid");
  10164. if (ceid != null)
  10165. {
  10166. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10167. if (entity != null)
  10168. {
  10169. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10170. {
  10171. return;
  10172. }
  10173. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10174. double price = 0;
  10175. if (cp == null)
  10176. {
  10177. JObject jsonObject12 = new JObject
  10178. {
  10179. { "UserId", "77886" },
  10180. { "Pwd", "lt666888" },
  10181. { "Filename", entity.seller_memo }
  10182. };
  10183. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10184. JObject jsonObjects1 = JObject.Parse(response1);
  10185. string ms1g = (string)jsonObjects1["msg"];
  10186. if (ms1g == "报价成功")
  10187. {
  10188. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10189. string data = (string)jsonObject1["price"];
  10190. 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 + "');";
  10191. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10192. returnSuccessMsg("获取报价成功:" + data);
  10193. price = Convert.ToDouble(data);
  10194. }
  10195. else
  10196. {
  10197. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10198. return;
  10199. }
  10200. }
  10201. String[] beizhu = entity.seller_memo.Split('-');
  10202. String chanp = "";
  10203. if (beizhu.Length > 0)
  10204. {
  10205. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10206. }
  10207. else
  10208. {
  10209. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10210. }
  10211. JObject jsonObject = new JObject
  10212. {
  10213. { "UserId", "77886" },
  10214. { "Pwd", "lt666888" },
  10215. { "Filename", chanp }
  10216. };
  10217. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10218. JObject jsonObjects = JObject.Parse(response);
  10219. string msg = (string)jsonObjects["msg"];
  10220. if (msg == "报价成功")
  10221. {
  10222. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10223. string data = (string)jsonObject1["price"];
  10224. 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 + "');";
  10225. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10226. returnSuccessMsg("获取报价成功:" + data);
  10227. price = Convert.ToDouble(data);
  10228. }
  10229. else
  10230. {
  10231. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10232. return;
  10233. }
  10234. if (price > 0)
  10235. {
  10236. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10237. if (ceErpTradeCellExtend == null)
  10238. {
  10239. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10240. ceErpTradeCellExtend.ctid = entity.ctid;
  10241. ceErpTradeCellExtend.payment_cyt = price;
  10242. ceErpTradeCellExtend.Create();
  10243. }
  10244. else
  10245. {
  10246. ceErpTradeCellExtend.payment_cyt = price;
  10247. ceErpTradeCellExtend.Update();
  10248. }
  10249. }
  10250. return;
  10251. }
  10252. }
  10253. else
  10254. {
  10255. returnErrorMsg("请至少选择一条数据");
  10256. return;
  10257. }
  10258. }
  10259. //新增
  10260. public void order_To_Supplier()
  10261. {
  10262. string ceid = GetPostString("tid");
  10263. String[] tid = ceid.Split(',');
  10264. if (tid.Length > 0)
  10265. {
  10266. try
  10267. {
  10268. for (int i = 0; i < tid.Length; i++)
  10269. {
  10270. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10271. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10272. entity.SupplierId = suid;
  10273. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10274. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10275. entity.Update();
  10276. }
  10277. }
  10278. catch (Exception ex)
  10279. {
  10280. returnErrorMsg("自动匹配供应商失败");
  10281. return;
  10282. }
  10283. }
  10284. else
  10285. {
  10286. returnErrorMsg("请至少选择一条数据");
  10287. return;
  10288. }
  10289. returnSuccessMsg("自动匹配供应商成功");
  10290. return;
  10291. }
  10292. public (string, string) UploadFiles(string[] urls)
  10293. {
  10294. string success = "";
  10295. string errors = "";
  10296. int userid = CurrentUser.UserID;
  10297. foreach (string url in urls)
  10298. {
  10299. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10300. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10301. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10302. {
  10303. JObject jsonObject = new JObject
  10304. {
  10305. { "Userid", "77886" },
  10306. { "pwd", "cyt86435015" },
  10307. { "content", base64FileContent },
  10308. { "ext", Path.GetExtension(fileName) }
  10309. };
  10310. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10311. JObject jsonObjects = JObject.Parse(response);
  10312. string msg = (string)jsonObjects["msg"];
  10313. if (msg.Equals("上传成功"))
  10314. {
  10315. success += url + " 上传成功";
  10316. }
  10317. else
  10318. {
  10319. errors += url + " 上传失败";
  10320. }
  10321. }
  10322. else
  10323. {
  10324. errors += url + " 格式出现问题";
  10325. }
  10326. }
  10327. if (urls.Length == 0)
  10328. {
  10329. return (success, errors);
  10330. }
  10331. return (success, errors);
  10332. }
  10333. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10334. {
  10335. return true; //总是接受
  10336. }
  10337. public static string HttpPost(string url, string param = null)
  10338. {
  10339. HttpWebRequest request;
  10340. //如果是发送HTTPS请求
  10341. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10342. {
  10343. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10344. request = WebRequest.Create(url) as HttpWebRequest;
  10345. request.ProtocolVersion = HttpVersion.Version10;
  10346. }
  10347. else
  10348. {
  10349. request = WebRequest.Create(url) as HttpWebRequest;
  10350. }
  10351. request.Method = "POST";
  10352. request.ContentType = "application/json";
  10353. request.Accept = "*/*";
  10354. request.Timeout = 120000;
  10355. request.AllowAutoRedirect = false;
  10356. StreamWriter requestStream = null;
  10357. WebResponse response = null;
  10358. string responseStr = null;
  10359. try
  10360. {
  10361. requestStream = new StreamWriter(request.GetRequestStream());
  10362. requestStream.Write(param);
  10363. requestStream.Close();
  10364. response = request.GetResponse();
  10365. if (response != null)
  10366. {
  10367. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10368. responseStr = reader.ReadToEnd();
  10369. reader.Close();
  10370. }
  10371. }
  10372. catch (Exception ex)
  10373. {
  10374. return ex.Message;
  10375. }
  10376. finally
  10377. {
  10378. request = null;
  10379. requestStream = null;
  10380. response = null;
  10381. }
  10382. return responseStr;
  10383. }
  10384. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10385. {
  10386. string base64FileContent;
  10387. string fileName;
  10388. using (WebClient webClient = new WebClient())
  10389. {
  10390. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10391. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10392. {
  10393. using (Stream stream = response.GetResponseStream())
  10394. {
  10395. using (MemoryStream memoryStream = new MemoryStream())
  10396. {
  10397. stream.CopyTo(memoryStream);
  10398. byte[] fileBytes = memoryStream.ToArray();
  10399. base64FileContent = Convert.ToBase64String(fileBytes);
  10400. fileName = response.Headers["Content-Disposition"];
  10401. if (!string.IsNullOrEmpty(fileName))
  10402. {
  10403. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10404. if (index >= 0)
  10405. {
  10406. fileName = fileName.Substring(index + 9).Trim('\"');
  10407. }
  10408. }
  10409. else
  10410. {
  10411. fileName = Path.GetFileName(downloadUrl);
  10412. }
  10413. }
  10414. }
  10415. }
  10416. }
  10417. return (fileName, base64FileContent);
  10418. }
  10419. //新增
  10420. public void order_batch_caiyingtong(string[] downloadUrls)
  10421. {
  10422. try
  10423. {
  10424. //遍历文件
  10425. DataStruct dStruct = GetPostStruct();
  10426. DataTable dt = null;
  10427. int userid = CurrentUser.UserID;
  10428. List<string> ids = new List<string>();//失败组
  10429. List<string> tids = new List<string>();
  10430. using (WebClient webClient = new WebClient())
  10431. {
  10432. foreach (var url in downloadUrls)
  10433. {
  10434. try
  10435. {
  10436. tids.Add("'" + url + "'");
  10437. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10438. if (entity != null)
  10439. {
  10440. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10441. if (cp == null)
  10442. {
  10443. JObject jsonObject = new JObject
  10444. {
  10445. { "Userid", "77886" },
  10446. { "pwd", "lt666888" },
  10447. { "Filename",entity.seller_memo }
  10448. };
  10449. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10450. JObject jsonObjects = JObject.Parse(response);
  10451. string msg = (string)jsonObjects["msg"];
  10452. if (msg == "报价成功")
  10453. {
  10454. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10455. DownloadAndConvertToBase64(url1);
  10456. }
  10457. else
  10458. {
  10459. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10460. }
  10461. }
  10462. else
  10463. {
  10464. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10465. JObject jsonObject = new JObject
  10466. {
  10467. { "Userid", "77886" },
  10468. { "pwd", "lt666888" },
  10469. { "Filename",chanp }
  10470. };
  10471. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10472. JObject jsonObjects = JObject.Parse(response);
  10473. string msg = (string)jsonObjects["msg"];
  10474. if (msg == "报价成功")
  10475. {
  10476. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10477. DownloadAndConvertToBase64(url1);
  10478. }
  10479. else
  10480. {
  10481. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10482. }
  10483. }
  10484. }
  10485. // 上传文件到FTP
  10486. }
  10487. catch (Exception ex)
  10488. {
  10489. Console.WriteLine($"An error occurred: {ex.Message}");
  10490. }
  10491. }
  10492. List<string> lw = new List<string>();
  10493. lw.Add(string.Format("( OrderState < 6 )"));
  10494. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10495. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10496. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10497. if (dt.Rows.Count > 0)
  10498. {
  10499. foreach (DataRow dr in dt.Rows)
  10500. {
  10501. ids.Add(dr["ctid"].ToString());
  10502. }
  10503. }
  10504. String ErrorMsgs = "";
  10505. foreach (String id in ids)
  10506. {
  10507. ErrorMsgs += id + ",";
  10508. }
  10509. if (ErrorMsgs.Length > 1)
  10510. {
  10511. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10512. }
  10513. if (ErrorMsgs.Length < 1)
  10514. {
  10515. ErrorMsgs = "上传成功";
  10516. returnSuccessMsg(ErrorMsgs);
  10517. }
  10518. else
  10519. {
  10520. returnErrorMsg("以下订单" + ErrorMsgs);
  10521. }
  10522. }
  10523. // 删除文件夹及其内容
  10524. /* Directory.Delete(localDirectory, true);*/
  10525. }
  10526. catch { }
  10527. }
  10528. public void get_center_data()
  10529. {
  10530. int userId = CurrentUser.UserID;
  10531. string postCode = CurrentUser.UserPost.Post.Code;
  10532. List<string> lw = new List<string>();
  10533. List<string> ww = new List<string>();
  10534. DateTime currentTime = DateTime.Now;
  10535. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10536. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10537. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10538. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10539. string sql = " SELECT ";
  10540. string startTime = "2023-10-01 11:22:31";
  10541. //设计
  10542. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10543. {
  10544. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10545. 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));
  10546. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10547. 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));
  10548. }
  10549. //客服
  10550. else if (postCode == "CustomerService" || postCode == "Director")
  10551. {
  10552. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10553. 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));
  10554. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10555. 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));
  10556. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10557. 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));
  10558. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10559. 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));
  10560. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10561. 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));
  10562. }
  10563. //售后
  10564. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10565. {
  10566. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10567. 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));
  10568. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10569. 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));
  10570. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10571. 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));
  10572. }
  10573. //下单部
  10574. else if (postCode == "Place" || postCode == "PlaceMr")
  10575. {
  10576. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10577. 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));
  10578. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10579. 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));
  10580. }
  10581. //车间
  10582. else if (postCode == "Supplier")
  10583. {
  10584. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10585. 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));
  10586. }
  10587. DataTable dt = new DataTable();
  10588. if (lw.Count > 0)
  10589. {
  10590. sql += string.Join(" , ", lw);
  10591. sql += " FROM ";
  10592. sql += string.Join(" , ", ww);
  10593. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10594. }
  10595. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10596. }
  10597. public void get_center_data_list()
  10598. {
  10599. int userId = CurrentUser.UserID;
  10600. string postCode = CurrentUser.UserPost.Post.Code;
  10601. string shopIds = CurrentUser.User.pemShop;
  10602. DataStruct dStruct = GetPostStruct();
  10603. List<string> lw = new List<string>();
  10604. DateTime currentTime = DateTime.Now;
  10605. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10606. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10607. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10608. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10609. string startTime = "2023-10-01 11:22:31";
  10610. int order_type = GetPostInt("order_type");
  10611. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10612. {
  10613. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10614. if (order_type == 0)
  10615. {
  10616. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10617. }
  10618. else if (order_type == 3)
  10619. {
  10620. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10621. }
  10622. else
  10623. {
  10624. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10625. }
  10626. }
  10627. //客服
  10628. if (postCode == "CustomerService" || postCode == "Director")
  10629. {
  10630. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10631. if (order_type == 0)
  10632. {
  10633. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10634. }
  10635. else if (order_type == 1)
  10636. {
  10637. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10638. }
  10639. else if (order_type == 2)
  10640. {
  10641. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10642. }
  10643. else if (order_type == 3)
  10644. {
  10645. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10646. }
  10647. else if (order_type == 4)
  10648. {
  10649. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10650. }
  10651. else
  10652. {
  10653. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10654. }
  10655. }
  10656. //售后
  10657. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10658. {
  10659. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10660. if (shopIds != "")
  10661. {
  10662. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10663. }
  10664. if (order_type == 2)
  10665. {
  10666. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10667. }
  10668. else if (order_type == 4)
  10669. {
  10670. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10671. }
  10672. else if (order_type == 5)
  10673. {
  10674. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10675. }
  10676. else
  10677. {
  10678. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10679. }
  10680. }
  10681. //下单部
  10682. if (postCode == "Place" || postCode == "PlaceMr")
  10683. {
  10684. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10685. if (shopIds != "")
  10686. {
  10687. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10688. }
  10689. else if (order_type == 1)
  10690. {
  10691. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10692. }
  10693. else if (order_type == 2)
  10694. {
  10695. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10696. }
  10697. else
  10698. {
  10699. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10700. }
  10701. }
  10702. //车间
  10703. if (postCode == "Supplier")
  10704. {
  10705. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10706. if (order_type == 5)
  10707. {
  10708. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10709. }
  10710. else
  10711. {
  10712. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10713. }
  10714. }
  10715. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10716. dStruct.Fileds = "tid,ctid";
  10717. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10718. writeGridDataTableJson(dStruct.TotalCount, dt);
  10719. }
  10720. public void aftersale_audit_master()
  10721. {
  10722. if (UrlPostParmsCheck("ctid"))
  10723. {
  10724. string ctid = GetPostString("ctid");
  10725. if (ctid.Length > 0)
  10726. {
  10727. bool result = aftersale_data_change(ctid);
  10728. if (result)
  10729. {
  10730. returnSuccessMsg("修改成功!");
  10731. return;
  10732. }
  10733. }
  10734. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10735. }
  10736. }
  10737. public void aftersale_batch_audit_master()
  10738. {
  10739. if (UrlPostParmsCheck("ctids"))
  10740. {
  10741. string ctids = GetPostString("ctids");
  10742. if (ctids.Length > 0)
  10743. {
  10744. List<string> list = new List<string>();
  10745. string[] ctid_list = ctids.Split(',');
  10746. foreach (var item in ctid_list)
  10747. {
  10748. bool result = aftersale_data_change(item);
  10749. if (!result)
  10750. {
  10751. list.Add(item);
  10752. }
  10753. }
  10754. if (list.Count > 0)
  10755. {
  10756. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10757. return;
  10758. }
  10759. returnSuccessMsg("修改成功!");
  10760. return;
  10761. }
  10762. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10763. }
  10764. }
  10765. public bool aftersale_data_change(string ctid)
  10766. {
  10767. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10768. if (ceErpTradeCell != null)
  10769. {
  10770. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10771. ceErpTradeCell.AfterSaleSupplierState = 0;
  10772. StringBuilder sql = new StringBuilder();
  10773. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10774. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10775. CeErpTradeResponsible.DelByTid(ctid, 0);
  10776. 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 == "不理赔")
  10777. {
  10778. CeErpTradeResponsible.DelByTid(ctid, 1);
  10779. ceErpTradeCell.AfterSaleSupplierState = 1;
  10780. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10781. ceErpTradeCell.AfterSaleState = 4;
  10782. }
  10783. else
  10784. {
  10785. ceErpTradeCell.AfterSaleState = 3;
  10786. }
  10787. bool needCyt = false;
  10788. if (dt != null)
  10789. {
  10790. if (dt.Rows.Count == 1)
  10791. {
  10792. bool isEnd = false;
  10793. foreach (DataRow dr in dt.Rows)
  10794. {
  10795. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10796. {
  10797. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10798. isEnd = true;
  10799. }
  10800. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10801. {
  10802. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10803. isEnd = true;
  10804. }
  10805. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10806. {
  10807. needCyt = true;
  10808. }
  10809. }
  10810. if (isEnd)
  10811. {
  10812. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10813. ceErpTradeCell.AfterSaleState = 4;
  10814. ceErpTradeCell.AfterSaleSupplierState = 1;
  10815. }
  10816. }
  10817. else
  10818. {
  10819. bool isAll = true;
  10820. foreach (DataRow dr in dt.Rows)
  10821. {
  10822. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10823. {
  10824. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10825. continue;
  10826. }
  10827. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10828. {
  10829. string path = "";
  10830. int OrgID = 0;
  10831. if (!Convert.IsDBNull(dr["OrgPath"]))
  10832. {
  10833. path = dr["OrgPath"].ToString();
  10834. }
  10835. if (!Convert.IsDBNull(dr["OrgID"]))
  10836. {
  10837. OrgID = Convert.ToInt32(dr["OrgID"]);
  10838. }
  10839. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10840. {
  10841. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10842. continue;
  10843. }
  10844. }
  10845. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10846. {
  10847. needCyt = true;
  10848. }
  10849. isAll = false;
  10850. }
  10851. if (isAll)
  10852. {
  10853. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10854. ceErpTradeCell.AfterSaleState = 4;
  10855. ceErpTradeCell.AfterSaleSupplierState = 1;
  10856. }
  10857. }
  10858. }
  10859. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10860. {
  10861. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10862. }
  10863. if (ceErpTradeCell.AfterSaleState == 4)
  10864. {
  10865. ApiVo apiVo = new ApiVo();
  10866. apiVo.orderNumber = ceErpTradeCell.ctid;
  10867. apiVo.actionName = "afterOver";
  10868. designHelper.API_WorkCore(apiVo); //afterOver
  10869. }
  10870. ceErpTradeCell.Update();
  10871. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10872. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10873. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10874. return true;
  10875. }
  10876. return false;
  10877. }
  10878. public void get_erp_wechatorder()
  10879. {
  10880. DataStruct dStruct = GetPostStruct();
  10881. List<string> lw = new List<string>();
  10882. string tid = GetPostString("tid");
  10883. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10884. string shopname = GetPostString("shopname");
  10885. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10886. string buyernick = GetPostString("buyer_nick");
  10887. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10888. string customer = GetPostString("customer");
  10889. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10890. string returndate1 = GetPostString("returndate1");
  10891. string returndate2 = GetPostString("returndate2");
  10892. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10893. if (dw.Length > 0) lw.Add(dw);
  10894. string finishDate1 = GetPostString("finishdate1");
  10895. string finishDate2 = GetPostString("finishdate2");
  10896. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10897. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10898. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10899. dStruct.Order = "created desc";
  10900. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10901. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10902. writeGridDataTableJson(dStruct.TotalCount, dt);
  10903. }
  10904. public void get_erp_wechatlist_sumprice()
  10905. {
  10906. DataStruct dStruct = GetPostStruct();
  10907. List<string> lw = new List<string>();
  10908. string tid = GetPostString("tid");
  10909. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10910. string shopname = GetPostString("shopname");
  10911. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10912. string buyernick = GetPostString("buyer_nick");
  10913. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10914. string customer = GetPostString("customer");
  10915. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10916. string returndate1 = GetPostString("returndate1");
  10917. string returndate2 = GetPostString("returndate2");
  10918. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10919. if (dw.Length > 0) lw.Add(dw);
  10920. string finishDate1 = GetPostString("finishdate1");
  10921. string finishDate2 = GetPostString("finishdate2");
  10922. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10923. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10924. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10925. string mainWhere = string.Join(" and ", lw.ToArray());
  10926. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10927. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10928. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10929. decimal total = 0;
  10930. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10931. {
  10932. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10933. }
  10934. var res = new
  10935. {
  10936. data = total
  10937. };
  10938. string ro_jsond = JsonConvert.SerializeObject(res);
  10939. returnSuccess(ro_jsond);
  10940. return;
  10941. }
  10942. public void get_erp_qr_waitdeliverylist()
  10943. {
  10944. DataStruct dStruct = GetPostStruct();
  10945. List<string> lw = new List<string>();
  10946. string tid = GetPostString("ctid");
  10947. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10948. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10949. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10950. var res_objz = new
  10951. {
  10952. restype = 1,
  10953. data = dt
  10954. };
  10955. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10956. returnSuccess(ro_jsonz);
  10957. }
  10958. public void get_erp_yield_list()
  10959. {
  10960. DataStruct dStruct = GetPostStruct();
  10961. List<string> lw = new List<string>();
  10962. string tid = GetPostString("ctid");
  10963. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10964. string shopname = GetPostString("shopname");
  10965. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10966. string buyernick = GetPostString("buyer_nick");
  10967. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10968. //if (tid.Length == 0 && buyernick.Length == 0)
  10969. //{
  10970. // lw.Add(string.Format("IsRefund<={0}", 1));
  10971. //}
  10972. string customer = GetPostString("customer");
  10973. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10974. string design = GetPostString("design");
  10975. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10976. string orderState = GetPostString("orderState");
  10977. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10978. string address = GetPostString("address");
  10979. 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));
  10980. string sellermemo = GetPostString("seller_memo");
  10981. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10982. string supplier = GetPostString("supplier");
  10983. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10984. string OrderArea = GetPostString("order_area");
  10985. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10986. string placedate1 = GetPostString("placedate1");
  10987. string placedate2 = GetPostString("placedate2");
  10988. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10989. if (fdw.Length > 0) lw.Add(fdw);
  10990. string price1 = GetPostString("price1");
  10991. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10992. string price2 = GetPostString("price2");
  10993. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10994. string unusualCon = GetPostString("unusualcon");
  10995. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10996. string posTag = CurrentUser.UserPost.Post.Code;
  10997. if (posTag == "Supplier")
  10998. {
  10999. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11000. }
  11001. lw.Add(string.Format("OrderState = 6 "));
  11002. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11003. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11004. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11005. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11006. writeGridDataTableJson(dStruct.TotalCount, dt);
  11007. }
  11008. public void change_erp_sup_state()
  11009. {
  11010. if (UrlPostParmsCheck("ctid"))
  11011. {
  11012. string ctid = GetPostString("ctid");
  11013. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11014. if (ceErpTradeCell != null)
  11015. {
  11016. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11017. if (ceErpTradeCellExtend == null)
  11018. {
  11019. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11020. ceErpTradeCellExtend.ctid = ctid;
  11021. ceErpTradeCellExtend.SupState = 1;
  11022. ceErpTradeCellExtend.Create();
  11023. }
  11024. else
  11025. {
  11026. ceErpTradeCellExtend.SupState = 1;
  11027. ceErpTradeCellExtend.Update();
  11028. }
  11029. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11030. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11031. return;
  11032. }
  11033. returnErrorMsg("找不到订单");
  11034. }
  11035. }
  11036. public void supplier_all_downs()
  11037. {
  11038. if (UrlPostParmsCheck("tids"))
  11039. {
  11040. string tids = GetPostString("tids");
  11041. if (tids != null && tids.Length > 0)
  11042. {
  11043. StringBuilder sql = new StringBuilder();
  11044. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11045. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11046. sql = new StringBuilder();
  11047. 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, "下载设计文件");
  11048. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11049. string[] list = tids.Split(',');
  11050. foreach (string ctid in list)
  11051. {
  11052. CeErpSukuraData.createInfo(ctid, 3);
  11053. }
  11054. designHelper.api_approveDesign(tids); //approveDesign
  11055. returnSuccessMsg("下载成功!");
  11056. return;
  11057. }
  11058. returnErrorMsg("下载订单更新失败");
  11059. }
  11060. }
  11061. public void uploaderFileSuccess()
  11062. {
  11063. if (UrlPostParmsCheck("fileName"))
  11064. {
  11065. string fileName = GetPostString("fileName");
  11066. ApiVo apiVo = new ApiVo();
  11067. apiVo.orderNumber = fileName;
  11068. apiVo.actionName = "finishDesign";
  11069. designHelper.API_WorkCore(apiVo);//finishDesign
  11070. returnSuccessMsg("");
  11071. }
  11072. }
  11073. public void get_sample2_order()
  11074. {
  11075. if (UrlPostParmsCheck("ctid"))
  11076. {
  11077. string ctid = GetPostString("ctid");
  11078. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11079. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11080. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11081. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11082. double total = 0.0;
  11083. double order_price = 0.0;
  11084. if (dt_bu.Rows.Count > 0)
  11085. {
  11086. foreach (DataRow dr in dt_bu.Rows)
  11087. {
  11088. total += Convert.ToDouble(dr["payment"]);
  11089. }
  11090. }
  11091. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11092. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11093. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11094. string tid = ctid.Replace("S_", "");
  11095. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11096. double paymant = 0.0;
  11097. if (entity != null)
  11098. {
  11099. paymant = entity.payment;
  11100. }
  11101. string return_reason = "";
  11102. if (dt_after != null && dt_after.Rows.Count > 0)
  11103. {
  11104. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11105. }
  11106. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11107. }
  11108. }
  11109. public void get_erp_design_status()
  11110. {
  11111. string designName = GetPostString("designName");
  11112. DataStruct dStruct = GetPostStruct();
  11113. if (designName.Length > 0)
  11114. {
  11115. 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";
  11116. sql_user += " and Name like '%" + designName + "%'";
  11117. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11118. List<string> ids_list = new List<string>();
  11119. if (user_table.Rows.Count > 0)
  11120. {
  11121. foreach (DataRow item in user_table.Rows)
  11122. {
  11123. ids_list.Add(item["id"].ToString());
  11124. string ids_s = item["TeamIds"].ToString();
  11125. if (ids_s.Length > 0)
  11126. {
  11127. ids_list.AddRange(ids_s.Split(','));
  11128. }
  11129. }
  11130. }
  11131. HashSet<string> set = new HashSet<string>(ids_list);
  11132. ids_list = set.ToList();
  11133. if (ids_list.Count > 0)
  11134. {
  11135. 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));
  11136. dStruct.MainWhere = sql;
  11137. DataTable dt = null;
  11138. dt = WebCache.GetData("view_ErpUser", dStruct);
  11139. writeGridDataTableJson(dStruct.TotalCount, dt);
  11140. }
  11141. }
  11142. }
  11143. public void change_erp_order_price()
  11144. {
  11145. string ctid = GetPostString("ctid");
  11146. double price = GetPostDouble("price");
  11147. if (ctid.Length > 0)
  11148. {
  11149. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11150. if (ceErpTradeCellExtend == null)
  11151. {
  11152. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11153. ceErpTradeCellExtend.ctid = ctid;
  11154. ceErpTradeCellExtend.payment_cyt = price;
  11155. ceErpTradeCellExtend.Create();
  11156. }
  11157. else
  11158. {
  11159. ceErpTradeCellExtend.payment_cyt = price;
  11160. ceErpTradeCellExtend.Update();
  11161. }
  11162. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11163. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11164. {
  11165. ceErpDataSendOrderInfo.isSync = false;
  11166. ceErpDataSendOrderInfo.Update();
  11167. }
  11168. if (ceErpDataSendOrderInfo == null)
  11169. {
  11170. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11171. ceErpDataSendOrderInfo.isSync = false;
  11172. ceErpDataSendOrderInfo.ctid = ctid;
  11173. ceErpDataSendOrderInfo.Create();
  11174. }
  11175. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11176. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11177. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11178. if (dth != null && dth.Rows.Count > 0)
  11179. {
  11180. dataSendOrderBean dataSendOrderBean = null;
  11181. foreach (DataRow item in dth.Rows)
  11182. {
  11183. try
  11184. {
  11185. dataSendOrderBean = new dataSendOrderBean();
  11186. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11187. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11188. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11189. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11190. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11191. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11192. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11193. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11194. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11195. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11196. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11197. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11198. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11199. if (result != null)
  11200. {
  11201. if ("0".Equals(result.errcode))
  11202. {
  11203. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11204. }
  11205. else
  11206. {
  11207. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11208. }
  11209. }
  11210. }
  11211. catch (Exception ex)
  11212. {
  11213. }
  11214. }
  11215. }
  11216. returnSuccessMsg("修改成功!");
  11217. return;
  11218. }
  11219. returnErrorMsg("找不到订单");
  11220. }
  11221. public void find_he_together()
  11222. {
  11223. string ctid = GetPostString("ctid");
  11224. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11225. List<string> list = new List<string>();
  11226. if (ceErpTradeCell != null)
  11227. {
  11228. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11229. {
  11230. 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);
  11231. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11232. if (table != null && table.Rows.Count > 0)
  11233. {
  11234. foreach (TableRow row in table.Rows)
  11235. {
  11236. }
  11237. }
  11238. }
  11239. }
  11240. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11241. }
  11242. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11243. {
  11244. //chy----19
  11245. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11246. //GD-CYT-----64
  11247. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11248. //ZHX----3
  11249. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11250. //JK----97
  11251. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11252. //ZT----70
  11253. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11254. //LHCY-----98
  11255. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11256. //XD-----90
  11257. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11258. //CYCY-----14
  11259. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11260. };
  11261. //其他改名
  11262. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11263. {
  11264. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11265. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11266. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11267. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11268. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11269. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11270. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11271. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11272. };
  11273. //不统计
  11274. List<int> no_suppliers = new List<int>()
  11275. {
  11276. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11277. };
  11278. //配件单
  11279. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11280. {
  11281. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11282. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11283. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11284. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11285. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11286. {"旗杆",new List<string>(){ "班旗" } },
  11287. {"牙签",new List<string>(){ "不干胶" } }
  11288. };
  11289. public void get_place_order_data()
  11290. {
  11291. string date1 = GetPostString("date1");
  11292. string date2 = GetPostString("date2");
  11293. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11294. DateTime start = DateTime.Parse(starttime);
  11295. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11296. DateTime end = DateTime.Parse(endtime);
  11297. if (date1 != null && date1.Length > 0)
  11298. {
  11299. DateTime dateTime = DateTime.Parse(date1);
  11300. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11301. start = DateTime.Parse(starttime);
  11302. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11303. end = DateTime.Parse(endtime);
  11304. }
  11305. if (date2 != null && date2.Length > 0)
  11306. {
  11307. DateTime dateTime = DateTime.Parse(date2);
  11308. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11309. end = DateTime.Parse(endtime);
  11310. }
  11311. 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);
  11312. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11313. //不干胶-----1,卡片-----29
  11314. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11315. foreach (DataRow row in data.Rows)
  11316. {
  11317. int productId = Convert.ToInt32(row["ProductId"]);
  11318. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11319. if (no_suppliers.Contains(supplierId))
  11320. {
  11321. continue;
  11322. }
  11323. string seller_memo = row["seller_memo"].ToString();
  11324. bool ispj = false;//是否配件单
  11325. bool isfirst = true;//第一个配
  11326. maps.Keys.ForEach(key =>
  11327. {
  11328. //备注包含配件
  11329. if (seller_memo.Contains(key) && isfirst)
  11330. {
  11331. List<string> list = maps[key];
  11332. ispj = true;
  11333. isfirst = false;
  11334. for (int i = 0; i < list.Count; i++)
  11335. {
  11336. if (seller_memo.Contains(list[i]))
  11337. {
  11338. ispj = false;
  11339. break;
  11340. }
  11341. }
  11342. }
  11343. });
  11344. if (ispj)
  11345. {
  11346. continue;
  11347. }
  11348. seller_memo = seller_memo.Replace("UV", "uv");
  11349. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11350. //吊牌归到卡片
  11351. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11352. seller_memo = seller_memo.Replace("卡套", "卡片");
  11353. seller_memo = seller_memo.Replace("封套", "卡片");
  11354. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11355. seller_memo = seller_memo.Replace("腰封", "卡片");
  11356. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11357. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11358. seller_memo = seller_memo.Replace("横幅", "条幅");
  11359. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11360. string map_key = "";
  11361. string type = "";
  11362. if (supplierMap.ContainsKey(supplierId))
  11363. {
  11364. foreach (var kvp in supplierMap[supplierId])
  11365. {
  11366. if (seller_memo.Contains(kvp.Key))
  11367. {
  11368. map_key = kvp.Value;
  11369. type = kvp.Value;
  11370. break;
  11371. }
  11372. }
  11373. }
  11374. if (map_key == "")
  11375. {
  11376. type = "其他";
  11377. map_key = "其他";
  11378. }
  11379. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11380. {
  11381. map_key = suppliers[supplierId];
  11382. }
  11383. if (supplierId == 70)
  11384. {
  11385. supplierId = 70;
  11386. }
  11387. map_key += "_" + row["SupplierName"].ToString();
  11388. Dictionary<string, int> map = null;
  11389. if (other_map.ContainsKey(map_key))
  11390. {
  11391. other_map.TryGetValue(map_key, out map);
  11392. }
  11393. else
  11394. {
  11395. map = new Dictionary<string, int>();
  11396. map.Add("dayDev", 0);//当天出货
  11397. map.Add("dayTotal", 0);//下单总数
  11398. map.Add("payTotal", 0);//500以上
  11399. map.Add("today", 0);//当天出货数量
  11400. map.Add("unusua", 0);//异常数
  11401. other_map.Add(map_key, map);
  11402. other_map.TryGetValue(map_key, out map);
  11403. }
  11404. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11405. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11406. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11407. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11408. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11409. {
  11410. map["dayTotal"]++;
  11411. if (supplierId == 97)
  11412. {
  11413. supplierId = 97;
  11414. }
  11415. }
  11416. if (Convert.ToDecimal(row["payment"]) >= 500)
  11417. {
  11418. map["payTotal"]++;
  11419. }
  11420. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11421. {
  11422. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11423. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11424. {
  11425. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11426. {
  11427. map["today"]++;
  11428. }
  11429. }
  11430. else
  11431. {
  11432. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11433. {
  11434. map["today"]++;
  11435. }
  11436. else
  11437. {
  11438. if (supplierId == 119)
  11439. {
  11440. Debug.WriteLine(row["seller_memo"].ToString());
  11441. }
  11442. }
  11443. }
  11444. }
  11445. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11446. {
  11447. map["unusua"]++;
  11448. }
  11449. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11450. //GD-CYT-----64
  11451. DateTime two = palceTimeStart.AddHours(14);
  11452. DateTime three = palceTimeStart.AddHours(15);
  11453. DateTime four = palceTimeStart.AddHours(16);
  11454. DateTime six = palceTimeStart.AddHours(18);
  11455. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11456. {
  11457. //下午四点前 500-1000
  11458. string count = row["ProductCount"].ToString();
  11459. if (count != null && count.Length > 0)
  11460. {
  11461. int productCount = commonHelper.getPlaceProductCount(count);
  11462. if (productCount >= 500 && productCount <= 1000)
  11463. {
  11464. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11465. {
  11466. map["dayDev"]++;
  11467. }
  11468. }
  11469. }
  11470. }
  11471. //UV
  11472. else if ("uv".Equals(type))
  11473. {
  11474. //ZT----70
  11475. //ZHX----3
  11476. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11477. {
  11478. map["dayDev"]++;
  11479. }
  11480. //JK----97
  11481. //HZX----105
  11482. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11483. {
  11484. map["dayDev"]++;
  11485. }
  11486. }
  11487. //帆布---52|条幅---27
  11488. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11489. {
  11490. //LHCY-----98
  11491. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11492. {
  11493. map["dayDev"]++;
  11494. }
  11495. }
  11496. //条幅
  11497. else if ("条幅".Equals(type))
  11498. {
  11499. //XD-----90
  11500. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11501. {
  11502. map["dayDev"]++;
  11503. }
  11504. }
  11505. //桌布
  11506. else if ("桌布".Equals(type))
  11507. {
  11508. //XD-----90
  11509. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11510. {
  11511. map["dayDev"]++;
  11512. }
  11513. }
  11514. //DL---10
  11515. //AYTW---119
  11516. //FS-CYT-DY ----80
  11517. //JK----97
  11518. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11519. {
  11520. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11521. {
  11522. map["dayDev"]++;
  11523. }
  11524. }
  11525. // QC---121
  11526. else if (supplierId == 121)
  11527. {
  11528. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11529. {
  11530. map["dayDev"]++;
  11531. }
  11532. }
  11533. }
  11534. DataTable dt = new DataTable();
  11535. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11536. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11537. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11538. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11539. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11540. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11541. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11542. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11543. other_map.Keys.ForEach(key =>
  11544. {
  11545. DataRow dr = dt.NewRow();
  11546. Dictionary<string, int> map = other_map[key];
  11547. string[] key_list = key.Split('_');
  11548. dr[0] = key_list[0];
  11549. dr[1] = key_list[1];
  11550. if (key_list.Length > 2)
  11551. {
  11552. dr[1] += "(" + key_list[2] + ")";
  11553. }
  11554. dr[2] = map["dayTotal"];
  11555. dr[3] = map["payTotal"];
  11556. dr[4] = map["today"];
  11557. dr[5] = map["unusua"];
  11558. dr[6] = map["dayDev"];
  11559. double rate = 0.00;
  11560. if (map["dayDev"] > 0)
  11561. {
  11562. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11563. }
  11564. dr[7] = rate.ToString();
  11565. dt.Rows.Add(dr);
  11566. });
  11567. DataView dv = new DataView(dt);
  11568. dv.Sort = "SupplierName";
  11569. //dv.Sort = "AllOrder desc";
  11570. DataTable dtNew = dv.ToTable();
  11571. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11572. }
  11573. public void check_order_desing_info()
  11574. {
  11575. string ctid = GetPostString("ctid");
  11576. if (!string.IsNullOrEmpty(ctid))
  11577. {
  11578. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11579. if (ceErpTradeCell != null)
  11580. {
  11581. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11582. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11583. return;
  11584. }
  11585. returnErrorMsg("找不到订单");
  11586. return;
  11587. }
  11588. returnErrorMsg("找不到订单");
  11589. }
  11590. public void get_timeout_detail()
  11591. {
  11592. string poscode = CurrentUser.UserPost.Post.Code;
  11593. DataStruct dStruct = GetPostStruct();
  11594. List<string> lw = new List<string>();
  11595. string id = GetPostString("id");
  11596. string pay_date1 = GetPostString("pay_date1");
  11597. string pay_date2 = GetPostString("pay_date2");
  11598. int type = GetPostInt("type");
  11599. if (type == 0)
  11600. {
  11601. if (pay_date1.Length > 0)
  11602. {
  11603. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11604. }
  11605. if (pay_date2.Length > 0)
  11606. {
  11607. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11608. }
  11609. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11610. }
  11611. if (type == 1)
  11612. {
  11613. if (pay_date1.Length > 0)
  11614. {
  11615. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11616. }
  11617. if (pay_date2.Length > 0)
  11618. {
  11619. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11620. }
  11621. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11622. }
  11623. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11624. DataTable dt = null;
  11625. dt = WebCache.GetData("view_orderlist", dStruct);
  11626. writeGridDataTableJson(dStruct.TotalCount, dt);
  11627. }
  11628. public void saveUrgentChargePrice()
  11629. {
  11630. string ctid = GetPostString("ctid");
  11631. if (!string.IsNullOrEmpty(ctid))
  11632. {
  11633. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11634. if (ceErpTradeCell != null)
  11635. {
  11636. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11637. if (prices <= 100)
  11638. {
  11639. returnErrorMsg("此订单金额不足100元,无法加急。");
  11640. return;
  11641. }
  11642. double price = GetPostDouble("price");
  11643. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11644. if (ceErpTradeCellExtend == null)
  11645. {
  11646. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11647. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11648. }
  11649. ceErpTradeCellExtend.urgentCharge = price;
  11650. if (ceErpTradeCellExtend.ID > 0)
  11651. {
  11652. ceErpTradeCellExtend.Update();
  11653. }
  11654. else
  11655. {
  11656. ceErpTradeCellExtend.Save();
  11657. }
  11658. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11659. returnSuccessMsg("修改成功!");
  11660. return;
  11661. }
  11662. returnErrorMsg("找不到订单");
  11663. return;
  11664. }
  11665. returnErrorMsg("找不到订单");
  11666. }
  11667. public void finish_erp_order()
  11668. {
  11669. string ctid = GetPostString("ctid");
  11670. if (!string.IsNullOrEmpty(ctid))
  11671. {
  11672. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11673. {
  11674. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11675. if (ceErpTradeCell != null)
  11676. {
  11677. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11678. ceErpTradeCell.Update();
  11679. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11680. returnSuccessMsg("修改成功!");
  11681. return;
  11682. }
  11683. }
  11684. }
  11685. returnErrorMsg("找不到订单");
  11686. }
  11687. public void get_trade_order_list()
  11688. {
  11689. string tid = GetPostString("tid");
  11690. if (!string.IsNullOrEmpty(tid))
  11691. {
  11692. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11693. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11694. writeGridDataTableJson(data.Rows.Count, data);
  11695. return;
  11696. }
  11697. returnErrorMsg("找不到订单");
  11698. }
  11699. public void save_cell_spu()
  11700. {
  11701. string ctid = GetPostString("ctid");
  11702. string spu_id = GetPostString("spu_id");
  11703. if (!string.IsNullOrEmpty(ctid))
  11704. {
  11705. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11706. if (ceErpTradeCellExtend == null)
  11707. {
  11708. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11709. ceErpTradeCellExtend.ctid = ctid;
  11710. }
  11711. ceErpTradeCellExtend.spu_id = spu_id;
  11712. if (!string.IsNullOrEmpty(spu_id))
  11713. {
  11714. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11715. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11716. }
  11717. if (ceErpTradeCellExtend.ID == 0)
  11718. {
  11719. ceErpTradeCellExtend.Create();
  11720. }
  11721. else
  11722. {
  11723. ceErpTradeCellExtend.Update();
  11724. }
  11725. returnSuccessMsg("修改成功!");
  11726. return;
  11727. }
  11728. returnErrorMsg("找不到订单");
  11729. }
  11730. public void change_express_info()
  11731. {
  11732. string ctid = GetPostString("ctid");
  11733. string transNo = GetPostString("transNo");
  11734. string transCom = GetPostString("transCom");
  11735. if (!string.IsNullOrEmpty(ctid))
  11736. {
  11737. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11738. if (ceErpTradeCellExtend == null)
  11739. {
  11740. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11741. ceErpTradeCellExtend.ctid = ctid;
  11742. }
  11743. ceErpTradeCellExtend.modExpressNo = transNo;
  11744. ceErpTradeCellExtend.modExpressCom = transCom;
  11745. ceErpTradeCellExtend.readMod = 2;
  11746. if (ceErpTradeCellExtend.ID == 0)
  11747. {
  11748. ceErpTradeCellExtend.Create();
  11749. }
  11750. else
  11751. {
  11752. ceErpTradeCellExtend.Update();
  11753. }
  11754. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11755. returnSuccessMsg("修改成功!");
  11756. return;
  11757. }
  11758. returnErrorMsg("找不到订单");
  11759. }
  11760. public void get_change_express_list()
  11761. {
  11762. DataStruct dStruct = GetPostStruct();
  11763. List<string> lw = new List<string>();
  11764. int st = 2;
  11765. string tid = GetPostString("ctid");
  11766. if (tid.Length > 0)
  11767. {
  11768. string select_tid = getTidByCtid(tid);
  11769. lw.Add(string.Format("tid='{0}'", select_tid));
  11770. }
  11771. string shopname = GetPostString("shopname");
  11772. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11773. string buyernick = GetPostString("buyer_nick");
  11774. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11775. string sellermemo = GetPostString("seller_memo");
  11776. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11777. string supplier = GetPostString("supplier");
  11778. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11779. string customer = GetPostString("customer");
  11780. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11781. string design = GetPostString("design");
  11782. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11783. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11784. string poscode = CurrentUser.UserPost.Post.Code;
  11785. if (poscode != "SysAdmin")
  11786. {
  11787. string shopid = CurrentUser.User.pemShop;
  11788. lw.Add(string.Format("shopId in ({0})", shopid));
  11789. }
  11790. lw.Add("readMod = 2");
  11791. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11792. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11793. writeGridDataTableJson(dStruct.TotalCount, dt);
  11794. }
  11795. public void deal_express_complete()
  11796. {
  11797. string ctid = GetPostString("ctid");
  11798. if (!string.IsNullOrEmpty(ctid))
  11799. {
  11800. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11801. if (ceErpTradeCellExtend == null)
  11802. {
  11803. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11804. ceErpTradeCellExtend.ctid = ctid;
  11805. }
  11806. ceErpTradeCellExtend.readMod = 1;
  11807. if (ceErpTradeCellExtend.ID == 0)
  11808. {
  11809. ceErpTradeCellExtend.Create();
  11810. }
  11811. else
  11812. {
  11813. ceErpTradeCellExtend.Update();
  11814. }
  11815. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11816. returnSuccessMsg("修改成功!");
  11817. return;
  11818. }
  11819. returnErrorMsg("找不到订单");
  11820. }
  11821. public void aftersale_return_visit()
  11822. {
  11823. string ctid = GetPostString("ctid");
  11824. if (!string.IsNullOrEmpty(ctid))
  11825. {
  11826. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11827. if (ceErpTradeCellExtend == null)
  11828. {
  11829. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11830. ceErpTradeCellExtend.ctid = ctid;
  11831. }
  11832. ceErpTradeCellExtend.returnVisit = 1;
  11833. if (ceErpTradeCellExtend.ID == 0)
  11834. {
  11835. ceErpTradeCellExtend.Create();
  11836. }
  11837. else
  11838. {
  11839. ceErpTradeCellExtend.Update();
  11840. }
  11841. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11842. if (ceErpTradeAfterSaleExtend != null)
  11843. {
  11844. ceErpTradeAfterSaleExtend.TextResult = "";
  11845. ceErpTradeAfterSaleExtend.Update();
  11846. }
  11847. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11848. returnSuccessMsg("修改成功!");
  11849. return;
  11850. }
  11851. returnErrorMsg("找不到订单");
  11852. }
  11853. public void orderPlaceInfo()
  11854. {
  11855. string ctids = GetPostString("ctids");
  11856. string[] list = ctids.Split(',');
  11857. foreach (string ctid in list)
  11858. {
  11859. CeErpSukuraData.createInfo(ctid, 3);
  11860. }
  11861. StringBuilder sql = new StringBuilder();
  11862. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11863. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11864. designHelper.api_approveDesign(ctids); //approveDesign
  11865. returnSuccessMsg("");
  11866. }
  11867. public void get_issue_list()
  11868. {
  11869. DataStruct dStruct = GetPostStruct();
  11870. List<string> lw = new List<string>();
  11871. int st = 2;
  11872. string tid = GetPostString("ctid");
  11873. if (tid.Length > 0)
  11874. {
  11875. string select_tid = getTidByCtid(tid);
  11876. lw.Add(string.Format("tid='{0}'", select_tid));
  11877. }
  11878. string shopname = GetPostString("shopname");
  11879. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11880. string buyernick = GetPostString("buyer_nick");
  11881. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11882. string sellermemo = GetPostString("seller_memo");
  11883. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11884. string supplier = GetPostString("supplier");
  11885. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11886. string customer = GetPostString("customer");
  11887. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11888. string design = GetPostString("design");
  11889. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11890. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11891. string poscode = CurrentUser.UserPost.Post.Code;
  11892. if (poscode != "SysAdmin")
  11893. {
  11894. string shopid = CurrentUser.User.pemShop;
  11895. lw.Add(string.Format("shopId in ({0})", shopid));
  11896. }
  11897. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11898. {
  11899. lw.Add("IssueState = 1");
  11900. }
  11901. lw.Add("IssueState > 0");
  11902. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11903. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11904. writeGridDataTableJson(dStruct.TotalCount, dt);
  11905. }
  11906. public void saveIssueContent()
  11907. {
  11908. string ctid = GetPostString("ctid");
  11909. if (!string.IsNullOrEmpty(ctid))
  11910. {
  11911. string content = GetPostString("content");
  11912. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11913. if (ceErpTradeAfterSaleExtend == null)
  11914. {
  11915. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11916. ceErpTradeAfterSaleExtend.tid = ctid;
  11917. }
  11918. ceErpTradeAfterSaleExtend.IssueContent = content;
  11919. ceErpTradeAfterSaleExtend.IssueState = 1;
  11920. if (ceErpTradeAfterSaleExtend.ID > 0)
  11921. {
  11922. ceErpTradeAfterSaleExtend.Update();
  11923. }
  11924. else
  11925. {
  11926. ceErpTradeAfterSaleExtend.Create();
  11927. }
  11928. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11929. returnSuccessMsg("添加成功!");
  11930. return;
  11931. }
  11932. returnErrorMsg("找不到订单");
  11933. }
  11934. public void dealIssueContent()
  11935. {
  11936. string ctid = GetPostString("ctid");
  11937. if (!string.IsNullOrEmpty(ctid))
  11938. {
  11939. string content = GetPostString("content");
  11940. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11941. if (ceErpTradeAfterSaleExtend != null)
  11942. {
  11943. ceErpTradeAfterSaleExtend.IssueState = 2;
  11944. ceErpTradeAfterSaleExtend.Update();
  11945. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11946. returnSuccessMsg("修改完成!");
  11947. return;
  11948. }
  11949. }
  11950. returnErrorMsg("找不到订单");
  11951. }
  11952. public void set_tid_attachments()
  11953. {
  11954. string tid = GetPostString("tid");
  11955. string atta = GetPostString("atta");
  11956. if (!string.IsNullOrEmpty(tid))
  11957. {
  11958. if (string.IsNullOrEmpty(atta))
  11959. {
  11960. returnErrorMsg("文件地址为空");
  11961. return;
  11962. }
  11963. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11964. if (ceErpTradeCell != null)
  11965. {
  11966. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11967. if (ceErpTrade == null)
  11968. {
  11969. returnErrorMsg("找不到订单");
  11970. return;
  11971. }
  11972. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11973. bool isSend = false;
  11974. if (dt != null && dt.Rows.Count > 0)
  11975. {
  11976. foreach (DataRow row in dt.Rows)
  11977. {
  11978. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11979. {
  11980. isSend = true;
  11981. }
  11982. }
  11983. if (isSend)
  11984. {
  11985. returnErrorMsg("已发货无法修改");
  11986. return;
  11987. }
  11988. ceErpTrade.Attachments = atta;
  11989. ceErpTrade.Update();
  11990. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  11991. returnSuccessMsg("上传成功!");
  11992. return;
  11993. }
  11994. }
  11995. }
  11996. returnErrorMsg("找不到订单");
  11997. }
  11998. public void get_tid_attachments()
  11999. {
  12000. string tid = GetPostString("tid");
  12001. if (!string.IsNullOrEmpty(tid))
  12002. {
  12003. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12004. if (ceErpTradeCell != null)
  12005. {
  12006. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12007. if (ceErpTrade == null)
  12008. {
  12009. returnErrorMsg("找不到订单");
  12010. return;
  12011. }
  12012. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12013. return;
  12014. }
  12015. }
  12016. returnErrorMsg("找不到订单");
  12017. }
  12018. public void check_erp_sameorders()
  12019. {
  12020. if (UrlPostParmsCheck("ctid"))
  12021. {
  12022. string eid = GetPostString("ctid");
  12023. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12024. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12025. if (entity != null && ceErpTrade != null)
  12026. {
  12027. if (entity.OrderState > 6)
  12028. {
  12029. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12030. return;
  12031. }
  12032. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12033. List<string> ids = new List<string>();
  12034. if (dt != null && dt.Rows.Count > 1)
  12035. {
  12036. bool needhe = true;
  12037. foreach (DataRow dr in dt.Rows)
  12038. {
  12039. ids.Add("'" + dr["ctid"] + "'");
  12040. /* //备注有合包
  12041. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12042. {
  12043. needhe = true;
  12044. }
  12045. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12046. {
  12047. needhe = true;
  12048. }
  12049. //顺丰快递
  12050. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12051. {
  12052. needhe = true;
  12053. }*/
  12054. }
  12055. if (!needhe)
  12056. {
  12057. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12058. return;
  12059. }
  12060. StringBuilder sql = new StringBuilder();
  12061. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12062. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12063. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12064. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12065. foreach (DataRow dr in dt.Rows)
  12066. {
  12067. dr["dstate"] = 0;
  12068. dr["dnumber"] = 0;
  12069. foreach (DataRow row in dt1.Rows)
  12070. {
  12071. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12072. {
  12073. dr["dstate"] = 2;
  12074. dr["default"] = 1;
  12075. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12076. }
  12077. }
  12078. if (eid.Equals(dr["ctid"].ToString()))
  12079. {
  12080. dr["dstate"] = 1;
  12081. dr["default"] = 1;
  12082. }
  12083. }
  12084. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12085. return;
  12086. }
  12087. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12088. return;
  12089. }
  12090. returnErrorMsg("未找到订单");
  12091. return;
  12092. }
  12093. returnErrorMsg("缺少必要的参数");
  12094. }
  12095. public void get_mark_number()
  12096. {
  12097. string eid = GetPostString("ctid");
  12098. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12099. if (entity != null)
  12100. {
  12101. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12102. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12103. int current = 1;
  12104. if (ceErpDeliverMark == null)
  12105. {
  12106. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12107. List<string> ids = new List<string>();
  12108. if (dt != null && dt.Rows.Count > 1)
  12109. {
  12110. foreach (DataRow dr in dt.Rows)
  12111. {
  12112. ids.Add("'" + dr["ctid"] + "'");
  12113. }
  12114. //查询已有的编号
  12115. StringBuilder sql = new StringBuilder();
  12116. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12117. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12118. if (dt1 == null || dt1.Rows.Count == 0)
  12119. {
  12120. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12121. List<int> list_number = new List<int>();
  12122. foreach (DataRow row in numbers.Rows)
  12123. {
  12124. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12125. }
  12126. //查询空余编号
  12127. for (int i = 0; i < list_number.Count + 2; i++)
  12128. {
  12129. if (!list_number.Contains(current))
  12130. {
  12131. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12132. //防止查询过程中有新数据生成
  12133. if (ceErpDeliverMark1 == null)
  12134. {
  12135. break;
  12136. }
  12137. }
  12138. current++;
  12139. }
  12140. }
  12141. else
  12142. {
  12143. foreach (DataRow row in dt1.Rows)
  12144. {
  12145. current = Convert.ToInt32(row["markNumber"]);
  12146. }
  12147. }
  12148. ceErpDeliverMark = new CeErpDeliverMark();
  12149. ceErpDeliverMark.ctid = eid;
  12150. ceErpDeliverMark.createtime = DateTime.Now;
  12151. if (ceErpTrade != null)
  12152. {
  12153. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12154. }
  12155. ceErpDeliverMark.markNumber = current;
  12156. ceErpDeliverMark.Create();
  12157. }
  12158. }
  12159. else
  12160. {
  12161. current = ceErpDeliverMark.markNumber;
  12162. }
  12163. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12164. return;
  12165. }
  12166. }
  12167. public void aftersaleCytSend()
  12168. {
  12169. string ctid = GetPostString("ctid");
  12170. if (!string.IsNullOrEmpty(ctid))
  12171. {
  12172. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12173. if (ceErpTradeCell != null)
  12174. {
  12175. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12176. }
  12177. returnSuccessMsg("推送成功");
  12178. return;
  12179. }
  12180. returnErrorMsg("缺少必要的参数");
  12181. }
  12182. public void packOrderInfo()
  12183. {
  12184. string ctids = GetPostString("ctids");
  12185. if (!string.IsNullOrEmpty(ctids))
  12186. {
  12187. string[] ctid_list = ctids.Split(',');
  12188. if (ctid_list.Length > 20)
  12189. {
  12190. returnErrorMsg("单次下载次数不能超过20个");
  12191. return;
  12192. }
  12193. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12194. StringBuilder sql = new StringBuilder();
  12195. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12196. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12197. int supplierId = 0;
  12198. StringBuilder insterSql = new StringBuilder();
  12199. for (int i = 0; i < dt.Rows.Count; i++)
  12200. {
  12201. DataRow row = dt.Rows[i];
  12202. if (i == 0)
  12203. {
  12204. supplierId = Convert.ToInt32(row["SupplierId"]);
  12205. }
  12206. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12207. {
  12208. returnErrorMsg("同车间的订单才能一起打包");
  12209. return;
  12210. }
  12211. int orderState = Convert.ToInt32(row["OrderState"]);
  12212. if (orderState != 5)
  12213. {
  12214. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12215. return;
  12216. }
  12217. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12218. }
  12219. CeErpPackData ceErpPackData = new CeErpPackData();
  12220. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12221. ceErpPackData.supplierId = supplierId;
  12222. ceErpPackData.createtime = DateTime.Now;
  12223. ceErpPackData.createBy = CurrentUser.UserID;
  12224. ceErpPackData.createName = CurrentUser.UserName;
  12225. ceErpPackData.Create();
  12226. if (ceErpPackData.ID > 0)
  12227. {
  12228. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12229. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12230. }
  12231. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12232. returnSuccessMsg("打包成功");
  12233. return;
  12234. }
  12235. returnErrorMsg("缺少必要的参数");
  12236. }
  12237. public void rePackOrderInfo()
  12238. {
  12239. string id = GetPostString("id");
  12240. if (!string.IsNullOrEmpty(id))
  12241. {
  12242. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12243. if (ceErpPackData == null)
  12244. {
  12245. returnSuccessMsg("查无数据");
  12246. return;
  12247. }
  12248. ceErpPackData.upStatus = 0;
  12249. ceErpPackData.message = "";
  12250. ceErpPackData.Update();
  12251. returnSuccessMsg("打包成功");
  12252. return;
  12253. }
  12254. returnErrorMsg("缺少必要的参数");
  12255. }
  12256. public void addPackDownNum()
  12257. {
  12258. string id = GetPostString("id");
  12259. if (!string.IsNullOrEmpty(id))
  12260. {
  12261. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12262. returnSuccessMsg("下载成功");
  12263. return;
  12264. }
  12265. returnErrorMsg("缺少必要的参数");
  12266. }
  12267. public void get_pack_list()
  12268. {
  12269. DataStruct dStruct = GetPostStruct();
  12270. List<string> lw = new List<string>();
  12271. string supplier = GetPostString("supplier");
  12272. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12273. string posTag = CurrentUser.UserPost.Post.Code;
  12274. if (posTag == "Supplier")
  12275. {
  12276. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12277. }
  12278. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12279. dStruct.Order = "createtime desc";
  12280. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12281. writeGridDataTableJson(dStruct.TotalCount, dt);
  12282. }
  12283. public void get_pack_order_list()
  12284. {
  12285. string packId = GetPostString("packId");
  12286. if (string.IsNullOrEmpty(packId))
  12287. {
  12288. returnErrorMsg("缺少必要的参数");
  12289. return;
  12290. }
  12291. StringBuilder sql = new StringBuilder();
  12292. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12293. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12294. if (dt == null || dt.Rows.Count == 0)
  12295. {
  12296. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12297. return;
  12298. }
  12299. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12300. return;
  12301. }
  12302. public void get_supplier_product_time_list()
  12303. {
  12304. DataStruct dStruct = GetPostStruct();
  12305. List<string> lw = new List<string>();
  12306. string supplier = GetPostString("supplier");
  12307. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12308. string posTag = CurrentUser.UserPost.Post.Code;
  12309. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12310. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12311. writeGridDataTableJson(dStruct.TotalCount, dt);
  12312. }
  12313. public void saveSupplierProductTime()
  12314. {
  12315. string productId = GetPostString("productId");
  12316. if (string.IsNullOrEmpty(productId))
  12317. {
  12318. returnErrorMsg("缺少必要的参数");
  12319. return;
  12320. }
  12321. string productName = GetPostString("productName");
  12322. int supplierId = GetPostInt("supplierId");
  12323. if (supplierId == 0)
  12324. {
  12325. returnErrorMsg("缺少必要的参数");
  12326. return;
  12327. }
  12328. int quantity = GetPostInt("quantity");
  12329. int sendDay = GetPostInt("sendTime");
  12330. string supplierName = GetPostString("supplierName");
  12331. string craft = GetPostString("craft");
  12332. string deadLine = GetPostString("deadLine");
  12333. string dayDeadLine = GetPostString("dayDeadLine");
  12334. try
  12335. {
  12336. int eid = GetPostInt("eid");
  12337. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12338. if (ceErpSupplierProductTime == null)
  12339. {
  12340. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12341. }
  12342. ceErpSupplierProductTime.productId = productId;
  12343. ceErpSupplierProductTime.productName = productName;
  12344. ceErpSupplierProductTime.supplierId = supplierId;
  12345. ceErpSupplierProductTime.supplierName = supplierName;
  12346. ceErpSupplierProductTime.craft = craft;
  12347. ceErpSupplierProductTime.sendDay = sendDay;
  12348. ceErpSupplierProductTime.quantity = quantity;
  12349. if (!string.IsNullOrEmpty(deadLine))
  12350. {
  12351. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12352. }
  12353. if (!string.IsNullOrEmpty(dayDeadLine))
  12354. {
  12355. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12356. }
  12357. if (ceErpSupplierProductTime.ID == 0)
  12358. {
  12359. ceErpSupplierProductTime.Save();
  12360. }
  12361. else
  12362. {
  12363. ceErpSupplierProductTime.Update();
  12364. }
  12365. }
  12366. catch (Exception e)
  12367. {
  12368. }
  12369. returnSuccessMsg("保存成功");
  12370. return;
  12371. }
  12372. public void delSupplierProductTime()
  12373. {
  12374. int eid = GetPostInt("eid");
  12375. if (eid > 0)
  12376. {
  12377. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12378. if (ceErpSupplierProductTime == null)
  12379. {
  12380. returnErrorMsg("查无数据");
  12381. return;
  12382. }
  12383. ceErpSupplierProductTime.Delete();
  12384. returnSuccessMsg("保存成功");
  12385. return;
  12386. }
  12387. returnErrorMsg("缺少必要的参数");
  12388. }
  12389. public void getExpressInfo()
  12390. {
  12391. string ctid = GetPostString("ctid");
  12392. if (!string.IsNullOrEmpty(ctid))
  12393. {
  12394. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12395. if (ceErpTradeCell != null)
  12396. {
  12397. string outSid = ceErpTradeCell.OutSid;
  12398. if (outSid.Length > 0)
  12399. {
  12400. 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);
  12401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12402. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12403. return;
  12404. }
  12405. }
  12406. returnErrorMsg("查无记录");
  12407. return;
  12408. }
  12409. returnErrorMsg("缺少必要的参数");
  12410. }
  12411. public void getExpressPostData()
  12412. {
  12413. string express = GetPostString("express");
  12414. if (!string.IsNullOrEmpty(express))
  12415. {
  12416. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12417. if (ceErpExpressInfo != null)
  12418. {
  12419. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12420. return;
  12421. }
  12422. }
  12423. returnErrorMsg("缺少必要的参数");
  12424. }
  12425. public void checkSupplierOrder()
  12426. {
  12427. string ctids = GetPostString("ctids");
  12428. if (ctids != null)
  12429. {
  12430. List<string> list = new List<string>();
  12431. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12432. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12433. for (int i = 0; i < dt.Rows.Count; i++)
  12434. {
  12435. DataRow row = dt.Rows[i];
  12436. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12437. {
  12438. continue;
  12439. }
  12440. list.Add(row["seller_memo"].ToString());
  12441. }
  12442. if (list.Count > 0)
  12443. {
  12444. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12445. return;
  12446. }
  12447. }
  12448. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12449. return;
  12450. }
  12451. }
  12452. }