sync.order.cs 654 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. namespace SiteCore.Handler
  54. {
  55. public partial class sync
  56. {
  57. public void get_erp_orderlist()
  58. {
  59. string poscode = CurrentUser.UserPost.Post.Code;
  60. DataStruct dStruct = GetPostStruct();
  61. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\1754898828671价格配置数据.xlsx");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{ \"content\":{ \"businessType\":\"RECEIPT\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1754976830000,\"deliveryType\":\"DUMMY\",\"discountFee\":0.0,\"flag\":\"YELLOW\",\"lines\":[{ \"mark2\":[\"DELIVERED\"],\"num\":1900,\"outerId\":\"\",\"payment\":19.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded///gw.alicdn.com/imgextra/i2/O1CN01MkKGcP1DAC83Qzv0g_!!6000000000175-2-tps-664-664.png\",\"platServiceFee\":0.0,\"price\":0.01,\"refOlId\":\"4680447879925908321\",\"refSkuId\":\"0\",\"refSpuId\":\"718974148282\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.01,\"singleFee\":0.01,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"SHIPPED\",\"title\":\"补差价专用\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.0}],\"logisticsOrderNo\":\"0000\",\"mark2\":[],\"modifyTime\":1754979750000,\"openBuyerId\":\"AAH5RHraABkUZRPgSx37tfjU\",\"openBuyerNick\":\"w**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1754976823000,\"payTime\":1754976826000,\"payment\":19.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{ \"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{ \"logisticNo\":\"0000\",\"logisticName\":\"VIRTUAL\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"09ab2cbe3d9209cfa8b5e0c4727a01cf\",\"receiverState\":\"\",\"receiverTown\":\"\",\"refOid\":\"4680447879925908321\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"补差价:4680342074074908321-wangjie7409\",\"serviceFee\":0.0,\"shippingTime\":1754976827000,\"status\":\"SHIPPED\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.0,\"type\":\"SALE\"} }");
  74. //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}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  89. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  90. List<string> tidList = new List<string>();
  91. if (dataTable != null && dataTable.Rows.Count > 0)
  92. {
  93. foreach (DataRow row in dataTable.Rows)
  94. {
  95. tidList.Add("'" + row["tid"].ToString() + "'");
  96. }
  97. }
  98. if (tidList.Count > 0)
  99. {
  100. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  101. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  102. if (dataTable != null && dataTable.Rows.Count > 0)
  103. {
  104. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  105. if (count > 0)
  106. {
  107. Debug.WriteLine(index++);
  108. continue;
  109. }
  110. }
  111. }
  112. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  113. }
  114. catch (Exception e)
  115. {
  116. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  117. }
  118. Debug.WriteLine(index++);
  119. }*/
  120. List<string> lw = new List<string>();
  121. string tid = GetPostString("ctid");
  122. string date1 = GetPostString("date1");
  123. //12-1 修改
  124. string urgent = GetPostString("urgent");
  125. string back = GetPostString("back");
  126. string offlineSearch = GetPostString("offlineSearch");
  127. int paramsCount = 0;
  128. if (!string.IsNullOrWhiteSpace(urgent))
  129. {
  130. if (urgent.Equals("true"))
  131. {
  132. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  133. }
  134. }
  135. if (!string.IsNullOrWhiteSpace(back))
  136. {
  137. if (back.Equals("true"))
  138. {
  139. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  140. }
  141. }
  142. if (!string.IsNullOrWhiteSpace(offlineSearch))
  143. {
  144. if (offlineSearch.Equals("true"))
  145. {
  146. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  147. }
  148. }
  149. //end
  150. string date2 = GetPostString("date2");
  151. string buyernick = GetPostString("buyer_nick");
  152. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  153. {
  154. if (tid.Length <= 0 && buyernick.Length <= 0)
  155. {
  156. return;
  157. }
  158. }
  159. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  160. {
  161. if (tid.Length > 0)
  162. {
  163. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  164. if (ceErpTradeCell != null)
  165. {
  166. tid = ceErpTradeCell.tid;
  167. }
  168. List<string> select_tid = getTidByCtidMore(tid);
  169. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  170. }
  171. if (buyernick.Length > 0)
  172. {
  173. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  174. }
  175. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  176. if (dw.Length > 0)
  177. {
  178. lw.Add(dw);
  179. }
  180. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  181. {
  182. string usershop = CurrentUser.User.pemShop;
  183. lw.Add(string.Format("ShopId in ({0})", usershop));
  184. }
  185. }
  186. else
  187. {
  188. if (ex_psize == 0)
  189. {
  190. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  191. }
  192. if (PKey != "admin" && poscode != "SysAdmin")
  193. {
  194. string usershop = CurrentUser.User.pemShop;
  195. lw.Add(string.Format("ShopId in ({0})", usershop));
  196. paramsCount++;
  197. }
  198. }
  199. string uploaddate1 = GetPostString("uploaddate1");
  200. string uploaddate2 = GetPostString("uploaddate2");
  201. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  202. if (update.Length > 0) lw.Add(update);
  203. string deliverydate1 = GetPostString("deliverydate1");
  204. string deliverydate2 = GetPostString("deliverydate2");
  205. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  206. if (deliverydate.Length > 0)
  207. {
  208. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  209. };
  210. string shopname = GetPostString("shopname");
  211. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  212. string addwechat = GetPostString("addwechat");
  213. if (addwechat.Length > 0)
  214. {
  215. int addWt = Convert.ToInt32(addwechat);
  216. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  217. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  218. }
  219. string customer = GetPostString("customer");
  220. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  221. string design = GetPostString("design");
  222. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  223. string orderState = GetPostString("orderState");
  224. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  225. string address = GetPostString("address");
  226. 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));
  227. string sellermemo = GetPostString("seller_memo");
  228. if (sellermemo.Length > 0)
  229. {
  230. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  231. }
  232. string backReason = GetPostString("backReason");
  233. if (backReason.Length > 0)
  234. {
  235. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  236. }
  237. string apdate1 = GetPostString("apdate1");
  238. string apdate2 = GetPostString("apdate2");
  239. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  240. if (dwap.Length > 0) lw.Add(dwap);
  241. string price1 = GetPostString("price1");
  242. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  243. string price2 = GetPostString("price2");
  244. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  245. string isoldcustomer = GetPostString("isoldcus");
  246. string spudata = GetPostString("spudata");
  247. if ("0".Equals(spudata))
  248. {
  249. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  250. }
  251. if ("1".Equals(spudata))
  252. {
  253. lw.Add(string.Format("spu_id <> ''"));
  254. }
  255. string finishdate1 = GetPostString("finishdate1");
  256. string finishdate2 = GetPostString("finishdate2");
  257. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  258. bool isFinish = false;
  259. if (finishdate.Length > 0)
  260. {
  261. lw.Add(finishdate);
  262. isFinish = true;
  263. paramsCount++;
  264. }
  265. if (isoldcustomer.Length > 0)
  266. {
  267. if ("2".Equals(isoldcustomer))
  268. {
  269. lw.Add(string.Format("VipCustomer=1"));
  270. }
  271. else
  272. {
  273. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  274. }
  275. }
  276. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  277. if (ex_psize > 0)
  278. {
  279. int UserID = CurrentUser.UserID;
  280. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  281. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  282. {
  283. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  284. }
  285. dStruct.Order = "pay_time desc";
  286. }
  287. string isNew = GetPostString("isNew");
  288. if (isNew == "true")
  289. {
  290. lw.Add(string.Format("IsNew = {0}", 1));
  291. }
  292. string overtime = GetPostString("overtime");
  293. if (overtime == "1")
  294. {
  295. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  296. }
  297. String usePost = CurrentUser.UserPost.Post.Code;
  298. if (usePost.Equals("Operation") == true)
  299. {
  300. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  301. }
  302. else
  303. {
  304. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  305. }
  306. //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";
  307. if (dStruct.PageSize == 100000)
  308. {
  309. dStruct.Order = "";
  310. }
  311. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  312. DataTable dt = null;
  313. string tablename = "view_orderlist";
  314. if (isFinish)
  315. {
  316. tablename = "view_orderlist_end";
  317. }
  318. dt = WebCache.GetData(tablename, dStruct);
  319. if (dt != null && dt.Rows.Count > 0)
  320. {
  321. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  322. foreach (DataRow dr in dt.Rows)
  323. {
  324. try
  325. {
  326. if (dr["refund_fees"] != null)
  327. {
  328. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  329. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  330. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  331. if (payment == refund_fees)
  332. {
  333. dr["refund_fees"] = Math.Round(refund_fees, 2);
  334. }
  335. else if (refund_fees == total_fee)
  336. {
  337. dr["refund_fees"] = payment;
  338. }
  339. else
  340. {
  341. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  342. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  343. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  344. }
  345. }
  346. // 对象操作
  347. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  348. ceErpTradeCell.ctid = dr["ctid"].ToString();
  349. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  350. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  351. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  352. if (dStruct.PageSize != 100000)
  353. {
  354. if (dr["DispatchSort"].ToString() == "2")
  355. {
  356. dr["gongchuang"] = 200;
  357. }
  358. else if ("外协".Equals(dr["ToType"].ToString()))
  359. {
  360. dr["gongchuang"] = 200;
  361. }
  362. else if ("内部".Equals(dr["ToType"].ToString()))
  363. {
  364. dr["gongchuang"] = -1;
  365. }
  366. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  367. {
  368. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  369. dr["gongchuang"] = response.code;
  370. }
  371. }
  372. }
  373. catch (NullReferenceException ex)
  374. {
  375. // 处理空引用异常
  376. dr["refund_fees"] = "0.00";
  377. }
  378. }
  379. }
  380. writeGridDataTableJson(dStruct.TotalCount, dt);
  381. }
  382. public void get_erp_orderlist_sumprice()
  383. {
  384. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  385. return;
  386. List<string> lw = new List<string>();
  387. string tid = GetPostString("ctid");
  388. string date1 = GetPostString("date1");
  389. string date2 = GetPostString("date2");
  390. if (tid.Length > 0 || date1.Length > 0)
  391. {
  392. lw.Add(string.Format("ctid like '%{0}%'", tid));
  393. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  394. if (dw.Length > 0) lw.Add(dw);
  395. }
  396. else
  397. {
  398. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  399. }
  400. string shopname = GetPostString("shopname");
  401. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  402. string buyernick = GetPostString("buyer_nick");
  403. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  404. string customer = GetPostString("customer");
  405. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  406. string design = GetPostString("design");
  407. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  408. string orderState = GetPostString("orderState");
  409. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  410. string address = GetPostString("address");
  411. 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));
  412. string sellermemo = GetPostString("seller_memo");
  413. if (sellermemo.Length > 0)
  414. {
  415. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  416. }
  417. string apdate1 = GetPostString("apdate1");
  418. string apdate2 = GetPostString("apdate2");
  419. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  420. if (dwap.Length > 0) lw.Add(dwap);
  421. string price1 = GetPostString("price1");
  422. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  423. string price2 = GetPostString("price2");
  424. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  425. string isoldcustomer = GetPostString("isoldcus");
  426. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  427. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  428. if (PKey != "admin")
  429. {
  430. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  431. lw.Add(string.Format("shopId in ({0})", usershop));
  432. }
  433. //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";
  434. string mainWhere = string.Join(" and ", lw.ToArray());
  435. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  436. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  437. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  438. decimal total = 0;
  439. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  440. {
  441. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  442. }
  443. var res = new
  444. {
  445. data = total
  446. };
  447. string ro_jsond = JsonConvert.SerializeObject(res);
  448. returnSuccess(ro_jsond);
  449. return;
  450. }
  451. public void get_erp_CustomerServiceGather()
  452. {
  453. string userWhere = "", orderWhere = "";
  454. List<string> lw = new List<string>();
  455. string customer = GetPostString("customer");
  456. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  457. string shopname = GetPostString("shopname");
  458. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  459. string date1 = GetPostString("date1");
  460. string date2 = GetPostString("date2");
  461. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  462. if (dw.Length > 0) lw.Add(dw);
  463. orderWhere = string.Join(" and ", lw.ToArray());
  464. 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 " +
  465. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  466. "left join " +
  467. "( " +
  468. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  469. ") as b on a.ID = b.CustomerUserId " +
  470. "left join " +
  471. "( " +
  472. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  473. ") as d on a.ID = d.CustomerUserId " +
  474. "left join " +
  475. "( " +
  476. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  477. ") as e on a.ID = e.CustomerUserId " +
  478. "left join " +
  479. "( " +
  480. " select CustomerUserId, RefundCount, RefundSum from " +
  481. " ( " +
  482. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  483. " from CE_ErpTradeRefund a " +
  484. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  485. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  486. " group by CustomerUserId " +
  487. " ) as a " +
  488. ") as f on a.ID = f.CustomerUserId " +
  489. "where a.PostCode = 'CustomerService'",
  490. userWhere, orderWhere);
  491. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  492. writeGridDataTableJson(dt.Rows.Count, dt);
  493. //writeGridDataTableJson(dt.Rows.Count, dt);
  494. }
  495. //设计汇总
  496. public void get_erp_DesignerGather()
  497. {
  498. string userWhere = "", orderWhere = "";
  499. List<string> lw = new List<string>();
  500. string Designer = GetPostString("designer");
  501. int org = GetPostInt("org");
  502. if (Designer.Length > 0)
  503. {
  504. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  505. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  506. }
  507. else if (org > 0)
  508. {
  509. userWhere = string.Format(" where OrgID ={0}", org);
  510. }
  511. string shopname = GetPostString("shopname");
  512. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  513. string state = GetPostString("state");
  514. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  515. string OrderArea = GetPostString("order_area");
  516. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  517. string date1 = GetPostString("date1");
  518. string date2 = GetPostString("date2");
  519. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  520. if (dw.Length > 0) lw.Add(dw);
  521. string UpDate1 = GetPostString("UpDate1");
  522. string UpDate2 = GetPostString("UpDate2");
  523. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  524. if (dw.Length > 0) lw.Add(dw);
  525. orderWhere = string.Join(" and ", lw.ToArray());
  526. 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 (" +
  527. "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 " +
  528. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  529. "left join " +
  530. "( " +
  531. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  532. ") as b on a.ID = b.DesignUserId " +
  533. "left join " +
  534. "( " +
  535. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  536. ") as d on a.ID = d.DesignUserId " +
  537. "left join " +
  538. "( " +
  539. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  540. ") as e on a.ID = e.DesignUserId " +
  541. "left join " +
  542. "( " +
  543. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  544. ") as g on a.ID = g.DesignUserId " +
  545. "left join " +
  546. "( " +
  547. " select CustomerUserId, RefundCount, RefundSum from " +
  548. " ( " +
  549. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  550. " from CE_ErpTradeRefund a " +
  551. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  552. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  553. " group by CustomerUserId " +
  554. " ) as a " +
  555. ") as f on a.ID = f.CustomerUserId " +
  556. "where a.PostCode = 'Designer') as z",
  557. userWhere, orderWhere);
  558. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  559. writeGridDataTableJson(dt.Rows.Count, dt);
  560. }
  561. //删除tradecell的订单
  562. public void del_erp_cellorder()
  563. {
  564. if (UrlPostParmsCheck("ctid"))
  565. {
  566. string eid = GetPostString("ctid");
  567. CeErpTradeCell.DelByCtid(eid);
  568. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  569. returnSuccessMsg("删除成功");
  570. }
  571. }
  572. public void clear_erp_refundstate()
  573. {
  574. if (UrlPostParmsCheck("ids"))
  575. {
  576. string eids = GetPostString("ids");
  577. string[] ctidList = eids.Split(',');
  578. foreach (string ctid in ctidList)
  579. {
  580. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  581. if (entity != null)
  582. {
  583. entity.IsRefund = 0;
  584. entity.Update();
  585. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  586. }
  587. else
  588. continue;
  589. }
  590. returnSuccessMsg("操作成功");
  591. return;
  592. }
  593. returnErrorMsg("缺少必要参数");
  594. }
  595. public void set_erp_urgency()
  596. {
  597. if (UrlPostParmsCheck("ctid"))
  598. {
  599. string eid = GetPostString("ctid");
  600. CeErpTradeCell entity = null;
  601. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  602. if (entity != null)
  603. {
  604. double prices = commonHelper.calculationPrice(entity);
  605. if (prices <= 100)
  606. {
  607. returnErrorMsg("此订单金额不足100元,无法加急。");
  608. return;
  609. }
  610. string utime = GetPostString("urgencytime");
  611. if (utime.Length > 0)
  612. {
  613. entity.UrgencyTime = Convert.ToDateTime(utime);
  614. }
  615. else
  616. {
  617. returnErrorMsg("请选择加急时间");
  618. return;
  619. }
  620. if (entity.OrderState <= 4)
  621. {
  622. //entity.seller_memo = entity.seller_memo + "-加急";
  623. string smemo = entity.seller_memo;
  624. int kindex = smemo.IndexOf(")");
  625. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  626. if (lastoneStr != "-")
  627. {
  628. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  629. }
  630. string prememo = smemo.Substring(0, kindex + 2);
  631. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  632. int lastkindex = lastmemo.IndexOf("(");
  633. DateTime urgtime = Convert.ToDateTime(utime);
  634. string newlastmemo = "";
  635. if (lastkindex == 0)
  636. {
  637. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  638. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  639. }
  640. else
  641. {
  642. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  643. }
  644. entity.seller_memo = prememo + newlastmemo;
  645. }
  646. entity.IsUrgency = true;
  647. entity.UpdateTime = DateTime.Now;
  648. entity.Update();
  649. ApiVo apiVo = new ApiVo();
  650. apiVo.orderNumber = entity.ctid;
  651. apiVo.actionName = "changeDesign";
  652. apiVo.orderRemarks = entity.seller_memo;
  653. apiVo.remarkSign = 3;
  654. designHelper.API_WorkCore(apiVo); //changeDesign
  655. CeErpSukuraData.createInfo(entity.ctid, 7);
  656. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  657. returnSuccessMsg("设置成功!");
  658. return;
  659. }
  660. returnErrorMsg("找不到记录");
  661. }
  662. }
  663. public void set_erp_reset()
  664. {
  665. if (UrlPostParmsCheck("ctid"))
  666. {
  667. string eid = GetPostString("ctid");
  668. CeErpTradeCell entity = null;
  669. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  670. if (entity != null)
  671. {
  672. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  673. {
  674. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  675. {
  676. returnErrorMsg("财务要求已下单已发货无法重置");
  677. return;
  678. }
  679. }
  680. entity.IsUrgency = false;
  681. entity.seller_memo = "";
  682. entity.OtherMemo = "";
  683. entity.OrderState = 0;
  684. entity.IsReturn = 0;
  685. //entity.IsRefund = 0;
  686. entity.MemoOpt = 0;
  687. entity.AfterSaleState = 0;
  688. entity.AfterSaleResponsible = "";
  689. entity.AfterSaleUserId = 0;
  690. entity.IsNeedBill = 0;
  691. entity.CustomerUserId = 0;
  692. entity.DesignUserId = 0;
  693. entity.SupplierId = 0;
  694. entity.PlaceUserId = 0;
  695. entity.ptid = "";
  696. entity.IsSample = 0;
  697. entity.IsXianHuo = 0;
  698. entity.isDianziOrder = 0;
  699. entity.DispatchSort = 0;
  700. entity.IsVerifyToSupplier = false;
  701. entity.FinishPlaceTime = null;
  702. entity.Update();
  703. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  704. if (trade != null)
  705. {
  706. trade.seller_memo = "";
  707. trade.Update();
  708. }
  709. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  710. returnSuccessMsg("重置成功!");
  711. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  712. if (desginBill != null)
  713. {
  714. desginBill.isDel = 1;
  715. desginBill.Update();
  716. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  717. }
  718. ApiVo apiVo = new ApiVo();
  719. apiVo.orderNumber = entity.ctid;
  720. apiVo.actionName = "resetDesign";
  721. designHelper.API_WorkCore(apiVo);//resetDesign
  722. return;
  723. }
  724. returnErrorMsg("找不到记录");
  725. }
  726. }
  727. public void save_erp_sellermemo()
  728. {
  729. if (UrlPostParmsCheck("ctid"))
  730. {
  731. string ctid = GetPostString("ctid");
  732. CeErpTradeCell entity = null;
  733. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  734. if (entity != null)
  735. {
  736. string memo = GetPostString("seller_memo");
  737. memo = memo.Replace(" ", "");
  738. if (memo.Contains("补差"))
  739. {
  740. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  741. return;
  742. }
  743. List<string> bitList = new List<string>
  744. {
  745. "\\","/",":","*","?", "\"","<" ,">","|"
  746. };
  747. bool isIn = false;
  748. foreach (string bit in bitList)
  749. {
  750. if (memo.Contains(bit))
  751. {
  752. isIn = true;
  753. }
  754. }
  755. if (isIn)
  756. {
  757. returnErrorMsg("不能使用 一些符合作为文件名");
  758. return;
  759. }
  760. if (entity.seller_memo != memo)
  761. {
  762. if (entity.IsSample == 2)
  763. {
  764. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  765. return;
  766. }
  767. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  768. {
  769. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  770. {
  771. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  772. return;
  773. }
  774. /*if (CurrentUser.UserPost.Post.Code != "Place")
  775. {
  776. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  777. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  778. {
  779. returnErrorMsg("售前系统订单无法再此修改!");
  780. return;
  781. }
  782. }*/
  783. }
  784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  785. }
  786. commonHelper.getCytPrice(entity);
  787. int memoopt = GetPostInt("MemoOpt");
  788. Boolean ismemoopt = false;
  789. if (memoopt > 0)
  790. {
  791. string stropt = "";
  792. if (memoopt == 1)
  793. {
  794. stropt = "“改稿”";
  795. ismemoopt = true;
  796. }
  797. else if (memoopt == 2)
  798. {
  799. stropt = "“定稿”";
  800. }
  801. else if (memoopt == 3)
  802. {
  803. stropt = "“查货”";
  804. CeErpSukuraData.createInfo(entity.ctid, 6);
  805. }
  806. entity.MemoOpt = Convert.ToInt32(memoopt);
  807. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  808. }
  809. if (entity.OrderState < 5)
  810. {
  811. memo = memo.Replace("(", "(");
  812. memo = memo.Replace(")", ")");
  813. }
  814. /* if (entity.OrderState < 3)
  815. {
  816. entity.DispatchSort = 0;
  817. }*/
  818. entity.seller_memo = memo;
  819. entity.UpdateTime = DateTime.Now;
  820. entity.Update();
  821. ApiVo apiVo = new ApiVo();
  822. apiVo.orderNumber = entity.ctid;
  823. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  824. apiVo.orderRemarks = memo;
  825. apiVo.remarkSign = memoopt;
  826. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  827. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  828. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  829. {
  830. dataHelper.api_orderBack(entity.ctid, "0", "");
  831. }
  832. if (entity.seller_memo.Contains("改稿"))
  833. {
  834. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  835. }
  836. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  837. returnSuccessMsg("保存成功!");
  838. return;
  839. }
  840. returnErrorMsg("找不到记录");
  841. }
  842. }
  843. public void ins_erp_checkorder()
  844. {
  845. if (UrlPostParmsCheck("ctid"))
  846. {
  847. string ctid = GetPostString("ctid");
  848. CeErpTradeCell entity = null;
  849. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  850. if (entity != null)
  851. {
  852. if (entity.OrderState < 6)
  853. {
  854. returnErrorMsg("下单完成后才可查货");
  855. return;
  856. }
  857. /*if (entity.OrderState > 6)
  858. {
  859. returnErrorMsg("订单已发货");
  860. return;
  861. }*/
  862. if (entity.FinishPlaceTime != null)
  863. {
  864. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  865. {
  866. returnErrorMsg("下单时间不足,无法查货");
  867. return;
  868. }
  869. }
  870. entity.MemoOpt = 3;
  871. entity.CheckOrderTime = DateTime.Now;
  872. entity.UpdateTime = DateTime.Now;
  873. entity.Update();
  874. CeErpSukuraData.createInfo(entity.ctid, 6);
  875. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  876. returnSuccessMsg("操作成功!");
  877. return;
  878. }
  879. returnErrorMsg("找不到记录");
  880. }
  881. }
  882. public void save_erp_othermemo()
  883. {
  884. if (UrlPostParmsCheck("ctid"))
  885. {
  886. string ctid = GetPostString("ctid");
  887. CeErpTradeCell entity = null;
  888. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  889. if (entity != null)
  890. {
  891. entity.OtherMemo = GetPostString("otherMemo");
  892. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  893. {
  894. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  895. StringBuilder sql = new StringBuilder();
  896. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  897. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  898. if (dt != null && dt.Rows.Count > 0)
  899. {
  900. foreach (DataRow dr in dt.Rows)
  901. {
  902. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  903. {
  904. //品类一直
  905. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  906. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  907. if (ceErpSampleCustomer == null)
  908. {
  909. ceErpSampleCustomer = new CeErpSampleCustomer();
  910. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  911. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  912. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  913. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  914. ceErpSampleCustomer.shopId = entity.ShopId;
  915. }
  916. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  917. ceErpSampleCustomer.lastTid = entity.tid;
  918. if (ceErpSampleCustomer.ID > 0)
  919. {
  920. ceErpSampleCustomer.Update();
  921. }
  922. else
  923. {
  924. ceErpSampleCustomer.Create();
  925. }
  926. }
  927. }
  928. }
  929. }
  930. //if (entity.IsOldCustomer == 1)
  931. //{
  932. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  933. //{
  934. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  935. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  936. //}
  937. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  938. //{
  939. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  940. // {
  941. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  942. // {
  943. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  944. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  945. // }
  946. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  947. // {
  948. // entity.OrderState = 2;
  949. // entity.DesignUserId = 0;
  950. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  951. // }
  952. // else
  953. // {
  954. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  955. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  956. // }
  957. // }
  958. //}
  959. //}
  960. entity.UpdateTime = DateTime.Now;
  961. entity.Update();
  962. returnSuccessMsg("保存成功!");
  963. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  964. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  965. if (entity.OtherMemo.Contains("改稿"))
  966. {
  967. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  968. }
  969. return;
  970. }
  971. returnErrorMsg("找不到记录");
  972. }
  973. }
  974. public void save_erp_customermemo()
  975. {
  976. if (UrlPostParmsCheck("ctid"))
  977. {
  978. string ctid = GetPostString("ctid");
  979. CeErpTradeCell entity = null;
  980. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  981. if (entity != null)
  982. {
  983. entity.UpdateTime = DateTime.Now;
  984. entity.CustomerMemo = GetPostString("CustomerMemo");
  985. entity.Update();
  986. ApiVo apiVo = new ApiVo();
  987. apiVo.orderNumber = entity.ctid;
  988. apiVo.actionName = "followRemarks";
  989. apiVo.orderRemarks = entity.CustomerMemo;
  990. designHelper.API_WorkCore(apiVo);//followRemarks
  991. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  992. returnSuccessMsg("保存成功!");
  993. return;
  994. }
  995. returnErrorMsg("找不到记录");
  996. }
  997. }
  998. public void upd_erp_addmemotag()
  999. {
  1000. if (UrlPostParmsCheck("ctid"))
  1001. {
  1002. ;
  1003. string eid = GetPostString("ctid");
  1004. string sfTagstr = GetPostString("memotag");
  1005. CeErpTradeCell entity = null;
  1006. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1007. if (entity != null)
  1008. {
  1009. ApiVo apiVo = new ApiVo();
  1010. if (entity.OrderState == 0)
  1011. {
  1012. returnErrorMsg("请先领单");
  1013. return;
  1014. }
  1015. //撤销顺丰
  1016. if (sfTagstr == "撤销顺丰")
  1017. {
  1018. entity.IsSF = 0;
  1019. string reMsg = "";
  1020. string oldmemo = entity.seller_memo;
  1021. if (entity.OrderState < 5)
  1022. {
  1023. oldmemo = oldmemo.Replace("顺丰到付", "");
  1024. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1025. entity.seller_memo = oldmemo;
  1026. }
  1027. else
  1028. {
  1029. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1030. {
  1031. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1032. }
  1033. }
  1034. entity.Update();
  1035. apiVo.orderNumber = entity.ctid;
  1036. apiVo.actionName = "orderRemarks";
  1037. apiVo.orderRemarks = entity.seller_memo;
  1038. apiVo.isSf = entity.IsSF.ToString();
  1039. designHelper.API_WorkCore(apiVo);//orderRemarks
  1040. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1041. returnSuccessMsg("撤销成功!" + reMsg);
  1042. return;
  1043. }
  1044. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1045. {
  1046. //string oldmemo = entity.seller_memo;
  1047. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1048. string sfStr = GetPostString("memotag");
  1049. string smemo = entity.seller_memo;
  1050. int kindex = smemo.IndexOf(")");
  1051. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1052. if (lastoneStr != "-")
  1053. {
  1054. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1055. }
  1056. string prememo = smemo.Substring(0, kindex + 2);
  1057. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1058. int lastkindex = lastmemo.IndexOf("(");
  1059. string newlastmemo = "";
  1060. if (lastkindex == 0)
  1061. {
  1062. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1063. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1064. }
  1065. else
  1066. {
  1067. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1068. }
  1069. entity.seller_memo = prememo + newlastmemo;
  1070. }
  1071. string sfTagMSg = "";
  1072. if (sfTagstr == "顺丰寄付")
  1073. {
  1074. entity.IsSF = 1;
  1075. sfTagMSg = "顺丰寄付";
  1076. }
  1077. else if (sfTagstr == "顺丰到付")
  1078. {
  1079. entity.IsSF = 2;
  1080. sfTagMSg = "顺丰到付";
  1081. }
  1082. entity.Update();
  1083. apiVo = new ApiVo();
  1084. apiVo.orderNumber = entity.ctid;
  1085. apiVo.actionName = "orderRemarks";
  1086. apiVo.orderRemarks = entity.seller_memo;
  1087. apiVo.isSf = entity.IsSF.ToString();
  1088. designHelper.API_WorkCore(apiVo);//orderRemarks
  1089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1090. returnSuccessMsg("标记成功!");
  1091. return;
  1092. }
  1093. returnErrorMsg("找不到记录");
  1094. }
  1095. }
  1096. public void upd_erp_ordertag()
  1097. {
  1098. if (UrlPostParmsCheck("ctid"))
  1099. {
  1100. string eid = GetPostString("ctid");
  1101. CeErpTradeCell entity = null;
  1102. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1103. if (entity != null)
  1104. {
  1105. int tag = GetPostInt("wechattag");
  1106. //if(tag==4 && entity.IsSample == 2)
  1107. //{
  1108. // returnErrorMsg("补差价单不能标记微信单");
  1109. // return;
  1110. //}
  1111. entity.wechatTag = tag;
  1112. entity.Update();
  1113. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1114. if (tag == 1)
  1115. {
  1116. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1117. if (cash == null)
  1118. {
  1119. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1120. cash = new CeErpReturnCash();
  1121. cash.tid = entity.tid;
  1122. cash.seller_nick = main.seller_nick;
  1123. cash.payment = trade.payment;
  1124. cash.buyer_nick = main.buyer_nick;
  1125. cash.cashstate = 0;
  1126. cash.rtype = "微信返现";
  1127. cash.returnprice = 0;
  1128. cash.created = DateTime.Now;
  1129. cash.con = "订单标记微信单";
  1130. cash.img = "";
  1131. cash.applyuserid = CurrentUser.UserID;
  1132. cash.Create();
  1133. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1134. }
  1135. else
  1136. {
  1137. cash.cashstate = 0;
  1138. cash.Update();
  1139. }
  1140. CeErpSukuraData.createInfo(entity.ctid, 9);
  1141. }
  1142. else if (tag == 2)
  1143. {
  1144. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1145. if (cash == null)
  1146. {
  1147. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1148. cash = new CeErpReturnCash();
  1149. cash.tid = entity.tid;
  1150. cash.seller_nick = main.seller_nick;
  1151. cash.payment = trade.payment;
  1152. cash.buyer_nick = main.buyer_nick;
  1153. cash.cashstate = 0;
  1154. cash.rtype = "推购返现";
  1155. cash.returnprice = 5;
  1156. cash.created = DateTime.Now;
  1157. cash.con = "订单标记推购单";
  1158. cash.img = "";
  1159. cash.applyuserid = CurrentUser.UserID;
  1160. cash.Create();
  1161. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1162. }
  1163. else
  1164. {
  1165. cash.cashstate = 0;
  1166. cash.Update();
  1167. }
  1168. CeErpSukuraData.createInfo(entity.ctid, 9);
  1169. }
  1170. else if (tag == 3)
  1171. {
  1172. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1173. if (pers == null)
  1174. {
  1175. pers = new CeErpPersuade();
  1176. pers.ctid = entity.ctid;
  1177. pers.pstate = 0;
  1178. pers.created = DateTime.Now;
  1179. pers.applyuserid = CurrentUser.UserID;
  1180. pers.Create();
  1181. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1182. }
  1183. else
  1184. {
  1185. pers.pstate = 0;
  1186. pers.Update();
  1187. }
  1188. }
  1189. else if (tag == 4 || tag == 5)
  1190. {
  1191. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1192. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1193. if (pers == null)
  1194. {
  1195. pers = CeErpStayGoods.GetByTid(entity.tid);
  1196. }
  1197. if (pers == null)
  1198. {
  1199. pers = new CeErpStayGoods();
  1200. pers.t_id = entity.tid;
  1201. pers.ctid = entity.ctid;
  1202. pers.status = "待审核";
  1203. pers.audit_type = 0;
  1204. if (tag == 4)
  1205. {
  1206. pers.stay_type = "微信推购";
  1207. }
  1208. else
  1209. {
  1210. pers.stay_type = "旺旺推购";
  1211. }
  1212. if (entity.IsXianHuo == 0)
  1213. {
  1214. pers.product_id = entity.ProductId;
  1215. }
  1216. pers.wangwang = main.buyer_nick;
  1217. pers.shop_name = main.seller_nick;
  1218. pers.creata_time = DateTime.Now;
  1219. pers.create_u_id = CurrentUser.UserID;
  1220. pers.create_u_name = CurrentUser.UserName;
  1221. pers.Create();
  1222. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1223. }
  1224. else
  1225. {
  1226. pers.ctid = entity.ctid;
  1227. pers.audit_type = 0;
  1228. pers.Update();
  1229. }
  1230. CeErpSukuraData.createInfo(entity.ctid, 10);
  1231. }
  1232. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1233. returnSuccessMsg("标记成功!");
  1234. return;
  1235. }
  1236. returnErrorMsg("找不到记录");
  1237. }
  1238. }
  1239. public void upd_erp_ordertag_cancel()
  1240. {
  1241. if (UrlPostParmsCheck("ctid"))
  1242. {
  1243. string eid = GetPostString("ctid");
  1244. CeErpTradeCell entity = null;
  1245. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1246. if (entity != null)
  1247. {
  1248. entity.wechatTag = 0;
  1249. entity.Update();
  1250. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1251. if (pers != null)
  1252. {
  1253. pers.status = "取消推购";
  1254. pers.audit_type = 3;
  1255. pers.Update();
  1256. }
  1257. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1258. returnSuccessMsg("标记成功!");
  1259. return;
  1260. }
  1261. returnErrorMsg("找不到记录");
  1262. }
  1263. }
  1264. public void upd_erp_addweichattag()
  1265. {
  1266. if (UrlPostParmsCheck("ctid"))
  1267. {
  1268. ;
  1269. string eid = GetPostString("ctid");
  1270. CeErpTradeCell entity = null;
  1271. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1272. if (entity != null)
  1273. {
  1274. if (entity.IsAddWechat > 0)
  1275. {
  1276. returnErrorMsg("此单已经标记过了");
  1277. return;
  1278. }
  1279. 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);
  1280. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1281. if (dt.Rows.Count > 0)
  1282. {
  1283. entity.IsAddWechat = 2;
  1284. }
  1285. else
  1286. {
  1287. entity.IsAddWechat = 1;
  1288. }
  1289. entity.Update();
  1290. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1291. returnSuccessMsg("标记成功!");
  1292. return;
  1293. }
  1294. returnErrorMsg("找不到记录");
  1295. }
  1296. }
  1297. public void upd_erp_getmyorder()
  1298. {
  1299. if (UrlPostParmsCheck("ctid"))
  1300. {
  1301. string eid = GetPostString("ctid");
  1302. CeErpTradeCell entity = null;
  1303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1304. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1305. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1306. {
  1307. returnErrorMsg("台湾客户需填写身份证号!");
  1308. return;
  1309. }
  1310. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1311. {
  1312. returnErrorMsg("偏远地区需要填写物流费!");
  1313. return;
  1314. }
  1315. if (entity != null)
  1316. {
  1317. if (entity.ctid.IndexOf("C") != -1)
  1318. {
  1319. StringBuilder sql = new StringBuilder();
  1320. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1321. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1322. if (dt.Rows.Count > 0)
  1323. {
  1324. decimal total = 0;
  1325. foreach (DataRow dr in dt.Rows)
  1326. {
  1327. total += Convert.ToDecimal(dr["payment"]);
  1328. }
  1329. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1330. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1331. {
  1332. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1333. return;
  1334. }
  1335. }
  1336. }
  1337. if (entity.OrderState == -1)
  1338. {
  1339. returnErrorMsg("待审核订单无法领取!");
  1340. return;
  1341. }
  1342. entity.CustomerUserId = CurrentUser.UserID;
  1343. if (entity.OrderState < 2)
  1344. {
  1345. entity.OrderState = 2;
  1346. if (entity.ShopId != 0)
  1347. {
  1348. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1349. }
  1350. }
  1351. entity.UpdateTime = DateTime.Now;
  1352. entity.Update();
  1353. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1354. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1355. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1356. {
  1357. dataHelper.api_orderBack(entity.ctid, "0", "");
  1358. }
  1359. returnSuccessMsg("领单成功!");
  1360. return;
  1361. }
  1362. returnErrorMsg("找不到记录");
  1363. }
  1364. }
  1365. public void getmyorder_from_init()
  1366. {
  1367. if (UrlPostParmsCheck("ctid"))
  1368. {
  1369. string eid = GetPostString("ctid");
  1370. CeErpTradeCell entity = null;
  1371. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1372. if (entity != null)
  1373. {
  1374. string sellerMemo = GetPostString("sellerMemo");
  1375. if (sellerMemo.Length > 0)
  1376. {
  1377. entity.seller_memo = sellerMemo;
  1378. }
  1379. string oterhMemo = GetPostString("otherMemo");
  1380. if (oterhMemo.Length > 0)
  1381. {
  1382. entity.OtherMemo = oterhMemo;
  1383. }
  1384. int urg = GetPostInt("urgency");
  1385. entity.IsUrgency = (urg == 1 ? true : false);
  1386. int wechat = GetPostInt("wechat");
  1387. int command = GetPostInt("command");
  1388. if (wechat == 1)
  1389. {
  1390. entity.wechatTag = 1;
  1391. }
  1392. if (command == 1)
  1393. {
  1394. entity.wechatTag = 2;
  1395. }
  1396. string pPro = GetPostString("pprofession");
  1397. if (pPro.Length > 0)
  1398. {
  1399. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1400. string spro = GetPostString("profession");
  1401. if (spro.Length > 0)
  1402. {
  1403. entity.ProfessionId = Convert.ToInt32(spro);
  1404. }
  1405. }
  1406. string proId = GetPostString("productId");
  1407. if (proId.Length > 0)
  1408. {
  1409. entity.ProductId = Convert.ToInt32(proId);
  1410. }
  1411. entity.Material = GetPostString("material");
  1412. entity.Craft = GetPostString("craft");
  1413. entity.CustomerUserId = CurrentUser.UserID;
  1414. if (entity.OrderState < 2)
  1415. {
  1416. entity.OrderState = 2;
  1417. if (entity.ShopId != 0)
  1418. {
  1419. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1420. }
  1421. }
  1422. entity.Update();
  1423. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1424. returnSuccessMsg("领单成功!");
  1425. return;
  1426. }
  1427. returnErrorMsg("找不到记录");
  1428. }
  1429. }
  1430. public void upd_erp_setrelationorder()
  1431. {
  1432. if (UrlPostParmsCheck("ctid"))
  1433. {
  1434. ;
  1435. string eid = GetPostString("ctid");
  1436. string ftid = GetPostString("ftid");
  1437. CeErpTradeCell entity = null;
  1438. CeErpTradeCell fentity = null;
  1439. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1440. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1441. if (fentity == null)
  1442. {
  1443. returnErrorMsg("找不到关联的主订单");
  1444. return;
  1445. }
  1446. if (entity != null)
  1447. {
  1448. if (entity.OrderState >= 5)
  1449. {
  1450. returnErrorMsg("本单已经设计完成无法关联");
  1451. return;
  1452. }
  1453. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1454. {
  1455. returnErrorMsg("线下单续审核后才能关联!");
  1456. return;
  1457. }
  1458. entity.ptid = ftid;
  1459. entity.OrderState = fentity.OrderState;
  1460. //entity.status = fentity.status;
  1461. entity.CustomerUserId = fentity.CustomerUserId;
  1462. entity.DesignUserId = fentity.DesignUserId;
  1463. entity.seller_memo = "补差价单:" + ftid;
  1464. entity.IsSample = 2;
  1465. entity.Update();
  1466. ApiVo apiVo = new ApiVo();
  1467. apiVo.orderNumber = ftid;
  1468. apiVo.payment = entity.payment;
  1469. apiVo.actionName = "repairDesign";
  1470. designHelper.API_WorkCore(apiVo);//repairDesign
  1471. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1472. returnSuccessMsg("关联成功!");
  1473. return;
  1474. }
  1475. else
  1476. returnErrorMsg("找不到记录");
  1477. }
  1478. }
  1479. public void download_erp_neworder()
  1480. {
  1481. string seller = GetPostString("seller_nick");
  1482. string tid = GetPostString("tid");
  1483. if (seller.Length <= 0 || tid.Length <= 0)
  1484. {
  1485. returnErrorMsg("数据错误");
  1486. }
  1487. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1488. //{
  1489. // returnErrorMsg("找不到店铺Sessionkey");
  1490. //}
  1491. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1492. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1493. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1494. if (res.IndexOf("refOid") == -1)
  1495. {
  1496. returnErrorMsg("下载订单数据失败");
  1497. return;
  1498. }
  1499. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1500. returnSuccessMsg("下载完成");
  1501. //tmcHelper.createNewOrder(res);
  1502. //CeErpTrade entr = null;
  1503. //entr = CeErpTrade.Get(tid);
  1504. //if (entr != null)
  1505. //{
  1506. // returnSuccess("下载成功");
  1507. // //下载成功之后,Cell表生成对应的订单;
  1508. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1509. //}
  1510. //else
  1511. //{
  1512. // returnErrorMsg("下载失败或者创建订单失败");
  1513. //}
  1514. }
  1515. public void set_erp_atersale()
  1516. {
  1517. if (UrlPostParmsCheck("ctid"))
  1518. {
  1519. string eid = GetPostString("ctid");
  1520. string reason = GetPostString("AfterSaleReason");
  1521. CeErpTradeCell entity = null;
  1522. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1523. if (entity != null)
  1524. {
  1525. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1526. {
  1527. returnErrorMsg("此订单已经在售后");
  1528. return;
  1529. }*/
  1530. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1531. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1532. entity.AfterSaleTime = DateTime.Now;
  1533. entity.HandleTime = null;
  1534. entity.Update();
  1535. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1536. returnSuccessMsg("转售后成功!");
  1537. return;
  1538. }
  1539. returnErrorMsg("找不到记录");
  1540. }
  1541. }
  1542. public void set_erp_withdraw()
  1543. {
  1544. if (UrlPostParmsCheck("ctid"))
  1545. {
  1546. try
  1547. {
  1548. string eid = GetPostString("ctid");//商品id
  1549. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1550. CeWithdraw ceWithdrawSelect = null;
  1551. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1552. if (ceWithdrawSelect != null)
  1553. {
  1554. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1555. {
  1556. ceWithdrawSelect.status = -1;
  1557. ceWithdrawSelect.Update();
  1558. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1559. returnSuccessMsg("重新发起审核成功");
  1560. return;
  1561. }
  1562. else
  1563. {
  1564. returnSuccessMsg("请勿重复申请!");
  1565. return;
  1566. }
  1567. }
  1568. else
  1569. {
  1570. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1571. if (string.IsNullOrEmpty(CustomerUserId))
  1572. {
  1573. CustomerUserId = "-1";
  1574. }
  1575. int Userid = CurrentUser.UserID;//用户id
  1576. CeWithdraw ceWithdraw = new CeWithdraw();
  1577. ceWithdraw.tid = eid;
  1578. ceWithdraw.userid = Userid;
  1579. ceWithdraw.providerid = CustomerUserId;
  1580. ceWithdraw.status = 3;
  1581. ceWithdraw.creationtime = DateTime.Now;
  1582. ceWithdraw.Create();
  1583. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1584. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1585. return;
  1586. }
  1587. }
  1588. catch
  1589. {
  1590. returnErrorMsg("申请撤回订单失败");
  1591. return;
  1592. }
  1593. }
  1594. }
  1595. public void ins_erp_billinfo()
  1596. {
  1597. if (UrlPostParmsCheck("ctid"))
  1598. {
  1599. string eid = GetPostString("ctid");
  1600. CeErpTradeCell entity = null;
  1601. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1602. if (entity != null)
  1603. {
  1604. CeErpBill bill = CeErpBill.GetByTid(eid);
  1605. bool isHave = false;
  1606. if (bill != null)
  1607. {
  1608. isHave = true;
  1609. if (bill.state != 4)
  1610. {
  1611. returnErrorMsg("此单已经申请过发票了");
  1612. return;
  1613. }
  1614. }
  1615. if (entity.IsNeedBill == 0)
  1616. {
  1617. entity.IsNeedBill = 1;
  1618. }
  1619. entity.Update();
  1620. string errjson = "";
  1621. try
  1622. {
  1623. CeErpBill bill_entity = new CeErpBill();
  1624. bill_entity.tid = entity.tid;
  1625. bill_entity.title = GetPostString("title");
  1626. string taxstr = GetPostString("tax");
  1627. taxstr = taxstr.Replace(" ", "");
  1628. bill_entity.tax = taxstr;
  1629. bill_entity.bank = GetPostString("bank");
  1630. string bankacstr = GetPostString("bankac");
  1631. bankacstr = bankacstr.Replace(" ", "");
  1632. bill_entity.bankac = bankacstr;
  1633. bill_entity.address = GetPostString("address");
  1634. bill_entity.phone = GetPostString("phone");
  1635. bill_entity.price = GetPostString("price");
  1636. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1637. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1638. {
  1639. billCount += 1;
  1640. }
  1641. string prebill = "ltb";
  1642. for (int idx = 1; idx <= billCount; idx++)
  1643. {
  1644. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1645. string billoid = prebill + idx + dtstr;
  1646. bill_entity.billOrderId += billoid;
  1647. if (idx < billCount)
  1648. {
  1649. bill_entity.billOrderId += ",";
  1650. }
  1651. }
  1652. bill_entity.productId = GetPostInt("ProductName");
  1653. bill_entity.num = GetPostInt("num");
  1654. bill_entity.unit = GetPostString("unit");
  1655. bill_entity.type = GetPostString("type");
  1656. bill_entity.sendType = GetPostString("SendType");
  1657. bill_entity.email = GetPostString("email");
  1658. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1659. bill_entity.shopName = GetPostString("ShopName");
  1660. bill_entity.applymemo = GetPostString("applyMemo");
  1661. bill_entity.createTime = DateTime.Now;
  1662. bill_entity.state = 0;
  1663. bill_entity.userId = CurrentUser.UserID;
  1664. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1665. bill_entity.Create();
  1666. }
  1667. catch (Exception ex)
  1668. {
  1669. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1670. returnErrorMsg("创建发票出错!");
  1671. return;
  1672. }
  1673. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1674. returnSuccessMsg("发票申请成功!");
  1675. return;
  1676. }
  1677. returnErrorMsg("找不到记录");
  1678. }
  1679. }
  1680. public void ins_erp_neworder()
  1681. {
  1682. if (UrlPostParmsCheck("receiver_name"))
  1683. {
  1684. CeErpTrade entity = new CeErpTrade();
  1685. string plat_form = GetPostString("platform");
  1686. string preStr = "N_";
  1687. if (plat_form == "拼多多")
  1688. {
  1689. preStr = "P_";
  1690. }
  1691. else if (plat_form == "阿里巴巴")
  1692. {
  1693. preStr = "A_";
  1694. }
  1695. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1696. entity.seller_nick = GetPostString("seller_nick");
  1697. entity.buyer_nick = GetPostString("buyer_nick");
  1698. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1699. entity.total_fee = entity.payment;
  1700. entity.pay_time = DateTime.Now;
  1701. entity.status = "NOT_SHIPPED";
  1702. entity.receiver_name = GetPostString("receiver_name");
  1703. entity.receiver_mobile = GetPostString("receiver_mobile");
  1704. entity.receiver_state = GetPostString("receiver_state");
  1705. entity.receiver_city = GetPostString("receiver_city");
  1706. entity.receiver_district = GetPostString("receiver_district");
  1707. entity.receiver_address = GetPostString("receiver_address");
  1708. if (entity.receiver_state == "" || entity.receiver_city == "")
  1709. {
  1710. returnErrorMsg("收件地址不能为空");
  1711. return;
  1712. }
  1713. int shopId = 0;
  1714. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1715. if (nShop != null)
  1716. {
  1717. shopId = nShop.ID;
  1718. }
  1719. if (shopId != 34 && entity.payment == 0)
  1720. {
  1721. returnErrorMsg("公司自用的单金额才能为0");
  1722. return;
  1723. }
  1724. entity.Create();
  1725. CeErpTradeCell entitycell = new CeErpTradeCell();
  1726. entitycell.ctid = entity.tid;
  1727. entitycell.tid = entity.tid;
  1728. entitycell.ShopId = shopId;
  1729. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1730. entitycell.OrderState = 0;
  1731. entitycell.pay_time = entity.pay_time;
  1732. entitycell.IsOffLineOrder = 1;
  1733. entitycell.Create();
  1734. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1735. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1736. return;
  1737. }
  1738. }
  1739. public void ins_erp_neworder2()
  1740. {
  1741. if (UrlPostParmsCheck("receiver_name"))
  1742. {
  1743. //string plat_form = GetPostString("platform");
  1744. string preStr = "X_";
  1745. string memo = GetPostString("memo");
  1746. string productId = GetPostString("productId");
  1747. string primg = GetPostString("proofimg");
  1748. string sellerNick = GetPostString("seller_nick");
  1749. string addFrom = GetPostString("addfrom");
  1750. if (addFrom == "1")
  1751. {
  1752. preStr = "N_";
  1753. }
  1754. int shopId = 0;
  1755. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1756. if (nShop != null)
  1757. {
  1758. shopId = nShop.ID;
  1759. }
  1760. else
  1761. {
  1762. returnErrorMsg("找不到对应店铺");
  1763. return;
  1764. }
  1765. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1766. {
  1767. returnErrorMsg("必须上传付款凭证");
  1768. return;
  1769. }
  1770. CeErpTrade entity = new CeErpTrade();
  1771. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1772. entity.seller_nick = sellerNick;
  1773. entity.buyer_nick = GetPostString("buyer_nick");
  1774. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1775. entity.total_fee = entity.payment;
  1776. entity.pay_time = DateTime.Now;
  1777. entity.status = "NOT_SHIPPED";
  1778. entity.receiver_name = GetPostString("receiver_name");
  1779. entity.receiver_mobile = GetPostString("receiver_mobile");
  1780. entity.receiver_state = GetPostString("receiver_state");
  1781. entity.receiver_city = GetPostString("receiver_city");
  1782. entity.receiver_district = GetPostString("receiver_district");
  1783. entity.receiver_address = GetPostString("receiver_address");
  1784. entity.seller_memo = memo;
  1785. entity.orderFrom = 20;
  1786. entity.orderType = 15;
  1787. if (entity.receiver_state == "" || entity.receiver_city == "")
  1788. {
  1789. returnErrorMsg("收件地址不能为空");
  1790. return;
  1791. }
  1792. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1793. {
  1794. returnErrorMsg("公司自用的单金额才能为0");
  1795. return;
  1796. }
  1797. entity.Create();
  1798. string toWhere = GetPostString("towhere");
  1799. CeErpTradeCell entitycell = new CeErpTradeCell();
  1800. entitycell.ctid = entity.tid;
  1801. //唯一标识
  1802. entitycell.OrderSn = entity.tid;
  1803. string orderSn = dataHelper.getSaleOrderSn();
  1804. if (orderSn != "")
  1805. {
  1806. entitycell.OrderSn = orderSn;
  1807. }
  1808. entitycell.tid = entity.tid;
  1809. //if (preStr == "X_")
  1810. //{
  1811. entitycell.IsOffLineOrder = 1;
  1812. //}
  1813. entitycell.CustomerUserId = CurrentUser.UserID;
  1814. entitycell.PayProofImg = primg;
  1815. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1816. entitycell.ProductId = Convert.ToInt32(productId);
  1817. entitycell.ShopId = shopId;
  1818. entitycell.UpdateTime = DateTime.Now;
  1819. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1820. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1821. {
  1822. entitycell.IsXianHuo = 1;
  1823. }
  1824. entitycell.pay_time = entity.pay_time;
  1825. if (toWhere == "1")
  1826. {
  1827. entitycell.OrderState = 2;
  1828. }
  1829. else
  1830. {
  1831. entitycell.OrderState = 6;
  1832. entitycell.FinishPlaceTime = entitycell.pay_time;
  1833. }
  1834. if (shopId == 94)
  1835. {
  1836. entitycell.OrderState = 4;
  1837. entitycell.WaitDesignTime = entitycell.pay_time;
  1838. entitycell.StartDesignTime = entitycell.pay_time;
  1839. entitycell.DesignUserId = 218;
  1840. }
  1841. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1842. {
  1843. entitycell.OrderState = -1;//修改12-5
  1844. CeWithdraw ceWithdraw = new CeWithdraw();
  1845. ceWithdraw.tid = entity.tid;
  1846. ceWithdraw.providerid = "-1";
  1847. ceWithdraw.status = -1;
  1848. ceWithdraw.creationtime = DateTime.Now;
  1849. ceWithdraw.userid = 742;
  1850. ceWithdraw.Create();
  1851. }
  1852. entitycell.Create();
  1853. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1854. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1855. {
  1856. addPlaceRegist(entitycell, CurrentUser.UserID);
  1857. }
  1858. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1859. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1860. return;
  1861. }
  1862. }
  1863. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1864. {
  1865. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1866. entity.PlactTime = tradecell.pay_time;
  1867. entity.AddUserId = userid;
  1868. entity.FileName = tradecell.seller_memo;
  1869. entity.Supplier = 24;
  1870. entity.CreateTime = DateTime.Now;
  1871. entity.Did = tradecell.ctid;
  1872. entity.tid = tradecell.tid;
  1873. entity.splitTag = tradecell.SplitTag;
  1874. entity.CurState = "未完成";
  1875. entity.Create();
  1876. }
  1877. public void get_erp_offlinelist()
  1878. {
  1879. DataStruct dStruct = GetPostStruct();
  1880. List<string> lw = new List<string>();
  1881. string tid = GetPostString("ctid");
  1882. string date1 = GetPostString("date1");
  1883. string date2 = GetPostString("date2");
  1884. if (tid.Length > 0 || date1.Length > 0)
  1885. {
  1886. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1887. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1888. if (dw.Length > 0) lw.Add(dw);
  1889. }
  1890. else
  1891. {
  1892. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1893. }
  1894. string shopname = GetPostString("shopname");
  1895. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1896. string buyernick = GetPostString("buyer_nick");
  1897. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1898. string customer = GetPostString("customer");
  1899. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1900. string design = GetPostString("design");
  1901. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1902. string orderState = GetPostString("orderState");
  1903. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1904. string address = GetPostString("address");
  1905. 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));
  1906. string sellermemo = GetPostString("seller_memo");
  1907. if (sellermemo.Length > 0)
  1908. {
  1909. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1910. }
  1911. string price1 = GetPostString("price1");
  1912. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1913. string price2 = GetPostString("price2");
  1914. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1915. //if (PKey != "admin")
  1916. //{
  1917. // string usershop = CurrentUser.User.pemShop;
  1918. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1919. //}
  1920. //if (ex_psize > 0)
  1921. //{
  1922. dStruct.Order = "pay_time desc";
  1923. //}
  1924. //else
  1925. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1926. lw.Add(string.Format("IsOffLineOrder=1"));
  1927. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1928. DataTable dt = null;
  1929. dt = WebCache.GetData("view_erptradecell", dStruct);
  1930. writeGridDataTableJson(dStruct.TotalCount, dt);
  1931. }
  1932. public void get_erp_returncashrecord()
  1933. {
  1934. DataStruct dStruct = GetPostStruct();
  1935. List<string> lw = new List<string>();
  1936. string tid = GetPostString("ctid");
  1937. if (tid.Length > 0)
  1938. {
  1939. lw.Add(string.Format("tid like '%{0}%'", tid));
  1940. dStruct.Order = "id desc";
  1941. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1942. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1943. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1944. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1945. return;
  1946. }
  1947. returnErrorMsg("id数据错误!");
  1948. }
  1949. public void ins_erp_returncashrecord()
  1950. {
  1951. if (UrlPostParmsCheck("tid"))
  1952. {
  1953. string tid = GetPostString("tid");
  1954. string retype = GetPostString("type");
  1955. StringBuilder sql = new StringBuilder();
  1956. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1957. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1958. if (dt.Rows.Count > 0)
  1959. {
  1960. returnErrorMsg("相同返现类型记录已存在");
  1961. return;
  1962. }
  1963. CeErpReturnCash entity = new CeErpReturnCash();
  1964. entity.tid = tid;
  1965. entity.seller_nick = GetPostString("seller_nick");
  1966. string pment = GetPostString("payment");
  1967. if (pment.Length > 0)
  1968. {
  1969. entity.payment = Convert.ToDouble(pment);
  1970. }
  1971. entity.buyer_nick = GetPostString("buyer_nick");
  1972. entity.cashstate = 0;
  1973. entity.rtype = retype;
  1974. string rPrice = GetPostString("returnprice");
  1975. if (rPrice.Length > 0)
  1976. {
  1977. entity.returnprice = Convert.ToDouble(rPrice);
  1978. }
  1979. entity.created = DateTime.Now;
  1980. entity.con = GetPostString("con");
  1981. entity.img = GetPostString("img");
  1982. entity.applyuserid = CurrentUser.UserID;
  1983. entity.Create();
  1984. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1985. returnSuccessMsg("操作成功!");
  1986. return;
  1987. }
  1988. }
  1989. public void set_erp_predelivery()
  1990. {
  1991. if (UrlPostParmsCheck("ctid"))
  1992. {
  1993. string eid = GetPostString("ctid");
  1994. CeErpTradeCell entity = null;
  1995. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1996. if (entity != null)
  1997. {
  1998. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1999. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2000. //{
  2001. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2002. // return;
  2003. //}
  2004. entity.IsPreDelivery = 1;
  2005. entity.Update();
  2006. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2007. returnSuccessMsg("预发货成功!");
  2008. return;
  2009. //string shop = GetPostString("seller_nick");
  2010. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2011. //string comName = GetPostString("comName");
  2012. //string comCode = GetPostString("comCode");
  2013. //string outSid = GetPostString("outSid");//运单号
  2014. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2015. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2016. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2017. //string apires = "";
  2018. //if (deliveryType == "虚拟发货")
  2019. //{
  2020. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2021. //}
  2022. //else
  2023. //{
  2024. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2025. //}
  2026. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2027. ////{
  2028. //if (apires.IndexOf("发货成功") != -1)
  2029. //{
  2030. // if (deliveryType != "虚拟发货")
  2031. // {
  2032. // //还要插入快递信息到 快递信息表
  2033. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2034. // exinfo.tid = eid;
  2035. // exinfo.out_sid = outSid;
  2036. // exinfo.company_code = comCode;
  2037. // exinfo.company_name = comName;
  2038. // exinfo.delivery_memo = deliveryMemo;
  2039. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2040. // exinfo.deliveryType = deliveryType;
  2041. // exinfo.Create();
  2042. // }
  2043. // returnSuccessMsg("发货成功!");
  2044. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2045. //}
  2046. //else
  2047. //{
  2048. // returnErrorMsg("淘宝发货失败!!");
  2049. //}
  2050. //return;
  2051. }
  2052. returnErrorMsg("找不到订单记录");
  2053. }
  2054. }
  2055. public void get_erp_unusuallist()
  2056. {
  2057. DataStruct dStruct = GetPostStruct();
  2058. List<string> lw = new List<string>();
  2059. string tid = GetPostString("ctid");
  2060. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2061. string shopname = GetPostString("shopname");
  2062. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2063. string buyernick = GetPostString("buyer_nick");
  2064. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2065. string ResponsibleMan = GetPostString("responsible");
  2066. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2067. string date1 = GetPostString("date1");
  2068. string date2 = GetPostString("date2");
  2069. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2070. if (dw.Length > 0) lw.Add(dw);
  2071. string price1 = GetPostString("price1");
  2072. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2073. string price2 = GetPostString("price2");
  2074. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2075. string orderState = GetPostString("orderState");
  2076. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2077. string sellermemo = GetPostString("seller_memo");
  2078. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2079. lw.Add(string.Format("UnusualTag > 0"));
  2080. lw.Add(string.Format("IsRefund<={0}", 1));
  2081. dStruct.Order = "pay_time desc";
  2082. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2083. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2084. writeGridDataTableJson(dStruct.TotalCount, dt);
  2085. }
  2086. public void set_erp_unusualtonomal()
  2087. {
  2088. if (UrlPostParmsCheck("ctid"))
  2089. {
  2090. string eid = GetPostString("ctid");
  2091. CeErpTradeCell entity = null;
  2092. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2093. if (entity != null)
  2094. {
  2095. entity.UnusualTag = -1;
  2096. entity.Update();
  2097. returnSuccessMsg("忽略成功!");
  2098. return;
  2099. }
  2100. returnErrorMsg("找不到记录");
  2101. }
  2102. }
  2103. public void ins_erp_unusualreason()
  2104. {
  2105. if (UrlPostParmsCheck("ctid"))
  2106. {
  2107. string eid = GetPostString("ctid");
  2108. CeErpTradeCell entity = null;
  2109. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2110. if (entity != null)
  2111. {
  2112. entity.MemoOpt = 4;
  2113. entity.UnusualCon = GetPostString("con");
  2114. entity.Update();
  2115. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2116. if (trade != null)
  2117. {
  2118. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2119. }
  2120. //查货是否超时
  2121. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2122. if (ceErpTradeCellExtend == null)
  2123. {
  2124. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2125. ceErpTradeCellExtend.ctid = entity.ctid;
  2126. }
  2127. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2128. {
  2129. ceErpTradeCellExtend.CheckOut += 1;
  2130. }
  2131. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2132. if (ceErpTradeCellExtend.ID > 0)
  2133. {
  2134. ceErpTradeCellExtend.Update();
  2135. }
  2136. else
  2137. {
  2138. ceErpTradeCellExtend.Create();
  2139. }
  2140. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2141. returnSuccessMsg("操作成功!");
  2142. return;
  2143. }
  2144. returnErrorMsg("找不到记录");
  2145. }
  2146. }
  2147. public void upd_erp_sampleorder()
  2148. {
  2149. if (UrlPostParmsCheck("ctid"))
  2150. {
  2151. string eid = GetPostString("ctid");
  2152. string[] eArr = eid.Split(',');
  2153. if (eArr.Length > 1)
  2154. {
  2155. List<string> eLst = new List<string>();
  2156. for (int i = 0; i < eArr.Length; i++)
  2157. {
  2158. eLst.Add("'" + eArr[i] + "'");
  2159. }
  2160. eid = string.Join(",", eLst.ToArray());
  2161. }
  2162. else
  2163. {
  2164. eid = "'" + eid + "'";
  2165. }
  2166. StringBuilder sql = new StringBuilder();
  2167. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2168. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2169. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2170. if (dt.Rows.Count > 0)
  2171. {
  2172. string errmsg = "";
  2173. foreach (DataRow dr in dt.Rows)
  2174. {
  2175. StringBuilder sqlsb = new StringBuilder();
  2176. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2177. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2178. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2179. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2180. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2181. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2182. {
  2183. continue;
  2184. }
  2185. else
  2186. {
  2187. string emsg = commonHelper.KeepChinese(apires);
  2188. errmsg += emsg;
  2189. }
  2190. }
  2191. if (errmsg.Length > 0)
  2192. {
  2193. returnErrorMsg(errmsg);
  2194. return;
  2195. }
  2196. returnSuccessMsg("操作成功");
  2197. return;
  2198. }
  2199. returnErrorMsg("找不到记录");
  2200. }
  2201. }
  2202. public void upd_erp_transcustomer()
  2203. {
  2204. if (UrlPostParmsCheck("ctid"))
  2205. {
  2206. string eid = GetPostString("ctid");
  2207. int userid = GetPostInt("CustomerUserId");
  2208. CeErpTradeCell entity = null;
  2209. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2210. if (entity != null)
  2211. {
  2212. //string[] mlist = entity.seller_memo.Split('-');
  2213. //string sql = "select * from view_erpuser where id=" + userid;
  2214. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2215. //if (dt != null && dt.Rows.Count > 0)
  2216. //{
  2217. // string nmemo = "";
  2218. // for(int i = 0; i < mlist.Length - 1; i++)
  2219. // {
  2220. // nmemo += mlist[i];
  2221. // nmemo += "-";
  2222. // }
  2223. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2224. // entity.seller_memo = nmemo;
  2225. //}
  2226. entity.CustomerUserId = userid;
  2227. entity.Update();
  2228. returnSuccessMsg("操作成功!");
  2229. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2230. return;
  2231. }
  2232. returnErrorMsg("找不到记录");
  2233. }
  2234. }
  2235. public void upd_erp_transdesigner()
  2236. {
  2237. if (UrlPostParmsCheck("ctid"))
  2238. {
  2239. string eids = GetPostString("ctid");
  2240. string[] ctidList = eids.Split(',');
  2241. int userid = GetPostInt("DesignUserId");
  2242. foreach (string ctid in ctidList)
  2243. {
  2244. CeErpTradeCell entity = null;
  2245. CeErpDesignerBill entitys = null;
  2246. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2247. entitys = CeErpDesignerBill.GetByTid(ctid);
  2248. if (entity != null)
  2249. {
  2250. if (entity.OrderState > 4)
  2251. {
  2252. continue;
  2253. }
  2254. //存在退款不能流转
  2255. if (entity.IsRefund > 0)
  2256. {
  2257. continue;
  2258. }
  2259. entity.DesignUserId = userid;
  2260. entity.WaitDesignTime = DateTime.Now;
  2261. entity.Update();
  2262. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2263. }
  2264. }
  2265. returnSuccessMsg("操作成功!");
  2266. }
  2267. }
  2268. public void upd_erp_distributedesigner()
  2269. {
  2270. if (UrlPostParmsCheck("ctid"))
  2271. {
  2272. string eid = GetPostString("ctid");
  2273. int userid = GetPostInt("DesignUserId");
  2274. string[] idlist = eid.Split(',');
  2275. if (idlist.Length <= 0)
  2276. {
  2277. returnErrorMsg("订单不能为空");
  2278. return;
  2279. }
  2280. foreach (string ctid in idlist)
  2281. {
  2282. CeErpTradeCell entity = null;
  2283. CeErpDesignerBill entitys = null;
  2284. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2285. else continue;
  2286. if (entity != null)
  2287. {
  2288. if (userid == 2125 || userid == 3542)
  2289. { }
  2290. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2291. {
  2292. returnErrorMsg("金额错误的订单无法指派");
  2293. return;
  2294. }
  2295. if (entity.OrderState >= 5)
  2296. {
  2297. returnErrorMsg("已经设计完成无法指派");
  2298. return;
  2299. }
  2300. if (entity.OrderState == -1)
  2301. {
  2302. returnErrorMsg("审核中的订单无法指派");
  2303. return;
  2304. }
  2305. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2306. {
  2307. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2308. return;
  2309. }
  2310. //157赖橙帆 159林晨 73 静之颖
  2311. 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)
  2312. {
  2313. returnErrorMsg("指派设计共创无法再次指派!");
  2314. return;
  2315. }
  2316. entity.OrderState = 3;
  2317. if (entity.SupplierId == 0)
  2318. {
  2319. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2320. entity.SupplierId = suid;
  2321. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2322. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2323. }
  2324. if (userid == 2125 && entity.seller_memo != "")
  2325. {
  2326. apiDesign.API_GetPrintData_CreateOrder(entity);
  2327. }
  2328. if (userid == 3542 && entity.seller_memo != "")
  2329. {
  2330. string userPost = CurrentUser.UserPost.Post.Code;
  2331. if (CurrentUser.UserID == 73)
  2332. {
  2333. userPost = "SysAdmin";
  2334. }
  2335. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2336. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2337. if (response.msg != "设计共创:成功")
  2338. {
  2339. returnErrorMsg(response.msg);
  2340. return;
  2341. }
  2342. entity.DispatchSort = 2;
  2343. }
  2344. else
  2345. {
  2346. if (entity.DispatchSort == 2)
  2347. {
  2348. ApiVo apiVo = new ApiVo();
  2349. apiVo.actionName = "closeDesign";
  2350. apiVo.orderNumber = entity.ctid;
  2351. designHelper.API_WorkCore(apiVo);//closeDesign
  2352. }
  2353. entity.DispatchSort = 0;
  2354. }
  2355. entity.DesignUserId = userid;
  2356. entity.WaitDesignTime = DateTime.Now;
  2357. entity.UpdateTime = DateTime.Now;
  2358. entity.Update();
  2359. string name = commonHelper.getUserNameById(userid);
  2360. commonHelper.UpdateRelationOrder(entity.ctid);
  2361. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2362. }
  2363. }
  2364. returnSuccessMsg("操作成功!");
  2365. return;
  2366. }
  2367. }
  2368. public string getTidByCtid(string ctid)
  2369. {
  2370. string tid = "";
  2371. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2372. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2373. if (dataTable != null && dataTable.Rows.Count > 0)
  2374. {
  2375. tid = dataTable.Rows[0]["tid"].ToString();
  2376. }
  2377. return tid;
  2378. }
  2379. public List<string> getTidByCtidMore(string ctid)
  2380. {
  2381. 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);
  2382. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2383. List<string> list = new List<string>();
  2384. if (dataTable != null && dataTable.Rows.Count > 0)
  2385. {
  2386. foreach (DataRow item in dataTable.Rows)
  2387. {
  2388. list.Add("'" + item["tid"].ToString() + "'");
  2389. }
  2390. }
  2391. return list;
  2392. }
  2393. public List<string> getTidByCtidLike(string ctid)
  2394. {
  2395. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2396. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2397. List<string> list = new List<string>();
  2398. if (dataTable != null && dataTable.Rows.Count > 0)
  2399. {
  2400. foreach (DataRow item in dataTable.Rows)
  2401. {
  2402. list.Add("'" + item["tid"].ToString() + "'");
  2403. }
  2404. }
  2405. return list;
  2406. }
  2407. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2408. {
  2409. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2410. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2411. List<string> list = new List<string>();
  2412. if (dataTable != null && dataTable.Rows.Count > 0)
  2413. {
  2414. foreach (DataRow item in dataTable.Rows)
  2415. {
  2416. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2417. {
  2418. continue;
  2419. }
  2420. list.Add("'" + item["receiverId"].ToString() + "'");
  2421. }
  2422. }
  2423. return list;
  2424. }
  2425. public void get_erp_myorderlist()
  2426. {
  2427. DataStruct dStruct = GetPostStruct();
  2428. List<string> lw = new List<string>();
  2429. string tid = GetPostString("ctid");
  2430. if (tid.Length > 0)
  2431. {
  2432. string select_tid = getTidByCtid(tid);
  2433. lw.Add(string.Format("tid='{0}'", select_tid));
  2434. }
  2435. else
  2436. {
  2437. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2438. }
  2439. //12-1 修改
  2440. string urgent = GetPostString("urgent");
  2441. string back = GetPostString("back");
  2442. string offlineSearch = GetPostString("offlineSearch");
  2443. if (!string.IsNullOrWhiteSpace(urgent))
  2444. {
  2445. if (urgent.Equals("true"))
  2446. {
  2447. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2448. }
  2449. }
  2450. if (!string.IsNullOrWhiteSpace(back))
  2451. {
  2452. if (back.Equals("true"))
  2453. {
  2454. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2455. }
  2456. }
  2457. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2458. {
  2459. if (offlineSearch.Equals("true"))
  2460. {
  2461. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2462. }
  2463. }
  2464. //end
  2465. string shopname = GetPostString("shopname");
  2466. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2467. string buyernick = GetPostString("buyer_nick");
  2468. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2469. string design = GetPostString("design");
  2470. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2471. string orderState = GetPostString("orderState");
  2472. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2473. string sellermemo = GetPostString("seller_memo");
  2474. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2475. string date1 = GetPostString("date1");
  2476. string date2 = GetPostString("date2");
  2477. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2478. if (dw.Length > 0) lw.Add(dw);
  2479. string price1 = GetPostString("price1");
  2480. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2481. string price2 = GetPostString("price2");
  2482. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2483. string urgency = GetPostString("urgency");
  2484. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2485. string after = GetPostString("after");
  2486. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2487. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2488. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2489. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2490. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2491. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2492. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2493. if (dt != null && dt.Rows.Count > 0)
  2494. {
  2495. foreach (DataRow dr in dt.Rows)
  2496. {
  2497. try
  2498. {
  2499. // 对象操作
  2500. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2501. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2502. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2503. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2504. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2505. if (dStruct.PageSize != 100000)
  2506. {
  2507. if (dr["DispatchSort"].ToString() == "2")
  2508. {
  2509. dr["gongchuang"] = 200;
  2510. }
  2511. else if ("外协".Equals(dr["ToType"].ToString()))
  2512. {
  2513. dr["gongchuang"] = 200;
  2514. }
  2515. else if ("内部".Equals(dr["ToType"].ToString()))
  2516. {
  2517. dr["gongchuang"] = -1;
  2518. }
  2519. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2520. {
  2521. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2522. dr["gongchuang"] = response.code;
  2523. }
  2524. }
  2525. }
  2526. catch (NullReferenceException ex)
  2527. {
  2528. }
  2529. }
  2530. }
  2531. writeGridDataTableJson(dStruct.TotalCount, dt);
  2532. }
  2533. public void get_erp_myreturnorderlist()
  2534. {
  2535. DataStruct dStruct = GetPostStruct();
  2536. List<string> lw = new List<string>();
  2537. string tid = GetPostString("ctid");
  2538. if (tid.Length > 0)
  2539. {
  2540. string select_tid = getTidByCtid(tid);
  2541. lw.Add(string.Format("tid='{0}'", select_tid));
  2542. }
  2543. else
  2544. {
  2545. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2546. }
  2547. string shopname = GetPostString("shopname");
  2548. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2549. string buyernick = GetPostString("buyer_nick");
  2550. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2551. string design = GetPostString("design");
  2552. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2553. string orderState = GetPostString("orderState");
  2554. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2555. string sellermemo = GetPostString("seller_memo");
  2556. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2557. string date1 = GetPostString("date1");
  2558. string date2 = GetPostString("date2");
  2559. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2560. if (dw.Length > 0) lw.Add(dw);
  2561. string price1 = GetPostString("price1");
  2562. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2563. string price2 = GetPostString("price2");
  2564. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2565. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2566. {
  2567. lw.Add(string.Format("CusOrgID = 94"));
  2568. }
  2569. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2570. {
  2571. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2572. }
  2573. else
  2574. {
  2575. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2576. }
  2577. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2578. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2579. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2580. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2581. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2582. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2583. if (dt != null && dt.Rows.Count > 0)
  2584. {
  2585. foreach (DataRow dr in dt.Rows)
  2586. {
  2587. try
  2588. {
  2589. // 对象操作
  2590. if (dStruct.PageSize != 100000)
  2591. {
  2592. if (dr["DispatchSort"].ToString() == "2")
  2593. {
  2594. dr["gongchuang"] = 200;
  2595. }
  2596. else if ("外协".Equals(dr["ToType"].ToString()))
  2597. {
  2598. dr["gongchuang"] = 200;
  2599. }
  2600. else if ("内部".Equals(dr["ToType"].ToString()))
  2601. {
  2602. dr["gongchuang"] = -1;
  2603. }
  2604. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2605. {
  2606. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2607. dr["gongchuang"] = response.code;
  2608. }
  2609. }
  2610. }
  2611. catch (NullReferenceException ex)
  2612. {
  2613. // 处理空引用异常
  2614. }
  2615. }
  2616. }
  2617. writeGridDataTableJson(dStruct.TotalCount, dt);
  2618. }
  2619. public void get_erp_myorderlist_pregather()
  2620. {
  2621. string date1 = GetPostString("date1");
  2622. string date2 = GetPostString("date2");
  2623. int userId = CurrentUser.UserID; //客服id
  2624. string orderWhere = "";
  2625. List<string> lw = new List<string>();
  2626. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2627. if (dw.Length > 0) lw.Add(dw);
  2628. lw.Add(string.Format("CustomerUserId={0}", userId));
  2629. lw.Add(string.Format("OrderState<9"));
  2630. orderWhere = string.Join(" and ", lw.ToArray());
  2631. string orderWhere2 = "";
  2632. List<string> lw2 = new List<string>();
  2633. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2634. if (dw2.Length > 0) lw2.Add(dw2);
  2635. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2636. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2637. string sql = string.Format("select *" +
  2638. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2639. "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 " +
  2640. "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 " +
  2641. "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");
  2642. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2643. //writeGridDataTableJson(dt.Rows.Count, dt);
  2644. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2645. }
  2646. public void upd_erp_publishorder()
  2647. {
  2648. if (UrlPostParmsCheck("ctid"))
  2649. {
  2650. string eid = GetPostString("ctid");
  2651. CeErpTradeCell entity = null;
  2652. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2653. if (entity != null)
  2654. {
  2655. entity.OrderState = 0; //发布后,变为待抢单
  2656. entity.Update();
  2657. commonHelper.UpdateRelationOrder(entity.ctid);
  2658. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2659. returnSuccessMsg("发布成功!");
  2660. return;
  2661. }
  2662. returnErrorMsg("找不到记录");
  2663. }
  2664. }
  2665. public void get_erp_my_tiporder()
  2666. {
  2667. StringBuilder sql = new StringBuilder();
  2668. int userId = 0;
  2669. if (CurrentUser != null) userId = CurrentUser.UserID;
  2670. string posCode = CurrentUser.UserPost.Post.Code;
  2671. string isTipedAfterSaleVerify = GetPostString("af");
  2672. DataTable dt = new DataTable();
  2673. if (posCode != "Supplier")
  2674. {
  2675. if (posCode == "CustomerService" || posCode == "Director")
  2676. {
  2677. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2678. }
  2679. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2680. {
  2681. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2682. }
  2683. else
  2684. {
  2685. string teamIds = CurrentUser.User.TeamIds;
  2686. if (teamIds == "")
  2687. {
  2688. teamIds = "0";
  2689. }
  2690. 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);
  2691. }
  2692. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2693. }
  2694. if (dt.Rows.Count <= 0)
  2695. {
  2696. string key = "aftersale_order_" + userId;
  2697. if (RedisHelper.HasKey(key))
  2698. {
  2699. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2700. dt.Columns.Add("ctid", typeof(string));
  2701. dt.Columns.Add("IsReadTag", typeof(int));
  2702. foreach (var i in list)
  2703. {
  2704. DataRow data = dt.NewRow();
  2705. data["ctid"] = i;
  2706. data["IsReadTag"] = 4;
  2707. dt.Rows.Add(data);
  2708. }
  2709. RedisHelper.StringDelete(key);
  2710. }
  2711. }
  2712. if (dt.Rows.Count <= 0)
  2713. {
  2714. sql = new StringBuilder();
  2715. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2716. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2717. }
  2718. if (posCode == "Supplier")
  2719. {
  2720. string ids = CurrentUser.User.pemVend;
  2721. if (ids != null && ids.Length > 0)
  2722. {
  2723. string[] ids_list = ids.Split(',');
  2724. foreach (var item in ids_list)
  2725. {
  2726. string key = "return_order_" + item;
  2727. if (RedisHelper.HasKey(key))
  2728. {
  2729. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2730. dt.Columns.Add("ctid", typeof(string));
  2731. dt.Columns.Add("IsReadTag", typeof(int));
  2732. foreach (var i in list)
  2733. {
  2734. DataRow data = dt.NewRow();
  2735. data["ctid"] = i;
  2736. data["IsReadTag"] = 1;
  2737. dt.Rows.Add(data);
  2738. }
  2739. RedisHelper.StringDelete(key);
  2740. }
  2741. }
  2742. }
  2743. if (dt.Rows.Count <= 0)
  2744. {
  2745. sql = new StringBuilder();
  2746. 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);
  2747. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2748. }
  2749. }
  2750. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2751. }
  2752. public void reset_erp_tiporder()
  2753. {
  2754. string ids = GetPostString("ids");
  2755. string[] ctidList = ids.Split(',');
  2756. foreach (string ctid in ctidList)
  2757. {
  2758. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2759. if (enty != null)
  2760. {
  2761. enty.IsReadTag = 0;
  2762. enty.Update();
  2763. }
  2764. }
  2765. returnSuccessMsg("成功!");
  2766. return;
  2767. }
  2768. public void get_erp_designlist()
  2769. {
  2770. DataStruct dStruct = GetPostStruct();
  2771. List<string> lw = new List<string>();
  2772. string tid = GetPostString("ctid");
  2773. if (tid.Length > 0)
  2774. {
  2775. string select_tid = getTidByCtid(tid);
  2776. lw.Add(string.Format("tid='{0}'", select_tid));
  2777. }
  2778. string shopname = GetPostString("shopname");
  2779. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2780. string buyernick = GetPostString("buyer_nick");
  2781. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2782. string customer = GetPostString("customer");
  2783. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2784. string design = GetPostString("design");
  2785. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2786. string orderState = GetPostString("orderState");
  2787. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2788. lw.Add(string.Format("OrderState<6"));
  2789. string address = GetPostString("address");
  2790. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2791. string sellermemo = GetPostString("seller_memo");
  2792. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2793. string date1 = GetPostString("date1");
  2794. string date2 = GetPostString("date2");
  2795. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2796. if (dw.Length > 0) lw.Add(dw);
  2797. string apdate1 = GetPostString("apdate1");
  2798. string apdate2 = GetPostString("apdate2");
  2799. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2800. if (dwap.Length > 0) lw.Add(dwap);
  2801. string price1 = GetPostString("price1");
  2802. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2803. string price2 = GetPostString("price2");
  2804. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2805. string designTime = GetPostString("designtime");
  2806. if (designTime.Length > 0)
  2807. {
  2808. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2809. }
  2810. string usershop = CurrentUser.User.pemShop;
  2811. if (usershop.Length > 0)
  2812. {
  2813. lw.Add(string.Format("shopId in ({0})", usershop));
  2814. }
  2815. int myOrgid = CurrentUser.UserPost.OrgID;
  2816. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2817. if (myOrgCode.IndexOf("Designer") != -1)
  2818. {
  2819. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2820. {
  2821. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2822. }
  2823. else
  2824. {
  2825. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2826. }
  2827. }
  2828. else
  2829. {
  2830. string orgId = GetPostString("designerhd");
  2831. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2832. }
  2833. if (tid.Length > 0 || buyernick.Length > 0)
  2834. {
  2835. lw.Add(string.Format("OrderState >= 3"));
  2836. }
  2837. else
  2838. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2839. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2840. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2841. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2842. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2843. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2844. if (dt != null && dt.Rows.Count > 0)
  2845. {
  2846. foreach (DataRow dr in dt.Rows)
  2847. {
  2848. try
  2849. {
  2850. // 对象操作
  2851. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2852. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2853. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2854. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2855. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2856. if (dStruct.PageSize != 100000)
  2857. {
  2858. if (dr["DispatchSort"].ToString() == "2")
  2859. {
  2860. dr["gongchuang"] = 200;
  2861. }
  2862. else if ("外协".Equals(dr["ToType"].ToString()))
  2863. {
  2864. dr["gongchuang"] = 200;
  2865. }
  2866. else if ("内部".Equals(dr["ToType"].ToString()))
  2867. {
  2868. dr["gongchuang"] = -1;
  2869. }
  2870. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2871. {
  2872. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2873. dr["gongchuang"] = response.code;
  2874. }
  2875. }
  2876. }
  2877. catch (NullReferenceException ex)
  2878. {
  2879. }
  2880. }
  2881. }
  2882. writeGridDataTableJson(dStruct.TotalCount, dt);
  2883. }
  2884. public void get_erp_mydesignlist()
  2885. {
  2886. DataStruct dStruct = GetPostStruct();
  2887. List<string> lw = new List<string>();
  2888. string tid = GetPostString("ctid");
  2889. if (tid.Length > 0)
  2890. {
  2891. string select_tid = getTidByCtid(tid);
  2892. lw.Add(string.Format("tid='{0}'", select_tid));
  2893. }
  2894. string shopname = GetPostString("shopname");
  2895. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2896. string buyernick = GetPostString("buyer_nick");
  2897. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2898. string customer = GetPostString("customer");
  2899. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2900. string orderState = GetPostString("orderState");
  2901. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2902. //lw.Add(string.Format("OrderState<6"));
  2903. string date1 = GetPostString("date1");
  2904. string date2 = GetPostString("date2");
  2905. string dw = GetDateWhere("pay_time", date1, date2);
  2906. if (dw.Length > 0) lw.Add(dw);
  2907. string apdate1 = GetPostString("apdate1");
  2908. string apdate2 = GetPostString("apdate2");
  2909. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2910. if (dwap.Length > 0) lw.Add(dwap);
  2911. string price1 = GetPostString("price1");
  2912. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2913. string price2 = GetPostString("price2");
  2914. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2915. string olddownload = GetPostString("olddown");
  2916. if (olddownload == "1")
  2917. {
  2918. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2919. }
  2920. else if (olddownload == "2")
  2921. {
  2922. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2923. }
  2924. string sellermemo = GetPostString("seller_memo");
  2925. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2926. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2927. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2928. {
  2929. if (CurrentUser.User.TeamIds.Length > 0)
  2930. {
  2931. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2932. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2933. else
  2934. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2935. }
  2936. else
  2937. {
  2938. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2939. }
  2940. }
  2941. if (tid.Length <= 0)
  2942. {
  2943. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2944. }
  2945. lw.Add(string.Format("IsReturn!=3"));
  2946. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2947. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2948. string teamids = CurrentUser.User.TeamIds.ToString();
  2949. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2950. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2951. if (dt != null && dt.Rows.Count > 0)
  2952. {
  2953. foreach (DataRow dr in dt.Rows)
  2954. {
  2955. try
  2956. {
  2957. // 对象操作
  2958. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2959. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2960. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2961. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2962. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2963. if (dStruct.PageSize != 100000)
  2964. {
  2965. if (dr["DispatchSort"].ToString() == "2")
  2966. {
  2967. dr["gongchuang"] = 200;
  2968. }
  2969. else if ("外协".Equals(dr["ToType"].ToString()))
  2970. {
  2971. dr["gongchuang"] = 200;
  2972. }
  2973. else if ("内部".Equals(dr["ToType"].ToString()))
  2974. {
  2975. dr["gongchuang"] = -1;
  2976. }
  2977. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2978. {
  2979. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2980. dr["gongchuang"] = response.code;
  2981. }
  2982. }
  2983. }
  2984. catch (NullReferenceException ex)
  2985. {
  2986. }
  2987. }
  2988. }
  2989. writeGridDataTableJson(dStruct.TotalCount, dt);
  2990. }
  2991. public void set_erp_startdesign()
  2992. {
  2993. if (UrlPostParmsCheck("ctid"))
  2994. {
  2995. string eid = GetPostString("ctid");
  2996. CeErpTradeCell entity = null;
  2997. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2998. if (entity != null)
  2999. {
  3000. if (entity.OrderState != 3)
  3001. {
  3002. returnErrorMsg("请刷新,订单已经设计了");
  3003. return;
  3004. }
  3005. entity.StartDesignTime = DateTime.Now;
  3006. entity.OrderState = 4;
  3007. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3008. {
  3009. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3010. entity.SupplierId = suid;
  3011. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3012. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3013. }
  3014. entity.UpdateTime = DateTime.Now;
  3015. //entity.MakeSupplier = suname;
  3016. entity.Update();
  3017. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3019. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3020. commonHelper.getCytPrice(entity);
  3021. returnSuccessMsg("操作成功!");
  3022. return;
  3023. }
  3024. returnErrorMsg("找不到记录");
  3025. }
  3026. }
  3027. public void ins_erp_designselfmemo()
  3028. {
  3029. if (UrlPostParmsCheck("ctid"))
  3030. {
  3031. string eid = GetPostString("ctid");
  3032. string con = GetPostString("con");
  3033. CeErpTradeCell entity = null;
  3034. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3035. if (entity != null)
  3036. {
  3037. entity.DesignSelfMemo = con;
  3038. entity.Update();
  3039. returnSuccessMsg("操作成功!");
  3040. return;
  3041. }
  3042. returnErrorMsg("找不到记录");
  3043. }
  3044. }
  3045. public void ins_erp_designprice()
  3046. {
  3047. if (UrlPostParmsCheck("ctid"))
  3048. {
  3049. string eid = GetPostString("ctid");
  3050. int uid = CurrentUser.UserID;
  3051. string userName = CurrentUser.UserName;
  3052. CeErpTradeCell entity = null;
  3053. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3054. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3055. if (entitys == null)
  3056. {
  3057. entitys = new CeErpDesignerBill();
  3058. }
  3059. if (entity != null)
  3060. {
  3061. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3062. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3063. entity.StartDesignTime = DateTime.Now;
  3064. entity.OrderState = 4;
  3065. string suname = "";
  3066. if (entity.SupplierId == 0)
  3067. {
  3068. int sid = commonHelper.autoDistributeToSupplier(entity);
  3069. entity.SupplierId = sid;
  3070. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3071. }
  3072. entity.Update();
  3073. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3074. if (ceErpUserPost != null)
  3075. {
  3076. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3077. if (ceErpPost != null)
  3078. {
  3079. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3080. {
  3081. entitys.tid = entity.ctid;
  3082. entitys.oid = entity.tid;
  3083. entitys.uid = uid;
  3084. entitys.userName = userName;
  3085. entitys.designerType = 1;
  3086. entitys.designerTypeText = "内部设计师";
  3087. entitys.price = Convert.ToDouble(GetPostString("price"));
  3088. entitys.designNum = GetPostInt("designNum");
  3089. entitys.modifyNum = GetPostInt("modifyNum");
  3090. entitys.designSize = GetPostString("designSize");
  3091. entitys.modifySize = GetPostString("modifySize");
  3092. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3093. {
  3094. entitys.create_time = DateTime.Now;
  3095. entitys.create_u_id = uid;
  3096. entitys.create_u_name = userName;
  3097. entitys.Save();
  3098. }
  3099. else
  3100. {
  3101. entitys.update_time = DateTime.Now;
  3102. entitys.update_u_id = uid;
  3103. entitys.update_u_name = userName;
  3104. entitys.Update();
  3105. }
  3106. }
  3107. }
  3108. }
  3109. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3110. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3111. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3112. if (suname != "")
  3113. {
  3114. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3115. }
  3116. commonHelper.getCytPrice(entity);
  3117. returnSuccessMsg("操作成功!");
  3118. return;
  3119. }
  3120. returnErrorMsg("找不到记录");
  3121. }
  3122. }
  3123. public void upload_erp_filecomplete()
  3124. {
  3125. if (UrlPostParmsCheck("ctid"))
  3126. {
  3127. string eid = GetPostString("ctid");
  3128. CeErpTradeCell entity = null;
  3129. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3130. if (entity != null)
  3131. {
  3132. entity.OrderState = 5; //设计完成
  3133. entity.Update();
  3134. returnSuccessMsg(eid + "上传成功,设计完成!");
  3135. return;
  3136. }
  3137. returnErrorMsg("找不到订单记录");
  3138. }
  3139. }
  3140. public void get_erp_designovertimelist()
  3141. {
  3142. DataStruct dStruct = GetPostStruct();
  3143. List<string> lw = new List<string>();
  3144. string tid = GetPostString("ctid");
  3145. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3146. string shopname = GetPostString("shopname");
  3147. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3148. string buyernick = GetPostString("buyer_nick");
  3149. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3150. string ResponsibleMan = GetPostString("responsible");
  3151. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3152. string date1 = GetPostString("date1");
  3153. string date2 = GetPostString("date2");
  3154. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3155. if (dw.Length > 0) lw.Add(dw);
  3156. string price1 = GetPostString("price1");
  3157. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3158. string price2 = GetPostString("price2");
  3159. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3160. string orderState = GetPostString("orderState");
  3161. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3162. string sellermemo = GetPostString("seller_memo");
  3163. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3164. lw.Add(string.Format("UnusualTag=3"));
  3165. lw.Add(string.Format("IsRefund<={0}", 1));
  3166. dStruct.Order = "WaitDesignTime desc";
  3167. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3168. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3169. writeGridDataTableJson(dStruct.TotalCount, dt);
  3170. }
  3171. //设计管理 获取抢单大厅列表
  3172. public void get_erp_grabinglist()
  3173. {
  3174. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3175. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3176. bool oldOrder = false;
  3177. if (org != null)
  3178. {
  3179. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3180. }
  3181. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3182. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3183. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3184. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3185. //先处理订单数据
  3186. if (dt.Rows.Count > 0)
  3187. {
  3188. Dictionary<string, int> design = null;
  3189. int count = 0;
  3190. foreach (DataRow row in dt.Rows)
  3191. {
  3192. if (map.ContainsKey(row["ShopId"].ToString()))
  3193. {
  3194. map.TryGetValue(row["ShopId"].ToString(), out design);
  3195. }
  3196. else
  3197. {
  3198. design = new Dictionary<string, int>();
  3199. }
  3200. if (design.ContainsKey(row["ProductId"].ToString()))
  3201. {
  3202. design.TryGetValue(row["ProductId"].ToString(), out count);
  3203. }
  3204. count++;
  3205. design[row["ProductId"].ToString()] = count;
  3206. map[row["ShopId"].ToString()] = design;
  3207. }
  3208. }
  3209. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3210. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3211. //把店铺排序和技能排序分类
  3212. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3213. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3214. if (design_dt.Rows.Count > 0)
  3215. {
  3216. Dictionary<string, string> design = null;
  3217. List<string> shopIds = null;
  3218. foreach (DataRow row in design_dt.Rows)
  3219. {
  3220. if ("0".Equals(row["designId"].ToString()))
  3221. {
  3222. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3223. {
  3224. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3225. }
  3226. else
  3227. {
  3228. shopIds = new List<string>();
  3229. }
  3230. shopIds.Add(row["shopId"].ToString());
  3231. shop_orders[row["orders"].ToString()] = shopIds;
  3232. }
  3233. else
  3234. {
  3235. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3236. {
  3237. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3238. }
  3239. else
  3240. {
  3241. design = new Dictionary<string, string>();
  3242. }
  3243. design[row["orders"].ToString()] = row["designId"].ToString();
  3244. design_orders[row["shopId"].ToString()] = design;
  3245. }
  3246. }
  3247. //处理成key value后根据key排序
  3248. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3249. foreach (List<string> val in shop_orders.Values)
  3250. {
  3251. if (val != null)
  3252. {
  3253. foreach (string key in val)
  3254. {
  3255. if (design_orders.ContainsKey(key.ToString()))
  3256. {
  3257. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3258. }
  3259. }
  3260. }
  3261. }
  3262. }
  3263. //校验哪个优先级有订单
  3264. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3265. foreach (string key in shop_orders.Keys)
  3266. {
  3267. List<string> ids = null;
  3268. shop_orders.TryGetValue(key, out ids);
  3269. //id为shopid
  3270. foreach (string id in ids)
  3271. {
  3272. Dictionary<string, int> list = null;
  3273. Dictionary<string, string> desing = null;
  3274. map.TryGetValue(id, out list);
  3275. design_orders.TryGetValue(id, out desing);
  3276. if (list != null && desing != null)
  3277. {
  3278. foreach (var item in desing)
  3279. {
  3280. int count = 0;
  3281. if (list.ContainsKey(item.Value))
  3282. {
  3283. list.TryGetValue(item.Value, out count);
  3284. if (count > 0)
  3285. {
  3286. designIds[id] = item.Value;
  3287. break;
  3288. }
  3289. }
  3290. }
  3291. }
  3292. }
  3293. if (designIds.Count > 0)
  3294. {
  3295. break;
  3296. }
  3297. }
  3298. DataTable table = new DataTable();
  3299. table.Columns.Add("tid", typeof(string));
  3300. table.Columns.Add("ctid", typeof(string));
  3301. table.Columns.Add("seller_nick", typeof(string));
  3302. table.Columns.Add("productName", typeof(string));
  3303. table.Columns.Add("pay_time", typeof(string));
  3304. table.Columns.Add("seller_memo", typeof(string));
  3305. if (designIds.Count > 0)
  3306. {
  3307. string shopId = "";
  3308. string productId = "";
  3309. foreach (var designInfo in designIds)
  3310. {
  3311. shopId = designInfo.Key;
  3312. productId = designInfo.Value;
  3313. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3314. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3315. if (dt.Rows.Count > 0)
  3316. {
  3317. foreach (DataRow row in dt.Rows)
  3318. {
  3319. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3320. {
  3321. DataRow data = table.NewRow();
  3322. data["ctid"] = row["ctid"].ToString();
  3323. data["tid"] = row["tid"].ToString();
  3324. data["seller_nick"] = ceErpShop.ShopName;
  3325. data["pay_time"] = row["pay_time"].ToString();
  3326. data["seller_memo"] = row["seller_memo"].ToString();
  3327. data["productName"] = ceErpProduct.PType;
  3328. table.Rows.Add(data);
  3329. }
  3330. }
  3331. }
  3332. }
  3333. }
  3334. writeGridDataTableJson(table.Rows.Count, table);
  3335. }
  3336. private object rushLockObject = new object();
  3337. public void set_erp_grabingorder()
  3338. {
  3339. if (UrlPostParmsCheck("ctid"))
  3340. {
  3341. int total = CurrentUser.User.Person.Total;
  3342. int userId = CurrentUser.User.ID;
  3343. int noFinish = CurrentUser.User.Person.NoFinish;
  3344. int finalization = CurrentUser.User.Person.Finalization;
  3345. string eids = GetPostString("ctid");
  3346. string key = "RushKey_" + userId;
  3347. int count = 0;
  3348. if (erpRedis.RedisHelper.KeyExists(key))
  3349. {
  3350. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3351. if (redisCount != null)
  3352. {
  3353. count = Convert.ToInt32(redisCount);
  3354. }
  3355. }
  3356. if (count >= total)
  3357. {
  3358. returnErrorMsg("半小时内已经抢" + total + "单");
  3359. return;
  3360. }
  3361. string[] ctidlist = eids.Split(',');
  3362. if (count + ctidlist.Length > total)
  3363. {
  3364. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3365. return;
  3366. }
  3367. int itag = 0;
  3368. lock (rushLockObject)
  3369. {
  3370. if (ctidlist.Length > 0)
  3371. {
  3372. string[] dtList = new string[ctidlist.Length];
  3373. for (int i = 0; i < ctidlist.Length; i++)
  3374. {
  3375. dtList[i] = "'" + ctidlist[i] + "'";
  3376. }
  3377. 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"));
  3378. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3379. if (dt_user.Rows.Count > 0)
  3380. {
  3381. int doing = 0;//未定稿
  3382. int finish = 0;//已完成
  3383. foreach (DataRow dr in dt_user.Rows)
  3384. {
  3385. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3386. {
  3387. doing++;
  3388. }
  3389. else
  3390. {
  3391. finish++;
  3392. }
  3393. }
  3394. if (doing >= noFinish)
  3395. {
  3396. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3397. return;
  3398. }
  3399. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3400. {
  3401. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3402. return;
  3403. }
  3404. }
  3405. //校验选择单子状态
  3406. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3407. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3408. if (dt.Rows.Count > 0)
  3409. {
  3410. List<string> list = new List<string>();
  3411. foreach (DataRow dr in dt.Rows)
  3412. {
  3413. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3414. {
  3415. list.Add(dr["ctid"].ToString());
  3416. }
  3417. }
  3418. if (list.Count > 0)
  3419. {
  3420. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3421. return;
  3422. }
  3423. }
  3424. foreach (string ctid in ctidlist)
  3425. {
  3426. CeErpTradeCell entity = null;
  3427. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3428. if (entity != null)
  3429. {
  3430. entity.OrderState = 3;
  3431. entity.DesignUserId = CurrentUser.UserID;
  3432. entity.WaitDesignTime = DateTime.Now;
  3433. entity.StartDesignTime = DateTime.Now;
  3434. entity.Update();
  3435. commonHelper.UpdateRelationOrder(entity.ctid);
  3436. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3437. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3438. itag++;
  3439. }
  3440. }
  3441. }
  3442. }
  3443. count += ctidlist.Length;
  3444. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3445. if (itag == 0)
  3446. returnErrorMsg("没有找到相关订单");
  3447. else
  3448. returnSuccessMsg("抢单成功!");
  3449. return;
  3450. }
  3451. }
  3452. public void get_erp_waitorderlist()
  3453. {
  3454. DataStruct dStruct = GetPostStruct();
  3455. List<string> lw = new List<string>();
  3456. string tid = GetPostString("ctid");
  3457. if (tid.Length > 0)
  3458. {
  3459. string select_tid = getTidByCtid(tid);
  3460. lw.Add(string.Format("tid='{0}'", select_tid));
  3461. }
  3462. string shopname = GetPostString("shopname");
  3463. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3464. string buyernick = GetPostString("buyer_nick");
  3465. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3466. string customer = GetPostString("customer");
  3467. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3468. string design = GetPostString("design");
  3469. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3470. string orderState = GetPostString("orderState");
  3471. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3472. string supplier = GetPostString("supplier");
  3473. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3474. string sellermemo = GetPostString("seller_memo");
  3475. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3476. string otherMemo = GetPostString("otherMemo");
  3477. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3478. string address = GetPostString("address");
  3479. 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));
  3480. string date1 = GetPostString("date1");
  3481. string date2 = GetPostString("date2");
  3482. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3483. if (dw.Length > 0) lw.Add(dw);
  3484. string price1 = GetPostString("price1");
  3485. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3486. string price2 = GetPostString("price2");
  3487. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3488. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3489. lw.Add(string.Format("IsSample != 2 "));
  3490. lw.Add(string.Format("OrderState = 5 "));
  3491. lw.Add(string.Format("IsRefund<={0}", 1));
  3492. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3493. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3494. string pagesize = GetPostString("pagesize");
  3495. if (pagesize != null)
  3496. {
  3497. dStruct.PageSize = 200;
  3498. }
  3499. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3500. List<string> tids = new List<string>();
  3501. if (dt != null)
  3502. {
  3503. dt.Columns.Add("compenPrice", typeof(double));
  3504. foreach (DataRow dr in dt.Rows)
  3505. {
  3506. if (Convert.IsDBNull(dr["compenPrice"]))
  3507. {
  3508. dr["compenPrice"] = 0;
  3509. }
  3510. tids.Add("'" + dr["tid"].ToString() + "'");
  3511. 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();
  3512. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3513. {
  3514. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3515. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3516. entity.SupplierId = suid;
  3517. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3518. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3519. entity.Update();
  3520. }
  3521. }
  3522. }
  3523. if (tids.Count > 0)
  3524. {
  3525. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3526. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3527. if (dt_price != null && dt_price.Rows.Count > 0)
  3528. {
  3529. foreach (DataRow dr in dt_price.Rows)
  3530. {
  3531. foreach (DataRow row in dt.Rows)
  3532. {
  3533. if (row["tid"].Equals(dr["ptid"]))
  3534. {
  3535. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3536. break;
  3537. }
  3538. }
  3539. }
  3540. }
  3541. }
  3542. writeGridDataTableJson(dStruct.TotalCount, dt);
  3543. }
  3544. public void get_erp_supplierwaitorderlist()
  3545. {
  3546. DataStruct dStruct = GetPostStruct();
  3547. List<string> lw = new List<string>();
  3548. string tid = GetPostString("ctid");
  3549. if (tid.Length > 0)
  3550. {
  3551. string select_tid = getTidByCtid(tid);
  3552. lw.Add(string.Format("tid='{0}'", select_tid));
  3553. }
  3554. string shopname = GetPostString("shopname");
  3555. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3556. string sellermemo = GetPostString("seller_memo");
  3557. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3558. string date1 = GetPostString("date1");
  3559. string date2 = GetPostString("date2");
  3560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3561. if (dw.Length > 0) lw.Add(dw);
  3562. lw.Add(string.Format("OrderState = 5 "));
  3563. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3564. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3565. {
  3566. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3567. }
  3568. string supplier = GetPostString("supplier");
  3569. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3570. {
  3571. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3572. }
  3573. lw.Add(string.Format("IsRefund<={0}", 1));
  3574. dStruct.Order = "FinishDesignTime desc";
  3575. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3576. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3577. if (dt != null)
  3578. {
  3579. foreach (DataRow dr in dt.Rows)
  3580. {
  3581. 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();
  3582. }
  3583. }
  3584. writeGridDataTableJson(dStruct.TotalCount, dt);
  3585. }
  3586. public void upd_erp_verifytosupplier()
  3587. {
  3588. if (UrlPostParmsCheck("ctid"))
  3589. {
  3590. string eids = GetPostString("ctid");
  3591. CeErpTradeCell entity = null;
  3592. string[] eidsList = eids.Split(',');
  3593. if (eidsList.Length <= 0)
  3594. {
  3595. returnErrorMsg("订单号不能空");
  3596. return;
  3597. }
  3598. List<string> tLst = new List<string>();
  3599. foreach (string ctidstr in eidsList)
  3600. {
  3601. tLst.Add("'" + ctidstr + "'");
  3602. CeErpDataSendOrderInfo.createObject(ctidstr);
  3603. }
  3604. string needtids = string.Join(",", tLst.ToArray());
  3605. StringBuilder sql = new StringBuilder();
  3606. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3607. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
  3608. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3609. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3610. returnSuccessMsg("操作成功!");
  3611. return;
  3612. /**foreach (string ctidstr in eidsList)
  3613. {
  3614. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3615. if (entity != null)
  3616. {
  3617. if (entity.SupplierId == 0)
  3618. {
  3619. continue;
  3620. }
  3621. entity.IsVerifyToSupplier = true;
  3622. if (entity.IsReturn == 1) //1是供应商打回
  3623. {
  3624. entity.IsReturn = 0;
  3625. }
  3626. entity.FinishPlaceTime = DateTime.Now;
  3627. entity.PlaceUserId = CurrentUser.UserID;
  3628. entity.Update();
  3629. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3630. }
  3631. }
  3632. returnSuccessMsg("操作成功!");
  3633. return;**/
  3634. }
  3635. }
  3636. public void upd_erp_supplierback()
  3637. {
  3638. if (UrlPostParmsCheck("ctid"))
  3639. {
  3640. string eid = GetPostString("ctid");
  3641. string reason = GetPostString("returnreason");
  3642. CeErpTradeCell entity = null;
  3643. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3644. if (entity != null)
  3645. {
  3646. string message = "操作成功!";
  3647. string isDown = "";
  3648. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3649. {
  3650. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3651. isDown = "被点击下载";
  3652. }
  3653. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3654. {
  3655. string key = "return_order_" + entity.SupplierId;
  3656. List<string> list = new List<string>();
  3657. if (RedisHelper.HasKey(key))
  3658. {
  3659. object data = RedisHelper.StringGet(key);
  3660. list = Convert.ToString(data).Split(',').ToList();
  3661. }
  3662. list.Add(eid);
  3663. RedisHelper.StringSet(key, string.Join(",", list));
  3664. }
  3665. entity.IsVerifyToSupplier = false;
  3666. entity.IsReturn = 1;
  3667. entity.IsHaveNewOrder = 0;
  3668. entity.ReturnTime = DateTime.Now;
  3669. entity.ReturnReason = reason;
  3670. if (entity.OrderState == 6)
  3671. {
  3672. entity.OrderState = 5;
  3673. }
  3674. entity.Update();
  3675. CeErpSukuraData.createInfo(entity.ctid, 5);
  3676. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3677. returnSuccessMsg(message);
  3678. return;
  3679. }
  3680. returnErrorMsg("找不到订单记录");
  3681. }
  3682. }
  3683. public void upd_erp_toaftersaleorder()
  3684. {
  3685. if (UrlPostParmsCheck("ctid"))
  3686. {
  3687. string eid = GetPostString("ctid");
  3688. string reason = GetPostString("returnreason");
  3689. CeErpTradeCell entity = null;
  3690. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3691. if (entity != null)
  3692. {
  3693. if (entity.isAfterSaleOrder != 1)
  3694. {
  3695. returnErrorMsg("带S的售后单才能打回给售后");
  3696. return;
  3697. }
  3698. if (entity.OrderState >= 5)
  3699. {
  3700. returnErrorMsg("已经设计完成了不能打回给售后");
  3701. return;
  3702. }
  3703. entity.OrderState = 0;
  3704. entity.IsReturn = 3;
  3705. entity.ReturnTime = DateTime.Now;
  3706. entity.UpdateTime = DateTime.Now;
  3707. entity.ReturnReason = reason;
  3708. entity.Update();
  3709. CeErpSukuraData.createInfo(entity.ctid, 5);
  3710. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3711. returnSuccessMsg("操作成功!");
  3712. return;
  3713. }
  3714. returnErrorMsg("找不到订单记录");
  3715. }
  3716. }
  3717. public void upd_erp_aftersaletodesign()
  3718. {
  3719. if (UrlPostParmsCheck("ctid"))
  3720. {
  3721. string eid = GetPostString("ctid");
  3722. CeErpTradeCell entity = null;
  3723. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3724. if (entity != null)
  3725. {
  3726. entity.OrderState = 3;
  3727. entity.IsReturn = 0;
  3728. entity.UpdateTime = DateTime.Now;
  3729. entity.Update();
  3730. CeErpSukuraData.createInfo(entity.ctid, 5);
  3731. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3732. returnSuccessMsg("操作成功!");
  3733. return;
  3734. }
  3735. returnErrorMsg("找不到订单记录");
  3736. }
  3737. }
  3738. public void assign_erp_supplier()
  3739. {
  3740. if (UrlPostParmsCheck("ctid"))
  3741. {
  3742. string eids = GetPostString("ctid");
  3743. int sid = GetPostInt("SupplierName");
  3744. string fromTag = GetPostString("tag");
  3745. string[] eidList = eids.Split(',');
  3746. if (eidList.Length <= 0)
  3747. {
  3748. returnErrorMsg("指派不能为空");
  3749. return;
  3750. }
  3751. string errMsg = "";
  3752. string suname = commonHelper.getSupplierNameById(sid);
  3753. foreach (string ctid in eidList)
  3754. {
  3755. CeErpTradeCell entity = null;
  3756. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3757. if (entity != null)
  3758. {
  3759. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3760. {
  3761. errMsg += (ctid + "指派失败!!!");
  3762. continue;
  3763. }
  3764. entity.SupplierId = sid;
  3765. entity.Update();
  3766. commonHelper.UpdateRelationOrder(entity.ctid);
  3767. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3768. if (entity.OrderState >= 6)
  3769. {
  3770. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3771. //{
  3772. // string msl = entity.MakeSupplier;
  3773. // string[] mslist = msl.Split(',');
  3774. // 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);
  3775. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3776. //}
  3777. //else
  3778. //{
  3779. StringBuilder sql = new StringBuilder();
  3780. 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);
  3781. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3782. //}
  3783. }
  3784. }
  3785. else
  3786. {
  3787. continue;
  3788. }
  3789. }
  3790. if (errMsg.Length > 0)
  3791. {
  3792. returnErrorMsg(errMsg);
  3793. return;
  3794. }
  3795. returnSuccessMsg("操作成功!");
  3796. return;
  3797. }
  3798. }
  3799. public void assign_erp_makesupplier()
  3800. {
  3801. if (UrlPostParmsCheck("ctid"))
  3802. {
  3803. string eids = GetPostString("ctid");
  3804. string sname = GetPostString("SupplierName");
  3805. string[] eidList = eids.Split(',');
  3806. if (eidList.Length <= 0)
  3807. {
  3808. returnErrorMsg("指派不能为空");
  3809. return;
  3810. }
  3811. List<string> tLst = new List<string>();
  3812. foreach (string ctid in eidList)
  3813. {
  3814. CeErpTradeCell entity = null;
  3815. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3816. if (entity != null)
  3817. {
  3818. entity.MakeSupplier = sname;
  3819. entity.Update();
  3820. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3821. tLst.Add("'" + ctid + "'");
  3822. }
  3823. else
  3824. {
  3825. continue;
  3826. }
  3827. }
  3828. string ctids = string.Join(",", tLst.ToArray());
  3829. StringBuilder sql2 = new StringBuilder();
  3830. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3831. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3832. returnSuccessMsg("操作成功!");
  3833. return;
  3834. }
  3835. }
  3836. public void ins_erp_returnreason()
  3837. {
  3838. if (UrlPostParmsCheck("ctid"))
  3839. {
  3840. string eid = GetPostString("ctid");
  3841. CeErpTradeCell entity = null;
  3842. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3843. string userpost = CurrentUser.UserPost.Post.Code;
  3844. if (entity != null)
  3845. {
  3846. bool isPlace = false;
  3847. if (entity.OrderState > 6)
  3848. {
  3849. returnErrorMsg("已发货无法打回!");
  3850. return;
  3851. }
  3852. if (entity.OrderState == 6)
  3853. {
  3854. isPlace = true;
  3855. }
  3856. bool isNeedUpdateCell2 = false;
  3857. if (entity.OrderState >= 6)
  3858. {
  3859. isNeedUpdateCell2 = true;
  3860. }
  3861. int returnTag = 2;
  3862. if (userpost == "Supplier")
  3863. {
  3864. returnTag = 1;
  3865. }
  3866. int toType = GetPostInt("totype");
  3867. string fromType = "3";
  3868. if (entity.OrderState < 5)
  3869. {
  3870. fromType = "3";
  3871. }
  3872. else
  3873. {
  3874. fromType = "4";
  3875. }
  3876. if (entity.IsXianHuo == 0)
  3877. {
  3878. if (returnTag == 2)
  3879. {
  3880. if (toType == 1)
  3881. {
  3882. entity.OrderState = 0;
  3883. entity.ReturnUserType = 1;
  3884. string clearman = GetPostString("clearman");
  3885. if (!string.IsNullOrEmpty(clearman))
  3886. {
  3887. entity.DesignUserId = 0;
  3888. }
  3889. }
  3890. else
  3891. {
  3892. entity.OrderState = 3;
  3893. entity.ReturnUserType = 2;
  3894. }
  3895. entity.IsReadTag = 1;
  3896. }
  3897. else if (returnTag == 1)
  3898. {
  3899. entity.OrderState = 5;
  3900. }
  3901. entity.IsVerifyToSupplier = false;
  3902. }
  3903. if (entity.IsXianHuo == 1)
  3904. {
  3905. entity.OrderState = 5;
  3906. }
  3907. entity.UnusualTag = 0;
  3908. entity.UnusualTime = null;
  3909. entity.UnusualCon = "";
  3910. entity.IsReturn = returnTag;
  3911. entity.ReturnTime = DateTime.Now;
  3912. entity.UpdateTime = DateTime.Now;
  3913. entity.ReturnReason = GetPostString("returnreason");
  3914. entity.Update();
  3915. if (entity.OrderState == 3)
  3916. {
  3917. ApiVo apiVo = new ApiVo();
  3918. apiVo.orderNumber = entity.ctid;
  3919. apiVo.actionName = "rebutDesign";
  3920. apiVo.orderRemarks = entity.ReturnReason;
  3921. designHelper.API_WorkCore(apiVo);//rebutDesign
  3922. }
  3923. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3924. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3925. {
  3926. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3927. }
  3928. CeErpSukuraData.createInfo(entity.ctid, 5);
  3929. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3930. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3931. if (isPlace)
  3932. {
  3933. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3934. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3935. if (dth != null && dth.Rows.Count > 0)
  3936. {
  3937. dataSendOrderBean dataSendOrderBean = null;
  3938. foreach (DataRow item in dth.Rows)
  3939. {
  3940. try
  3941. {
  3942. dataSendOrderBean = new dataSendOrderBean();
  3943. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3944. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3945. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3946. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3947. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3948. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3949. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3950. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3951. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3952. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3953. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3954. dataSendOrderBean.Radio1723534706288 = "打回";
  3955. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3956. if (result != null)
  3957. {
  3958. if ("0".Equals(result.errcode))
  3959. {
  3960. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3961. }
  3962. else
  3963. {
  3964. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3965. }
  3966. }
  3967. }
  3968. catch (Exception ex)
  3969. {
  3970. }
  3971. }
  3972. }
  3973. }
  3974. if (isNeedUpdateCell2)
  3975. {
  3976. if (entity.MakeSupplier.IndexOf(",") != -1)
  3977. {
  3978. StringBuilder sql2 = new StringBuilder();
  3979. 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);
  3980. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3981. }
  3982. else
  3983. {
  3984. StringBuilder sql2 = new StringBuilder();
  3985. 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);
  3986. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3987. }
  3988. }
  3989. returnSuccessMsg("操作成功!");
  3990. return;
  3991. }
  3992. returnErrorMsg("找不到订单记录");
  3993. }
  3994. }
  3995. public void cyt_erp_returnreason()
  3996. {
  3997. if (UrlPostParmsCheck("ctid"))
  3998. {
  3999. string eid = GetPostString("ctid");
  4000. CeErpTradeCell entity = null;
  4001. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4002. string userpost = CurrentUser.UserPost.Post.Code;
  4003. if (entity != null)
  4004. {
  4005. if (entity.OrderState > 6)
  4006. {
  4007. returnErrorMsg("已发货无法打回!");
  4008. return;
  4009. }
  4010. JObject jsonObject = new JObject
  4011. {
  4012. { "Userid", "77886" },
  4013. { "Pwd", "lt666888" },
  4014. { "LTOrderId",eid }
  4015. };
  4016. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4017. JObject jsonObjects = JObject.Parse(response);
  4018. string msg = (string)jsonObjects["msg"];
  4019. if (msg != "取消成功")
  4020. {
  4021. returnErrorMsg(msg);
  4022. return;
  4023. }
  4024. bool isNeedUpdateCell2 = false;
  4025. if (entity.OrderState >= 6)
  4026. {
  4027. isNeedUpdateCell2 = true;
  4028. }
  4029. int returnTag = 2;
  4030. if (userpost == "Supplier")
  4031. {
  4032. returnTag = 1;
  4033. }
  4034. if (entity.IsXianHuo == 0)
  4035. {
  4036. if (returnTag == 2)
  4037. {
  4038. int toType = GetPostInt("totype");
  4039. if (toType == 1)
  4040. {
  4041. entity.OrderState = 0;
  4042. entity.ReturnUserType = 1;
  4043. }
  4044. else
  4045. {
  4046. entity.OrderState = 4;
  4047. entity.ReturnUserType = 2;
  4048. }
  4049. entity.IsReadTag = 1;
  4050. }
  4051. else if (returnTag == 1)
  4052. {
  4053. entity.OrderState = 5;
  4054. }
  4055. entity.IsVerifyToSupplier = false;
  4056. }
  4057. entity.UnusualTag = 0;
  4058. entity.UnusualTime = null;
  4059. entity.UnusualCon = "";
  4060. entity.IsReturn = returnTag;
  4061. entity.ReturnTime = DateTime.Now;
  4062. entity.ReturnReason = GetPostString("returnreason");
  4063. entity.Update();
  4064. if (entity.OrderState == 4)
  4065. {
  4066. ApiVo apiVo = new ApiVo();
  4067. apiVo.orderNumber = entity.ctid;
  4068. apiVo.actionName = "rebutDesign";
  4069. apiVo.orderRemarks = entity.ReturnReason;
  4070. designHelper.API_WorkCore(apiVo);//rebutDesign
  4071. }
  4072. CeErpSukuraData.createInfo(entity.ctid, 5);
  4073. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4074. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4075. if (isNeedUpdateCell2)
  4076. {
  4077. if (entity.MakeSupplier.IndexOf(",") != -1)
  4078. {
  4079. StringBuilder sql2 = new StringBuilder();
  4080. 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);
  4081. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4082. }
  4083. else
  4084. {
  4085. StringBuilder sql2 = new StringBuilder();
  4086. 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);
  4087. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4088. }
  4089. }
  4090. returnSuccessMsg("操作成功!");
  4091. return;
  4092. }
  4093. returnErrorMsg("找不到订单记录");
  4094. }
  4095. }
  4096. public void upd_erp_xianhuoreturntag()
  4097. {
  4098. if (UrlPostParmsCheck("ctid"))
  4099. {
  4100. string eids = GetPostString("ctid");
  4101. string[] ctids = eids.Split(',');
  4102. foreach (string ctid in ctids)
  4103. {
  4104. CeErpTradeCell entity = null;
  4105. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4106. if (entity != null)
  4107. {
  4108. entity.IsReturn = 0;
  4109. entity.Update();
  4110. CeErpSukuraData.createInfo(entity.ctid, 5);
  4111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4112. }
  4113. }
  4114. returnSuccessMsg("操作成功!");
  4115. return;
  4116. }
  4117. }
  4118. public void get_erp_waitdeliverylist()
  4119. {
  4120. DataStruct dStruct = GetPostStruct();
  4121. List<string> lw = new List<string>();
  4122. string tid = GetPostString("ctid");
  4123. if (tid.Length > 0)
  4124. {
  4125. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4126. if (tid.Length > 5)
  4127. {
  4128. List<string> tids = getTidByCtidLike(tid);
  4129. if (tids.Count > 0 && tids.Count < 10)
  4130. {
  4131. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4132. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4133. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4134. {
  4135. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4136. }*/
  4137. }
  4138. }
  4139. lw.Add(tid_sql);
  4140. }
  4141. string shopname = GetPostString("shopname");
  4142. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4143. string buyernick = GetPostString("buyer_nick");
  4144. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4145. //if (tid.Length == 0 && buyernick.Length == 0)
  4146. //{
  4147. // lw.Add(string.Format("IsRefund<={0}", 1));
  4148. //}
  4149. string customer = GetPostString("customer");
  4150. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4151. string design = GetPostString("design");
  4152. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4153. string orderState = GetPostString("orderState");
  4154. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4155. string address = GetPostString("address");
  4156. 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));
  4157. string sellermemo = GetPostString("seller_memo");
  4158. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4159. string supplier = GetPostString("supplier");
  4160. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4161. string OrderArea = GetPostString("order_area");
  4162. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4163. string placedate1 = GetPostString("placedate1");
  4164. string placedate2 = GetPostString("placedate2");
  4165. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4166. if (fdw.Length > 0) lw.Add(fdw);
  4167. string price1 = GetPostString("price1");
  4168. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4169. string price2 = GetPostString("price2");
  4170. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4171. string unusualCon = GetPostString("unusualcon");
  4172. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4173. string otherMemo = GetPostString("otherMemo");
  4174. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4175. string posTag = CurrentUser.UserPost.Post.Code;
  4176. if (posTag == "Supplier")
  4177. {
  4178. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4179. }
  4180. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4181. lw.Add(string.Format("type != 'PDD' "));
  4182. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4183. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4184. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4185. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4186. writeGridDataTableJson(dStruct.TotalCount, dt);
  4187. }
  4188. public void get_erp_changedeliverylist()
  4189. {
  4190. DataStruct dStruct = GetPostStruct();
  4191. List<string> lw = new List<string>();
  4192. string tid = GetPostString("ctid");
  4193. if (tid.Length > 0)
  4194. {
  4195. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4196. if (tid.Length > 5)
  4197. {
  4198. List<string> tids = getTidByCtidLike(tid);
  4199. if (tids.Count > 0 && tids.Count < 10)
  4200. {
  4201. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4202. }
  4203. }
  4204. lw.Add(tid_sql);
  4205. }
  4206. string shopname = GetPostString("shopname");
  4207. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4208. string buyernick = GetPostString("buyer_nick");
  4209. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4210. //if (tid.Length == 0 && buyernick.Length == 0)
  4211. //{
  4212. // lw.Add(string.Format("IsRefund<={0}", 1));
  4213. //}
  4214. string customer = GetPostString("customer");
  4215. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4216. string design = GetPostString("design");
  4217. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4218. string orderState = GetPostString("orderState");
  4219. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4220. string address = GetPostString("address");
  4221. 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));
  4222. string sellermemo = GetPostString("seller_memo");
  4223. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4224. string supplier = GetPostString("supplier");
  4225. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4226. string OrderArea = GetPostString("order_area");
  4227. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4228. string placedate1 = GetPostString("placedate1");
  4229. string placedate2 = GetPostString("placedate2");
  4230. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4231. if (fdw.Length > 0) lw.Add(fdw);
  4232. string price1 = GetPostString("price1");
  4233. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4234. string price2 = GetPostString("price2");
  4235. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4236. string unusualCon = GetPostString("unusualcon");
  4237. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4238. string otherMemo = GetPostString("otherMemo");
  4239. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4240. string posTag = CurrentUser.UserPost.Post.Code;
  4241. if (posTag == "Supplier")
  4242. {
  4243. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4244. }
  4245. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4246. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4247. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4248. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4249. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4250. /*if (tid.Length > 0)
  4251. {
  4252. List<string> tids = new List<string>();
  4253. if (dt != null && dt.Rows.Count > 0)
  4254. {
  4255. foreach (DataRow item in dt.Rows)
  4256. {
  4257. tids.Add("'" + item["tid"] + "'");
  4258. }
  4259. }
  4260. if (tids.Count > 0)
  4261. {
  4262. lw.RemoveAt(0);
  4263. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4264. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4265. dt = WebCache.GetData("view_erptradecell", dStruct);
  4266. }
  4267. }*/
  4268. writeGridDataTableJson(dStruct.TotalCount, dt);
  4269. }
  4270. public void get_erp_pddderiving()
  4271. {
  4272. DataStruct dStruct = GetPostStruct();
  4273. List<string> lw = new List<string>();
  4274. string tid = GetPostString("ctid");
  4275. if (tid.Length > 0)
  4276. {
  4277. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4278. if (tid.Length > 5)
  4279. {
  4280. List<string> tids = getTidByCtidLike(tid);
  4281. if (tids.Count > 0 && tids.Count < 10)
  4282. {
  4283. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4284. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4285. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4286. {
  4287. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4288. }*/
  4289. }
  4290. }
  4291. lw.Add(tid_sql);
  4292. }
  4293. string shopname = GetPostString("shopname");
  4294. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4295. string buyernick = GetPostString("buyer_nick");
  4296. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4297. //if (tid.Length == 0 && buyernick.Length == 0)
  4298. //{
  4299. // lw.Add(string.Format("IsRefund<={0}", 1));
  4300. //}
  4301. string customer = GetPostString("customer");
  4302. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4303. string design = GetPostString("design");
  4304. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4305. string orderState = GetPostString("orderState");
  4306. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4307. string address = GetPostString("address");
  4308. 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));
  4309. string sellermemo = GetPostString("seller_memo");
  4310. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4311. string supplier = GetPostString("supplier");
  4312. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4313. string OrderArea = GetPostString("order_area");
  4314. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4315. string placedate1 = GetPostString("placedate1");
  4316. string placedate2 = GetPostString("placedate2");
  4317. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4318. if (fdw.Length > 0) lw.Add(fdw);
  4319. string price1 = GetPostString("price1");
  4320. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4321. string price2 = GetPostString("price2");
  4322. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4323. string unusualCon = GetPostString("unusualcon");
  4324. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4325. string posTag = CurrentUser.UserPost.Post.Code;
  4326. if (posTag == "Supplier")
  4327. {
  4328. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4329. }
  4330. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4331. lw.Add(string.Format("type = 'PDD' "));
  4332. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4333. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4334. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4335. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4336. /*if (tid.Length > 0)
  4337. {
  4338. List<string> tids = new List<string>();
  4339. if (dt != null && dt.Rows.Count > 0)
  4340. {
  4341. foreach (DataRow item in dt.Rows)
  4342. {
  4343. tids.Add("'" + item["tid"] + "'");
  4344. }
  4345. }
  4346. if (tids.Count > 0)
  4347. {
  4348. lw.RemoveAt(0);
  4349. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4350. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4351. dt = WebCache.GetData("view_erptradecell", dStruct);
  4352. }
  4353. }*/
  4354. writeGridDataTableJson(dStruct.TotalCount, dt);
  4355. }
  4356. public void get_erp_jdderiving()
  4357. {
  4358. DataStruct dStruct = GetPostStruct();
  4359. List<string> lw = new List<string>();
  4360. string tid = GetPostString("ctid");
  4361. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4362. string shopname = GetPostString("shopname");
  4363. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4364. string buyernick = GetPostString("buyer_nick");
  4365. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4366. //if (tid.Length == 0 && buyernick.Length == 0)
  4367. //{
  4368. // lw.Add(string.Format("IsRefund<={0}", 1));
  4369. //}
  4370. string customer = GetPostString("customer");
  4371. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4372. string design = GetPostString("design");
  4373. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4374. string orderState = GetPostString("orderState");
  4375. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4376. string address = GetPostString("address");
  4377. 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));
  4378. string sellermemo = GetPostString("seller_memo");
  4379. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4380. string supplier = GetPostString("supplier");
  4381. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4382. string OrderArea = GetPostString("order_area");
  4383. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4384. string placedate1 = GetPostString("placedate1");
  4385. string placedate2 = GetPostString("placedate2");
  4386. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4387. if (fdw.Length > 0) lw.Add(fdw);
  4388. string price1 = GetPostString("price1");
  4389. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4390. string price2 = GetPostString("price2");
  4391. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4392. string unusualCon = GetPostString("unusualcon");
  4393. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4394. string posTag = CurrentUser.UserPost.Post.Code;
  4395. if (posTag == "Supplier")
  4396. {
  4397. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4398. }
  4399. lw.Add(string.Format("OrderState = 6 "));
  4400. lw.Add(string.Format("type = 'JD' "));
  4401. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4402. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4403. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4404. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4405. writeGridDataTableJson(dStruct.TotalCount, dt);
  4406. }
  4407. public void get_erp_demoorderlist()
  4408. {
  4409. DataStruct dStruct = GetPostStruct();
  4410. List<string> lw = new List<string>();
  4411. string tid = GetPostString("ctid");
  4412. if (tid.Length > 0)
  4413. {
  4414. string select_tid = getTidByCtid(tid);
  4415. lw.Add(string.Format("tid='{0}'", select_tid));
  4416. }
  4417. string shopname = GetPostString("shopname");
  4418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4419. string buyernick = GetPostString("buyer_nick");
  4420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4421. string customer = GetPostString("customer");
  4422. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4423. string design = GetPostString("design");
  4424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4425. string orderState = GetPostString("orderState");
  4426. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4427. string address = GetPostString("address");
  4428. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4429. string sellermemo = GetPostString("seller_memo");
  4430. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4431. string supplier = GetPostString("supplier");
  4432. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4433. string OrderArea = GetPostString("order_area");
  4434. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4435. string date1 = GetPostString("date1");
  4436. string date2 = GetPostString("date2");
  4437. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4438. if (dw.Length > 0) lw.Add(dw);
  4439. string price1 = GetPostString("price1");
  4440. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4441. string price2 = GetPostString("price2");
  4442. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4443. string posTag = CurrentUser.UserPost.Post.Code;
  4444. if (posTag == "Supplier")
  4445. {
  4446. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4447. }
  4448. //lw.Add(string.Format("OrderState = 6 "));
  4449. lw.Add(string.Format("IsSample={0}", 3));
  4450. lw.Add(string.Format("IsRefund<={0}", 1));
  4451. dStruct.Order = "pay_time desc";
  4452. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4453. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4454. writeGridDataTableJson(dStruct.TotalCount, dt);
  4455. }
  4456. public void save_erp_checkmemo()
  4457. {
  4458. if (UrlPostParmsCheck("ctid"))
  4459. {
  4460. string ctid = GetPostString("ctid");
  4461. CeErpTradeCell entity = null;
  4462. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4463. if (entity != null)
  4464. {
  4465. entity.CheckMemo = GetPostString("CheckMemo");
  4466. entity.Update();
  4467. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4468. if (trade != null)
  4469. {
  4470. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4471. }
  4472. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4473. returnSuccessMsg("保存成功!");
  4474. return;
  4475. }
  4476. returnErrorMsg("找不到记录");
  4477. }
  4478. }
  4479. public void get_erp_returnlist()
  4480. {
  4481. DataStruct dStruct = GetPostStruct();
  4482. List<string> lw = new List<string>();
  4483. string tid = GetPostString("ctid");
  4484. if (tid.Length > 0)
  4485. {
  4486. string select_tid = getTidByCtid(tid);
  4487. lw.Add(string.Format("tid='{0}'", select_tid));
  4488. }
  4489. string shopname = GetPostString("shopname");
  4490. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4491. string buyernick = GetPostString("buyer_nick");
  4492. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4493. string customer = GetPostString("customer");
  4494. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4495. string design = GetPostString("design");
  4496. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4497. string orderState = GetPostString("orderState");
  4498. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4499. string address = GetPostString("address");
  4500. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4501. string sellermemo = GetPostString("seller_memo");
  4502. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4503. string supplier = GetPostString("supplier");
  4504. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4505. string date1 = GetPostString("date1");
  4506. string date2 = GetPostString("date2");
  4507. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4508. if (dw.Length > 0) lw.Add(dw);
  4509. string bdate1 = GetPostString("backdate1");
  4510. string bdate2 = GetPostString("backdate2");
  4511. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4512. if (dw_back.Length > 0) lw.Add(dw_back);
  4513. string price1 = GetPostString("price1");
  4514. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4515. string price2 = GetPostString("price2");
  4516. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4517. lw.Add(string.Format("IsReturn>0"));
  4518. lw.Add(string.Format("IsXianHuo=0"));
  4519. lw.Add(string.Format("IsReturn!=3"));
  4520. string backtype = GetPostString("backtype");
  4521. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4522. dStruct.Order = "FinishDesignTime desc";
  4523. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4524. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4525. writeGridDataTableJson(dStruct.TotalCount, dt);
  4526. }
  4527. public void get_erp_today_sumreturn()
  4528. {
  4529. DataStruct dStruct = GetPostStruct();
  4530. List<string> lw = new List<string>();
  4531. string bdate1 = GetPostString("returnTimeS");
  4532. string bdate2 = GetPostString("returnTimeE");
  4533. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4534. if (dw_back.Length > 0) lw.Add(dw_back);
  4535. lw.Add(string.Format("IsReturn=0"));
  4536. lw.Add(string.Format("IsXianHuo=0"));
  4537. string mainWhere = string.Join(" and ", lw.ToArray());
  4538. string sql = "";
  4539. if (dw_back.Length > 0)
  4540. {
  4541. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4542. }
  4543. else
  4544. {
  4545. 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 + "'";
  4546. }
  4547. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4548. decimal total = 0, today_finish = 0;
  4549. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4550. {
  4551. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4552. }
  4553. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4554. {
  4555. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4556. }
  4557. var res = new
  4558. {
  4559. data = total,
  4560. data1 = today_finish,
  4561. };
  4562. string ro_jsond = JsonConvert.SerializeObject(res);
  4563. returnSuccess(ro_jsond);
  4564. return;
  4565. }
  4566. public void get_erp_allreturnlist()
  4567. {
  4568. DataStruct dStruct = GetPostStruct();
  4569. List<string> lw = new List<string>();
  4570. string tid = GetPostString("ctid");
  4571. if (tid.Length > 0)
  4572. {
  4573. string select_tid = getTidByCtid(tid);
  4574. lw.Add(string.Format("tid='{0}'", select_tid));
  4575. }
  4576. string shopname = GetPostString("shopname");
  4577. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4578. string buyernick = GetPostString("buyer_nick");
  4579. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4580. string customer = GetPostString("customer");
  4581. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4582. string design = GetPostString("design");
  4583. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4584. string orderState = GetPostString("orderState");
  4585. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4586. string address = GetPostString("address");
  4587. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4588. string sellermemo = GetPostString("seller_memo");
  4589. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4590. string supplier = GetPostString("supplier");
  4591. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4592. string date1 = GetPostString("date1");
  4593. string date2 = GetPostString("date2");
  4594. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4595. if (dw.Length > 0) lw.Add(dw);
  4596. string bdate1 = GetPostString("backdate1");
  4597. string bdate2 = GetPostString("backdate2");
  4598. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4599. if (dw_back.Length > 0) lw.Add(dw_back);
  4600. string price1 = GetPostString("price1");
  4601. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4602. string price2 = GetPostString("price2");
  4603. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4604. string backreason = GetPostString("backreason");
  4605. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4606. lw.Add(string.Format("IsXianHuo=0"));
  4607. lw.Add(string.Format("ReturnTime != ''"));
  4608. string backtype = GetPostString("backtype");
  4609. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4610. dStruct.Order = "FinishDesignTime desc";
  4611. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4612. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4613. writeGridDataTableJson(dStruct.TotalCount, dt);
  4614. }
  4615. public void get_erp_aftersalereturnlist()
  4616. {
  4617. DataStruct dStruct = GetPostStruct();
  4618. List<string> lw = new List<string>();
  4619. string tid = GetPostString("ctid");
  4620. if (tid.Length > 0)
  4621. {
  4622. string select_tid = getTidByCtid(tid);
  4623. lw.Add(string.Format("tid='{0}'", select_tid));
  4624. }
  4625. string shopname = GetPostString("shopname");
  4626. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4627. string buyernick = GetPostString("buyer_nick");
  4628. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4629. string customer = GetPostString("customer");
  4630. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4631. string design = GetPostString("design");
  4632. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4633. string orderState = GetPostString("orderState");
  4634. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4635. string address = GetPostString("address");
  4636. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4637. string sellermemo = GetPostString("seller_memo");
  4638. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4639. string supplier = GetPostString("supplier");
  4640. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4641. string date1 = GetPostString("date1");
  4642. string date2 = GetPostString("date2");
  4643. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4644. if (dw.Length > 0) lw.Add(dw);
  4645. string bdate1 = GetPostString("backdate1");
  4646. string bdate2 = GetPostString("backdate2");
  4647. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4648. if (dw_back.Length > 0) lw.Add(dw_back);
  4649. string price1 = GetPostString("price1");
  4650. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4651. string price2 = GetPostString("price2");
  4652. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4653. lw.Add(string.Format("IsReturn=3"));
  4654. string backtype = GetPostString("backtype");
  4655. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4656. string backreason = GetPostString("backreason");
  4657. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4658. dStruct.Order = "ReturnTime desc";
  4659. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4660. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4661. writeGridDataTableJson(dStruct.TotalCount, dt);
  4662. }
  4663. public void get_erp_xianhuoreturnlist()
  4664. {
  4665. DataStruct dStruct = GetPostStruct();
  4666. List<string> lw = new List<string>();
  4667. string tid = GetPostString("ctid");
  4668. if (tid.Length > 0)
  4669. {
  4670. string select_tid = getTidByCtid(tid);
  4671. lw.Add(string.Format("tid='{0}'", select_tid));
  4672. }
  4673. string shopname = GetPostString("shopname");
  4674. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4675. string buyernick = GetPostString("buyer_nick");
  4676. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4677. string customer = GetPostString("customer");
  4678. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4679. string design = GetPostString("design");
  4680. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4681. string orderState = GetPostString("orderState");
  4682. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4683. string address = GetPostString("address");
  4684. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4685. string sellermemo = GetPostString("seller_memo");
  4686. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4687. string supplier = GetPostString("supplier");
  4688. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4689. string OrderArea = GetPostString("order_area");
  4690. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4691. string date1 = GetPostString("date1");
  4692. string date2 = GetPostString("date2");
  4693. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4694. if (dw.Length > 0) lw.Add(dw);
  4695. string price1 = GetPostString("price1");
  4696. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4697. string price2 = GetPostString("price2");
  4698. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4699. string posTag = CurrentUser.UserPost.Post.Code;
  4700. if (posTag == "Supplier")
  4701. {
  4702. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4703. }
  4704. lw.Add(string.Format("OrderState=6 "));
  4705. lw.Add(string.Format("IsXianHuo=1 "));
  4706. lw.Add(string.Format("IsReturn>0 "));
  4707. lw.Add(string.Format("IsReturn!=3"));
  4708. lw.Add(string.Format("IsRefund<={0}", 1));
  4709. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4710. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4711. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4712. writeGridDataTableJson(dStruct.TotalCount, dt);
  4713. }
  4714. public void set_erp_orderdelivery()
  4715. {
  4716. if (UrlPostParmsCheck("ctid"))
  4717. {
  4718. string eid = GetPostString("ctid");
  4719. CeErpTradeCell entity = null;
  4720. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4721. if (entity != null)
  4722. {
  4723. if (entity.OrderState >= 7)
  4724. {
  4725. returnErrorMsg("此单已发货,无需重复发货");
  4726. return;
  4727. }
  4728. if (entity.OrderState != 6)
  4729. {
  4730. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4731. return;
  4732. }
  4733. string shop = GetPostString("seller_nick");
  4734. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4735. string comName = GetPostString("comName");
  4736. string comCode = GetPostString("comCode");
  4737. string outSid = GetPostString("outSid");
  4738. string deliveryType = GetPostString("deliveryType");
  4739. string deliveryMemo = GetPostString("deliveryMemo");
  4740. outSid = outSid.Trim();
  4741. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4742. if (mainEn == null)
  4743. {
  4744. returnErrorMsg("找不到原始订单记录");
  4745. return;
  4746. }
  4747. bool isInitOrderDeliv = false;
  4748. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4749. {
  4750. isInitOrderDeliv = true;
  4751. }
  4752. string apires = "";
  4753. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4754. 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)
  4755. {
  4756. apires = "发货成功true";
  4757. }
  4758. else
  4759. {
  4760. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4761. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4762. }
  4763. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4764. {
  4765. entity.OrderState = 7;//发货后订单已发货
  4766. entity.OutSid = outSid;
  4767. entity.MemoOpt = 0;
  4768. entity.UpdateTime = DateTime.Now;
  4769. entity.FinishDeliveryTime = DateTime.Now;
  4770. entity.Update();
  4771. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4772. commonHelper.UpdateRelationOrder(entity.ctid);
  4773. //还要插入快递信息到 快递信息表
  4774. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4775. exinfo.tid = eid;
  4776. exinfo.out_sid = outSid;
  4777. exinfo.company_code = comCode;
  4778. exinfo.company_name = comName;
  4779. exinfo.delivery_memo = deliveryMemo;
  4780. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4781. exinfo.deliveryType = deliveryType;
  4782. exinfo.Create();
  4783. returnSuccessMsg("发货操作成功!");
  4784. commonHelper.UpdateRelationOrder(entity.ctid);
  4785. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4786. CeErpSukuraData.createInfo(entity.ctid, 4);
  4787. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4788. {
  4789. commonHelper.sendCytExpress(exinfo);
  4790. }
  4791. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4792. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4793. }
  4794. else
  4795. {
  4796. string errmsg = commonHelper.KeepChinese(apires);
  4797. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4798. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4799. }
  4800. return;
  4801. }
  4802. returnErrorMsg("找不到订单记录");
  4803. }
  4804. }
  4805. public void set_erp_multidelivery()
  4806. {
  4807. string eids = GetPostString("tids");
  4808. string[] eidList = eids.Split(',');
  4809. if (eidList.Length <= 0)
  4810. {
  4811. returnErrorMsg("发货不能为空");
  4812. return;
  4813. }
  4814. foreach (string ctid in eidList)
  4815. {
  4816. if (ctid.Length <= 0) continue;
  4817. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4818. if (expInfo != null)
  4819. {
  4820. StringBuilder sql = new StringBuilder();
  4821. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4822. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4823. if (dt.Rows.Count > 0)
  4824. {
  4825. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4826. {
  4827. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4828. expInfo.state = "异常";
  4829. expInfo.isMultiDelivery = 1;
  4830. expInfo.Update();
  4831. continue;
  4832. }
  4833. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4834. {
  4835. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4836. expInfo.state = "异常";
  4837. expInfo.Update();
  4838. continue;
  4839. }
  4840. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4841. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4842. bool isInitOrderDeliv = false;
  4843. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4844. {
  4845. isInitOrderDeliv = true;
  4846. expInfo.isMultiDelivery = 1;
  4847. }
  4848. if (ctid.IndexOf("N") != -1)
  4849. {
  4850. StringBuilder sqlbucha = new StringBuilder();
  4851. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4852. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4853. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4854. commonHelper.UpdateRelationOrder(ctid);
  4855. expInfo.delivery_memo = "发货成功";
  4856. expInfo.state = "发货成功";
  4857. expInfo.isMultiDelivery = 1;
  4858. expInfo.Update();
  4859. }
  4860. else
  4861. {
  4862. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4863. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4864. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4865. {
  4866. expInfo.delivery_memo = "发货成功";
  4867. expInfo.state = "发货成功";
  4868. expInfo.isMultiDelivery = 1;
  4869. expInfo.Update();
  4870. commonHelper.UpdateRelationOrder(ctid);
  4871. CeErpSukuraData.createInfo(ctid, 4);
  4872. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4873. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4874. }
  4875. else
  4876. {
  4877. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4878. expInfo.state = "异常";
  4879. expInfo.Update();
  4880. }
  4881. }
  4882. }
  4883. }
  4884. }
  4885. returnSuccessMsg("操作完成");
  4886. }
  4887. public void reset_erp_memoopt()
  4888. {
  4889. if (UrlPostParmsCheck("ctid"))
  4890. {
  4891. string eid = GetPostString("ctid");
  4892. CeErpTradeCell entity = null;
  4893. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4894. if (entity != null)
  4895. {
  4896. string stropt = "";
  4897. if (entity.MemoOpt == 1)
  4898. {
  4899. stropt = "“改稿”";
  4900. }
  4901. else if (entity.MemoOpt == 2)
  4902. {
  4903. stropt = "“定稿”";
  4904. }
  4905. else if (entity.MemoOpt == 3)
  4906. {
  4907. stropt = "“完成查货”";
  4908. CeErpSukuraData.createInfo(entity.ctid, 6);
  4909. }
  4910. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4911. entity.UpdateTime = DateTime.Now;
  4912. entity.MemoOpt = 0;
  4913. entity.Update();
  4914. returnSuccessMsg("操作成功!");
  4915. return;
  4916. }
  4917. returnErrorMsg("找不到记录");
  4918. }
  4919. }
  4920. public void get_erp_deliveryunusual()
  4921. {
  4922. DataStruct dStruct = GetPostStruct();
  4923. List<string> lw = new List<string>();
  4924. string tid = GetPostString("ctid");
  4925. if (tid.Length > 0)
  4926. {
  4927. string select_tid = getTidByCtid(tid);
  4928. lw.Add(string.Format("tid='{0}'", select_tid));
  4929. }
  4930. string shopname = GetPostString("shopname");
  4931. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4932. string buyernick = GetPostString("buyer_nick");
  4933. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4934. string customer = GetPostString("customer");
  4935. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4936. string design = GetPostString("design");
  4937. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4938. string sellermemo = GetPostString("seller_memo");
  4939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4940. string supplier = GetPostString("supplier");
  4941. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4942. string date1 = GetPostString("date1");
  4943. string date2 = GetPostString("date2");
  4944. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4945. if (dw.Length > 0) lw.Add(dw);
  4946. string placedate1 = GetPostString("placedate1");
  4947. string placedate2 = GetPostString("placedate2");
  4948. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4949. if (dw_place.Length > 0) lw.Add(dw_place);
  4950. string price1 = GetPostString("price1");
  4951. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4952. string price2 = GetPostString("price2");
  4953. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4954. string unusualCon = GetPostString("unusualcon");
  4955. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4956. string posTag = CurrentUser.UserPost.Post.Code;
  4957. if (posTag == "Supplier")
  4958. {
  4959. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4960. }
  4961. lw.Add(string.Format("OrderState = 6"));
  4962. lw.Add(string.Format("UnusualTag = 5"));
  4963. lw.Add(string.Format("IsRefund<={0}", 1));
  4964. dStruct.Order = "FinishPlaceTime desc";
  4965. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4966. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4967. writeGridDataTableJson(dStruct.TotalCount, dt);
  4968. }
  4969. public void get_erp_deliveryedlist()
  4970. {
  4971. DataStruct dStruct = GetPostStruct();
  4972. List<string> lw = new List<string>();
  4973. string tid = GetPostString("ctid");
  4974. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4975. string shopname = GetPostString("shopname");
  4976. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4977. string buyernick = GetPostString("buyer_nick");
  4978. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4979. string customer = GetPostString("customer");
  4980. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4981. string design = GetPostString("design");
  4982. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4983. string sellermemo = GetPostString("seller_memo");
  4984. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4985. string logistics = GetPostString("logistics");
  4986. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4987. string date1 = GetPostString("date1");
  4988. string date2 = GetPostString("date2");
  4989. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4990. //if (dw.Length > 0) lw.Add(dw);
  4991. string placedate1 = GetPostString("placedate1");
  4992. string placedate2 = GetPostString("placedate2");
  4993. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4994. if (fdw.Length > 0) lw.Add(fdw);
  4995. string devdate1 = GetPostString("deliverydate1");
  4996. string devdate2 = GetPostString("deliverydate2");
  4997. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4998. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4999. string price1 = GetPostString("price1");
  5000. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5001. string price2 = GetPostString("price2");
  5002. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5003. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5004. {
  5005. if (tid.Length > 0)
  5006. {
  5007. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5008. if (tid.Length > 5)
  5009. {
  5010. List<string> tids = getTidByCtidLike(tid);
  5011. if (tids.Count > 0 && tids.Count < 10)
  5012. {
  5013. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5014. }
  5015. }
  5016. lw.Add(tid_sql);
  5017. }
  5018. if (buyernick.Length > 0)
  5019. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5020. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5021. if (dw.Length > 0) lw.Add(dw);
  5022. }
  5023. else
  5024. {
  5025. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5026. }
  5027. string posTag = CurrentUser.UserPost.Post.Code;
  5028. if (posTag == "Supplier")
  5029. {
  5030. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5031. }
  5032. else
  5033. {
  5034. string supplier = GetPostString("supplier");
  5035. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5036. }
  5037. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5038. lw.Add(string.Format("type != 'PDD' "));
  5039. lw.Add(string.Format("IsRefund!={0}", 2));
  5040. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5041. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5042. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5043. /*if (tid.Length > 0)
  5044. {
  5045. List<string> tids = new List<string>();
  5046. if (dt != null && dt.Rows.Count > 0)
  5047. {
  5048. foreach (DataRow item in dt.Rows)
  5049. {
  5050. tids.Add("'" + item["tid"] + "'");
  5051. }
  5052. }
  5053. if (tids.Count > 0)
  5054. {
  5055. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5056. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5057. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5058. dt = WebCache.GetData("view_erptradecell", dStruct);
  5059. }
  5060. }*/
  5061. if (dt != null)
  5062. {
  5063. foreach (DataRow dr in dt.Rows)
  5064. {
  5065. 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();
  5066. }
  5067. }
  5068. writeGridDataTableJson(dStruct.TotalCount, dt);
  5069. }
  5070. public void get_erp_pdddeliveryed()
  5071. {
  5072. DataStruct dStruct = GetPostStruct();
  5073. List<string> lw = new List<string>();
  5074. string tid = GetPostString("ctid");
  5075. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5076. string shopname = GetPostString("shopname");
  5077. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5078. string buyernick = GetPostString("buyer_nick");
  5079. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5080. string customer = GetPostString("customer");
  5081. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5082. string design = GetPostString("design");
  5083. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5084. string sellermemo = GetPostString("seller_memo");
  5085. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5086. string logistics = GetPostString("logistics");
  5087. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5088. string date1 = GetPostString("date1");
  5089. string date2 = GetPostString("date2");
  5090. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5091. //if (dw.Length > 0) lw.Add(dw);
  5092. string placedate1 = GetPostString("placedate1");
  5093. string placedate2 = GetPostString("placedate2");
  5094. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5095. if (fdw.Length > 0) lw.Add(fdw);
  5096. string devdate1 = GetPostString("deliverydate1");
  5097. string devdate2 = GetPostString("deliverydate2");
  5098. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5099. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5100. string price1 = GetPostString("price1");
  5101. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5102. string price2 = GetPostString("price2");
  5103. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5104. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5105. {
  5106. if (tid.Length > 0)
  5107. {
  5108. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5109. if (tid.Length > 5)
  5110. {
  5111. List<string> tids = getTidByCtidLike(tid);
  5112. if (tids.Count > 0 && tids.Count < 10)
  5113. {
  5114. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5115. }
  5116. }
  5117. lw.Add(tid_sql);
  5118. }
  5119. if (buyernick.Length > 0)
  5120. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5121. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5122. if (dw.Length > 0) lw.Add(dw);
  5123. }
  5124. else
  5125. {
  5126. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5127. }
  5128. string posTag = CurrentUser.UserPost.Post.Code;
  5129. if (posTag == "Supplier")
  5130. {
  5131. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5132. }
  5133. else
  5134. {
  5135. string supplier = GetPostString("supplier");
  5136. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5137. }
  5138. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5139. lw.Add(string.Format("type = 'PDD' "));
  5140. lw.Add(string.Format("IsRefund!={0}", 2));
  5141. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5142. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5143. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5144. /* if (tid.Length > 0)
  5145. {
  5146. List<string> tids = new List<string>();
  5147. if (dt != null && dt.Rows.Count > 0)
  5148. {
  5149. foreach (DataRow item in dt.Rows)
  5150. {
  5151. tids.Add("'" + item["tid"] + "'");
  5152. }
  5153. }
  5154. if (tids.Count > 0)
  5155. {
  5156. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5157. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5158. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5159. dt = WebCache.GetData("view_erptradecell", dStruct);
  5160. }
  5161. }*/
  5162. foreach (DataRow dr in dt.Rows)
  5163. {
  5164. 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();
  5165. }
  5166. writeGridDataTableJson(dStruct.TotalCount, dt);
  5167. }
  5168. public void get_erp_jddeliveryed()
  5169. {
  5170. DataStruct dStruct = GetPostStruct();
  5171. List<string> lw = new List<string>();
  5172. string tid = GetPostString("ctid");
  5173. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5174. string shopname = GetPostString("shopname");
  5175. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5176. string buyernick = GetPostString("buyer_nick");
  5177. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5178. string customer = GetPostString("customer");
  5179. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5180. string design = GetPostString("design");
  5181. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5182. string sellermemo = GetPostString("seller_memo");
  5183. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5184. string date1 = GetPostString("date1");
  5185. string date2 = GetPostString("date2");
  5186. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5187. //if (dw.Length > 0) lw.Add(dw);
  5188. string placedate1 = GetPostString("placedate1");
  5189. string placedate2 = GetPostString("placedate2");
  5190. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5191. if (fdw.Length > 0) lw.Add(fdw);
  5192. string devdate1 = GetPostString("deliverydate1");
  5193. string devdate2 = GetPostString("deliverydate2");
  5194. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5195. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5196. string price1 = GetPostString("price1");
  5197. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5198. string price2 = GetPostString("price2");
  5199. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5200. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5201. {
  5202. if (tid.Length > 0)
  5203. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5204. if (buyernick.Length > 0)
  5205. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5206. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5207. if (dw.Length > 0) lw.Add(dw);
  5208. }
  5209. else
  5210. {
  5211. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5212. }
  5213. string posTag = CurrentUser.UserPost.Post.Code;
  5214. if (posTag == "Supplier")
  5215. {
  5216. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5217. }
  5218. else
  5219. {
  5220. string supplier = GetPostString("supplier");
  5221. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5222. }
  5223. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5224. lw.Add(string.Format("type = 'JD' "));
  5225. lw.Add(string.Format("IsRefund!={0}", 2));
  5226. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5227. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5228. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5229. foreach (DataRow dr in dt.Rows)
  5230. {
  5231. 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();
  5232. }
  5233. writeGridDataTableJson(dStruct.TotalCount, dt);
  5234. }
  5235. public void get_erp_allplacelist()
  5236. {
  5237. DataStruct dStruct = GetPostStruct();
  5238. List<string> lw = new List<string>();
  5239. string tid = GetPostString("ctid");
  5240. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5241. string shopname = GetPostString("shopname");
  5242. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5243. string buyernick = GetPostString("buyer_nick");
  5244. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5245. string customer = GetPostString("customer");
  5246. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5247. string design = GetPostString("design");
  5248. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5249. string sellermemo = GetPostString("seller_memo");
  5250. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5251. string supplier = GetPostString("supplier");
  5252. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5253. string date1 = GetPostString("date1");
  5254. string date2 = GetPostString("date2");
  5255. string pldate1 = GetPostString("placedate1");
  5256. string pldate2 = GetPostString("placedate2");
  5257. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5258. //if (dw.Length > 0) lw.Add(dw);
  5259. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5260. {
  5261. if (tid.Length > 0)
  5262. {
  5263. string select_tid = getTidByCtid(tid);
  5264. lw.Add(string.Format("tid='{0}'", select_tid));
  5265. }
  5266. if (buyernick.Length > 0)
  5267. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5268. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5269. if (dw.Length > 0) lw.Add(dw);
  5270. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5271. if (dw_place.Length > 0) lw.Add(dw_place);
  5272. }
  5273. else
  5274. {
  5275. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5276. {
  5277. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5278. }
  5279. }
  5280. string price1 = GetPostString("price1");
  5281. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5282. string price2 = GetPostString("price2");
  5283. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5284. string posTag = CurrentUser.UserPost.Post.Code;
  5285. if (posTag == "Supplier")
  5286. {
  5287. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5288. }
  5289. lw.Add(string.Format("OrderState >= 6"));
  5290. lw.Add(string.Format("IsSample != 2 "));
  5291. //lw.Add(string.Format("isDianziOrder = 0 "));
  5292. lw.Add(string.Format("SupplierId > 0 "));
  5293. //lw.Add(string.Format("IsRefund<={0}", 1));
  5294. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5296. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5297. foreach (DataRow dr in dt.Rows)
  5298. {
  5299. 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();
  5300. }
  5301. writeGridDataTableJson(dStruct.TotalCount, dt);
  5302. }
  5303. public void get_erp_financeallplacelist()
  5304. {
  5305. DataStruct dStruct = GetPostStruct();
  5306. List<string> lw = new List<string>();
  5307. string tid = GetPostString("ctid");
  5308. string shopname = GetPostString("shopname");
  5309. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5310. string buyernick = GetPostString("buyer_nick");
  5311. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5312. string customer = GetPostString("customer");
  5313. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5314. string design = GetPostString("design");
  5315. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5316. string sellermemo = GetPostString("seller_memo");
  5317. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5318. string supplier = GetPostString("supplier");
  5319. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5320. string date1 = GetPostString("date1");
  5321. string date2 = GetPostString("date2");
  5322. string pldate1 = GetPostString("placedate1");
  5323. string pldate2 = GetPostString("placedate2");
  5324. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5325. {
  5326. if (tid.Length > 0)
  5327. {
  5328. string select_tid = getTidByCtid(tid);
  5329. lw.Add(string.Format("tid='{0}'", select_tid));
  5330. }
  5331. if (buyernick.Length > 0)
  5332. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5333. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5334. if (dw.Length > 0) lw.Add(dw);
  5335. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5336. if (dw_place.Length > 0) lw.Add(dw_place);
  5337. }
  5338. else
  5339. {
  5340. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5341. {
  5342. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5343. }
  5344. }
  5345. string price1 = GetPostString("price1");
  5346. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5347. string price2 = GetPostString("price2");
  5348. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5349. string posTag = CurrentUser.UserPost.Post.Code;
  5350. if (posTag == "Supplier")
  5351. {
  5352. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5353. }
  5354. //lw.Add(string.Format("OrderState >= 6"));
  5355. lw.Add(string.Format("IsSample != 2 "));
  5356. lw.Add(string.Format("isDianziOrder = 0 "));
  5357. //lw.Add(string.Format("IsRefund<={0}", 1));
  5358. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5359. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5360. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5361. foreach (DataRow dr in dt.Rows)
  5362. {
  5363. 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();
  5364. }
  5365. writeGridDataTableJson(dStruct.TotalCount, dt);
  5366. }
  5367. public void get_erp_expresslist()
  5368. {
  5369. int listtype = GetInt("ltype");
  5370. DataStruct dStruct = GetPostStruct();
  5371. List<string> lw = new List<string>();
  5372. string tid = GetPostString("tid");
  5373. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5374. string outsid = GetPostString("out_sid");
  5375. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5376. string importer = GetPostString("ImportUserName");
  5377. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5378. string file = GetPostString("import_file");
  5379. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5380. string printman = GetPostString("printman");
  5381. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5382. string date1 = GetPostString("date1");
  5383. string date2 = GetPostString("date2");
  5384. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5385. if (dw.Length > 0) lw.Add(dw);
  5386. string fdate1 = GetPostString("finishdate1");
  5387. string fdate2 = GetPostString("finishdate2");
  5388. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5389. if (fdw.Length > 0) lw.Add(fdw);
  5390. string supplierId = GetPostString("supplierId");
  5391. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5392. if (listtype == 1)
  5393. {
  5394. lw.Add(string.Format("importUserId !=0"));
  5395. }
  5396. string posTag = CurrentUser.UserPost.Post.Code;
  5397. if (posTag == "Supplier")
  5398. {
  5399. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5400. }
  5401. if (dStruct.PageSize != 100000)
  5402. {
  5403. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5404. }
  5405. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5406. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5407. writeGridDataTableJson(dStruct.TotalCount, dt);
  5408. }
  5409. public void set_erp_buchaorderdelivery()
  5410. {
  5411. if (UrlPostParmsCheck("ctid"))
  5412. {
  5413. string eid = GetPostString("ctid");
  5414. CeErpTradeCell entity = null;
  5415. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5416. if (entity != null)
  5417. {
  5418. if (entity.IsSample != 2)
  5419. {
  5420. returnErrorMsg("补差价单才能标记为已发货");
  5421. return;
  5422. }
  5423. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5424. entity.OrderState = 7;
  5425. entity.Update();
  5426. returnSuccessMsg("操作成功!");
  5427. return;
  5428. }
  5429. returnErrorMsg("找不到记录");
  5430. }
  5431. }
  5432. public void get_stdtemplates()
  5433. {
  5434. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5435. //string res = taobaoHelper.test();
  5436. string res = apiHelper.API_PrintTemplate();
  5437. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5438. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5439. {
  5440. int sidx = res.IndexOf("error_code");
  5441. int eidx = res.IndexOf("success");
  5442. string msg = res.Substring(sidx, eidx - sidx);
  5443. returnErrorMsg(msg);
  5444. return;
  5445. }
  5446. if (res.Length <= 0)
  5447. {
  5448. returnErrorMsg("模板数据为空!");
  5449. return;
  5450. }
  5451. ReturnSuccess(res);
  5452. }
  5453. public void cancel_print_order()
  5454. {
  5455. if (UrlPostParmsCheck("ctid"))
  5456. {
  5457. string ctid = GetPostString("ctid");
  5458. CeErpTradeCell entity = null;
  5459. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5460. if (entity != null)
  5461. {
  5462. string res = "";
  5463. string code = entity.LastBillWaybillCode;
  5464. if (code == "")
  5465. {
  5466. code = entity.OutSid;
  5467. }
  5468. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5469. XLog.SaveLog(0, "取消面单" + res);
  5470. }
  5471. }
  5472. }
  5473. public void set_erp_printwaybill()
  5474. {
  5475. if (UrlPostParmsCheck("ctid"))
  5476. {
  5477. string ctid = GetPostString("ctid");
  5478. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5479. string cpName = GetPostString("cpname");
  5480. string isTogether = GetPostString("together");
  5481. string printType = GetPostString("printType");
  5482. //var res_obj = new
  5483. //{
  5484. // restype = 1,
  5485. // 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\"}"
  5486. //};
  5487. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5488. //ReturnSuccess(ro_json);
  5489. //return;
  5490. bool isUseLastWayBillCode = false;
  5491. CeErpTradeCell entity = null;
  5492. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5493. if (entity != null)
  5494. {
  5495. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5496. {
  5497. isUseLastWayBillCode = true;
  5498. }
  5499. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5500. {
  5501. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5502. return;
  5503. }
  5504. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5505. {
  5506. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5507. return;
  5508. }
  5509. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5510. {
  5511. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5512. return;
  5513. }
  5514. }
  5515. string res = "";
  5516. Api_waybill_code_response_Obj fullObj = null;
  5517. string pData_str = "";
  5518. string curUseWayBillCode = "";
  5519. if (isUseLastWayBillCode == false)
  5520. {
  5521. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5522. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5523. if (res.IndexOf("failure") != -1)
  5524. {
  5525. //int idx = res.IndexOf("sub_message");
  5526. //int idx2 = res.IndexOf("flag");
  5527. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5528. string errMsgNeed = commonHelper.KeepChinese(res);
  5529. var res_objd = new
  5530. {
  5531. restype = 0,
  5532. data = "获取面单失败" + errMsgNeed
  5533. };
  5534. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5535. returnSuccess(ro_jsond);
  5536. if (res.IndexOf("停发") != -1)
  5537. {
  5538. entity.UnusualCon = "物流停发";
  5539. entity.Update();
  5540. }
  5541. //returnErrorMsg("获取面单失败,"+emsg);
  5542. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5543. return;
  5544. }
  5545. else if (res.IndexOf("errorMsg") != -1)
  5546. {
  5547. //int idx = res.IndexOf("errorMsg");
  5548. //int idx2 = res.IndexOf("}]}");
  5549. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5550. string errMsgNeed = commonHelper.KeepChinese(res);
  5551. var res_objf = new
  5552. {
  5553. restype = 0,
  5554. data = "获取面单失败2" + errMsgNeed
  5555. };
  5556. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5557. if (res.IndexOf("停发") != -1)
  5558. {
  5559. entity.UnusualCon = "物流停发";
  5560. entity.Update();
  5561. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5562. if (trade != null)
  5563. {
  5564. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5565. }
  5566. }
  5567. returnSuccess(ro_jsonf);
  5568. //returnErrorMsg("获取面单失败," + emsg);
  5569. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5570. return;
  5571. }
  5572. try
  5573. {
  5574. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5575. //res = res.Replace(" ", "");
  5576. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5577. }
  5578. catch (Exception ex)
  5579. {
  5580. XLog.SaveLog(0, "生成fullObj" + res);
  5581. var res_objf = new
  5582. {
  5583. restype = 0,
  5584. data = "生成fullObj发生错误" + ex.Message
  5585. };
  5586. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5587. returnSuccess(ro_jsonf);
  5588. return;
  5589. }
  5590. if (fullObj.response.data.content.Count > 0)
  5591. {
  5592. ContentItem codeObj = fullObj.response.data.content[0];
  5593. if (cpCode.IndexOf("SFFQ-") != -1)
  5594. {
  5595. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5596. }
  5597. else
  5598. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5599. curUseWayBillCode = codeObj.waybillCode;
  5600. }
  5601. else
  5602. {
  5603. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5604. var res_objf = new
  5605. {
  5606. restype = 0,
  5607. data = "生成fullObj找不到快递单号waybillCode"
  5608. };
  5609. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5610. returnSuccess(ro_jsonf);
  5611. return;
  5612. }
  5613. }
  5614. else
  5615. {
  5616. //使用上次打印的快递单号
  5617. if (cpCode == "SFFQ-LY")
  5618. {
  5619. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5620. }
  5621. else
  5622. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5623. curUseWayBillCode = entity.LastBillWaybillCode;
  5624. }
  5625. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5626. {
  5627. var res_obje = new
  5628. {
  5629. restype = 0,
  5630. data = "获取加密打印数据失败"
  5631. };
  5632. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5633. returnSuccess(ro_jsone);
  5634. entity.LastBillCpCode = cpCode;
  5635. entity.LastBillWaybillCode = curUseWayBillCode;
  5636. entity.Update();
  5637. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5638. //returnErrorMsg("获取加密打印数据失败");
  5639. return;
  5640. }
  5641. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5642. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5643. string btnType = "";
  5644. string errorMsg = "";
  5645. if (entity != null)
  5646. {
  5647. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5648. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5649. //cpcode是 YTO-CAINIAO
  5650. //string comCode = cpCode.Split('-')[0].ToString();
  5651. string apires = "";
  5652. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5653. //isTogether=2是新的合包弹窗
  5654. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5655. {
  5656. if (ctid.IndexOf("N") != -1)
  5657. {
  5658. apires = "发货成功";
  5659. }
  5660. else
  5661. {
  5662. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5663. }
  5664. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5665. //打单后发货
  5666. StringBuilder sql = new StringBuilder();
  5667. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5668. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5669. {
  5670. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5671. }
  5672. else
  5673. {
  5674. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5675. }
  5676. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5677. foreach (DataRow row in dt.Rows)
  5678. {
  5679. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5680. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5681. {
  5682. try
  5683. {
  5684. btnType = "待发货";
  5685. entity.OutSid = curUseWayBillCode;
  5686. entity.OrderState = 7;
  5687. entity.IsUrgency = false;
  5688. entity.LastBillCpCode = "";
  5689. entity.LastBillWaybillCode = "";
  5690. entity.FinishDeliveryTime = DateTime.Now;
  5691. entity.IsReturn = 0;
  5692. entity.MemoOpt = 0;
  5693. entity.UpdateTime = DateTime.Now;
  5694. entity.Update();
  5695. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5696. //还要插入快递信息到 快递信息表
  5697. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5698. exinfo.tid = entity.ctid;
  5699. exinfo.out_sid = curUseWayBillCode;
  5700. exinfo.company_code = cpCode;
  5701. exinfo.company_name = cpName;
  5702. exinfo.supplierUserName = supplierName;
  5703. exinfo.deliveryType = "发货成功";
  5704. exinfo.print_time = DateTime.Now;
  5705. exinfo.printUser = CurrentUser.UserName;
  5706. exinfo.postData = pData_str;
  5707. exinfo.Create();
  5708. commonHelper.UpdateRelationOrder(entity.ctid);
  5709. CeErpSukuraData.createInfo(ctid, 4);
  5710. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5711. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5712. {
  5713. commonHelper.sendCytExpress(exinfo);
  5714. }
  5715. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5716. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5717. }
  5718. catch (Exception ex)
  5719. {
  5720. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5721. }
  5722. }
  5723. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5724. {
  5725. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5726. if (entity.OrderState == 6)
  5727. {
  5728. entity.OrderState = 7;
  5729. }
  5730. entity.UpdateTime = DateTime.Now;
  5731. entity.FinishDeliveryTime = DateTime.Now;
  5732. btnType = "已发货";
  5733. entity.Update();
  5734. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5735. exinfo.tid = entity.ctid;
  5736. exinfo.out_sid = curUseWayBillCode;
  5737. exinfo.company_code = cpCode;
  5738. exinfo.company_name = cpName;
  5739. exinfo.supplierUserName = supplierName;
  5740. exinfo.deliveryType = "发货成功";
  5741. exinfo.print_time = DateTime.Now;
  5742. exinfo.printUser = CurrentUser.UserName;
  5743. exinfo.postData = pData_str;
  5744. exinfo.Create();
  5745. commonHelper.UpdateRelationOrder(entity.ctid);
  5746. CeErpSukuraData.createInfo(entity.ctid, 4);
  5747. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5748. {
  5749. commonHelper.sendCytExpress(exinfo);
  5750. }
  5751. //不处理
  5752. }
  5753. else
  5754. {
  5755. entity.UpdateTime = DateTime.Now;
  5756. entity.LastBillCpCode = cpCode;
  5757. entity.LastBillWaybillCode = curUseWayBillCode;
  5758. entity.Update();
  5759. string errmsg = commonHelper.KeepChinese(apires);
  5760. var res_objz = new
  5761. {
  5762. restype = 0,
  5763. data = "打单后发货失败"
  5764. };
  5765. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5766. returnSuccess(ro_jsonz);
  5767. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5768. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5769. return;
  5770. }
  5771. }
  5772. }
  5773. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5774. {
  5775. string ctids = GetPostString("ctids");
  5776. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5777. List<string> list = new List<string>();
  5778. List<string> send_list = new List<string>();
  5779. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5780. CeErpTrade ceErpTrade = new CeErpTrade();
  5781. //可合包的合并一起发货
  5782. if (dt == null && string.IsNullOrEmpty(ctids))
  5783. {
  5784. var res_objz = new
  5785. {
  5786. restype = 0,
  5787. data = "打单后发货失败"
  5788. };
  5789. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5790. returnSuccess(ro_jsonz);
  5791. return;
  5792. }
  5793. if (!string.IsNullOrEmpty(ctids))
  5794. {
  5795. StringBuilder sql = new StringBuilder();
  5796. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5797. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5798. }
  5799. foreach (DataRow row in dt.Rows)
  5800. {
  5801. list.Add("'" + row["ctid"] + "'");
  5802. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5803. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5804. if (ctid.IndexOf("N") != -1)
  5805. {
  5806. apires = "发货成功";
  5807. }
  5808. else
  5809. {
  5810. if (!send_list.Contains(ceErpTrade.tid))
  5811. {
  5812. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5813. }
  5814. else
  5815. {
  5816. apires = "发货成功";
  5817. }
  5818. }
  5819. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5820. {
  5821. send_list.Add(ceErpTrade.tid);
  5822. try
  5823. {
  5824. btnType = "待发货";
  5825. ceErpTradeCell.OutSid = curUseWayBillCode;
  5826. ceErpTradeCell.OrderState = 7;
  5827. ceErpTradeCell.IsUrgency = false;
  5828. ceErpTradeCell.LastBillCpCode = "";
  5829. ceErpTradeCell.LastBillWaybillCode = "";
  5830. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5831. ceErpTradeCell.IsReturn = 0;
  5832. ceErpTradeCell.MemoOpt = 0;
  5833. ceErpTradeCell.UpdateTime = DateTime.Now;
  5834. ceErpTradeCell.Update();
  5835. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5836. //还要插入快递信息到 快递信息表
  5837. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5838. exinfo.tid = ceErpTradeCell.ctid;
  5839. exinfo.out_sid = curUseWayBillCode;
  5840. exinfo.company_code = cpCode;
  5841. exinfo.company_name = cpName;
  5842. exinfo.supplierUserName = supplierName;
  5843. exinfo.deliveryType = "发货成功";
  5844. exinfo.print_time = DateTime.Now;
  5845. exinfo.printUser = CurrentUser.UserName;
  5846. exinfo.postData = pData_str;
  5847. exinfo.Create();
  5848. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5849. CeErpSukuraData.createInfo(ctid, 4);
  5850. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5851. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5852. {
  5853. commonHelper.sendCytExpress(exinfo);
  5854. }
  5855. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5856. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5857. }
  5858. catch (Exception ex)
  5859. {
  5860. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5861. }
  5862. }
  5863. else
  5864. {
  5865. ceErpTradeCell.UpdateTime = DateTime.Now;
  5866. ceErpTradeCell.LastBillCpCode = cpCode;
  5867. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5868. ceErpTradeCell.Update();
  5869. string errmsg = commonHelper.KeepChinese(apires);
  5870. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5871. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5872. }
  5873. }
  5874. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5875. }
  5876. }
  5877. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5878. var res_obj = new
  5879. {
  5880. restype = 1,
  5881. data = pData_str,
  5882. errorMsg
  5883. };
  5884. string ro_json = JsonConvert.SerializeObject(res_obj);
  5885. ReturnSuccess(ro_json);
  5886. return;
  5887. }
  5888. }
  5889. private string GetUTF8String(byte[] vs)
  5890. {
  5891. throw new NotImplementedException();
  5892. }
  5893. public void set_erp_printwaybill_cn()
  5894. {
  5895. if (UrlPostParmsCheck("ctid"))
  5896. {
  5897. string ctid = GetPostString("ctid");
  5898. string cpCode = GetPostString("cpcode");
  5899. string cpName = GetPostString("cpname");
  5900. string tempUrl = GetPostString("tempurl");
  5901. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5902. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5903. //string res = taobaoHelper.test();
  5904. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5905. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5906. {
  5907. int sidx = res.IndexOf("errorMsg");
  5908. int eidx = res.IndexOf("}");
  5909. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5910. var res_objzxx = new
  5911. {
  5912. restype = 0,
  5913. data = msg
  5914. };
  5915. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5916. returnSuccess(ro_jsonzxx);
  5917. //returnErrorMsg(msg);
  5918. return;
  5919. }
  5920. int idx = res.IndexOf("waybillCode");
  5921. int idx2 = res.IndexOf("printData");
  5922. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5923. string eid = GetPostString("ctid");
  5924. CeErpTradeCell entity = null;
  5925. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5926. if (entity != null)
  5927. {
  5928. string osid = entity.OutSid;
  5929. entity.OutSid = osid + "," + outsid;
  5930. entity.FinishDeliveryTime = DateTime.Now;
  5931. entity.OrderState = 7;
  5932. entity.UpdateTime = DateTime.Now;
  5933. entity.IsReturn = 0;
  5934. entity.Update();
  5935. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5936. exinfo.tid = entity.ctid;
  5937. exinfo.out_sid = outsid;
  5938. exinfo.company_code = cpCode;
  5939. exinfo.company_name = cpName;
  5940. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5941. exinfo.deliveryType = "发货成功";
  5942. exinfo.print_time = DateTime.Now;
  5943. exinfo.printUser = CurrentUser.UserName;
  5944. exinfo.Create();
  5945. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5946. {
  5947. commonHelper.sendCytExpress(exinfo);
  5948. }
  5949. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5950. }
  5951. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5952. var res_objz = new
  5953. {
  5954. restype = 1,
  5955. data = res
  5956. };
  5957. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5958. returnSuccess(ro_jsonz);
  5959. //ReturnSuccess(res);
  5960. }
  5961. }
  5962. ////打单,打印面单 获取面单号
  5963. //public void set_erp_printwaybill()
  5964. //{
  5965. // if (UrlPostParmsCheck("ctid"))
  5966. // {
  5967. // string ctid = GetPostString("ctid");
  5968. // string cpCode = GetPostString("cpcode");
  5969. // string tempUrl = GetPostString("tempurl");
  5970. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5971. // //string res = taobaoHelper.test();
  5972. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5973. // if (res.IndexOf("error_response") != -1)
  5974. // {
  5975. // int sidx = res.IndexOf("sub_msg");
  5976. // int eidx = res.IndexOf("request_id");
  5977. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5978. // returnErrorMsg(msg);
  5979. // return;
  5980. // }
  5981. // int idx = res.IndexOf("waybill_code");
  5982. // int idx2 = res.IndexOf("}]}");
  5983. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5984. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5985. // ReturnSuccess(res);
  5986. // }
  5987. //}
  5988. public void cancel_erp_aftersale()
  5989. {
  5990. if (UrlPostParmsCheck("ctid"))
  5991. {
  5992. string eid = GetPostString("ctid");
  5993. CeErpTradeCell entity = null;
  5994. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5995. if (entity != null)
  5996. {
  5997. //有过处理的售后,取消也不能删除 售 字,保留
  5998. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5999. {
  6000. entity.AfterSaleState = 4;
  6001. }
  6002. else
  6003. entity.AfterSaleState = 0;
  6004. entity.UpdateTime = DateTime.Now;
  6005. entity.Update();
  6006. returnSuccessMsg("操作成功!");
  6007. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6008. return;
  6009. }
  6010. returnErrorMsg("找不到订单记录");
  6011. }
  6012. }
  6013. public void get_erp_aftersalelist()
  6014. {
  6015. DataStruct dStruct = GetPostStruct();
  6016. List<string> lw = new List<string>();
  6017. int st = GetInt("st");
  6018. string tid = GetPostString("ctid");
  6019. if (st == 3)
  6020. {
  6021. if (tid.Length > 0)
  6022. {
  6023. string select_tid = getTidByCtid(tid);
  6024. lw.Add(string.Format("tid='{0}'", select_tid));
  6025. }
  6026. }
  6027. else
  6028. {
  6029. if (tid.Length > 0)
  6030. {
  6031. string select_tid = getTidByCtid(tid);
  6032. lw.Add(string.Format("tid='{0}'", select_tid));
  6033. }
  6034. }
  6035. string shopname = GetPostString("shopname");
  6036. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6037. string buyernick = GetPostString("buyer_nick");
  6038. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6039. string sellermemo = GetPostString("seller_memo");
  6040. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6041. string orderState = GetPostString("orderState");
  6042. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6043. string afterState = GetPostString("afterstate");
  6044. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6045. string date1 = GetPostString("date1");
  6046. string date2 = GetPostString("date2");
  6047. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6048. if (dw.Length > 0) lw.Add(dw);
  6049. string price1 = GetPostString("price1");
  6050. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6051. string price2 = GetPostString("price2");
  6052. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6053. //lw.Add(string.Format("IsRefund!={0}", 1));
  6054. string reason = GetPostString("reason");
  6055. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6056. string method = GetPostString("method");
  6057. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6058. string handler = GetPostString("handler");
  6059. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6060. string handledate1 = GetPostString("handledate1");
  6061. string handledate2 = GetPostString("handledate2");
  6062. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6063. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6064. string finish1 = GetPostString("finishdate1");
  6065. string finish2 = GetPostString("finishdate2");
  6066. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6067. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6068. string afterdate1 = GetPostString("afterdate1");
  6069. string afterdate2 = GetPostString("afterdate2");
  6070. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6071. if (afterDate.Length > 0) lw.Add(afterDate);
  6072. string supplier = GetPostString("supplier");
  6073. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6074. string responsible = GetPostString("responsibleman");
  6075. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6076. string customer = GetPostString("customer");
  6077. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6078. string design = GetPostString("design");
  6079. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6080. string afterMemoType = GetPostString("aftermemotype");
  6081. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6082. string posCode = CurrentUser.UserPost.Post.Code;
  6083. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6084. //{
  6085. // string vstate = GetPostString("vstate");
  6086. // if (vstate.Length > 0)
  6087. // {
  6088. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6089. // }
  6090. // if (posCode == "Supplier")
  6091. // {
  6092. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6093. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6094. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6095. // }
  6096. // else
  6097. // {
  6098. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6099. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6100. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6101. // {
  6102. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6103. // }
  6104. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6105. // {
  6106. // int orgid = CurrentUser.UserPost.OrgID;
  6107. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6108. // }
  6109. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6110. // {
  6111. // string shopid = CurrentUser.User.pemShop;
  6112. // lw.Add(string.Format("shopId in ({0})", shopid));
  6113. // }
  6114. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6115. // //{
  6116. // // int org_id = CurrentUser.UserPost.OrgID;
  6117. // // lw.Add(string.Format("OrgID={0}", org_id));
  6118. // //}
  6119. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6120. // }
  6121. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6122. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6123. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6124. //}
  6125. if (st == 5)
  6126. {
  6127. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6128. {
  6129. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6130. {
  6131. string shopid = CurrentUser.User.pemShop;
  6132. lw.Add(string.Format("shopId in ({0})", shopid));
  6133. }
  6134. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6135. {
  6136. int mrOrgid = CurrentUser.UserPost.OrgID;
  6137. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6138. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6139. }
  6140. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6141. //{
  6142. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6143. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6144. //}
  6145. else
  6146. {
  6147. string userIdStr = "";
  6148. if (posCode == "CustomerService")
  6149. {
  6150. userIdStr = CurrentUser.UserID + "_k";
  6151. }
  6152. else if (posCode == "Designer" || posCode == "wxDesigner")
  6153. {
  6154. userIdStr = CurrentUser.UserID + "_s";
  6155. }
  6156. else if (posCode == "Place")
  6157. {
  6158. userIdStr = CurrentUser.UserID + "_x";
  6159. }
  6160. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6161. }
  6162. }
  6163. string placedate1 = GetPostString("placedate1");
  6164. string placedate2 = GetPostString("placedate2");
  6165. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6166. if (dwplace.Length > 0) lw.Add(dwplace);
  6167. string supState = GetPostString("supState");
  6168. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6169. string searchType = GetPostString("searchType");
  6170. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6171. {
  6172. lw.Add(string.Format("BackNum>1"));
  6173. }
  6174. lw.Add(string.Format("AfterSaleState>0"));
  6175. if (ex_psize > 0)
  6176. {
  6177. if (CurrentUser.UserPost.Post.Code == "Finance")
  6178. dStruct.Order = "pay_time desc";
  6179. else
  6180. dStruct.Order = "HandleTime desc";
  6181. }
  6182. else
  6183. dStruct.Order = "HandleTime desc";
  6184. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6185. DataTable dt = WebCache.GetData("view_test", dStruct);
  6186. writeGridDataTableJson(dStruct.TotalCount, dt);
  6187. }
  6188. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6189. //{
  6190. // lw.Add(string.Format("AfterSaleState=4"));
  6191. // string code = CurrentUser.UserPost.Post.Code;
  6192. // if (code == "CustomerService")
  6193. // {
  6194. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6195. // }
  6196. // else if (code == "Designer" || code == "DesignerMr")
  6197. // {
  6198. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6199. // }
  6200. // else if (code == "Place" || code == "PlaceMr")
  6201. // {
  6202. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6203. // }
  6204. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6205. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6206. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6207. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6208. //}
  6209. //else //处理中的售后,待处理和处理中合并
  6210. //{
  6211. // if (afterState.Length <= 0)
  6212. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6213. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6214. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6215. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6216. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6217. //}
  6218. }
  6219. public void get_erp_disagreeftersalelist()
  6220. {
  6221. DataStruct dStruct = GetPostStruct();
  6222. List<string> lw = new List<string>();
  6223. int st = 2;
  6224. string tid = GetPostString("ctid");
  6225. if (tid.Length > 0)
  6226. {
  6227. string select_tid = getTidByCtid(tid);
  6228. lw.Add(string.Format("tid='{0}'", select_tid));
  6229. }
  6230. string shopname = GetPostString("shopname");
  6231. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6232. string buyernick = GetPostString("buyer_nick");
  6233. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6234. string sellermemo = GetPostString("seller_memo");
  6235. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6236. string orderState = GetPostString("orderState");
  6237. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6238. string afterState = GetPostString("afterstate");
  6239. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6240. string date1 = GetPostString("date1");
  6241. string date2 = GetPostString("date2");
  6242. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6243. if (dw.Length > 0) lw.Add(dw);
  6244. string price1 = GetPostString("price1");
  6245. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6246. string price2 = GetPostString("price2");
  6247. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6248. //lw.Add(string.Format("IsRefund!={0}", 1));
  6249. string reason = GetPostString("reason");
  6250. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6251. string method = GetPostString("method");
  6252. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6253. string handler = GetPostString("handler");
  6254. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6255. string handledate1 = GetPostString("handledate1");
  6256. string handledate2 = GetPostString("handledate2");
  6257. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6258. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6259. string afterdate1 = GetPostString("afterdate1");
  6260. string afterdate2 = GetPostString("afterdate2");
  6261. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6262. if (afterDate.Length > 0) lw.Add(afterDate);
  6263. string backdate1 = GetPostString("backdate1");
  6264. string backdate2 = GetPostString("backdate2");
  6265. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6266. if (backDate.Length > 0) lw.Add(backDate);
  6267. string supplier = GetPostString("supplier");
  6268. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6269. string responsible = GetPostString("responsibleman");
  6270. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6271. string customer = GetPostString("customer");
  6272. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6273. string design = GetPostString("design");
  6274. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6275. string afterSaleMemo = GetPostString("afterSaleMemo");
  6276. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6277. string afterMemoType = GetPostString("aftermemotype");
  6278. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6279. string aftersakereason = GetPostString("aftersakereason");
  6280. if (aftersakereason.Length > 0)
  6281. {
  6282. if (aftersakereason == "1")
  6283. {
  6284. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6285. }
  6286. if (aftersakereason == "2")
  6287. {
  6288. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6289. }
  6290. }
  6291. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6292. string poscode = CurrentUser.UserPost.Post.Code;
  6293. if (poscode != "SysAdmin")
  6294. {
  6295. string shopid = CurrentUser.User.pemShop;
  6296. lw.Add(string.Format("shopId in ({0})", shopid));
  6297. }
  6298. string searchType = GetPostString("searchType");
  6299. if (searchType == "wait")
  6300. {
  6301. lw.Add(string.Format("HandleTime is null"));
  6302. }
  6303. if (searchType == "handling")
  6304. {
  6305. lw.Add(string.Format("HandleTime is not null "));
  6306. }
  6307. if (searchType == "back" || searchType == "puBack")
  6308. {
  6309. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6310. }
  6311. if (searchType == "reBack")
  6312. {
  6313. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6314. }
  6315. if (searchType == "moreBack")
  6316. {
  6317. lw.Add(string.Format("backNum > 1"));
  6318. }
  6319. lw.Add(string.Format("(AfterSaleState=5)"));
  6320. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6321. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6322. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6323. writeGridDataTableJson(dStruct.TotalCount, dt);
  6324. }
  6325. public void get_erp_handlingaftersalelist()
  6326. {
  6327. DataStruct dStruct = GetPostStruct();
  6328. List<string> lw = new List<string>();
  6329. int st = 2;
  6330. string tid = GetPostString("ctid");
  6331. if (tid.Length > 0)
  6332. {
  6333. string select_tid = getTidByCtid(tid);
  6334. lw.Add(string.Format("tid='{0}'", select_tid));
  6335. }
  6336. string shopname = GetPostString("shopname");
  6337. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6338. string buyernick = GetPostString("buyer_nick");
  6339. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6340. string sellermemo = GetPostString("seller_memo");
  6341. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6342. string orderState = GetPostString("orderState");
  6343. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6344. string afterState = GetPostString("afterstate");
  6345. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6346. string date1 = GetPostString("date1");
  6347. string date2 = GetPostString("date2");
  6348. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6349. if (dw.Length > 0) lw.Add(dw);
  6350. string price1 = GetPostString("price1");
  6351. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6352. string price2 = GetPostString("price2");
  6353. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6354. //lw.Add(string.Format("IsRefund!={0}", 1));
  6355. string reason = GetPostString("reason");
  6356. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6357. string method = GetPostString("method");
  6358. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6359. string handler = GetPostString("handler");
  6360. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6361. string handledate1 = GetPostString("handledate1");
  6362. string handledate2 = GetPostString("handledate2");
  6363. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6364. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6365. string afterdate1 = GetPostString("afterdate1");
  6366. string afterdate2 = GetPostString("afterdate2");
  6367. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6368. if (afterDate.Length > 0) lw.Add(afterDate);
  6369. string supplier = GetPostString("supplier");
  6370. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6371. string responsible = GetPostString("responsibleman");
  6372. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6373. string customer = GetPostString("customer");
  6374. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6375. string design = GetPostString("design");
  6376. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6377. string afterSaleMemo = GetPostString("afterSaleMemo");
  6378. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6379. string afterMemoType = GetPostString("aftermemotype");
  6380. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6381. string afterresult = GetPostString("afterresult");
  6382. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6383. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6384. string poscode = CurrentUser.UserPost.Post.Code;
  6385. if (poscode != "SysAdmin")
  6386. {
  6387. string shopid = CurrentUser.User.pemShop;
  6388. lw.Add(string.Format("shopId in ({0})", shopid));
  6389. }
  6390. string searchType = GetPostString("searchType");
  6391. if (searchType == "wait")
  6392. {
  6393. lw.Add(string.Format("HandleTime is null"));
  6394. }
  6395. if (searchType == "documentary")
  6396. {
  6397. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6398. }
  6399. if (searchType == "handling")
  6400. {
  6401. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6402. }
  6403. if (searchType == "back" || searchType == "puBack")
  6404. {
  6405. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6406. }
  6407. if (searchType == "reBack")
  6408. {
  6409. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6410. }
  6411. if (afterState.Length <= 0)
  6412. {
  6413. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6414. }
  6415. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6416. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6417. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6418. writeGridDataTableJson(dStruct.TotalCount, dt);
  6419. }
  6420. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6421. //public void get_erp_back_handlingaftersalelist()
  6422. //{
  6423. // DataStruct dStruct = GetPostStruct();
  6424. // List<string> lw = new List<string>();
  6425. // string tid = GetPostString("ctid");
  6426. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6427. // string shopname = GetPostString("shopname");
  6428. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6429. // string buyernick = GetPostString("buyer_nick");
  6430. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6431. // string sellermemo = GetPostString("seller_memo");
  6432. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6433. // string orderState = GetPostString("orderState");
  6434. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6435. // string afterState = GetPostString("afterstate");
  6436. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6437. // string date1 = GetPostString("date1");
  6438. // string date2 = GetPostString("date2");
  6439. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6440. // if (dw.Length > 0) lw.Add(dw);
  6441. // string price1 = GetPostString("price1");
  6442. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6443. // string price2 = GetPostString("price2");
  6444. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6445. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6446. // string reason = GetPostString("reason");
  6447. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6448. // string method = GetPostString("method");
  6449. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6450. // string handler = GetPostString("handler");
  6451. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6452. // string handledate1 = GetPostString("handledate1");
  6453. // string handledate2 = GetPostString("handledate2");
  6454. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6455. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6456. // string afterdate1 = GetPostString("afterdate1");
  6457. // string afterdate2 = GetPostString("afterdate2");
  6458. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6459. // if (afterDate.Length > 0) lw.Add(afterDate);
  6460. // string supplier = GetPostString("supplier");
  6461. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6462. // string responsible = GetPostString("responsibleman");
  6463. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6464. // string customer = GetPostString("customer");
  6465. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6466. // string design = GetPostString("design");
  6467. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6468. // string afterMemoType = GetPostString("aftermemotype");
  6469. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6470. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6471. // if (afterState.Length <= 0)
  6472. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6473. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6474. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6475. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6476. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6477. //}
  6478. public void get_erp_aftersaleverifylist()
  6479. {
  6480. DataStruct dStruct = GetPostStruct();
  6481. List<string> lw = new List<string>();
  6482. string tid = GetPostString("ctid");
  6483. if (tid.Length > 0)
  6484. {
  6485. string select_tid = getTidByCtid(tid);
  6486. lw.Add(string.Format("otid='{0}'", select_tid));
  6487. }
  6488. string shopname = GetPostString("shopname");
  6489. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6490. string buyernick = GetPostString("buyer_nick");
  6491. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6492. string sellermemo = GetPostString("seller_memo");
  6493. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6494. string orderState = GetPostString("orderState");
  6495. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6496. //lw.Add(string.Format("IsRefund!={0}", 1));
  6497. string reason = GetPostString("reason");
  6498. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6499. string method = GetPostString("method");
  6500. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6501. string handler = GetPostString("handler");
  6502. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6503. string handledate1 = GetPostString("handledate1");
  6504. string handledate2 = GetPostString("handledate2");
  6505. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6506. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6507. string finish1 = GetPostString("finishdate1");
  6508. string finish2 = GetPostString("finishdate2");
  6509. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6510. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6511. string supplier = GetPostString("supplier");
  6512. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6513. string responsible = GetPostString("responsibleman");
  6514. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6515. string posCode = CurrentUser.UserPost.Post.Code;
  6516. string vstate = GetPostString("vstate");
  6517. if (vstate.Length > 0)
  6518. {
  6519. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6520. }
  6521. if (posCode == "Supplier")
  6522. {
  6523. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6524. lw.Add(string.Format("VerifyState = 0"));
  6525. lw.Add("type = 1");
  6526. lw.Add(string.Format("AfterSaleState={0}", 3));
  6527. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6528. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6529. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6530. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6531. writeGridDataTableJson(dStruct.TotalCount, dt);
  6532. }
  6533. else if (posCode == "logistics")
  6534. {
  6535. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6536. lw.Add(string.Format("VerifyState = 0"));
  6537. lw.Add("type = 2");
  6538. lw.Add(string.Format("AfterSaleState={0}", 3));
  6539. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6541. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6542. writeGridDataTableJson(dStruct.TotalCount, dt);
  6543. }
  6544. else
  6545. {
  6546. lw.Add(string.Format("(AfterSaleState = 3)"));
  6547. lw.Add("type = 0");
  6548. string reasonState = GetPostString("reasonState");
  6549. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6550. {
  6551. if (reasonState == "2")
  6552. {
  6553. lw.Add("VerifyState = 3");
  6554. }
  6555. else if (reasonState == "1")
  6556. {
  6557. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6558. }
  6559. else
  6560. {
  6561. lw.Add("VerifyState in (0,3)");
  6562. }
  6563. //不加条件,可以看全部
  6564. }
  6565. 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")
  6566. {
  6567. int orgid = CurrentUser.UserPost.OrgID;
  6568. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6569. if (string.IsNullOrEmpty(manageOrgId))
  6570. {
  6571. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6572. }
  6573. else
  6574. {
  6575. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6576. }
  6577. if (reasonState == "1")
  6578. {
  6579. lw.Add("VerifyState = 3");
  6580. }
  6581. else if (reasonState == "2")
  6582. {
  6583. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6584. }
  6585. else
  6586. {
  6587. }
  6588. }
  6589. else
  6590. {
  6591. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6592. }
  6593. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6594. //{
  6595. // int org_id = CurrentUser.UserPost.OrgID;
  6596. // lw.Add(string.Format("OrgID={0}", org_id));
  6597. //}
  6598. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6599. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6600. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6601. writeGridDataTableJson(dStruct.TotalCount, dt);
  6602. }
  6603. }
  6604. public void get_erp_finishaftersalelist()
  6605. {
  6606. DataStruct dStruct = GetPostStruct();
  6607. List<string> lw = new List<string>();
  6608. int st = 4;
  6609. string tid = GetPostString("ctid");
  6610. if (tid.Length > 0)
  6611. {
  6612. string select_tid = getTidByCtid(tid);
  6613. lw.Add(string.Format("otid='{0}'", select_tid));
  6614. }
  6615. string shopname = GetPostString("shopname");
  6616. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6617. //lw.Add(string.Format("IsRefund!={0}", 1));
  6618. string reason = GetPostString("reason");
  6619. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6620. string method = GetPostString("method");
  6621. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6622. string buyernick = GetPostString("buyer_nick");
  6623. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6624. string handler = GetPostString("handler");
  6625. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6626. string handledate1 = GetPostString("handledate1");
  6627. string handledate2 = GetPostString("handledate2");
  6628. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6629. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6630. string finish1 = GetPostString("finishdate1");
  6631. string finish2 = GetPostString("finishdate2");
  6632. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6633. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6634. string supplier = GetPostString("supplier");
  6635. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6636. string responsible = GetPostString("responsibleman");
  6637. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6638. string vstate = GetPostString("vstate");
  6639. if (vstate.Length > 0)
  6640. {
  6641. if ("3".Equals(vstate))
  6642. {
  6643. lw.Add(string.Format("IsTem=1"));
  6644. }
  6645. else
  6646. {
  6647. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6648. }
  6649. }
  6650. lw.Add(string.Format("AfterSaleState=4"));
  6651. string code = CurrentUser.UserPost.Post.Code;
  6652. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6653. {
  6654. //不加条件,可以看全部
  6655. }
  6656. else if (code == "Supplier")
  6657. {
  6658. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6659. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6660. lw.Add("type = 1");
  6661. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6662. }
  6663. else if (code == "logistics")
  6664. {
  6665. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6666. lw.Add("type = 2");
  6667. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6668. }
  6669. 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")
  6670. {
  6671. lw.Add("type = 0");
  6672. int orgid = CurrentUser.UserPost.OrgID;
  6673. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6674. if (string.IsNullOrEmpty(manageOrgIds))
  6675. {
  6676. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6677. }
  6678. else
  6679. {
  6680. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6681. }
  6682. }
  6683. else
  6684. {
  6685. lw.Add("type = 0");
  6686. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6687. }
  6688. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6689. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6690. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6691. writeGridDataTableJson(dStruct.TotalCount, dt);
  6692. }
  6693. public void handle_erp_aftersale()
  6694. {
  6695. if (UrlPostParmsCheck("ctid"))
  6696. {
  6697. string eid = GetPostString("ctid");
  6698. string responStr = GetPostString("AfterSaleResponsible");
  6699. if (responStr.Length <= 0)
  6700. {
  6701. returnErrorMsg("售后责任人不能为空");
  6702. return;
  6703. }
  6704. bool isDesign = false;
  6705. double designFree = 0.00;
  6706. int responsibleId = 0;
  6707. CeErpTradeCell entity = null;
  6708. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6709. if (entity != null)
  6710. {
  6711. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6712. string afterMethod = GetPostString("AfterSaleMethod");
  6713. if (isNeedNewOrder == 1)
  6714. {
  6715. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6716. bool ishav = true;
  6717. if (newentity == null)
  6718. {
  6719. newentity = entity.Clone() as CeErpTradeCell;
  6720. ishav = false;
  6721. newentity.ctid = "S_" + entity.ctid;
  6722. newentity.OrderState = 0;
  6723. //唯一标识
  6724. newentity.OrderSn = newentity.ctid;
  6725. string orderSn = dataHelper.getSaleOrderSn();
  6726. if (orderSn != "")
  6727. {
  6728. newentity.OrderSn = orderSn;
  6729. }
  6730. }
  6731. newentity.UpdateTime = DateTime.Now;
  6732. newentity.AfterSaleState = 0;
  6733. newentity.AfterSaleMethod = afterMethod;
  6734. if (!ishav)
  6735. {
  6736. string memo_str = newentity.seller_memo;
  6737. memo_str = memo_str.Replace("(", "(");
  6738. memo_str = memo_str.Replace(")", ")");
  6739. int sIndex = memo_str.IndexOf("(");
  6740. int eIndex = memo_str.IndexOf(")");
  6741. if (sIndex == -1 || eIndex == -1)
  6742. {
  6743. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6744. return;
  6745. }
  6746. string first = memo_str.Substring(0, sIndex + 1);
  6747. string memoCtid = newentity.OrderSn;
  6748. //if (memoCtid.IndexOf("C") != -1)
  6749. //{
  6750. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6751. //if (CIdx.IndexOf("+") != -1)
  6752. //{
  6753. //CIdx = "C" + CIdx.Split('+')[1];
  6754. //}
  6755. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6756. //}
  6757. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6758. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6759. string newMemo = first + memoCtid + last;
  6760. newentity.seller_memo = newMemo;
  6761. newentity.FinishPlaceTime = null;
  6762. newentity.UnusualTag = 0;
  6763. newentity.UnusualCon = "";
  6764. newentity.UnusualTime = null;
  6765. newentity.AfterSaleMemo = "";
  6766. newentity.AfterSaleMethod = afterMethod;
  6767. newentity.AfterSalePreTime = null;
  6768. newentity.AfterSaleReason = "";
  6769. newentity.AfterSaleResponsible = "";
  6770. newentity.AfterSaleState = 0;
  6771. newentity.AfterSaleTime = null;
  6772. newentity.AfterSaleUserId = 0;
  6773. newentity.AfterSaleSupplierState = 0;
  6774. newentity.LastBillWaybillCode = "";
  6775. newentity.LastBillCpCode = "";
  6776. newentity.FinishAfterSaleTime = null;
  6777. newentity.HandleTime = null;
  6778. newentity.IsSF = 0;
  6779. newentity.IsOldCustomer = 0;
  6780. newentity.UrgencyTime = null;
  6781. newentity.ResponsibleUserId = "";
  6782. newentity.IsVerifyToSupplier = false;
  6783. newentity.payment = 0;
  6784. newentity.CheckMemo = "";
  6785. newentity.OutSid = "";
  6786. newentity.CheckOrderTime = null;
  6787. newentity.MemoOpt = 0;
  6788. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6789. }
  6790. newentity.isAfterSaleOrder = 1;
  6791. newentity.IsRefund = 0;
  6792. string receiveMobile = GetPostString("receiver_mobile");
  6793. if (receiveMobile.Length > 0)
  6794. {
  6795. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6796. if (trade != null)
  6797. {
  6798. trade.receiver_name = GetPostString("receiver_name");
  6799. trade.receiver_mobile = receiveMobile;
  6800. trade.receiver_state = GetPostString("receiver_state");
  6801. trade.receiver_city = GetPostString("receiver_city");
  6802. trade.receiver_district = GetPostString("receiver_district");
  6803. trade.receiver_address = GetPostString("receiver_address");
  6804. newentity.IsOffLineOrder = 1;
  6805. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6806. }
  6807. }
  6808. string st = GetPostString("ToState");
  6809. if (st.Length > 0)
  6810. {
  6811. if (newentity.OrderState <= 3)
  6812. {
  6813. newentity.WaitDesignTime = DateTime.Now;
  6814. newentity.StartDesignTime = null;
  6815. newentity.FinishDesignTime = null;
  6816. newentity.OrderState = 3;
  6817. if (st == "下单员")
  6818. {
  6819. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6820. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6821. {
  6822. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6823. }
  6824. }
  6825. else
  6826. {
  6827. newentity.WaitDesignTime = DateTime.Now;
  6828. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6829. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6830. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6831. {
  6832. DataRow user = dt1.Rows[0];
  6833. //找主管
  6834. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6835. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6836. if (dt != null && dt.Rows.Count > 0)
  6837. {
  6838. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6839. newentity.DesignUserId = designMr;
  6840. string key = "aftersale_order_" + designMr;
  6841. if (RedisHelper.HasKey(key))
  6842. {
  6843. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6844. list.Add(newentity.ctid);
  6845. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6846. }
  6847. }
  6848. //账号正常
  6849. if (user["State"].ToString() == "0")
  6850. {
  6851. newentity.DesignUserId = entity.DesignUserId;
  6852. string key = "aftersale_order_" + entity.DesignUserId;
  6853. if (RedisHelper.HasKey(key))
  6854. {
  6855. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6856. list.Add(newentity.ctid);
  6857. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6858. }
  6859. }
  6860. }
  6861. }
  6862. }
  6863. if (entity.IsXianHuo == 1)
  6864. {
  6865. newentity.OrderState = 6;
  6866. entity.FinishPlaceTime = DateTime.Now;
  6867. }
  6868. }
  6869. if (ishav)
  6870. {
  6871. newentity.Update();
  6872. }
  6873. else
  6874. {
  6875. newentity.Create();
  6876. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6877. newCellExtend.ctid = newentity.ctid;
  6878. newCellExtend.orderFrom = 20;
  6879. newCellExtend.orderType = 30;
  6880. if (st == "下单员")
  6881. {
  6882. }
  6883. else
  6884. {
  6885. newCellExtend.ReprintTime = DateTime.Now;
  6886. }
  6887. newCellExtend.Create();
  6888. }
  6889. if (st != "下单员")
  6890. {
  6891. if (entity.DispatchSort == 2)
  6892. {
  6893. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6894. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6895. }
  6896. }
  6897. }
  6898. //处理售后扩展
  6899. string resIdStr = GetPostString("ResponsibleUserId");
  6900. string refundFees = GetPostString("refundFrees");
  6901. int IsComplain = GetPostInt("isComplain");
  6902. int IsBad = GetPostInt("isBad");
  6903. string IsOriginal = GetPostString("isOriginal");
  6904. double diffResultPrice = GetPostDouble("diffResultPrice");
  6905. string textResult = GetPostString("textResult");
  6906. string supplierResponsible = GetPostString("supplierResponsible");
  6907. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6908. if (ceErpTradeAfterSaleExtend == null)
  6909. {
  6910. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6911. ceErpTradeAfterSaleExtend.tid = eid;
  6912. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6913. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6914. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6915. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6916. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6917. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6918. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6919. ceErpTradeAfterSaleExtend.Create();
  6920. }
  6921. else
  6922. {
  6923. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6924. {
  6925. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6926. }
  6927. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6928. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6929. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6930. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6931. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6932. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6933. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6934. ceErpTradeAfterSaleExtend.Update();
  6935. }
  6936. int gysid = GetPostInt("ResponsibleSupId");
  6937. if (entity.AfterSaleUserId == 0)
  6938. {
  6939. entity.AfterSaleUserId = CurrentUser.UserID;
  6940. }
  6941. entity.ResponsibleUserId = resIdStr;
  6942. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6943. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6944. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6945. {
  6946. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6947. int backNum = 0;
  6948. if (number != null)
  6949. {
  6950. backNum = number.BackNum;
  6951. }
  6952. char[] separator = { ',' };
  6953. string[] sArray = resIdStr.Split(separator);
  6954. string[] refundFreeList = { };
  6955. if (refundFees.Length > 0)
  6956. {
  6957. refundFreeList = refundFees.Split(separator);
  6958. }
  6959. int index = -1;
  6960. List<int> responsibleIds = new List<int>();
  6961. foreach (string i in sArray)
  6962. {
  6963. index++;
  6964. if (i.Length <= 0) continue;
  6965. char[] separator2 = { '_' };
  6966. string idstr = i.Split(separator2)[0];
  6967. string idtype = i.Split(separator2)[1];
  6968. double refudFree = 0;
  6969. if (refundFreeList.Length > 0)
  6970. {
  6971. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6972. }
  6973. if (idtype == "s")
  6974. {
  6975. isDesign = true;
  6976. designFree = refudFree;
  6977. }
  6978. int userId = Convert.ToInt32(idstr);
  6979. int type = 0;
  6980. if (idtype == "g")
  6981. {
  6982. type = 1;
  6983. }
  6984. if (idtype == "w")
  6985. {
  6986. type = 2;
  6987. }
  6988. if (idtype == "t")
  6989. {
  6990. type = 3;
  6991. }
  6992. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6993. if (ceErpTradeResponsible == null)
  6994. {
  6995. ceErpTradeResponsible = new CeErpTradeResponsible();
  6996. ceErpTradeResponsible.tid = eid;
  6997. ceErpTradeResponsible.UserId = userId;
  6998. ceErpTradeResponsible.createdTime = DateTime.Now;
  6999. ceErpTradeResponsible.type = type;
  7000. if (type == 1)
  7001. {
  7002. ceErpTradeResponsible.IsSup = 1;
  7003. }
  7004. if (type == 2)
  7005. {
  7006. ceErpTradeResponsible.IsFlow = 1;
  7007. }
  7008. }
  7009. int state = 0;
  7010. //已认可的不需要再次认可
  7011. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7012. {
  7013. state = 1;
  7014. }
  7015. ceErpTradeResponsible.RefundFee = refudFree;
  7016. ceErpTradeResponsible.VerifyState = state;
  7017. if (userId == 2125 || idtype == "w")
  7018. {
  7019. ceErpTradeResponsible.VerifyState = 1;
  7020. }
  7021. if (idtype == "w" && userId == 101)
  7022. {
  7023. ceErpTradeResponsible.VerifyState = state;
  7024. }
  7025. if (ceErpTradeResponsible.ID > 0)
  7026. {
  7027. ceErpTradeResponsible.Update();
  7028. }
  7029. else
  7030. {
  7031. ceErpTradeResponsible.Create();
  7032. }
  7033. if (isDesign)
  7034. {
  7035. responsibleId = ceErpTradeResponsible.ID;
  7036. }
  7037. responsibleIds.Add(ceErpTradeResponsible.ID);
  7038. }
  7039. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7040. CeErpTradeResponsible.NumByTid(backNum, eid);
  7041. }
  7042. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7043. if (ceErpTradeCellExtend != null)
  7044. {
  7045. ceErpTradeCellExtend.returnVisit = 0;
  7046. ceErpTradeCellExtend.Update();
  7047. }
  7048. if (entity.HandleTime != null)
  7049. {
  7050. if (entity.AfterSaleState == 1)
  7051. {
  7052. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7053. }
  7054. else
  7055. {
  7056. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7057. }
  7058. }
  7059. else
  7060. {
  7061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7062. entity.HandleTime = DateTime.Now;
  7063. }
  7064. bool isCompale = false;
  7065. if (entity.AfterSaleState == 5)
  7066. {
  7067. isCompale = true;
  7068. entity.AfterSaleState = 3;
  7069. }
  7070. entity.AfterSaleSupplierState = 0;
  7071. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7072. {
  7073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7074. }
  7075. string sImgs = GetPostString("img");
  7076. entity.AfterSaleSupplierImg = sImgs;
  7077. entity.supRefundType = GetPostString("supRefundType");
  7078. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7079. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7080. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7081. entity.AfterSaleMemoType = GetPostString("MemoType");
  7082. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7083. {
  7084. //entity.AfterSaleSupplierState = 2;
  7085. }
  7086. string df = GetPostString("DeductFee");
  7087. if (df == "")
  7088. {
  7089. df = "0";
  7090. }
  7091. string rf = GetPostString("RefundFee");
  7092. if (rf == "")
  7093. {
  7094. rf = "0";
  7095. }
  7096. string pm = GetPostString("AfterSalePayment");
  7097. if (pm == "")
  7098. {
  7099. pm = "0";
  7100. }
  7101. entity.AfterSalePayment = Convert.ToDouble(pm);
  7102. entity.DeductFee = Convert.ToDouble(df);
  7103. entity.RefundFee = Convert.ToDouble(rf);
  7104. entity.UpdateTime = DateTime.Now;
  7105. entity.Update();
  7106. string toState = GetPostString("ToState");
  7107. string original = GetPostString("isOriginal");
  7108. ApiVo apiVo = new ApiVo();
  7109. apiVo.orderNumber = entity.ctid;
  7110. apiVo.actionName = "afterDesign";
  7111. apiVo.orderRemarks = entity.AfterSaleMethod;
  7112. apiVo.reasonRemarks = entity.AfterSaleReason;
  7113. apiVo.isDesign = isDesign;
  7114. apiVo.designFree = designFree;
  7115. apiVo.responsibleId = responsibleId;
  7116. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7117. if (toState == "设计师")
  7118. {
  7119. apiVo.isOriginal = Convert.ToBoolean(original);
  7120. }
  7121. designHelper.API_WorkCore(apiVo);//afterDesign
  7122. CeErpMethod methodSql = new CeErpMethod();
  7123. methodSql.con = entity.AfterSaleMethod;
  7124. methodSql.addTime = DateTime.Now;
  7125. methodSql.Create();
  7126. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7127. CeErpMethod.ExecuteNonQuery(delsql);
  7128. if (isCompale)
  7129. {
  7130. aftersale_data_change(entity.ctid);
  7131. }
  7132. returnSuccessMsg("操作成功!");
  7133. return;
  7134. }
  7135. returnErrorMsg("找不到订单记录");
  7136. }
  7137. }
  7138. public void ins_erp_toresponsible()
  7139. {
  7140. if (UrlPostParmsCheck("ctid"))
  7141. {
  7142. string eid = GetPostString("ctid");
  7143. CeErpTradeCell entity = null;
  7144. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7145. if (entity != null)
  7146. {
  7147. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7148. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7149. {
  7150. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7151. return;
  7152. }
  7153. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7154. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7155. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7156. if (entity.AfterSalePreTime == null)
  7157. {
  7158. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7159. {
  7160. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7161. }
  7162. }
  7163. entity.AfterSalePreTime = DateTime.Now;
  7164. //预完成给售后主管审核客户问题直接完成
  7165. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7166. {
  7167. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7168. {
  7169. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7170. }
  7171. }
  7172. ceErpTradeAfterSaleExtend.Update();
  7173. entity.AfterSaleState = 2;
  7174. entity.UpdateTime = DateTime.Now;
  7175. entity.Update();
  7176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7177. aftersale_data_change(entity.ctid);
  7178. returnSuccessMsg("操作成功!");
  7179. return;
  7180. }
  7181. returnErrorMsg("找不到订单记录");
  7182. }
  7183. }
  7184. public void cancel_erp_aftersaleanddelnew()
  7185. {
  7186. if (UrlPostParmsCheck("ctid"))
  7187. {
  7188. string eid = GetPostString("ctid");
  7189. CeErpTradeCell entity = null;
  7190. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7191. if (entity != null)
  7192. {
  7193. entity.AfterSaleState = 0;
  7194. entity.AfterSaleReason = "";
  7195. entity.AfterSaleMethod = "";
  7196. entity.AfterSaleMemo = "";
  7197. entity.AfterSaleResponsible = "";
  7198. entity.ResponsibleUserId = "";
  7199. entity.DeductFee = 0;
  7200. entity.RefundFee = 0;
  7201. entity.IsArbitrate = 0;
  7202. CeErpTradeResponsible.DelByTid(eid, -1);
  7203. entity.Update();
  7204. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7205. if (after != null)
  7206. {
  7207. if (after.OrderState < 5)
  7208. CeErpTradeCell.DelByCtid("S_" + eid);
  7209. }
  7210. returnSuccessMsg("操作成功!");
  7211. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7212. return;
  7213. }
  7214. returnErrorMsg("找不到订单记录");
  7215. }
  7216. }
  7217. public void get_erp_aftersale_pregather()
  7218. {
  7219. List<string> lw = new List<string>();
  7220. int st = GetInt("st");
  7221. string tid = GetPostString("ctid");
  7222. if (tid.Length > 0)
  7223. {
  7224. string select_tid = getTidByCtid(tid);
  7225. lw.Add(string.Format("tid='{0}'", select_tid));
  7226. }
  7227. string shopname = GetPostString("shopname");
  7228. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7229. string buyernick = GetPostString("buyer_nick");
  7230. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7231. string sellermemo = GetPostString("seller_memo");
  7232. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7233. string orderState = GetPostString("orderState");
  7234. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7235. string reason = GetPostString("reason");
  7236. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7237. string method = GetPostString("method");
  7238. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7239. string handler = GetPostString("handler");
  7240. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7241. string handledate1 = GetPostString("handledate1");
  7242. string handledate2 = GetPostString("handledate2");
  7243. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7244. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7245. string supplier = GetPostString("supplier");
  7246. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7247. string responsible = GetPostString("responsibleman");
  7248. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7249. string customer = GetPostString("customer");
  7250. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7251. string design = GetPostString("design");
  7252. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7253. string afterMemoType = GetPostString("aftermemotype");
  7254. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7255. string afterSaleMemo = GetPostString("afterSaleMemo");
  7256. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7257. string afterresult = GetPostString("afterresult");
  7258. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7259. string poscode = CurrentUser.UserPost.Post.Code;
  7260. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7261. {
  7262. string shopid = CurrentUser.User.pemShop;
  7263. lw.Add(string.Format("shopId in ({0})", shopid));
  7264. }
  7265. var mainwhere = string.Join(" and ", lw.ToArray());
  7266. string ro_json = "";
  7267. string type = GetPostString("gather_type");
  7268. int number = 0;
  7269. if (poscode == "AfterSale")
  7270. {
  7271. //处理中
  7272. if (type == "Handling")
  7273. {
  7274. 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) : ""));
  7275. DataTable dt = null;
  7276. try
  7277. {
  7278. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7279. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7280. }
  7281. catch (Exception e)
  7282. {
  7283. dt = new DataTable();
  7284. }
  7285. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7286. return;
  7287. }
  7288. if (type == "Wait")
  7289. {
  7290. //待处理
  7291. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7292. DataTable dt1 = null;
  7293. try
  7294. {
  7295. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7296. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7297. }
  7298. catch (Exception e)
  7299. {
  7300. dt1 = new DataTable();
  7301. }
  7302. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7303. return;
  7304. }
  7305. if (type == "back")
  7306. {
  7307. //打回
  7308. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7309. DataTable dt2 = null;
  7310. try
  7311. {
  7312. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7313. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7314. }
  7315. catch (Exception e)
  7316. {
  7317. dt2 = new DataTable();
  7318. }
  7319. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7320. return;
  7321. }
  7322. if (type == "preCompletion")
  7323. {
  7324. //预完成
  7325. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7326. DataTable dt3 = null;
  7327. try
  7328. {
  7329. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7330. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7331. }
  7332. catch (Exception e)
  7333. {
  7334. dt3 = new DataTable();
  7335. }
  7336. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7337. return;
  7338. }
  7339. if (type == "documentary")
  7340. {
  7341. //跟单中
  7342. 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) : ""));
  7343. DataTable dt4 = null;
  7344. try
  7345. {
  7346. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7347. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7348. }
  7349. catch (Exception e)
  7350. {
  7351. dt4 = new DataTable();
  7352. }
  7353. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7354. return;
  7355. }
  7356. if (type == "reBack")
  7357. {
  7358. //被打回
  7359. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7360. DataTable dt1 = null;
  7361. try
  7362. {
  7363. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7364. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7365. }
  7366. catch (Exception e)
  7367. {
  7368. dt1 = new DataTable();
  7369. }
  7370. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7371. return;
  7372. }
  7373. }
  7374. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7375. {
  7376. if (type == "puBack")
  7377. {
  7378. //退回
  7379. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7380. DataTable dt = null;
  7381. try
  7382. {
  7383. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7384. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7385. }
  7386. catch (Exception e)
  7387. {
  7388. dt = new DataTable();
  7389. }
  7390. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7391. return;
  7392. }
  7393. if (type == "reBack")
  7394. {
  7395. //打回
  7396. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7397. DataTable dt1 = null;
  7398. try
  7399. {
  7400. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7401. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7402. }
  7403. catch (Exception e)
  7404. {
  7405. dt1 = new DataTable();
  7406. }
  7407. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7408. return;
  7409. }
  7410. if (type == "examEd")
  7411. {
  7412. //已审核
  7413. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7414. DataTable dt2 = null;
  7415. try
  7416. {
  7417. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7418. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7419. }
  7420. catch (Exception e)
  7421. {
  7422. dt2 = new DataTable();
  7423. }
  7424. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7425. return;
  7426. }
  7427. if (type == "waitExam")
  7428. {
  7429. //待审核
  7430. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7431. DataTable dt3 = null;
  7432. try
  7433. {
  7434. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7435. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7436. }
  7437. catch (Exception e)
  7438. {
  7439. dt3 = new DataTable();
  7440. }
  7441. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7442. return;
  7443. }
  7444. if (type == "Handling")
  7445. {
  7446. //处理中
  7447. 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) : ""));
  7448. DataTable dt4 = null;
  7449. try
  7450. {
  7451. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7452. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7453. }
  7454. catch (Exception e)
  7455. {
  7456. dt4 = new DataTable();
  7457. }
  7458. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7459. return;
  7460. }
  7461. if (type == "Wait")
  7462. {
  7463. //待处理
  7464. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7465. DataTable dt5 = null;
  7466. try
  7467. {
  7468. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7469. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7470. }
  7471. catch (Exception e)
  7472. {
  7473. dt5 = new DataTable();
  7474. }
  7475. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7476. return;
  7477. }
  7478. if (type == "documentary")
  7479. {
  7480. //跟单中
  7481. 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) : ""));
  7482. DataTable dt6 = null;
  7483. try
  7484. {
  7485. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7486. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7487. }
  7488. catch (Exception e)
  7489. {
  7490. dt6 = new DataTable();
  7491. }
  7492. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7493. return;
  7494. }
  7495. }
  7496. returnSuccess(ro_json);
  7497. }
  7498. public void end_erp_aftersale()
  7499. {
  7500. if (UrlPostParmsCheck("ctid"))
  7501. {
  7502. string eid = GetPostString("ctid");
  7503. CeErpTradeCell entity = null;
  7504. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7505. if (entity != null)
  7506. {
  7507. string stype = GetPostString("stype");
  7508. string typeStr = stype;
  7509. entity.AfterSaleState = 4;
  7510. entity.FinishAfterSaleTime = DateTime.Now;
  7511. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7512. entity.Update();
  7513. ApiVo apiVo = new ApiVo();
  7514. apiVo.orderNumber = entity.ctid;
  7515. apiVo.actionName = "afterOver";
  7516. designHelper.API_WorkCore(apiVo); //afterOver
  7517. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7518. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7519. CeErpSukuraData.createInfo(entity.ctid, 8);
  7520. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7521. returnSuccessMsg("操作成功!");
  7522. return;
  7523. }
  7524. returnErrorMsg("找不到订单记录");
  7525. }
  7526. }
  7527. public void ins_erp_finishaftersale()
  7528. {
  7529. if (UrlPostParmsCheck("id"))
  7530. {
  7531. string eid = GetPostString("id");
  7532. CeErpTradeResponsible entity = null;
  7533. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7534. if (entity != null)
  7535. {
  7536. entity.VerifyState = 1;
  7537. entity.VerifyTime = DateTime.Now;
  7538. entity.Update();
  7539. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7540. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7541. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7542. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7543. if (dt.Rows.Count <= 0)
  7544. {
  7545. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7546. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7547. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7548. CeErpSukuraData.createInfo(entity.tid, 8);
  7549. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7550. {
  7551. CeErpDesignerBill.Del(entity.tid);
  7552. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7553. }
  7554. }
  7555. returnSuccessMsg("操作成功!");
  7556. return;
  7557. }
  7558. returnErrorMsg("找不到订单记录");
  7559. }
  7560. }
  7561. public void upd_erp_arbitrateaftersale()
  7562. {
  7563. if (UrlPostParmsCheck("id"))
  7564. {
  7565. string eid = GetPostString("id");
  7566. CeErpTradeResponsible entity = null;
  7567. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7568. if (entity != null)
  7569. {
  7570. entity.IsArbitrate = 1;
  7571. entity.ArbitradeMemo = GetPostString("reason");
  7572. entity.VerifyState = 2;
  7573. entity.Update();
  7574. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7575. if (tradecell != null)
  7576. {
  7577. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7578. tradecell.IsArbitrate = 1;
  7579. tradecell.Update();
  7580. }
  7581. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7582. returnSuccessMsg("操作成功!");
  7583. return;
  7584. }
  7585. returnErrorMsg("找不到订单记录");
  7586. }
  7587. }
  7588. public void upd_erp_backaftersale()
  7589. {
  7590. if (UrlPostParmsCheck("tid"))
  7591. {
  7592. string eid = GetPostString("tid");
  7593. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7594. int backNum = 0;
  7595. if (number != null)
  7596. {
  7597. backNum = number.BackNum;
  7598. }
  7599. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7600. CeErpTradeCell entity = null;
  7601. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7602. if (entity != null)
  7603. {
  7604. entity.AfterSaleBackReason = GetPostString("backreason");
  7605. entity.AfterSaleState = 1;
  7606. entity.AfterSaleSupplierState = 0;
  7607. entity.UpdateTime = DateTime.Now;
  7608. entity.Update();
  7609. returnSuccessMsg("操作成功!");
  7610. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7611. return;
  7612. }
  7613. returnErrorMsg("找不到订单记录");
  7614. }
  7615. }
  7616. public void get_erp_supplieraftersalelist()
  7617. {
  7618. DataStruct dStruct = GetPostStruct();
  7619. List<string> lw = new List<string>();
  7620. string tid = GetPostString("ctid");
  7621. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7622. string shopname = GetPostString("shopname");
  7623. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7624. string buyernick = GetPostString("buyer_nick");
  7625. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7626. string sellermemo = GetPostString("seller_memo");
  7627. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7628. string orderState = GetPostString("orderState");
  7629. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7630. string afterState = GetPostString("afterstate");
  7631. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7632. string date1 = GetPostString("date1");
  7633. string date2 = GetPostString("date2");
  7634. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7635. if (dw.Length > 0) lw.Add(dw);
  7636. string price1 = GetPostString("price1");
  7637. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7638. string price2 = GetPostString("price2");
  7639. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7640. string reason = GetPostString("reason");
  7641. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7642. string method = GetPostString("method");
  7643. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7644. string handledate1 = GetPostString("handledate1");
  7645. string handledate2 = GetPostString("handledate2");
  7646. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7647. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7648. string handler = GetPostString("handler");
  7649. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7650. string afterdate1 = GetPostString("afterdate1");
  7651. string afterdate2 = GetPostString("afterdate2");
  7652. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7653. if (afterDate.Length > 0) lw.Add(afterDate);
  7654. string customer = GetPostString("customer");
  7655. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7656. string design = GetPostString("design");
  7657. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7658. string afterMemoType = GetPostString("aftermemotype");
  7659. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7660. string vstate = GetPostString("vstate");
  7661. if (vstate.Length > 0)
  7662. {
  7663. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7664. }
  7665. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7666. string supplier = GetPostString("supplier");
  7667. int supid = commonHelper.getSupplierIDByName(supplier);
  7668. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7669. string posCode = CurrentUser.UserPost.Post.Code;
  7670. if (posCode == "Supplier")
  7671. {
  7672. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7673. }
  7674. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7675. {
  7676. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7677. }
  7678. else
  7679. {
  7680. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7681. }
  7682. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7683. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7684. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7685. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7686. writeGridDataTableJson(dStruct.TotalCount, dt);
  7687. }
  7688. public void upd_erp_supverifyaftersale()
  7689. {
  7690. if (UrlPostParmsCheck("id"))
  7691. {
  7692. string id = GetPostString("id");
  7693. int st = GetPostInt("afterstate");
  7694. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7695. CeErpTradeCell entity = null;
  7696. if (ceErpTradeResponsible != null)
  7697. {
  7698. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7699. }
  7700. string afmemo = GetPostString("supmemo");
  7701. string image = GetPostString("image");
  7702. if (entity != null)
  7703. {
  7704. entity.AfterSaleSupplierState = st;
  7705. entity.AfterSaleSupplierMemo = afmemo;
  7706. if (st == 1)
  7707. {
  7708. ceErpTradeResponsible.VerifyState = 1;
  7709. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7710. ceErpTradeResponsible.Update();
  7711. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7712. if (isAll)
  7713. {
  7714. entity.AfterSaleState = 4;
  7715. entity.FinishAfterSaleTime = DateTime.Now;
  7716. }
  7717. }
  7718. else
  7719. {
  7720. CeErpTradeResponsible.dateByTid(entity.ctid);
  7721. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7722. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7723. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7724. if (num <= 1)
  7725. {
  7726. entity.AfterSaleState = 1;
  7727. }
  7728. else
  7729. {
  7730. entity.AfterSaleState = 5;
  7731. }
  7732. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7733. if (ceErpTradeAfterSaleExtend != null)
  7734. {
  7735. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7736. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7737. ceErpTradeAfterSaleExtend.Update();
  7738. }
  7739. else
  7740. {
  7741. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7742. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7743. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7744. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7745. ceErpTradeAfterSaleExtend.Create();
  7746. }
  7747. }
  7748. if (entity.AfterSaleState == 4)
  7749. {
  7750. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7751. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7752. {
  7753. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7754. }
  7755. ApiVo apiVo = new ApiVo();
  7756. apiVo.orderNumber = entity.ctid;
  7757. apiVo.actionName = "afterOver";
  7758. designHelper.API_WorkCore(apiVo); //afterOver
  7759. }
  7760. entity.UpdateTime = DateTime.Now;
  7761. entity.Update();
  7762. returnSuccessMsg("操作成功!");
  7763. CeErpSukuraData.createInfo(entity.ctid, 8);
  7764. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7765. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7766. return;
  7767. }
  7768. returnErrorMsg("找不到订单记录");
  7769. }
  7770. }
  7771. public void upd_erp_masteraftersale()
  7772. {
  7773. if (UrlPostParmsCheck("id"))
  7774. {
  7775. string id = GetPostString("id");
  7776. int st = GetPostInt("afterstate");
  7777. string afmemo = GetPostString("supmemo");
  7778. string image = GetPostString("image");
  7779. string textResult = GetPostString("textResult");
  7780. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7781. if (ceErpTradeResponsible != null)
  7782. {
  7783. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7784. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7785. ceErpTradeResponsible.Update();
  7786. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7787. if (entity != null)
  7788. {
  7789. entity.AfterSaleSupplierState = st;
  7790. entity.AfterSaleSupplierMemo = afmemo;
  7791. if (st == 1)
  7792. {
  7793. }
  7794. else
  7795. {
  7796. CeErpTradeResponsible.dateByTid(entity.ctid);
  7797. //退回到售后
  7798. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7799. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7800. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7801. if (num <= 1)
  7802. {
  7803. entity.AfterSaleState = 1;
  7804. }
  7805. else
  7806. {
  7807. entity.AfterSaleState = 5;
  7808. }
  7809. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7810. if (ceErpTradeAfterSaleExtend != null)
  7811. {
  7812. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7813. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7814. ceErpTradeAfterSaleExtend.Update();
  7815. }
  7816. else
  7817. {
  7818. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7819. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7820. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7821. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7822. ceErpTradeAfterSaleExtend.Create();
  7823. }
  7824. }
  7825. entity.UpdateTime = DateTime.Now;
  7826. entity.Update();
  7827. returnSuccessMsg("操作成功!");
  7828. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7829. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7830. return;
  7831. }
  7832. }
  7833. returnErrorMsg("找不到订单记录");
  7834. }
  7835. }
  7836. public void upd_erp_personaftersale()
  7837. {
  7838. if (UrlPostParmsCheck("id"))
  7839. {
  7840. //林小连
  7841. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7842. {
  7843. upd_erp_masteraftersale();
  7844. return;
  7845. }
  7846. string id = GetPostString("id");
  7847. int st = GetPostInt("afterstate");
  7848. string afmemo = GetPostString("supmemo");
  7849. string image = GetPostString("image");
  7850. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7851. if (ceErpTradeResponsible != null)
  7852. {
  7853. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7854. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7855. ceErpTradeResponsible.Update();
  7856. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7857. if (entity != null)
  7858. {
  7859. entity.AfterSaleSupplierMemo = afmemo;
  7860. entity.AfterSaleSupplierState = st;
  7861. if (st == 1)
  7862. {
  7863. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7864. if (isAll)
  7865. {
  7866. entity.AfterSaleState = 4;
  7867. entity.FinishAfterSaleTime = DateTime.Now;
  7868. }
  7869. }
  7870. else
  7871. {
  7872. CeErpTradeResponsible.dateByTid(entity.ctid);
  7873. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7874. if (ceErpTradeAfterSaleExtend != null)
  7875. {
  7876. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7877. ceErpTradeAfterSaleExtend.Update();
  7878. }
  7879. else
  7880. {
  7881. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7882. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7883. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7884. ceErpTradeAfterSaleExtend.Create();
  7885. }
  7886. //退回到主管
  7887. //entity.AfterSaleState = 2;
  7888. }
  7889. if (entity.AfterSaleState == 4)
  7890. {
  7891. ApiVo apiVo = new ApiVo();
  7892. apiVo.orderNumber = entity.ctid;
  7893. apiVo.actionName = "afterOver";
  7894. designHelper.API_WorkCore(apiVo); //afterOver
  7895. }
  7896. entity.UpdateTime = DateTime.Now;
  7897. entity.Update();
  7898. returnSuccessMsg("操作成功!");
  7899. CeErpSukuraData.createInfo(entity.ctid, 8);
  7900. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7901. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7902. return;
  7903. }
  7904. }
  7905. returnErrorMsg("找不到订单记录");
  7906. }
  7907. }
  7908. public void set_erp_supplierrefundtag()
  7909. {
  7910. if (UrlPostParmsCheck("ctid"))
  7911. {
  7912. string eid = GetPostString("ctid");
  7913. CeErpTradeCell entity = null;
  7914. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7915. if (entity != null)
  7916. {
  7917. entity.IsSupplierRefund = GetPostInt("tag");
  7918. entity.Update();
  7919. returnSuccessMsg("操作成功!");
  7920. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7921. return;
  7922. }
  7923. returnErrorMsg("找不到订单记录");
  7924. }
  7925. }
  7926. public void get_erp_refundlist()
  7927. {
  7928. DataStruct dStruct = GetPostStruct();
  7929. List<string> lw = new List<string>();
  7930. string tid = GetPostString("tid");
  7931. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7932. //string rid = GetPostString("refund_id");
  7933. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7934. string shopname = GetPostString("shopname");
  7935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7936. string buyernick = GetPostString("buyer_nick");
  7937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7938. string customer = GetPostString("customer");
  7939. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7940. string design = GetPostString("design");
  7941. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7942. string sellermemo = GetPostString("seller_memo");
  7943. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7944. //string date1 = GetPostString("date1");
  7945. //string date2 = GetPostString("date2");
  7946. //string dateType = GetPostString("dateType");
  7947. //if (dateType.Length > 0)
  7948. //{
  7949. // if (dateType == "1001") dateType = "0";
  7950. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7951. // if (searchDT.Count == 2)
  7952. // {
  7953. // date1 = searchDT[0].ToString();
  7954. // date2 = searchDT[1].ToString();
  7955. // }
  7956. //}
  7957. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7958. //if (dw.Length > 0) lw.Add(dw);
  7959. string redate1 = GetPostString("refunddate1");
  7960. string redate2 = GetPostString("refunddate2");
  7961. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7962. if (dwdate.Length > 0) lw.Add(dwdate);
  7963. string price1 = GetPostString("price1");
  7964. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7965. string price2 = GetPostString("price2");
  7966. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7967. string ispartrefund = GetPostString("ispartrefund");
  7968. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7969. string refundState = GetPostString("refundvstate");
  7970. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7971. int st = GetInt("st");
  7972. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7973. {
  7974. string responsible = GetPostString("responsibleman");
  7975. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7976. lw.Add(string.Format("RefundState>={0}", st));
  7977. string code = CurrentUser.UserPost.Post.Code;
  7978. if (code == "CustomerService")
  7979. {
  7980. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7981. }
  7982. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7983. {
  7984. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7985. }
  7986. else if (code == "Place" || code == "PlaceMr")
  7987. {
  7988. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7989. }
  7990. dStruct.Order = "RefundState asc,created desc";
  7991. }
  7992. else if (st == 10)
  7993. {
  7994. string responsible = GetPostString("responsibleman");
  7995. if (responsible == "空白")
  7996. {
  7997. lw.Add(string.Format("ResponsibleUserName = ''"));
  7998. }
  7999. else if (responsible.Length > 0)
  8000. {
  8001. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8002. }
  8003. lw.Add(string.Format("RefundState>=0"));
  8004. dStruct.Order = "created desc";
  8005. }
  8006. else
  8007. {
  8008. string responsible = GetPostString("responsibleman");
  8009. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8010. lw.Add(string.Format("RefundState={0}", st));
  8011. dStruct.Order = "created desc";
  8012. }
  8013. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8014. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8015. dt.Columns.Add("refund_fees");
  8016. foreach (DataRow dr in dt.Rows)
  8017. {
  8018. String status = dr["status"].ToString();
  8019. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8020. {
  8021. dr["refund_fees"] = dr["refund_fee"];
  8022. }
  8023. else
  8024. {
  8025. dr["refund_fees"] = "0.0";
  8026. }
  8027. }
  8028. writeGridDataTableJson(dStruct.TotalCount, dt);
  8029. }
  8030. public void get_erp_refunddesignlist()
  8031. {
  8032. DataStruct dStruct = GetPostStruct();
  8033. List<string> lw = new List<string>();
  8034. string tid = GetPostString("tid");
  8035. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8036. string shopname = GetPostString("shopname");
  8037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8038. string buyernick = GetPostString("buyer_nick");
  8039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8040. string customer = GetPostString("customer");
  8041. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8042. string design = GetPostString("design");
  8043. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8044. string sellermemo = GetPostString("seller_memo");
  8045. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8046. string redate1 = GetPostString("refunddate1");
  8047. string redate2 = GetPostString("refunddate2");
  8048. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8049. if (dwdate.Length > 0) lw.Add(dwdate);
  8050. string price1 = GetPostString("price1");
  8051. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8052. string price2 = GetPostString("price2");
  8053. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8054. string ispartrefund = GetPostString("ispartrefund");
  8055. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8056. string designerorg = GetPostString("designerorg");
  8057. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8058. string refundState = GetPostString("refundState");
  8059. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8060. int myOrgid = CurrentUser.UserPost.OrgID;
  8061. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8062. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8063. {
  8064. if (CurrentUser.User.TeamIds.Length > 0)
  8065. {
  8066. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8067. }
  8068. else
  8069. {
  8070. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8071. }
  8072. }
  8073. else if ("SysAdmin".Equals(myOrgCode))
  8074. {
  8075. }
  8076. else
  8077. {
  8078. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8079. {
  8080. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8081. }
  8082. else
  8083. {
  8084. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8085. }
  8086. }
  8087. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8088. dStruct.Order = "created desc";
  8089. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8090. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8091. dt.Columns.Add("refund_fees");
  8092. foreach (DataRow dr in dt.Rows)
  8093. {
  8094. String status = dr["status"].ToString();
  8095. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8096. {
  8097. dr["refund_fees"] = dr["refund_fee"];
  8098. }
  8099. else
  8100. {
  8101. dr["refund_fees"] = "0.0";
  8102. }
  8103. }
  8104. writeGridDataTableJson(dStruct.TotalCount, dt);
  8105. }
  8106. public void handle_erp_refundtag()
  8107. {
  8108. if (UrlPostParmsCheck("refund_id"))
  8109. {
  8110. string eid = GetPostString("refund_id");
  8111. string respMan = GetPostString("ResponsibleName");
  8112. if (respMan.Length <= 0)
  8113. {
  8114. returnErrorMsg("责任人不能为空");
  8115. return;
  8116. }
  8117. CeErpTradeRefund entity = null;
  8118. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8119. if (entity != null)
  8120. {
  8121. entity.ResponsibleUserName = respMan;
  8122. string userid = GetPostString("ResponsibleUserId");
  8123. if (userid.Length > 0)
  8124. {
  8125. entity.ResponsibleUserId = userid;
  8126. }
  8127. entity.Memo = GetPostString("Memo");
  8128. if (respMan.IndexOf("客服") != -1 ||
  8129. respMan.IndexOf("设计师") != -1 ||
  8130. respMan.IndexOf("下单员") != -1)
  8131. {
  8132. entity.RefundState = 2;
  8133. }
  8134. else
  8135. {
  8136. entity.RefundState = 3;
  8137. }
  8138. entity.modified = DateTime.Now;
  8139. entity.Update();
  8140. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8141. returnSuccessMsg("操作成功!");
  8142. return;
  8143. }
  8144. returnErrorMsg("找不到订单记录");
  8145. }
  8146. }
  8147. public void handle_erp_designrefundtag()
  8148. {
  8149. if (UrlPostParmsCheck("refund_id"))
  8150. {
  8151. string eid = GetPostString("refund_id");
  8152. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8153. if (ceErpTradeCellExtend == null)
  8154. {
  8155. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8156. ceErpTradeCellExtend.ctid = eid;
  8157. }
  8158. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8159. if (ceErpTradeCellExtend.ID > 0)
  8160. {
  8161. ceErpTradeCellExtend.Update();
  8162. }
  8163. else
  8164. {
  8165. ceErpTradeCellExtend.Create();
  8166. }
  8167. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8168. returnSuccessMsg("操作成功!");
  8169. return;
  8170. }
  8171. returnErrorMsg("找不到订单记录");
  8172. }
  8173. public void upd_erp_refundverify()
  8174. {
  8175. if (UrlPostParmsCheck("refund_id"))
  8176. {
  8177. string eid = GetPostString("refund_id");
  8178. CeErpTradeRefund entity = null;
  8179. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8180. if (entity != null)
  8181. {
  8182. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8183. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8184. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8185. {
  8186. entity.RefundState = 2;
  8187. }
  8188. else
  8189. {
  8190. entity.RefundState = 3;
  8191. }
  8192. entity.Update();
  8193. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8194. returnSuccessMsg("操作成功!");
  8195. return;
  8196. }
  8197. returnErrorMsg("找不到订单记录");
  8198. }
  8199. }
  8200. public void upd_erp_refundapprove()
  8201. {
  8202. if (UrlPostParmsCheck("refund_id"))
  8203. {
  8204. string eid = GetPostString("refund_id");
  8205. CeErpTradeRefund entity = null;
  8206. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8207. if (entity != null)
  8208. {
  8209. int apr = GetPostInt("approve");
  8210. if (apr == 0)
  8211. {
  8212. entity.RefundState = 1;
  8213. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8214. }
  8215. else if (apr == 1)
  8216. {
  8217. entity.RefundState = 3;
  8218. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8219. }
  8220. entity.modified = DateTime.Now;
  8221. entity.Update();
  8222. returnSuccessMsg("操作成功!");
  8223. return;
  8224. }
  8225. returnErrorMsg("找不到订单记录");
  8226. }
  8227. }
  8228. public void get_erp_billlist()
  8229. {
  8230. DataStruct dStruct = GetPostStruct();
  8231. List<string> lw = new List<string>();
  8232. string title = GetPostString("title");
  8233. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8234. string tid = GetPostString("tid");
  8235. string tids = GetPostString("tids");
  8236. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8237. if (tids.Length > 0)
  8238. {
  8239. tids = "'" + tids + "'";
  8240. tids = tids.Replace(",", "','");
  8241. lw.Add(string.Format("tid in ({0})", tids));
  8242. }
  8243. string shopname = GetPostString("shopname");
  8244. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8245. string buyernick = GetPostString("buyer_nick");
  8246. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8247. string customer = GetPostString("customer");
  8248. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8249. string date1 = GetPostString("date1");
  8250. string date2 = GetPostString("date2");
  8251. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8252. if (dw.Length > 0) lw.Add(dw);
  8253. string price1 = GetPostString("price1");
  8254. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8255. string price2 = GetPostString("price2");
  8256. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8257. string returndate1 = GetPostString("returndate1");
  8258. string returndate2 = GetPostString("returndate2");
  8259. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8260. if (dw1.Length > 0) lw.Add(dw1);
  8261. string billtype = GetPostString("billtype");
  8262. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8263. string billstate = GetPostString("billstate");
  8264. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8265. string usershop = CurrentUser.User.pemShop;
  8266. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8267. dStruct.Order = "createTime desc";
  8268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8269. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8270. //foreach (DataRow dr in dt.Rows)
  8271. //{
  8272. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8273. //}
  8274. writeGridDataTableJson(dStruct.TotalCount, dt);
  8275. }
  8276. public void modify_erp_billinfo()
  8277. {
  8278. if (UrlPostParmsCheck("ID"))
  8279. {
  8280. string eid = GetPostString("ID");
  8281. CeErpBill bill_entity = null;
  8282. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8283. if (bill_entity != null)
  8284. {
  8285. bill_entity.tid = GetPostString("tid");
  8286. bill_entity.title = GetPostString("title");
  8287. bill_entity.tax = GetPostString("tax");
  8288. bill_entity.bank = GetPostString("bank");
  8289. bill_entity.bankac = GetPostString("bankac");
  8290. bill_entity.address = GetPostString("address");
  8291. bill_entity.phone = GetPostString("phone");
  8292. bill_entity.price = GetPostString("price");
  8293. bill_entity.productId = GetPostInt("ProductName");
  8294. bill_entity.num = GetPostInt("num");
  8295. bill_entity.unit = GetPostString("unit");
  8296. bill_entity.type = GetPostString("type");
  8297. bill_entity.sendType = GetPostString("SendType");
  8298. bill_entity.email = GetPostString("email");
  8299. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8300. bill_entity.shopName = GetPostString("ShopName");
  8301. bill_entity.applymemo = GetPostString("applymemo");
  8302. bill_entity.modifyTime = DateTime.Now;
  8303. bill_entity.createTime = DateTime.Now;
  8304. bill_entity.state = 0;
  8305. bill_entity.Update();
  8306. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8307. returnSuccessMsg("发票修改成功!");
  8308. return;
  8309. }
  8310. returnErrorMsg("找不到对应记录");
  8311. }
  8312. }
  8313. public void set_erp_invoicing()
  8314. {
  8315. if (UrlPostParmsCheck("id"))
  8316. {
  8317. try
  8318. {
  8319. string eid = GetPostString("id");
  8320. CeErpBill bill_entity = null;
  8321. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8322. if (bill_entity != null)
  8323. {
  8324. int ComId = GetPostInt("ComId");
  8325. //string memo = GetPostString("Memo");
  8326. int allInfo = GetPostInt("allinfo");
  8327. string clert = CurrentUser.User.Name;
  8328. //string detailValue = GetPostString("detailvalue");
  8329. string billId = bill_entity.billOrderId;
  8330. string[] billIdList = billId.Split(',');
  8331. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8332. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8333. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8334. {
  8335. billCount += 1;
  8336. }
  8337. if (billId.Length <= 0 || billIdList.Length != billCount)
  8338. {
  8339. bill_entity.billOrderId = "";
  8340. string prebill = "ltb";
  8341. for (int idx = 1; idx <= billCount; idx++)
  8342. {
  8343. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8344. string billoid = prebill + idx + dtstr;
  8345. bill_entity.billOrderId += billoid;
  8346. if (idx < billCount)
  8347. {
  8348. bill_entity.billOrderId += ",";
  8349. }
  8350. }
  8351. }
  8352. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8353. if (bill_entity.state == 5)
  8354. {
  8355. string errMsg = bill_entity.failerror;
  8356. string[] errlist = errMsg.Split('|');
  8357. string[] errTags = new string[errlist.Length];
  8358. for (int itag = 0; itag < errlist.Length; itag++)
  8359. {
  8360. if (errlist[itag].Length <= 0) continue;
  8361. errTags[itag] = errlist[itag].Split('&')[0];
  8362. }
  8363. for (int iii = 0; iii < errTags.Length; iii++)
  8364. {
  8365. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8366. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8367. if (billOrderList.Length >= erroBillOrderTag)
  8368. {
  8369. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8370. if (needModifyBillId.Length <= 19)
  8371. {
  8372. needModifyBillId = needModifyBillId + "1";
  8373. }
  8374. else
  8375. {
  8376. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8377. last = last + 1;
  8378. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8379. }
  8380. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8381. }
  8382. }
  8383. }
  8384. bool isHaveBillSucces = false;
  8385. string totalRes = "";
  8386. bill_entity.failerror = "";
  8387. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8388. {
  8389. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8390. totalRes += res;
  8391. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8392. {
  8393. isHaveBillSucces = true;
  8394. bill_entity.comId = ComId;
  8395. bill_entity.state = 1;
  8396. bill_entity.executeTime = DateTime.Now;
  8397. bill_entity.executeUser = clert;
  8398. }
  8399. else
  8400. {
  8401. bill_entity.state = 5;
  8402. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8403. }
  8404. }
  8405. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8406. bill_entity.Update();
  8407. if (isHaveBillSucces)
  8408. {
  8409. StringBuilder sql = new StringBuilder();
  8410. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8411. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8412. }
  8413. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8414. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8415. {
  8416. returnErrorMsg("开票失败");
  8417. }
  8418. else
  8419. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8420. return;
  8421. }
  8422. returnErrorMsg("找不到对应记录");
  8423. }
  8424. catch (Exception ex)
  8425. {
  8426. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8427. returnErrorMsg("操作失败");
  8428. }
  8429. }
  8430. }
  8431. public void get_erp_invoicing_back()
  8432. {
  8433. if (UrlPostParmsCheck("id"))
  8434. {
  8435. try
  8436. {
  8437. string id = GetPostString("id");
  8438. CeErpBill entiy = CeErpBill.Get(id);
  8439. if (entiy != null)
  8440. {
  8441. if (entiy.state == 0)
  8442. {
  8443. returnErrorMsg("发票还未开具");
  8444. return;
  8445. }
  8446. string[] billOrderList = entiy.billOrderId.Split(',');
  8447. int iTag = 0;
  8448. entiy.fplsh = "";
  8449. entiy.fpdm = "";
  8450. entiy.fphm = "";
  8451. foreach (string billOrderId in billOrderList)
  8452. {
  8453. iTag++;
  8454. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8455. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8456. {
  8457. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8458. try
  8459. {
  8460. Invoicing_get_response_Obj iObj = null;
  8461. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8462. if (iObj != null)
  8463. {
  8464. entiy.state = 2;
  8465. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8466. entiy.fpdm += iObj.list[0].c_fpdm;
  8467. entiy.fphm += iObj.list[0].c_fphm;
  8468. if (iTag < billOrderList.Length)
  8469. {
  8470. entiy.fplsh += ",";
  8471. entiy.fpdm += ",";
  8472. entiy.fphm += ",";
  8473. }
  8474. entiy.Update();
  8475. }
  8476. StringBuilder sql = new StringBuilder();
  8477. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8478. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8479. returnSuccessMsg("开票成功");
  8480. }
  8481. catch (Exception ex)
  8482. {
  8483. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8484. }
  8485. return;
  8486. }
  8487. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8488. {
  8489. var res_obj = new
  8490. {
  8491. data = "开票中"
  8492. };
  8493. string ro_json = JsonConvert.SerializeObject(res_obj);
  8494. returnSuccess(ro_json);
  8495. return;
  8496. }
  8497. else
  8498. {
  8499. int eidx = res.IndexOf("c_resultmsg");
  8500. int lidx = res.IndexOf("c_status");
  8501. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8502. entiy.state = 5;
  8503. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8504. entiy.Update();
  8505. returnErrorMsg("开票失败");
  8506. return;
  8507. }
  8508. }
  8509. }
  8510. }
  8511. catch (Exception ex)
  8512. {
  8513. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8514. }
  8515. return;
  8516. }
  8517. }
  8518. public void get_erp_invoicing()
  8519. {
  8520. if (UrlPostParmsCheck("id"))
  8521. {
  8522. try
  8523. {
  8524. string id = GetPostString("id");
  8525. CeErpBill entiy = CeErpBill.Get(id);
  8526. if (entiy != null)
  8527. {
  8528. if (entiy.state == 0)
  8529. {
  8530. returnErrorMsg("发票还未开具");
  8531. return;
  8532. }
  8533. if (entiy.sendType == "纸质发票")
  8534. {
  8535. if (entiy.img.Length <= 0)
  8536. {
  8537. returnErrorMsg("查无纸质发票");
  8538. return;
  8539. }
  8540. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8541. returnSuccess(returnres);
  8542. return;
  8543. }
  8544. string[] billOrderList = entiy.billOrderId.Split(',');
  8545. int iTag = 0;
  8546. string fpUrl = "";
  8547. entiy.fplsh = "";
  8548. entiy.fpdm = "";
  8549. entiy.fphm = "";
  8550. foreach (string billOrderId in billOrderList)
  8551. {
  8552. iTag++;
  8553. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8554. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8555. {
  8556. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8557. Invoicing_get_response_Obj iObj = null;
  8558. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8559. if (iObj != null)
  8560. {
  8561. //entiy.state = 2;
  8562. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8563. entiy.fpdm += iObj.list[0].c_fpdm;
  8564. entiy.fphm += iObj.list[0].c_fphm;
  8565. if (iTag < billOrderList.Length)
  8566. {
  8567. entiy.fplsh += ",";
  8568. entiy.fpdm += ",";
  8569. entiy.fphm += ",";
  8570. }
  8571. entiy.Update();
  8572. fpUrl += iObj.list[0].c_url + ",";
  8573. }
  8574. //returnSuccess(res);
  8575. StringBuilder sql = new StringBuilder();
  8576. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8577. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8578. }
  8579. else
  8580. {
  8581. int eidx = res.IndexOf("c_resultmsg");
  8582. //int lidx = res.IndexOf("c_status");
  8583. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8584. //开票失败
  8585. entiy.state = 5;
  8586. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8587. entiy.Update();
  8588. returnErrorMsg("开票失败");
  8589. return;
  8590. }
  8591. }
  8592. var returnObj = new
  8593. {
  8594. data = fpUrl
  8595. };
  8596. string ro_json = JsonConvert.SerializeObject(returnObj);
  8597. returnSuccess(ro_json);
  8598. }
  8599. }
  8600. catch (Exception ex)
  8601. {
  8602. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8603. }
  8604. return;
  8605. }
  8606. }
  8607. public void save_erp_billimg()
  8608. {
  8609. if (UrlPostParmsCheck("id"))
  8610. {
  8611. string eid = GetPostString("id");
  8612. CeErpBill bill_entity = null;
  8613. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8614. if (bill_entity != null)
  8615. {
  8616. bill_entity.img = GetPostString("img");
  8617. bill_entity.executeTime = DateTime.Now;
  8618. bill_entity.state = 2;
  8619. bill_entity.Update();
  8620. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8621. returnSuccessMsg("保存成功");
  8622. }
  8623. return;
  8624. }
  8625. }
  8626. public void upd_erp_billreturnback()
  8627. {
  8628. if (UrlPostParmsCheck("id"))
  8629. {
  8630. int eid = GetPostInt("id");
  8631. CeErpBill bill_entity = null;
  8632. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8633. if (bill_entity != null)
  8634. {
  8635. bill_entity.state = 3;
  8636. bill_entity.returnReason = GetPostString("reason");
  8637. bill_entity.Update();
  8638. returnSuccessMsg("驳回成功!");
  8639. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8640. }
  8641. return;
  8642. }
  8643. }
  8644. public void cancel_erp_bill()
  8645. {
  8646. if (UrlPostParmsCheck("id"))
  8647. {
  8648. int eid = GetPostInt("id");
  8649. int detailValue = GetPostInt("detailvalue");
  8650. CeErpBill bill_entity = null;
  8651. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8652. string cres = "";
  8653. string gres = "";
  8654. if (bill_entity != null)
  8655. {
  8656. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8657. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8658. {
  8659. int iTag = 0;
  8660. bill_entity.fplsh = "";
  8661. bill_entity.fpdm = "";
  8662. bill_entity.fphm = "";
  8663. foreach (string billOrderId in billOrderList)
  8664. {
  8665. iTag++;
  8666. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8667. if (gres.IndexOf("success") != -1)
  8668. {
  8669. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8670. Invoicing_get_response_Obj iObj = null;
  8671. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8672. if (iObj != null)
  8673. {
  8674. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8675. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8676. bill_entity.fphm += iObj.list[0].c_fphm;
  8677. if (iTag < billOrderList.Length)
  8678. {
  8679. bill_entity.fplsh += ",";
  8680. bill_entity.fpdm += ",";
  8681. bill_entity.fphm += ",";
  8682. }
  8683. bill_entity.Update();
  8684. }
  8685. }
  8686. else
  8687. {
  8688. returnErrorMsg(gres);
  8689. return;
  8690. }
  8691. }
  8692. }
  8693. if (bill_entity.sendType == "纸质发票")
  8694. {
  8695. //作废
  8696. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8697. //if (DateTime.Now.Month == extime.Month)
  8698. //{
  8699. //cres = taobaoHelper.cancel_invoicing(eid);
  8700. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8701. //{
  8702. bill_entity.state = 4;//已作废
  8703. bill_entity.Update();
  8704. returnSuccessMsg("发票已作废");
  8705. return;
  8706. //}
  8707. //else
  8708. //{
  8709. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8710. // bill_entity.Update();
  8711. // returnErrorMsg(cres);
  8712. // return;
  8713. //}
  8714. //}
  8715. //else
  8716. //{
  8717. // returnErrorMsg("纸质发票只能作废本月的发票");
  8718. // return;
  8719. //}
  8720. }
  8721. //红冲
  8722. int redTag = 0;
  8723. string[] fpdmList = bill_entity.fpdm.Split(',');
  8724. string[] fphmList = bill_entity.fphm.Split(',');
  8725. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8726. {
  8727. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8728. return;
  8729. }
  8730. foreach (string billOrderId in billOrderList)
  8731. {
  8732. redTag++;
  8733. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8734. cres += onecres;
  8735. cres += ",";
  8736. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8737. {
  8738. bill_entity.state = 4;//已作废
  8739. //bill_entity.Update();
  8740. //returnSuccessMsg("发票已红冲");
  8741. }
  8742. else if (onecres.IndexOf("重复冲红") != -1)
  8743. {
  8744. bill_entity.state = 4;//已作废
  8745. //bill_entity.Update();
  8746. //returnSuccessMsg("发票已红冲");
  8747. }
  8748. else
  8749. {
  8750. string errmsg = commonHelper.KeepChinese(onecres);
  8751. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8752. }
  8753. }
  8754. bill_entity.Update();
  8755. if (cres.IndexOf("失败") != -1)
  8756. returnErrorMsg("红冲失败");
  8757. else
  8758. returnSuccessMsg("发票已红冲");
  8759. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8760. return;
  8761. }
  8762. return;
  8763. }
  8764. }
  8765. public void del_erp_billorder()
  8766. {
  8767. if (UrlPostParmsCheck("id"))
  8768. {
  8769. string eid = GetPostString("id");
  8770. CeErpBill.Del(eid);
  8771. CeErpBill bill = CeErpBill.Get(eid);
  8772. if (bill != null)
  8773. {
  8774. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8775. }
  8776. returnSuccessMsg("删除成功");
  8777. }
  8778. }
  8779. public void finish_erp_bill()
  8780. {
  8781. if (UrlPostParmsCheck("ids"))
  8782. {
  8783. string eids = GetPostString("ids");
  8784. string[] list = eids.Split(',');
  8785. foreach (string eid in list)
  8786. {
  8787. CeErpBill bill = CeErpBill.Get(eid);
  8788. if (bill != null)
  8789. {
  8790. bill.state = 2;
  8791. bill.Update();
  8792. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8793. }
  8794. }
  8795. returnSuccessMsg("操作成功");
  8796. }
  8797. }
  8798. public void get_erp_returncash()
  8799. {
  8800. DataStruct dStruct = GetPostStruct();
  8801. List<string> lw = new List<string>();
  8802. string tid = GetPostString("tid");
  8803. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8804. string shopname = GetPostString("shopname");
  8805. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8806. string buyernick = GetPostString("buyer_nick");
  8807. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8808. string customer = GetPostString("customer");
  8809. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8810. string returndate1 = GetPostString("returndate1");
  8811. string returndate2 = GetPostString("returndate2");
  8812. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8813. if (dw.Length > 0) lw.Add(dw);
  8814. string finishDate1 = GetPostString("finishdate1");
  8815. string finishDate2 = GetPostString("finishdate2");
  8816. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8817. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8818. string returntype = GetPostString("returntype");
  8819. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8820. string returnvstate = GetPostString("returnvstate");
  8821. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8822. dStruct.Order = "created desc";
  8823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8824. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8825. writeGridDataTableJson(dStruct.TotalCount, dt);
  8826. }
  8827. public void get_erp_staygoods()
  8828. {
  8829. DataStruct dStruct = GetPostStruct();
  8830. List<string> lw = new List<string>();
  8831. string tid = GetPostString("tid");
  8832. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8833. string shopname = GetPostString("shopname");
  8834. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8835. string wangwang = GetPostString("wangwang");
  8836. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8837. string customer = GetPostString("customer");
  8838. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8839. string returndate1 = GetPostString("returndate1");
  8840. string returndate2 = GetPostString("returndate2");
  8841. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8842. if (dw.Length > 0) lw.Add(dw);
  8843. string finishDate1 = GetPostString("finishdate1");
  8844. string finishDate2 = GetPostString("finishdate2");
  8845. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8846. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8847. string returnvstate = GetPostString("returnvstate");
  8848. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8849. string persuadetype = GetPostString("persuadetype");
  8850. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8851. string customerOrg = GetPostString("customerOrg");
  8852. if (customerOrg.Length > 0)
  8853. {
  8854. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8855. }
  8856. dStruct.Order = "creata_time desc";
  8857. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8858. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8859. writeGridDataTableJson(dStruct.TotalCount, dt);
  8860. }
  8861. public void upd_erp_staygoods()
  8862. {
  8863. if (UrlPostParmsCheck("id"))
  8864. {
  8865. int eid = GetPostInt("id");
  8866. CeErpStayGoods entity = null;
  8867. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8868. if (entity != null)
  8869. {
  8870. entity.audit_type = 1;
  8871. entity.audit_time = DateTime.Now;
  8872. entity.audit_u_id = CurrentUser.UserID;
  8873. entity.audit_u_name = CurrentUser.UserName;
  8874. entity.Update();
  8875. returnSuccessMsg("审核成功!");
  8876. return;
  8877. }
  8878. returnErrorMsg("找不到订单记录");
  8879. }
  8880. }
  8881. public void upd_erp_stayGoodsback()
  8882. {
  8883. if (UrlPostParmsCheck("id"))
  8884. {
  8885. int eid = GetPostInt("id");
  8886. CeErpStayGoods entity = null;
  8887. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8888. if (entity != null)
  8889. {
  8890. entity.audit_text = GetPostString("reason");
  8891. entity.audit_type = 2;
  8892. entity.audit_time = DateTime.Now;
  8893. entity.audit_u_id = CurrentUser.UserID;
  8894. entity.audit_u_name = CurrentUser.UserName;
  8895. entity.Update();
  8896. returnSuccessMsg("退回成功!");
  8897. return;
  8898. }
  8899. returnErrorMsg("找不到订单记录");
  8900. }
  8901. }
  8902. public void upd_erp_returncashverify()
  8903. {
  8904. if (UrlPostParmsCheck("ID"))
  8905. {
  8906. int eid = GetPostInt("ID");
  8907. CeErpReturnCash entity = null;
  8908. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8909. if (entity != null)
  8910. {
  8911. entity.cashstate = 1;
  8912. entity.verifytime = DateTime.Now;
  8913. entity.verifyuserid = CurrentUser.UserID;
  8914. entity.Update();
  8915. returnSuccessMsg("审核成功!");
  8916. return;
  8917. }
  8918. returnErrorMsg("找不到订单记录");
  8919. }
  8920. }
  8921. public void upd_all_erp_returncashverify()
  8922. {
  8923. if (UrlPostParmsCheck("ID"))
  8924. {
  8925. String[] list = GetPostString("ID").Split(',');
  8926. CeErpReturnCash entity = null;
  8927. for (int i = 0; i < list.Length; i++)
  8928. {
  8929. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8930. if (entity != null)
  8931. {
  8932. if (entity.cashstate == 1)
  8933. {
  8934. returnErrorMsg("已审核过的订单不需要在审核!");
  8935. return;
  8936. }
  8937. entity.cashstate = 1;
  8938. entity.verifytime = DateTime.Now;
  8939. entity.verifyuserid = CurrentUser.UserID;
  8940. entity.Update();
  8941. }
  8942. }
  8943. returnSuccessMsg("审核成功!");
  8944. return;
  8945. }
  8946. }
  8947. public void upd_erp_returncashback()
  8948. {
  8949. if (UrlPostParmsCheck("ID"))
  8950. {
  8951. int eid = GetPostInt("ID");
  8952. CeErpReturnCash entity = null;
  8953. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8954. if (entity != null)
  8955. {
  8956. entity.backreason = GetPostString("reason");
  8957. entity.cashstate = 2;
  8958. entity.verifytime = DateTime.Now;
  8959. entity.verifyuserid = CurrentUser.UserID;
  8960. entity.Update();
  8961. returnSuccessMsg("退回成功!");
  8962. return;
  8963. }
  8964. returnErrorMsg("找不到订单记录");
  8965. }
  8966. }
  8967. public void upd_erp_returnprice()
  8968. {
  8969. if (UrlPostParmsCheck("ID"))
  8970. {
  8971. int eid = GetPostInt("ID");
  8972. CeErpReturnCash entity = null;
  8973. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8974. if (entity != null)
  8975. {
  8976. if (entity.cashstate == 1)
  8977. {
  8978. returnErrorMsg("审核通过了不能改");
  8979. return;
  8980. }
  8981. entity.returnprice = GetPostDouble("returnprice");
  8982. entity.Update();
  8983. returnSuccessMsg("修改成功!");
  8984. return;
  8985. }
  8986. returnErrorMsg("找不到订单记录");
  8987. }
  8988. }
  8989. public void del_erp_returncash()
  8990. {
  8991. if (UrlPostParmsCheck("ID"))
  8992. {
  8993. int eid = GetPostInt("ID");
  8994. CeErpReturnCash.Del(eid);
  8995. returnSuccessMsg("操作成功");
  8996. return;
  8997. }
  8998. }
  8999. public void test_for_do_sql()
  9000. {
  9001. string sql = GetPostString("sqlstr");
  9002. if (sql.Length > 0)
  9003. {
  9004. try
  9005. {
  9006. DbHelper.DbConn.ExecuteNonQuery(sql);
  9007. var res_obj = new
  9008. {
  9009. data = "成功",
  9010. };
  9011. string ro_json = JsonConvert.SerializeObject(res_obj);
  9012. returnSuccess(ro_json);
  9013. }
  9014. catch (Exception ex)
  9015. {
  9016. var res_obj = new
  9017. {
  9018. data = ex.Message,
  9019. };
  9020. string ro_json = JsonConvert.SerializeObject(res_obj);
  9021. returnSuccess(ro_json);
  9022. }
  9023. }
  9024. }
  9025. public void get_user_info()
  9026. {
  9027. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9028. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9029. }
  9030. public void get_total_data()
  9031. {
  9032. int userId = CurrentUser.UserID;
  9033. string sql = "";
  9034. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9035. {
  9036. 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);
  9037. }
  9038. else
  9039. {
  9040. 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 " +
  9041. "(select ID from CE_ErpUser where ID = {0}) d " +
  9042. "left join " +
  9043. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9044. ") a on d.ID = a.id left join " +
  9045. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9046. ") b on a.id = b.id1 left join" +
  9047. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9048. ") c on a.id = c.id2;", userId);
  9049. }
  9050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9051. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9052. }
  9053. public void get_date_area_total_data2()
  9054. {
  9055. int userId = CurrentUser.UserID;
  9056. string date_type = GetPostString("timetype");
  9057. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9058. string sql = "";
  9059. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9060. {
  9061. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9062. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9063. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9064. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9065. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9066. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9067. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9068. ") a on e.ID = a.id left join " +
  9069. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9070. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9071. ") b on a.id = b.id1 " +
  9072. "left join " +
  9073. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9074. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9075. ") c on a.id = c.id2 " +
  9076. "left join " +
  9077. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9078. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9079. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9080. }
  9081. else
  9082. {
  9083. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9084. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9085. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9086. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9087. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9088. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9089. ") a on e.ID = a.id left join " +
  9090. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9091. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9092. ") c on a.id = c.id2 " +
  9093. "left join " +
  9094. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9095. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9096. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9097. }
  9098. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9099. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9100. }
  9101. public void get_date_area_total_data()
  9102. {
  9103. int userId = CurrentUser.UserID;
  9104. string date_type = GetPostString("timetype");
  9105. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9106. string date1 = searchDT[0].ToString();
  9107. string date2 = searchDT[1].ToString();
  9108. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9109. {
  9110. SqlParameter[] sqlParameter ={
  9111. new SqlParameter("@userId", SqlDbType.Int,4),
  9112. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9113. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9114. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9115. };
  9116. sqlParameter[0].Value = userId;
  9117. sqlParameter[1].Value = date1;
  9118. sqlParameter[2].Value = date2;
  9119. sqlParameter[3].Direction = ParameterDirection.Output;
  9120. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9121. string res = sqlParameter[3].Value.ToString();
  9122. var res_obj = new
  9123. {
  9124. data = res
  9125. };
  9126. string ro_json = JsonConvert.SerializeObject(res_obj);
  9127. returnSuccess(ro_json);
  9128. }
  9129. else
  9130. {
  9131. SqlParameter[] sqlParameter ={
  9132. new SqlParameter("@userId", SqlDbType.Int,4),
  9133. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9134. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9135. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9136. };
  9137. sqlParameter[0].Value = userId;
  9138. sqlParameter[1].Value = date1;
  9139. sqlParameter[2].Value = date2;
  9140. sqlParameter[3].Direction = ParameterDirection.Output;
  9141. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9142. string res = sqlParameter[3].Value.ToString();
  9143. var res_obj = new
  9144. {
  9145. data = res
  9146. };
  9147. string ro_json = JsonConvert.SerializeObject(res_obj);
  9148. returnSuccess(ro_json);
  9149. }
  9150. //writeGridDataViewJson(dt.Rows.Count, dv);
  9151. }
  9152. public void get_order_list()
  9153. {
  9154. string strFields = GetPostString("paraFields");
  9155. string strOrder = GetPostString("paraOrder");
  9156. string strWhere = GetPostString("paraWhere");
  9157. string strPageSize = GetPostString("paraPageSize");
  9158. DataStruct dStruct = GetPostStruct();
  9159. dStruct.PageSize = int.Parse(strPageSize);
  9160. dStruct.Fileds = strFields;
  9161. dStruct.Order = strOrder;
  9162. dStruct.MainWhere = strWhere;
  9163. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9164. writeGridDataTableJson(dStruct.TotalCount, dt);
  9165. }
  9166. ////获取待开始订单列表
  9167. //public void get_wait_design_order_list()
  9168. //{
  9169. // string date_type = GetPostString("date_type");
  9170. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9171. // DataStruct dStruct = GetPostStruct();
  9172. // dStruct.PageSize = 1000;
  9173. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9174. // List<string> lw = new List<string>();
  9175. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9176. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9177. // dStruct.Order = "WaitDesignTime asc";
  9178. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9179. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9180. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9181. //}
  9182. //获取完成单量排名
  9183. public void get_finish_order_count_ranking()
  9184. {
  9185. /* string date_type = GetPostString("date_type");
  9186. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9187. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9188. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9189. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9190. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9191. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9192. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9193. writeGridDataTableJson(0, new DataTable());
  9194. }
  9195. public void get_finish_order_amount_ranking()
  9196. {
  9197. /*string date_type = GetPostString("date_type");
  9198. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9199. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9200. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9201. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9202. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9203. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9204. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9205. writeGridDataTableJson(0, new DataTable());
  9206. }
  9207. public void get_finish_refund_count_ranking()
  9208. {
  9209. string date_type = GetPostString("date_type");
  9210. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9211. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9212. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9213. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9214. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9215. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9216. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9217. writeGridDataTableJson(dt.Rows.Count, dt);
  9218. }
  9219. public void get_finish_refund_amount_ranking()
  9220. {
  9221. string date_type = GetPostString("date_type");
  9222. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9223. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9224. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9225. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9226. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9227. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9228. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9229. writeGridDataTableJson(dt.Rows.Count, dt);
  9230. }
  9231. public void set_erp_finishorder_director()
  9232. {
  9233. if (UrlPostParmsCheck("ctid"))
  9234. {
  9235. string eid = GetPostString("ctid");
  9236. CeErpTradeCell entity = null;
  9237. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9238. if (entity != null)
  9239. {
  9240. entity.OrderState = 8;
  9241. entity.Update();
  9242. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9243. returnSuccessMsg("操作成功!");
  9244. return;
  9245. }
  9246. returnErrorMsg("找不到记录");
  9247. }
  9248. }
  9249. public void get_erp_placeregistlist()
  9250. {
  9251. DataStruct dStruct = GetPostStruct();
  9252. List<string> lw = new List<string>();
  9253. string outsid = GetPostString("outsid");
  9254. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9255. string memo = GetPostString("memo");
  9256. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9257. string filename = GetPostString("filename");
  9258. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9259. string islate = GetPostString("islate");
  9260. if (islate.Length > 0)
  9261. {
  9262. if (islate == "1")
  9263. lw.Add(string.Format("OutLate>0"));
  9264. else
  9265. lw.Add(string.Format("OutLate=0"));
  9266. }
  9267. string placedate1 = GetPostString("placedate1");
  9268. string placedate2 = GetPostString("placedate2");
  9269. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9270. if (dw.Length > 0) lw.Add(dw);
  9271. string deliveryDate1 = GetPostString("deliverydate1");
  9272. string deliveryDate2 = GetPostString("deliverydate2");
  9273. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9274. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9275. dStruct.Order = "ID desc";
  9276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9277. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9278. writeGridDataTableJson(dStruct.TotalCount, dt);
  9279. }
  9280. public void ins_erp_placeregist()
  9281. {
  9282. if (UrlPostParmsCheck("id"))
  9283. {
  9284. string eid = GetPostString("id");
  9285. CeErpPlaceRegister entity = null;
  9286. if (eid == "0")//新增
  9287. {
  9288. entity = new CeErpPlaceRegister();
  9289. string xdTime = GetPostString("placeTime");
  9290. if (xdTime.Length > 0)
  9291. {
  9292. entity.PlactTime = Convert.ToDateTime(xdTime);
  9293. }
  9294. string fhTime = GetPostString("deliveryTime");
  9295. if (fhTime.Length > 0)
  9296. {
  9297. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9298. }
  9299. string preTime = GetPostString("preOutTime");
  9300. if (preTime.Length > 0)
  9301. {
  9302. entity.PreOutTime = Convert.ToDateTime(preTime);
  9303. }
  9304. entity.DeliveryCount = GetPostInt("deliveryCount");
  9305. entity.ReceiveCount = GetPostInt("receiveCount");
  9306. entity.OutSid = GetPostString("outSid");
  9307. entity.FileName = GetPostString("fileName");
  9308. entity.Memo = GetPostString("memo");
  9309. entity.AddUserId = CurrentUser.UserID;
  9310. entity.CreateTime = DateTime.Now;
  9311. entity.Img = GetPostString("img");
  9312. entity.Supplier = GetPostInt("supplier");
  9313. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9314. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9315. {
  9316. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9317. DateTime dt2 = (DateTime)entity.PreOutTime;
  9318. TimeSpan span = dt1.Subtract(dt2);
  9319. if (span.Days > 0)
  9320. {
  9321. entity.OutLate = span.Days;
  9322. }
  9323. }
  9324. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9325. entity.Create();
  9326. returnSuccessMsg("添加成功!");
  9327. return;
  9328. }
  9329. else //修改
  9330. {
  9331. entity = CeErpPlaceRegister.Get(eid);
  9332. if (entity != null)
  9333. {
  9334. string xdTime = GetPostString("placeTime");
  9335. if (xdTime.Length > 0)
  9336. {
  9337. entity.PlactTime = Convert.ToDateTime(xdTime);
  9338. }
  9339. string fhTime = GetPostString("deliveryTime");
  9340. if (fhTime.Length > 0)
  9341. {
  9342. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9343. }
  9344. string preTime = GetPostString("preOutTime");
  9345. if (preTime.Length > 0)
  9346. {
  9347. entity.PreOutTime = Convert.ToDateTime(preTime);
  9348. }
  9349. entity.DeliveryCount = GetPostInt("deliveryCount");
  9350. entity.ReceiveCount = GetPostInt("receiveCount");
  9351. if (entity.DeliveryCount == entity.ReceiveCount)
  9352. {
  9353. entity.CurState = "已完成";
  9354. }
  9355. else
  9356. {
  9357. entity.CurState = "未完成";
  9358. }
  9359. entity.OutSid = GetPostString("outSid");
  9360. entity.FileName = GetPostString("fileName");
  9361. entity.Memo = GetPostString("memo");
  9362. entity.Img = GetPostString("img");
  9363. entity.Supplier = GetPostInt("supplier");
  9364. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9365. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9366. {
  9367. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9368. DateTime dt2 = (DateTime)entity.PreOutTime;
  9369. TimeSpan span = dt1.Subtract(dt2);
  9370. if (span.Days > 0)
  9371. {
  9372. entity.OutLate = span.Days;
  9373. }
  9374. }
  9375. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9376. entity.Update();
  9377. returnSuccessMsg("修改成功");
  9378. return;
  9379. }
  9380. returnErrorMsg("找不到对应的记录");
  9381. return;
  9382. }
  9383. }
  9384. returnErrorMsg("缺少必要参数");
  9385. }
  9386. public void del_erp_placeregist()
  9387. {
  9388. string eid = GetPostString("id");
  9389. CeErpPlaceRegister.Del(eid);
  9390. returnSuccessMsg("删除成功!");
  9391. return;
  9392. }
  9393. public void ins_erp_placeregistbyorder()
  9394. {
  9395. string ctid = GetPostString("ctid");
  9396. if (ctid.Length > 0)
  9397. {
  9398. StringBuilder sql = new StringBuilder();
  9399. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9400. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9401. if (dt.Rows.Count > 0)
  9402. {
  9403. foreach (DataRow dr in dt.Rows)
  9404. {
  9405. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9406. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9407. entity.AddUserId = CurrentUser.UserID;
  9408. entity.tid = dr["tid"].ToString();
  9409. entity.Did = Convert.ToString(dr["ctid"]);
  9410. entity.splitTag = dr["SplitTag"].ToString();
  9411. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9412. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9413. if (pre_ctid.Length > 0)
  9414. {
  9415. sellmemo = sellmemo.Replace(pre_ctid, "");
  9416. }
  9417. sellmemo = sellmemo.Replace("[", "");
  9418. sellmemo = sellmemo.Replace("]", "");
  9419. entity.FileName = sellmemo;
  9420. string count = dr["ProductCount"].ToString();
  9421. int usecount = commonHelper.getIntCountFromString(count);
  9422. entity.DeliveryCount = usecount;
  9423. entity.CurState = "未完成";
  9424. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9425. {
  9426. entity.Supplier = 24;//dl手提袋定制
  9427. }
  9428. else
  9429. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9430. entity.CreateTime = DateTime.Now;
  9431. entity.Create();
  9432. }
  9433. returnSuccessMsg("操作成功");
  9434. return;
  9435. }
  9436. returnErrorMsg("没有找到对应订单");
  9437. return;
  9438. }
  9439. returnErrorMsg("缺少订单编号");
  9440. return;
  9441. }
  9442. public void get_erp_persuadelist()
  9443. {
  9444. DataStruct dStruct = GetPostStruct();
  9445. List<string> lw = new List<string>();
  9446. string ctid = GetPostString("ctid");
  9447. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9448. string shopname = GetPostString("shopname");
  9449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9450. string buyernick = GetPostString("buyer_nick");
  9451. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9452. string customer = GetPostString("customer");
  9453. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9454. string returndate1 = GetPostString("returndate1");
  9455. string returndate2 = GetPostString("returndate2");
  9456. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9457. if (dw.Length > 0) lw.Add(dw);
  9458. string finishDate1 = GetPostString("finishdate1");
  9459. string finishDate2 = GetPostString("finishdate2");
  9460. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9461. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9462. string persuadetype = GetPostString("persuadetype");
  9463. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9464. string returnvstate = GetPostString("returnvstate");
  9465. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9466. dStruct.Order = "created desc";
  9467. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9468. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9469. writeGridDataTableJson(dStruct.TotalCount, dt);
  9470. }
  9471. public void upd_erp_returnpersuadeback()
  9472. {
  9473. if (UrlPostParmsCheck("ID"))
  9474. {
  9475. int eid = GetPostInt("ID");
  9476. CeErpPersuade entity = null;
  9477. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9478. if (entity != null)
  9479. {
  9480. entity.backreason = GetPostString("reason");
  9481. entity.pstate = 2;
  9482. entity.verifytime = DateTime.Now;
  9483. entity.verifyuserid = CurrentUser.UserID;
  9484. entity.Update();
  9485. returnSuccessMsg("退回成功!");
  9486. return;
  9487. }
  9488. returnErrorMsg("找不到订单记录");
  9489. }
  9490. }
  9491. public void upd_erp_returnpersuadeverify()
  9492. {
  9493. if (UrlPostParmsCheck("ID"))
  9494. {
  9495. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9496. {
  9497. returnErrorMsg("暂无权限审核");
  9498. return;
  9499. }
  9500. int eid = GetPostInt("ID");
  9501. CeErpPersuade entity = null;
  9502. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9503. if (entity != null)
  9504. {
  9505. entity.pstate = 1;
  9506. entity.verifytime = DateTime.Now;
  9507. entity.verifyuserid = CurrentUser.UserID;
  9508. entity.Update();
  9509. returnSuccessMsg("审核成功!");
  9510. return;
  9511. }
  9512. returnErrorMsg("找不到订单记录");
  9513. }
  9514. }
  9515. public void del_erp_persuade()
  9516. {
  9517. if (UrlPostParmsCheck("ID"))
  9518. {
  9519. int eid = GetPostInt("ID");
  9520. CeErpPersuade.Del(eid);
  9521. returnSuccessMsg("操作成功");
  9522. return;
  9523. }
  9524. }
  9525. public void get_erp_oldcustoupload()
  9526. {
  9527. DataStruct dStruct = GetPostStruct();
  9528. List<string> lw = new List<string>();
  9529. string buyernick = GetPostString("buyer_nick");
  9530. if (buyernick.Length > 0)
  9531. {
  9532. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9533. }
  9534. else
  9535. return;
  9536. dStruct.Order = "pay_time desc";
  9537. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9538. DataTable dt = null;
  9539. dt = WebCache.GetData("view_erptradecell", dStruct);
  9540. writeGridDataTableJson(dStruct.TotalCount, dt);
  9541. }
  9542. public void get_erp_checkorderlist()
  9543. {
  9544. DataStruct dStruct = GetPostStruct();
  9545. List<string> lw = new List<string>();
  9546. string tid = GetPostString("ctid");
  9547. if (tid.Length > 0)
  9548. {
  9549. string select_tid = getTidByCtid(tid);
  9550. lw.Add(string.Format("tid='{0}'", select_tid));
  9551. }
  9552. string shopname = GetPostString("shopname");
  9553. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9554. string buyernick = GetPostString("buyer_nick");
  9555. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9556. string customer = GetPostString("customer");
  9557. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9558. string design = GetPostString("design");
  9559. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9560. string orderState = GetPostString("orderState");
  9561. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9562. string address = GetPostString("address");
  9563. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9564. string sellermemo = GetPostString("seller_memo");
  9565. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9566. string supplier = GetPostString("supplier");
  9567. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9568. {
  9569. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9570. }
  9571. else
  9572. {
  9573. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9574. }
  9575. string date1 = GetPostString("date1");
  9576. string date2 = GetPostString("date2");
  9577. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9578. if (dw.Length > 0) lw.Add(dw);
  9579. string placedate1 = GetPostString("placedate1");
  9580. string placedate2 = GetPostString("placedate2");
  9581. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9582. if (fdw.Length > 0) lw.Add(fdw);
  9583. string price1 = GetPostString("price1");
  9584. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9585. string price2 = GetPostString("price2");
  9586. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9587. string checkst = GetPostString("checkstate");
  9588. if (checkst.Length > 0 && "10".Equals(checkst))
  9589. {
  9590. lw.Add(string.Format("CheckOut>0"));
  9591. }
  9592. else
  9593. {
  9594. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9595. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9596. }
  9597. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9598. {
  9599. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9600. }
  9601. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9602. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9603. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9604. writeGridDataTableJson(dStruct.TotalCount, dt);
  9605. }
  9606. public void ins_erp_startCheck()
  9607. {
  9608. if (UrlPostParmsCheck("ctid"))
  9609. {
  9610. string eid = GetPostString("ctid");
  9611. CeErpTradeCell entity = null;
  9612. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9613. if (entity != null)
  9614. {
  9615. entity.MemoOpt = 4;
  9616. entity.UpdateTime = DateTime.Now;
  9617. entity.Update();
  9618. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9619. CeErpSukuraData.createInfo(entity.ctid, 6);
  9620. returnSuccessMsg("操作成功!");
  9621. return;
  9622. }
  9623. returnErrorMsg("找不到记录");
  9624. }
  9625. }
  9626. public void upd_erp_sendXlw()
  9627. {
  9628. if (UrlPostParmsCheck("ctid"))
  9629. {
  9630. string eid = GetPostString("ctid");
  9631. CeErpTradeCell entity = null;
  9632. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9633. if (entity != null)
  9634. {
  9635. if (entity.IsSendGift == 1)
  9636. {
  9637. returnErrorMsg("请勿重复标记");
  9638. return;
  9639. }
  9640. entity.IsSendGift = 1;
  9641. entity.Update();
  9642. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9643. returnSuccessMsg("操作成功!");
  9644. return;
  9645. }
  9646. returnErrorMsg("找不到记录");
  9647. }
  9648. }
  9649. public void cancel_sendXlw()
  9650. {
  9651. if (UrlPostParmsCheck("ctid"))
  9652. {
  9653. string eid = GetPostString("ctid");
  9654. CeErpTradeCell entity = null;
  9655. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9656. if (entity != null)
  9657. {
  9658. if (entity.IsSendGift == 0)
  9659. {
  9660. returnErrorMsg("未标记小礼物");
  9661. return;
  9662. }
  9663. entity.IsSendGift = 0;
  9664. entity.Update();
  9665. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9666. returnSuccessMsg("操作成功!");
  9667. return;
  9668. }
  9669. returnErrorMsg("找不到记录");
  9670. }
  9671. }
  9672. public void get_erp_designbill()
  9673. {
  9674. DataStruct dStruct = GetPostStruct();
  9675. List<string> lw = new List<string>();
  9676. int isMy = GetInt("my");
  9677. if (isMy == 1)
  9678. {
  9679. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9680. }
  9681. string tid = GetPostString("tid");
  9682. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9683. string userName = GetPostString("design");
  9684. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9685. string price1 = GetPostString("price1");
  9686. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9687. string price2 = GetPostString("price2");
  9688. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9689. string rePrice1 = GetPostString("rePrice1");
  9690. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9691. string rePrice2 = GetPostString("rePrice2");
  9692. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9693. string designerType = GetPostString("designerType");
  9694. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9695. string orderState = GetPostString("orderState");
  9696. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9697. string endTime1 = GetPostString("endTime1");
  9698. string endTime2 = GetPostString("endTime2");
  9699. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9700. if (dw.Length > 0) lw.Add(dw);
  9701. string isDk = GetPostString("isDk");
  9702. if (isDk == "1")
  9703. {
  9704. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9705. }
  9706. else if (isDk == "0")
  9707. {
  9708. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9709. }
  9710. dStruct.Order = "oid, create_time desc";
  9711. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9712. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9713. writeGridDataTableJson(dStruct.TotalCount, dt);
  9714. }
  9715. public void upd_erp_designerbill()
  9716. {
  9717. if (UrlPostParmsCheck("ID"))
  9718. {
  9719. string eid = GetPostString("ID");
  9720. CeErpDesignerBill entity = null;
  9721. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9722. if (entity != null)
  9723. {
  9724. if (GetPostDouble("designerpirce") > 0)
  9725. {
  9726. entity.realPrice = GetPostDouble("designerpirce");
  9727. entity.update_time = DateTime.Now;
  9728. entity.update_u_id = CurrentUser.UserID;
  9729. entity.update_u_name = CurrentUser.UserName;
  9730. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9731. entity.Update();
  9732. returnSuccessMsg("操作成功!");
  9733. return;
  9734. }
  9735. else
  9736. {
  9737. entity.price = GetPostDouble("price");
  9738. entity.update_time = DateTime.Now;
  9739. entity.update_u_id = CurrentUser.UserID;
  9740. entity.update_u_name = CurrentUser.UserName;
  9741. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9742. entity.Update();
  9743. returnSuccessMsg("操作成功!");
  9744. return;
  9745. }
  9746. }
  9747. returnErrorMsg("找不到记录");
  9748. }
  9749. }
  9750. public void audit_erp_designerbill()
  9751. {
  9752. if (UrlPostParmsCheck("ID"))
  9753. {
  9754. string eid = GetPostString("ID");
  9755. CeErpDesignerBill entity = null;
  9756. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9757. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9758. if (entity != null)
  9759. {
  9760. entity.realPrice = GetPostDouble("designerpirce");
  9761. entity.update_time = DateTime.Now;
  9762. entity.update_u_id = CurrentUser.UserID;
  9763. entity.update_u_name = CurrentUser.UserName;
  9764. entity.isAudit = 1;
  9765. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9766. entity.Update();
  9767. if (orderEntity != null)
  9768. {
  9769. orderEntity.IsReadTag = 3;
  9770. orderEntity.Update();
  9771. }
  9772. returnSuccessMsg("操作成功!");
  9773. return;
  9774. }
  9775. returnErrorMsg("找不到记录");
  9776. }
  9777. }
  9778. public void all_audit_erp_designerbill()
  9779. {
  9780. if (UrlPostParmsCheck("idList"))
  9781. {
  9782. string[] list = GetPostString("idList").Split(',');
  9783. CeErpDesignerBill entity = null;
  9784. for (int i = 0; i < list.Length; i++)
  9785. {
  9786. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9787. if (entity == null) return;
  9788. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9789. if (orderEntity == null) return;
  9790. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9791. entity.update_time = DateTime.Now;
  9792. entity.update_u_id = CurrentUser.UserID;
  9793. entity.update_u_name = CurrentUser.UserName;
  9794. entity.isAudit = 1;
  9795. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9796. entity.Update();
  9797. orderEntity.IsReadTag = 3;
  9798. orderEntity.Update();
  9799. }
  9800. returnSuccessMsg("操作成功!");
  9801. return;
  9802. }
  9803. }
  9804. public void get_erp_sameorders()
  9805. {
  9806. if (UrlPostParmsCheck("ctid"))
  9807. {
  9808. string eid = GetPostString("ctid");
  9809. CeErpTradeCell entity = null;
  9810. entity = CeErpTradeCell.GetByCtid(eid);
  9811. if (entity != null)
  9812. {
  9813. StringBuilder sql = new StringBuilder();
  9814. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9815. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9816. var res = new
  9817. {
  9818. data = dt.Rows.Count
  9819. };
  9820. string ro_jsond = JsonConvert.SerializeObject(res);
  9821. returnSuccess(ro_jsond);
  9822. return;
  9823. }
  9824. returnErrorMsg("未找到订单");
  9825. return;
  9826. }
  9827. returnErrorMsg("缺少必要的参数");
  9828. }
  9829. public void get_erp_islasthavesameorder()
  9830. {
  9831. if (UrlPostParmsCheck("ctid"))
  9832. {
  9833. string eid = GetPostString("ctid");
  9834. string[] ctidList = eid.Split(',');
  9835. StringBuilder sql = new StringBuilder();
  9836. string tisCtid = "";
  9837. foreach (string ctid in ctidList)
  9838. {
  9839. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9840. if (entity != null)
  9841. {
  9842. sql = new StringBuilder();
  9843. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9844. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9845. if (dth.Rows.Count > 0)
  9846. {
  9847. tisCtid += entity.ctid;
  9848. tisCtid += ",";
  9849. }
  9850. }
  9851. }
  9852. if (tisCtid.Length > 0)
  9853. {
  9854. var res = new
  9855. {
  9856. data = tisCtid
  9857. };
  9858. string ro_jsond = JsonConvert.SerializeObject(res);
  9859. returnSuccess(ro_jsond);
  9860. }
  9861. else
  9862. {
  9863. var res = new
  9864. {
  9865. data = ""
  9866. };
  9867. string ro_jsond = JsonConvert.SerializeObject(res);
  9868. returnSuccess(ro_jsond);
  9869. }
  9870. return;
  9871. }
  9872. returnErrorMsg("缺少必要的参数");
  9873. }
  9874. public void file_client_down_url()
  9875. {
  9876. if (!UrlPostParmsCheck("userId"))
  9877. {
  9878. returnErrorMsg("缺少必要的参数");
  9879. }
  9880. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9881. }
  9882. public void checkout_form_data()
  9883. {
  9884. if (!UrlPostParmsCheck("tid"))
  9885. {
  9886. returnErrorMsg("缺少必要的参数");
  9887. }
  9888. string tid = GetPostString("tid");
  9889. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9890. if (ceErpOrderFormData != null)
  9891. {
  9892. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9893. returnSuccess(ro_jsond);
  9894. return;
  9895. }
  9896. returnErrorMsg("尚未有文件!");
  9897. }
  9898. public void back_supplier_audit()
  9899. {
  9900. int userId = CurrentUser.UserID;
  9901. StringBuilder sql = new StringBuilder();
  9902. 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);
  9903. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9904. if (dt.Rows.Count > 0)
  9905. {
  9906. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9907. }
  9908. else
  9909. {
  9910. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9911. }
  9912. }
  9913. public void back_supplier_query()
  9914. {
  9915. string eid = GetPostString("ctid");
  9916. if (eid != "")
  9917. {
  9918. StringBuilder sql = new StringBuilder();
  9919. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9920. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9921. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9922. }
  9923. else
  9924. {
  9925. returnErrorMsg("找不到订单记录");
  9926. return;
  9927. }
  9928. }
  9929. public void verified_to_order()
  9930. {
  9931. int userId = CurrentUser.UserID;
  9932. StringBuilder sql = new StringBuilder();
  9933. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9934. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9935. if (dt.Rows.Count > 0)
  9936. {
  9937. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9938. }
  9939. else
  9940. {
  9941. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9942. }
  9943. }
  9944. public void upd_supplier_audit()
  9945. {
  9946. if (UrlPostParmsCheck("ctid"))
  9947. {
  9948. string eid = GetPostString("ctid");
  9949. string reason = GetPostString("returnreason");
  9950. CeErpTradeCell entity = null;
  9951. CeWithdraw withdraw = null;
  9952. withdraw = CeWithdraw.GetByTid(eid);
  9953. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9954. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9955. {
  9956. if (withdraw != null)
  9957. {
  9958. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9959. {
  9960. returnSuccessMsg("您没有权限操作!");
  9961. return;
  9962. }
  9963. else
  9964. {
  9965. if (reason.Equals("1"))
  9966. {
  9967. if (entity.OrderState == -1)
  9968. {
  9969. if (entity.FinishPlaceTime == null)
  9970. {
  9971. entity.OrderState = 2;
  9972. }
  9973. else
  9974. {
  9975. entity.OrderState = 6;
  9976. }
  9977. }
  9978. entity.Update();
  9979. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9980. if (withdraw != null)
  9981. {
  9982. withdraw.status = int.Parse(reason);
  9983. withdraw.Update();
  9984. }
  9985. returnSuccessMsg("操作成功!");
  9986. return;
  9987. }
  9988. else
  9989. {
  9990. withdraw.status = int.Parse(reason);
  9991. withdraw.acknowledgingtime = DateTime.Now;
  9992. withdraw.Update();
  9993. returnSuccessMsg("查看详细请点击线下订单查询");
  9994. return;
  9995. }
  9996. }
  9997. }
  9998. // 第一个字符是 'N'
  9999. }
  10000. if (eid[0] != 'N')
  10001. {
  10002. }
  10003. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10004. {
  10005. entity.IsVerifyToSupplier = false;
  10006. entity.IsReturn = 1;
  10007. entity.ReturnTime = DateTime.Now;
  10008. entity.ReturnReason = reason;
  10009. if (entity.OrderState == 6)
  10010. {
  10011. entity.OrderState = 5;
  10012. }
  10013. entity.Update();
  10014. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10015. if (withdraw != null)
  10016. {
  10017. withdraw.status = int.Parse(reason);
  10018. withdraw.Update();
  10019. }
  10020. returnSuccessMsg("操作成功!");
  10021. return;
  10022. }
  10023. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10024. {
  10025. ;
  10026. if (withdraw != null)
  10027. {
  10028. withdraw.status = int.Parse(reason);
  10029. withdraw.acknowledgingtime = DateTime.Now;
  10030. withdraw.Update();
  10031. returnSuccessMsg("供应商取消撤回!");
  10032. return;
  10033. }
  10034. }
  10035. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10036. {
  10037. if (entity.OrderState == -1)
  10038. {
  10039. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10040. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10041. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10042. {
  10043. returnErrorMsg("台湾客户需填写身份证!");
  10044. return;
  10045. }
  10046. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10047. {
  10048. returnErrorMsg("偏远地区需要填写物流费!");
  10049. return;
  10050. }
  10051. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10052. {
  10053. returnErrorMsg("订单spu没有确认无法通过审核!");
  10054. return;
  10055. }
  10056. if (entity.FinishPlaceTime == null)
  10057. {
  10058. entity.OrderState = 2;
  10059. }
  10060. else
  10061. {
  10062. entity.OrderState = 3;
  10063. }
  10064. commonHelper.getCytPrice(entity);
  10065. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10066. {
  10067. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10068. }
  10069. }
  10070. entity.Update();
  10071. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10072. if (withdraw != null)
  10073. {
  10074. withdraw.status = int.Parse(reason);
  10075. withdraw.Update();
  10076. }
  10077. returnSuccessMsg("操作成功!");
  10078. return;
  10079. }
  10080. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10081. {
  10082. if (withdraw == null)
  10083. {
  10084. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10085. return;
  10086. }
  10087. }
  10088. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10089. {
  10090. if (withdraw != null)
  10091. {
  10092. withdraw.status = int.Parse(reason);
  10093. withdraw.acknowledgingtime = DateTime.Now;
  10094. withdraw.Update();
  10095. returnSuccessMsg("查看详细请点击线下订单查询");
  10096. return;
  10097. }
  10098. }
  10099. return;
  10100. }
  10101. }
  10102. //校验报价
  10103. public void refund_order_tip()
  10104. {
  10105. int userid = CurrentUser.UserID;
  10106. int sectionId = CurrentUser.UserPost.OrgID;
  10107. StringBuilder sql = new StringBuilder();
  10108. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10109. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10110. List<string> ids = new List<string>();
  10111. if (dth.Rows.Count > 0)
  10112. {
  10113. foreach (DataRow dr in dth.Rows)
  10114. {
  10115. ids.Add(dr["ID"].ToString());
  10116. }
  10117. try
  10118. {
  10119. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10120. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10121. }
  10122. catch (Exception ex)
  10123. {
  10124. }
  10125. }
  10126. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10127. }
  10128. public void refund_order_Design()
  10129. {
  10130. int userid = CurrentUser.UserID;
  10131. int sectionId = CurrentUser.UserPost.OrgID;
  10132. StringBuilder sql = new StringBuilder();
  10133. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10134. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10135. List<string> ids = new List<string>();
  10136. if (dth.Rows.Count > 0)
  10137. {
  10138. foreach (DataRow dr in dth.Rows)
  10139. {
  10140. ids.Add(dr["ID"].ToString());
  10141. }
  10142. try
  10143. {
  10144. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10145. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10146. }
  10147. catch (Exception ex)
  10148. {
  10149. }
  10150. }
  10151. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10152. }
  10153. public void change_order_info()
  10154. {
  10155. int userid = CurrentUser.UserID;
  10156. StringBuilder sql = new StringBuilder();
  10157. 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);
  10158. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10159. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10160. }
  10161. public void change_win_mome()
  10162. {
  10163. if (UrlPostParmsCheck("id,ctid"))
  10164. {
  10165. string id = GetPostString("id");
  10166. string ctid = GetPostString("ctid");
  10167. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10168. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10169. if (ce == null || ceErpMessageTip == null)
  10170. {
  10171. returnSuccessMsg("未找到对应的订单!");
  10172. return;
  10173. }
  10174. if (ce.OrderState >= 5)
  10175. {
  10176. ceErpMessageTip.isVisit = true;
  10177. ceErpMessageTip.Update();
  10178. returnSuccessMsg("已上传文件无法修改!");
  10179. return;
  10180. }
  10181. int type = GetPostInt("type");
  10182. string content = GetPostString("content");
  10183. if (type == 0)
  10184. {
  10185. content = content.Replace("(", "(");
  10186. content = content.Replace(")", ")");
  10187. string check = MidStrEx(content, "(", ")").Trim();
  10188. if (string.IsNullOrEmpty(check))
  10189. {
  10190. returnSuccessMsg("文件名格式不正确");
  10191. return;
  10192. }
  10193. }
  10194. ce.seller_memo = content;
  10195. ce.Update();
  10196. ceErpMessageTip.isVisit = true;
  10197. ceErpMessageTip.Update();
  10198. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10199. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10200. ApiVo apiVo = new ApiVo();
  10201. apiVo.orderNumber = ce.ctid;
  10202. apiVo.actionName = "demandDesign";
  10203. apiVo.orderRemarks = content;
  10204. apiVo.demandExamine = type + 1;
  10205. designHelper.API_WorkCore(apiVo);//demandDesign
  10206. returnSuccessMsg("修改成功!");
  10207. }
  10208. }
  10209. public static string MidStrEx(string sourse, string startstr, string endstr)
  10210. {
  10211. string result = string.Empty;
  10212. int startindex, endindex;
  10213. try
  10214. {
  10215. startindex = sourse.IndexOf(startstr);
  10216. if (startindex == -1)
  10217. return result;
  10218. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10219. endindex = tmpstr.IndexOf(endstr);
  10220. if (endindex == -1)
  10221. return result;
  10222. result = tmpstr.Remove(endindex);
  10223. }
  10224. catch (Exception ex)
  10225. {
  10226. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10227. }
  10228. return result;
  10229. }
  10230. public void refund_order_list()
  10231. {
  10232. int userid = CurrentUser.UserID;
  10233. int sectionId = CurrentUser.UserPost.OrgID;
  10234. StringBuilder sql = new StringBuilder();
  10235. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10236. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10237. DataStruct dStruct = GetPostStruct();
  10238. DataTable dt = null;
  10239. List<string> ids = new List<string>();
  10240. List<string> tids = new List<string>();
  10241. if (dth.Rows.Count > 0)
  10242. {
  10243. foreach (DataRow dr in dth.Rows)
  10244. {
  10245. tids.Add("'" + dr["tid"].ToString() + "'");
  10246. ids.Add(dr["id"].ToString());
  10247. }
  10248. try
  10249. {
  10250. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10251. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10252. List<string> lw = new List<string>();
  10253. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10254. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10255. dt = WebCache.GetData("view_orderlist", dStruct);
  10256. }
  10257. catch (Exception ex)
  10258. {
  10259. }
  10260. }
  10261. writeGridDataTableJson(dStruct.TotalCount, dt);
  10262. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10263. }
  10264. //新增
  10265. public void order_batch_downloads()
  10266. {
  10267. string ceid = GetPostString("tid");
  10268. String[] tid = ceid.Split(',');
  10269. order_batch_caiyingtong(tid);
  10270. /* (string success, string errors) = UploadFiles(tid);
  10271. returnSuccessMsg(success + errors);*/
  10272. return;
  10273. }
  10274. //报价接口
  10275. public void Get_To_Quote()
  10276. {
  10277. string ceid = GetPostString("ctid");
  10278. if (ceid != null)
  10279. {
  10280. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10281. if (entity != null)
  10282. {
  10283. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10284. {
  10285. return;
  10286. }
  10287. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10288. double price = 0;
  10289. if (cp == null)
  10290. {
  10291. JObject jsonObject12 = new JObject
  10292. {
  10293. { "UserId", "77886" },
  10294. { "Pwd", "lt666888" },
  10295. { "Filename", entity.seller_memo }
  10296. };
  10297. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10298. JObject jsonObjects1 = JObject.Parse(response1);
  10299. string ms1g = (string)jsonObjects1["msg"];
  10300. if (ms1g == "报价成功")
  10301. {
  10302. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10303. string data = (string)jsonObject1["price"];
  10304. 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 + "');";
  10305. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10306. returnSuccessMsg("获取报价成功:" + data);
  10307. price = Convert.ToDouble(data);
  10308. }
  10309. else
  10310. {
  10311. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10312. return;
  10313. }
  10314. }
  10315. String[] beizhu = entity.seller_memo.Split('-');
  10316. String chanp = "";
  10317. if (beizhu.Length > 0)
  10318. {
  10319. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10320. }
  10321. else
  10322. {
  10323. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10324. }
  10325. JObject jsonObject = new JObject
  10326. {
  10327. { "UserId", "77886" },
  10328. { "Pwd", "lt666888" },
  10329. { "Filename", chanp }
  10330. };
  10331. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10332. JObject jsonObjects = JObject.Parse(response);
  10333. string msg = (string)jsonObjects["msg"];
  10334. if (msg == "报价成功")
  10335. {
  10336. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10337. string data = (string)jsonObject1["price"];
  10338. 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 + "');";
  10339. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10340. returnSuccessMsg("获取报价成功:" + data);
  10341. price = Convert.ToDouble(data);
  10342. }
  10343. else
  10344. {
  10345. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10346. return;
  10347. }
  10348. if (price > 0)
  10349. {
  10350. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10351. if (ceErpTradeCellExtend == null)
  10352. {
  10353. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10354. ceErpTradeCellExtend.ctid = entity.ctid;
  10355. ceErpTradeCellExtend.payment_cyt = price;
  10356. ceErpTradeCellExtend.Create();
  10357. }
  10358. else
  10359. {
  10360. ceErpTradeCellExtend.payment_cyt = price;
  10361. ceErpTradeCellExtend.Update();
  10362. }
  10363. }
  10364. return;
  10365. }
  10366. }
  10367. else
  10368. {
  10369. returnErrorMsg("请至少选择一条数据");
  10370. return;
  10371. }
  10372. }
  10373. //新增
  10374. public void order_To_Supplier()
  10375. {
  10376. string ceid = GetPostString("tid");
  10377. String[] tid = ceid.Split(',');
  10378. if (tid.Length > 0)
  10379. {
  10380. try
  10381. {
  10382. for (int i = 0; i < tid.Length; i++)
  10383. {
  10384. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10385. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10386. entity.SupplierId = suid;
  10387. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10388. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10389. entity.Update();
  10390. }
  10391. }
  10392. catch (Exception ex)
  10393. {
  10394. returnErrorMsg("自动匹配供应商失败");
  10395. return;
  10396. }
  10397. }
  10398. else
  10399. {
  10400. returnErrorMsg("请至少选择一条数据");
  10401. return;
  10402. }
  10403. returnSuccessMsg("自动匹配供应商成功");
  10404. return;
  10405. }
  10406. public (string, string) UploadFiles(string[] urls)
  10407. {
  10408. string success = "";
  10409. string errors = "";
  10410. int userid = CurrentUser.UserID;
  10411. foreach (string url in urls)
  10412. {
  10413. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10414. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10415. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10416. {
  10417. JObject jsonObject = new JObject
  10418. {
  10419. { "Userid", "77886" },
  10420. { "pwd", "cyt86435015" },
  10421. { "content", base64FileContent },
  10422. { "ext", Path.GetExtension(fileName) }
  10423. };
  10424. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10425. JObject jsonObjects = JObject.Parse(response);
  10426. string msg = (string)jsonObjects["msg"];
  10427. if (msg.Equals("上传成功"))
  10428. {
  10429. success += url + " 上传成功";
  10430. }
  10431. else
  10432. {
  10433. errors += url + " 上传失败";
  10434. }
  10435. }
  10436. else
  10437. {
  10438. errors += url + " 格式出现问题";
  10439. }
  10440. }
  10441. if (urls.Length == 0)
  10442. {
  10443. return (success, errors);
  10444. }
  10445. return (success, errors);
  10446. }
  10447. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10448. {
  10449. return true; //总是接受
  10450. }
  10451. public static string HttpPost(string url, string param = null)
  10452. {
  10453. HttpWebRequest request;
  10454. //如果是发送HTTPS请求
  10455. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10456. {
  10457. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10458. request = WebRequest.Create(url) as HttpWebRequest;
  10459. request.ProtocolVersion = HttpVersion.Version10;
  10460. }
  10461. else
  10462. {
  10463. request = WebRequest.Create(url) as HttpWebRequest;
  10464. }
  10465. request.Method = "POST";
  10466. request.ContentType = "application/json";
  10467. request.Accept = "*/*";
  10468. request.Timeout = 120000;
  10469. request.AllowAutoRedirect = false;
  10470. StreamWriter requestStream = null;
  10471. WebResponse response = null;
  10472. string responseStr = null;
  10473. try
  10474. {
  10475. requestStream = new StreamWriter(request.GetRequestStream());
  10476. requestStream.Write(param);
  10477. requestStream.Close();
  10478. response = request.GetResponse();
  10479. if (response != null)
  10480. {
  10481. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10482. responseStr = reader.ReadToEnd();
  10483. reader.Close();
  10484. }
  10485. }
  10486. catch (Exception ex)
  10487. {
  10488. return ex.Message;
  10489. }
  10490. finally
  10491. {
  10492. request = null;
  10493. requestStream = null;
  10494. response = null;
  10495. }
  10496. return responseStr;
  10497. }
  10498. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10499. {
  10500. string base64FileContent;
  10501. string fileName;
  10502. using (WebClient webClient = new WebClient())
  10503. {
  10504. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10505. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10506. {
  10507. using (Stream stream = response.GetResponseStream())
  10508. {
  10509. using (MemoryStream memoryStream = new MemoryStream())
  10510. {
  10511. stream.CopyTo(memoryStream);
  10512. byte[] fileBytes = memoryStream.ToArray();
  10513. base64FileContent = Convert.ToBase64String(fileBytes);
  10514. fileName = response.Headers["Content-Disposition"];
  10515. if (!string.IsNullOrEmpty(fileName))
  10516. {
  10517. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10518. if (index >= 0)
  10519. {
  10520. fileName = fileName.Substring(index + 9).Trim('\"');
  10521. }
  10522. }
  10523. else
  10524. {
  10525. fileName = Path.GetFileName(downloadUrl);
  10526. }
  10527. }
  10528. }
  10529. }
  10530. }
  10531. return (fileName, base64FileContent);
  10532. }
  10533. //新增
  10534. public void order_batch_caiyingtong(string[] downloadUrls)
  10535. {
  10536. try
  10537. {
  10538. //遍历文件
  10539. DataStruct dStruct = GetPostStruct();
  10540. DataTable dt = null;
  10541. int userid = CurrentUser.UserID;
  10542. List<string> ids = new List<string>();//失败组
  10543. List<string> tids = new List<string>();
  10544. using (WebClient webClient = new WebClient())
  10545. {
  10546. foreach (var url in downloadUrls)
  10547. {
  10548. try
  10549. {
  10550. tids.Add("'" + url + "'");
  10551. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10552. if (entity != null)
  10553. {
  10554. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10555. if (cp == null)
  10556. {
  10557. JObject jsonObject = new JObject
  10558. {
  10559. { "Userid", "77886" },
  10560. { "pwd", "lt666888" },
  10561. { "Filename",entity.seller_memo }
  10562. };
  10563. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10564. JObject jsonObjects = JObject.Parse(response);
  10565. string msg = (string)jsonObjects["msg"];
  10566. if (msg == "报价成功")
  10567. {
  10568. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10569. DownloadAndConvertToBase64(url1);
  10570. }
  10571. else
  10572. {
  10573. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10574. }
  10575. }
  10576. else
  10577. {
  10578. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10579. JObject jsonObject = new JObject
  10580. {
  10581. { "Userid", "77886" },
  10582. { "pwd", "lt666888" },
  10583. { "Filename",chanp }
  10584. };
  10585. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10586. JObject jsonObjects = JObject.Parse(response);
  10587. string msg = (string)jsonObjects["msg"];
  10588. if (msg == "报价成功")
  10589. {
  10590. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10591. DownloadAndConvertToBase64(url1);
  10592. }
  10593. else
  10594. {
  10595. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10596. }
  10597. }
  10598. }
  10599. // 上传文件到FTP
  10600. }
  10601. catch (Exception ex)
  10602. {
  10603. Console.WriteLine($"An error occurred: {ex.Message}");
  10604. }
  10605. }
  10606. List<string> lw = new List<string>();
  10607. lw.Add(string.Format("( OrderState < 6 )"));
  10608. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10609. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10610. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10611. if (dt.Rows.Count > 0)
  10612. {
  10613. foreach (DataRow dr in dt.Rows)
  10614. {
  10615. ids.Add(dr["ctid"].ToString());
  10616. }
  10617. }
  10618. String ErrorMsgs = "";
  10619. foreach (String id in ids)
  10620. {
  10621. ErrorMsgs += id + ",";
  10622. }
  10623. if (ErrorMsgs.Length > 1)
  10624. {
  10625. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10626. }
  10627. if (ErrorMsgs.Length < 1)
  10628. {
  10629. ErrorMsgs = "上传成功";
  10630. returnSuccessMsg(ErrorMsgs);
  10631. }
  10632. else
  10633. {
  10634. returnErrorMsg("以下订单" + ErrorMsgs);
  10635. }
  10636. }
  10637. // 删除文件夹及其内容
  10638. /* Directory.Delete(localDirectory, true);*/
  10639. }
  10640. catch { }
  10641. }
  10642. public void get_center_data()
  10643. {
  10644. int userId = CurrentUser.UserID;
  10645. string postCode = CurrentUser.UserPost.Post.Code;
  10646. List<string> lw = new List<string>();
  10647. List<string> ww = new List<string>();
  10648. DateTime currentTime = DateTime.Now;
  10649. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10650. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10651. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10652. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10653. string sql = " SELECT ";
  10654. string startTime = "2023-10-01 11:22:31";
  10655. //设计
  10656. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10657. {
  10658. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10659. 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));
  10660. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10661. 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));
  10662. }
  10663. //客服
  10664. else if (postCode == "CustomerService" || postCode == "Director")
  10665. {
  10666. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10667. 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));
  10668. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10669. 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));
  10670. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10671. 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));
  10672. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10673. 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));
  10674. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10675. 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));
  10676. }
  10677. //售后
  10678. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10679. {
  10680. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10681. 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));
  10682. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10683. 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));
  10684. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10685. 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));
  10686. }
  10687. //下单部
  10688. else if (postCode == "Place" || postCode == "PlaceMr")
  10689. {
  10690. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10691. 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));
  10692. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10693. 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));
  10694. }
  10695. //车间
  10696. else if (postCode == "Supplier")
  10697. {
  10698. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10699. 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));
  10700. }
  10701. DataTable dt = new DataTable();
  10702. if (lw.Count > 0)
  10703. {
  10704. sql += string.Join(" , ", lw);
  10705. sql += " FROM ";
  10706. sql += string.Join(" , ", ww);
  10707. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10708. }
  10709. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10710. }
  10711. public void get_center_data_list()
  10712. {
  10713. int userId = CurrentUser.UserID;
  10714. string postCode = CurrentUser.UserPost.Post.Code;
  10715. string shopIds = CurrentUser.User.pemShop;
  10716. DataStruct dStruct = GetPostStruct();
  10717. List<string> lw = new List<string>();
  10718. DateTime currentTime = DateTime.Now;
  10719. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10720. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10721. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10722. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10723. string startTime = "2023-10-01 11:22:31";
  10724. int order_type = GetPostInt("order_type");
  10725. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10726. {
  10727. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10728. if (order_type == 0)
  10729. {
  10730. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10731. }
  10732. else if (order_type == 3)
  10733. {
  10734. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10735. }
  10736. else
  10737. {
  10738. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10739. }
  10740. }
  10741. //客服
  10742. if (postCode == "CustomerService" || postCode == "Director")
  10743. {
  10744. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10745. if (order_type == 0)
  10746. {
  10747. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10748. }
  10749. else if (order_type == 1)
  10750. {
  10751. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10752. }
  10753. else if (order_type == 2)
  10754. {
  10755. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10756. }
  10757. else if (order_type == 3)
  10758. {
  10759. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10760. }
  10761. else if (order_type == 4)
  10762. {
  10763. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10764. }
  10765. else
  10766. {
  10767. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10768. }
  10769. }
  10770. //售后
  10771. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10772. {
  10773. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10774. if (shopIds != "")
  10775. {
  10776. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10777. }
  10778. if (order_type == 2)
  10779. {
  10780. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10781. }
  10782. else if (order_type == 4)
  10783. {
  10784. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10785. }
  10786. else if (order_type == 5)
  10787. {
  10788. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10789. }
  10790. else
  10791. {
  10792. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10793. }
  10794. }
  10795. //下单部
  10796. if (postCode == "Place" || postCode == "PlaceMr")
  10797. {
  10798. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10799. if (shopIds != "")
  10800. {
  10801. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10802. }
  10803. else if (order_type == 1)
  10804. {
  10805. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10806. }
  10807. else if (order_type == 2)
  10808. {
  10809. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10810. }
  10811. else
  10812. {
  10813. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10814. }
  10815. }
  10816. //车间
  10817. if (postCode == "Supplier")
  10818. {
  10819. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10820. if (order_type == 5)
  10821. {
  10822. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10823. }
  10824. else
  10825. {
  10826. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10827. }
  10828. }
  10829. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10830. dStruct.Fileds = "tid,ctid";
  10831. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10832. writeGridDataTableJson(dStruct.TotalCount, dt);
  10833. }
  10834. public void aftersale_audit_master()
  10835. {
  10836. if (UrlPostParmsCheck("ctid"))
  10837. {
  10838. string ctid = GetPostString("ctid");
  10839. if (ctid.Length > 0)
  10840. {
  10841. bool result = aftersale_data_change(ctid);
  10842. if (result)
  10843. {
  10844. returnSuccessMsg("修改成功!");
  10845. return;
  10846. }
  10847. }
  10848. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10849. }
  10850. }
  10851. public void aftersale_batch_audit_master()
  10852. {
  10853. if (UrlPostParmsCheck("ctids"))
  10854. {
  10855. string ctids = GetPostString("ctids");
  10856. if (ctids.Length > 0)
  10857. {
  10858. List<string> list = new List<string>();
  10859. string[] ctid_list = ctids.Split(',');
  10860. foreach (var item in ctid_list)
  10861. {
  10862. bool result = aftersale_data_change(item);
  10863. if (!result)
  10864. {
  10865. list.Add(item);
  10866. }
  10867. }
  10868. if (list.Count > 0)
  10869. {
  10870. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10871. return;
  10872. }
  10873. returnSuccessMsg("修改成功!");
  10874. return;
  10875. }
  10876. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10877. }
  10878. }
  10879. public bool aftersale_data_change(string ctid)
  10880. {
  10881. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10882. if (ceErpTradeCell != null)
  10883. {
  10884. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10885. ceErpTradeCell.AfterSaleSupplierState = 0;
  10886. StringBuilder sql = new StringBuilder();
  10887. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10889. CeErpTradeResponsible.DelByTid(ctid, 0);
  10890. 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 == "不理赔")
  10891. {
  10892. CeErpTradeResponsible.DelByTid(ctid, 1);
  10893. ceErpTradeCell.AfterSaleSupplierState = 1;
  10894. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10895. ceErpTradeCell.AfterSaleState = 4;
  10896. }
  10897. else
  10898. {
  10899. ceErpTradeCell.AfterSaleState = 3;
  10900. }
  10901. bool needCyt = false;
  10902. if (dt != null)
  10903. {
  10904. if (dt.Rows.Count == 1)
  10905. {
  10906. bool isEnd = false;
  10907. foreach (DataRow dr in dt.Rows)
  10908. {
  10909. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10910. {
  10911. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10912. isEnd = true;
  10913. }
  10914. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10915. {
  10916. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10917. isEnd = true;
  10918. }
  10919. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10920. {
  10921. needCyt = true;
  10922. }
  10923. }
  10924. if (isEnd)
  10925. {
  10926. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10927. ceErpTradeCell.AfterSaleState = 4;
  10928. ceErpTradeCell.AfterSaleSupplierState = 1;
  10929. }
  10930. }
  10931. else
  10932. {
  10933. bool isAll = true;
  10934. foreach (DataRow dr in dt.Rows)
  10935. {
  10936. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10937. {
  10938. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10939. continue;
  10940. }
  10941. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10942. {
  10943. string path = "";
  10944. int OrgID = 0;
  10945. if (!Convert.IsDBNull(dr["OrgPath"]))
  10946. {
  10947. path = dr["OrgPath"].ToString();
  10948. }
  10949. if (!Convert.IsDBNull(dr["OrgID"]))
  10950. {
  10951. OrgID = Convert.ToInt32(dr["OrgID"]);
  10952. }
  10953. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10954. {
  10955. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10956. continue;
  10957. }
  10958. }
  10959. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10960. {
  10961. needCyt = true;
  10962. }
  10963. isAll = false;
  10964. }
  10965. if (isAll)
  10966. {
  10967. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10968. ceErpTradeCell.AfterSaleState = 4;
  10969. ceErpTradeCell.AfterSaleSupplierState = 1;
  10970. }
  10971. }
  10972. }
  10973. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10974. {
  10975. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10976. }
  10977. if (ceErpTradeCell.AfterSaleState == 4)
  10978. {
  10979. ApiVo apiVo = new ApiVo();
  10980. apiVo.orderNumber = ceErpTradeCell.ctid;
  10981. apiVo.actionName = "afterOver";
  10982. designHelper.API_WorkCore(apiVo); //afterOver
  10983. }
  10984. ceErpTradeCell.Update();
  10985. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10986. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10987. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10988. return true;
  10989. }
  10990. return false;
  10991. }
  10992. public void get_erp_wechatorder()
  10993. {
  10994. DataStruct dStruct = GetPostStruct();
  10995. List<string> lw = new List<string>();
  10996. string tid = GetPostString("tid");
  10997. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10998. string shopname = GetPostString("shopname");
  10999. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11000. string buyernick = GetPostString("buyer_nick");
  11001. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11002. string customer = GetPostString("customer");
  11003. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11004. string returndate1 = GetPostString("returndate1");
  11005. string returndate2 = GetPostString("returndate2");
  11006. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11007. if (dw.Length > 0) lw.Add(dw);
  11008. string finishDate1 = GetPostString("finishdate1");
  11009. string finishDate2 = GetPostString("finishdate2");
  11010. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11011. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11012. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11013. dStruct.Order = "created desc";
  11014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11015. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11016. writeGridDataTableJson(dStruct.TotalCount, dt);
  11017. }
  11018. public void get_erp_wechatlist_sumprice()
  11019. {
  11020. DataStruct dStruct = GetPostStruct();
  11021. List<string> lw = new List<string>();
  11022. string tid = GetPostString("tid");
  11023. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11024. string shopname = GetPostString("shopname");
  11025. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11026. string buyernick = GetPostString("buyer_nick");
  11027. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11028. string customer = GetPostString("customer");
  11029. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11030. string returndate1 = GetPostString("returndate1");
  11031. string returndate2 = GetPostString("returndate2");
  11032. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11033. if (dw.Length > 0) lw.Add(dw);
  11034. string finishDate1 = GetPostString("finishdate1");
  11035. string finishDate2 = GetPostString("finishdate2");
  11036. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11037. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11038. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11039. string mainWhere = string.Join(" and ", lw.ToArray());
  11040. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11041. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11042. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11043. decimal total = 0;
  11044. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11045. {
  11046. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11047. }
  11048. var res = new
  11049. {
  11050. data = total
  11051. };
  11052. string ro_jsond = JsonConvert.SerializeObject(res);
  11053. returnSuccess(ro_jsond);
  11054. return;
  11055. }
  11056. public void get_erp_qr_waitdeliverylist()
  11057. {
  11058. DataStruct dStruct = GetPostStruct();
  11059. List<string> lw = new List<string>();
  11060. string tid = GetPostString("ctid");
  11061. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11062. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11063. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11064. var res_objz = new
  11065. {
  11066. restype = 1,
  11067. data = dt
  11068. };
  11069. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11070. returnSuccess(ro_jsonz);
  11071. }
  11072. public void get_erp_yield_list()
  11073. {
  11074. DataStruct dStruct = GetPostStruct();
  11075. List<string> lw = new List<string>();
  11076. string tid = GetPostString("ctid");
  11077. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11078. string shopname = GetPostString("shopname");
  11079. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11080. string buyernick = GetPostString("buyer_nick");
  11081. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11082. //if (tid.Length == 0 && buyernick.Length == 0)
  11083. //{
  11084. // lw.Add(string.Format("IsRefund<={0}", 1));
  11085. //}
  11086. string customer = GetPostString("customer");
  11087. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11088. string design = GetPostString("design");
  11089. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11090. string orderState = GetPostString("orderState");
  11091. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11092. string address = GetPostString("address");
  11093. 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));
  11094. string sellermemo = GetPostString("seller_memo");
  11095. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11096. string supplier = GetPostString("supplier");
  11097. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11098. string OrderArea = GetPostString("order_area");
  11099. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11100. string placedate1 = GetPostString("placedate1");
  11101. string placedate2 = GetPostString("placedate2");
  11102. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11103. if (fdw.Length > 0) lw.Add(fdw);
  11104. string price1 = GetPostString("price1");
  11105. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11106. string price2 = GetPostString("price2");
  11107. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11108. string unusualCon = GetPostString("unusualcon");
  11109. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11110. string posTag = CurrentUser.UserPost.Post.Code;
  11111. if (posTag == "Supplier")
  11112. {
  11113. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11114. }
  11115. lw.Add(string.Format("OrderState = 6 "));
  11116. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11117. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11118. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11119. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11120. writeGridDataTableJson(dStruct.TotalCount, dt);
  11121. }
  11122. public void change_erp_sup_state()
  11123. {
  11124. if (UrlPostParmsCheck("ctid"))
  11125. {
  11126. string ctid = GetPostString("ctid");
  11127. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11128. if (ceErpTradeCell != null)
  11129. {
  11130. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11131. if (ceErpTradeCellExtend == null)
  11132. {
  11133. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11134. ceErpTradeCellExtend.ctid = ctid;
  11135. ceErpTradeCellExtend.SupState = 1;
  11136. ceErpTradeCellExtend.Create();
  11137. }
  11138. else
  11139. {
  11140. ceErpTradeCellExtend.SupState = 1;
  11141. ceErpTradeCellExtend.Update();
  11142. }
  11143. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11144. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11145. return;
  11146. }
  11147. returnErrorMsg("找不到订单");
  11148. }
  11149. }
  11150. public void supplier_all_downs()
  11151. {
  11152. if (UrlPostParmsCheck("tids"))
  11153. {
  11154. string tids = GetPostString("tids");
  11155. if (tids != null && tids.Length > 0)
  11156. {
  11157. StringBuilder sql = new StringBuilder();
  11158. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11159. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11160. sql = new StringBuilder();
  11161. 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, "下载设计文件");
  11162. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11163. string[] list = tids.Split(',');
  11164. foreach (string ctid in list)
  11165. {
  11166. CeErpSukuraData.createInfo(ctid, 3);
  11167. }
  11168. designHelper.api_approveDesign(tids); //approveDesign
  11169. returnSuccessMsg("下载成功!");
  11170. return;
  11171. }
  11172. returnErrorMsg("下载订单更新失败");
  11173. }
  11174. }
  11175. public void uploaderFileSuccess()
  11176. {
  11177. if (UrlPostParmsCheck("fileName"))
  11178. {
  11179. string fileName = GetPostString("fileName");
  11180. ApiVo apiVo = new ApiVo();
  11181. apiVo.orderNumber = fileName;
  11182. apiVo.actionName = "finishDesign";
  11183. designHelper.API_WorkCore(apiVo);//finishDesign
  11184. returnSuccessMsg("");
  11185. }
  11186. }
  11187. public void get_sample2_order()
  11188. {
  11189. if (UrlPostParmsCheck("ctid"))
  11190. {
  11191. string ctid = GetPostString("ctid");
  11192. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11193. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11194. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11195. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11196. double total = 0.0;
  11197. double order_price = 0.0;
  11198. if (dt_bu.Rows.Count > 0)
  11199. {
  11200. foreach (DataRow dr in dt_bu.Rows)
  11201. {
  11202. total += Convert.ToDouble(dr["payment"]);
  11203. }
  11204. }
  11205. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11206. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11207. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11208. string tid = ctid.Replace("S_", "");
  11209. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11210. double paymant = 0.0;
  11211. if (entity != null)
  11212. {
  11213. paymant = entity.payment;
  11214. }
  11215. string return_reason = "";
  11216. if (dt_after != null && dt_after.Rows.Count > 0)
  11217. {
  11218. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11219. }
  11220. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11221. }
  11222. }
  11223. public void get_erp_design_status()
  11224. {
  11225. string designName = GetPostString("designName");
  11226. DataStruct dStruct = GetPostStruct();
  11227. if (designName.Length > 0)
  11228. {
  11229. 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";
  11230. sql_user += " and Name like '%" + designName + "%'";
  11231. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11232. List<string> ids_list = new List<string>();
  11233. if (user_table.Rows.Count > 0)
  11234. {
  11235. foreach (DataRow item in user_table.Rows)
  11236. {
  11237. ids_list.Add(item["id"].ToString());
  11238. string ids_s = item["TeamIds"].ToString();
  11239. if (ids_s.Length > 0)
  11240. {
  11241. ids_list.AddRange(ids_s.Split(','));
  11242. }
  11243. }
  11244. }
  11245. HashSet<string> set = new HashSet<string>(ids_list);
  11246. ids_list = set.ToList();
  11247. if (ids_list.Count > 0)
  11248. {
  11249. 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));
  11250. dStruct.MainWhere = sql;
  11251. DataTable dt = null;
  11252. dt = WebCache.GetData("view_ErpUser", dStruct);
  11253. writeGridDataTableJson(dStruct.TotalCount, dt);
  11254. }
  11255. }
  11256. }
  11257. public void change_erp_order_price()
  11258. {
  11259. string ctid = GetPostString("ctid");
  11260. double price = GetPostDouble("price");
  11261. if (ctid.Length > 0)
  11262. {
  11263. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11264. if (ceErpTradeCellExtend == null)
  11265. {
  11266. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11267. ceErpTradeCellExtend.ctid = ctid;
  11268. ceErpTradeCellExtend.payment_cyt = price;
  11269. ceErpTradeCellExtend.Create();
  11270. }
  11271. else
  11272. {
  11273. ceErpTradeCellExtend.payment_cyt = price;
  11274. ceErpTradeCellExtend.Update();
  11275. }
  11276. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11277. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11278. {
  11279. ceErpDataSendOrderInfo.isSync = false;
  11280. ceErpDataSendOrderInfo.Update();
  11281. }
  11282. if (ceErpDataSendOrderInfo == null)
  11283. {
  11284. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11285. ceErpDataSendOrderInfo.isSync = false;
  11286. ceErpDataSendOrderInfo.ctid = ctid;
  11287. ceErpDataSendOrderInfo.Create();
  11288. }
  11289. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11290. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11291. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11292. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11293. {
  11294. dataSendOrderBean dataSendOrderBean = null;
  11295. foreach (DataRow item in dth.Rows)
  11296. {
  11297. try
  11298. {
  11299. dataSendOrderBean = new dataSendOrderBean();
  11300. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11301. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11302. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11303. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11304. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11305. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11306. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11307. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11308. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11309. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11310. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11311. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11312. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11313. if (result != null)
  11314. {
  11315. if ("0".Equals(result.errcode))
  11316. {
  11317. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11318. }
  11319. else
  11320. {
  11321. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11322. }
  11323. }
  11324. }
  11325. catch (Exception ex)
  11326. {
  11327. }
  11328. }
  11329. }
  11330. returnSuccessMsg("修改成功!");
  11331. return;
  11332. }
  11333. returnErrorMsg("找不到订单");
  11334. }
  11335. public void find_he_together()
  11336. {
  11337. string ctid = GetPostString("ctid");
  11338. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11339. List<string> list = new List<string>();
  11340. if (ceErpTradeCell != null)
  11341. {
  11342. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11343. {
  11344. 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);
  11345. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11346. if (table != null && table.Rows.Count > 0)
  11347. {
  11348. foreach (TableRow row in table.Rows)
  11349. {
  11350. }
  11351. }
  11352. }
  11353. }
  11354. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11355. }
  11356. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11357. {
  11358. //chy----19
  11359. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11360. //GD-CYT-----64
  11361. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11362. //ZHX----3
  11363. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11364. //JK----97
  11365. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11366. //ZT----70
  11367. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11368. //LHCY-----98
  11369. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11370. //XD-----90
  11371. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11372. //CYCY-----14
  11373. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11374. };
  11375. //其他改名
  11376. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11377. {
  11378. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11379. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11380. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11381. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11382. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11383. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11384. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11385. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11386. };
  11387. //不统计
  11388. List<int> no_suppliers = new List<int>()
  11389. {
  11390. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11391. };
  11392. //配件单
  11393. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11394. {
  11395. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11396. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11397. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11398. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11399. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11400. {"旗杆",new List<string>(){ "班旗" } },
  11401. {"牙签",new List<string>(){ "不干胶" } }
  11402. };
  11403. public void get_place_order_data()
  11404. {
  11405. string date1 = GetPostString("date1");
  11406. string date2 = GetPostString("date2");
  11407. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11408. DateTime start = DateTime.Parse(starttime);
  11409. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11410. DateTime end = DateTime.Parse(endtime);
  11411. if (date1 != null && date1.Length > 0)
  11412. {
  11413. DateTime dateTime = DateTime.Parse(date1);
  11414. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11415. start = DateTime.Parse(starttime);
  11416. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11417. end = DateTime.Parse(endtime);
  11418. }
  11419. if (date2 != null && date2.Length > 0)
  11420. {
  11421. DateTime dateTime = DateTime.Parse(date2);
  11422. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11423. end = DateTime.Parse(endtime);
  11424. }
  11425. 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);
  11426. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11427. //不干胶-----1,卡片-----29
  11428. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11429. foreach (DataRow row in data.Rows)
  11430. {
  11431. int productId = Convert.ToInt32(row["ProductId"]);
  11432. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11433. if (no_suppliers.Contains(supplierId))
  11434. {
  11435. continue;
  11436. }
  11437. string seller_memo = row["seller_memo"].ToString();
  11438. bool ispj = false;//是否配件单
  11439. bool isfirst = true;//第一个配
  11440. maps.Keys.ForEach(key =>
  11441. {
  11442. //备注包含配件
  11443. if (seller_memo.Contains(key) && isfirst)
  11444. {
  11445. List<string> list = maps[key];
  11446. ispj = true;
  11447. isfirst = false;
  11448. for (int i = 0; i < list.Count; i++)
  11449. {
  11450. if (seller_memo.Contains(list[i]))
  11451. {
  11452. ispj = false;
  11453. break;
  11454. }
  11455. }
  11456. }
  11457. });
  11458. if (ispj)
  11459. {
  11460. continue;
  11461. }
  11462. seller_memo = seller_memo.Replace("UV", "uv");
  11463. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11464. //吊牌归到卡片
  11465. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11466. seller_memo = seller_memo.Replace("卡套", "卡片");
  11467. seller_memo = seller_memo.Replace("封套", "卡片");
  11468. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11469. seller_memo = seller_memo.Replace("腰封", "卡片");
  11470. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11471. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11472. seller_memo = seller_memo.Replace("横幅", "条幅");
  11473. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11474. string map_key = "";
  11475. string type = "";
  11476. if (supplierMap.ContainsKey(supplierId))
  11477. {
  11478. foreach (var kvp in supplierMap[supplierId])
  11479. {
  11480. if (seller_memo.Contains(kvp.Key))
  11481. {
  11482. map_key = kvp.Value;
  11483. type = kvp.Value;
  11484. break;
  11485. }
  11486. }
  11487. }
  11488. if (map_key == "")
  11489. {
  11490. type = "其他";
  11491. map_key = "其他";
  11492. }
  11493. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11494. {
  11495. map_key = suppliers[supplierId];
  11496. }
  11497. if (supplierId == 70)
  11498. {
  11499. supplierId = 70;
  11500. }
  11501. map_key += "_" + row["SupplierName"].ToString();
  11502. Dictionary<string, int> map = null;
  11503. if (other_map.ContainsKey(map_key))
  11504. {
  11505. other_map.TryGetValue(map_key, out map);
  11506. }
  11507. else
  11508. {
  11509. map = new Dictionary<string, int>();
  11510. map.Add("dayDev", 0);//当天出货
  11511. map.Add("dayTotal", 0);//下单总数
  11512. map.Add("payTotal", 0);//500以上
  11513. map.Add("today", 0);//当天出货数量
  11514. map.Add("unusua", 0);//异常数
  11515. other_map.Add(map_key, map);
  11516. other_map.TryGetValue(map_key, out map);
  11517. }
  11518. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11519. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11520. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11521. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11522. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11523. {
  11524. map["dayTotal"]++;
  11525. if (supplierId == 97)
  11526. {
  11527. supplierId = 97;
  11528. }
  11529. }
  11530. if (Convert.ToDecimal(row["payment"]) >= 500)
  11531. {
  11532. map["payTotal"]++;
  11533. }
  11534. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11535. {
  11536. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11537. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11538. {
  11539. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11540. {
  11541. map["today"]++;
  11542. }
  11543. }
  11544. else
  11545. {
  11546. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11547. {
  11548. map["today"]++;
  11549. }
  11550. else
  11551. {
  11552. }
  11553. }
  11554. }
  11555. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11556. {
  11557. map["unusua"]++;
  11558. }
  11559. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11560. //GD-CYT-----64
  11561. DateTime two = palceTimeStart.AddHours(14);
  11562. DateTime three = palceTimeStart.AddHours(15);
  11563. DateTime four = palceTimeStart.AddHours(16);
  11564. DateTime six = palceTimeStart.AddHours(18);
  11565. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11566. {
  11567. //下午四点前 500-1000
  11568. string count = row["ProductCount"].ToString();
  11569. if (count != null && count.Length > 0)
  11570. {
  11571. int productCount = commonHelper.getPlaceProductCount(count);
  11572. if (productCount >= 500 && productCount <= 1000)
  11573. {
  11574. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11575. {
  11576. map["dayDev"]++;
  11577. }
  11578. }
  11579. }
  11580. }
  11581. //UV
  11582. else if ("uv".Equals(type))
  11583. {
  11584. //ZT----70
  11585. //ZHX----3
  11586. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11587. {
  11588. map["dayDev"]++;
  11589. }
  11590. //JK----97
  11591. //HZX----105
  11592. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11593. {
  11594. map["dayDev"]++;
  11595. }
  11596. }
  11597. //帆布---52|条幅---27
  11598. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11599. {
  11600. //LHCY-----98
  11601. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11602. {
  11603. map["dayDev"]++;
  11604. }
  11605. }
  11606. //条幅
  11607. else if ("条幅".Equals(type))
  11608. {
  11609. //XD-----90
  11610. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11611. {
  11612. map["dayDev"]++;
  11613. }
  11614. }
  11615. //桌布
  11616. else if ("桌布".Equals(type))
  11617. {
  11618. //XD-----90
  11619. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11620. {
  11621. map["dayDev"]++;
  11622. }
  11623. }
  11624. //DL---10
  11625. //AYTW---119
  11626. //FS-CYT-DY ----80
  11627. //JK----97
  11628. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11629. {
  11630. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11631. {
  11632. map["dayDev"]++;
  11633. }
  11634. }
  11635. // QC---121
  11636. else if (supplierId == 121)
  11637. {
  11638. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11639. {
  11640. map["dayDev"]++;
  11641. }
  11642. }
  11643. }
  11644. DataTable dt = new DataTable();
  11645. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11646. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11647. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11648. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11649. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11650. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11651. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11652. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11653. other_map.Keys.ForEach(key =>
  11654. {
  11655. DataRow dr = dt.NewRow();
  11656. Dictionary<string, int> map = other_map[key];
  11657. string[] key_list = key.Split('_');
  11658. dr[0] = key_list[0];
  11659. dr[1] = key_list[1];
  11660. if (key_list.Length > 2)
  11661. {
  11662. dr[1] += "(" + key_list[2] + ")";
  11663. }
  11664. dr[2] = map["dayTotal"];
  11665. dr[3] = map["payTotal"];
  11666. dr[4] = map["today"];
  11667. dr[5] = map["unusua"];
  11668. dr[6] = map["dayDev"];
  11669. double rate = 0.00;
  11670. if (map["dayDev"] > 0)
  11671. {
  11672. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11673. }
  11674. dr[7] = rate.ToString();
  11675. dt.Rows.Add(dr);
  11676. });
  11677. DataView dv = new DataView(dt);
  11678. dv.Sort = "SupplierName";
  11679. //dv.Sort = "AllOrder desc";
  11680. DataTable dtNew = dv.ToTable();
  11681. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11682. }
  11683. public void check_order_desing_info()
  11684. {
  11685. string ctid = GetPostString("ctid");
  11686. if (!string.IsNullOrEmpty(ctid))
  11687. {
  11688. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11689. if (ceErpTradeCell != null)
  11690. {
  11691. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11692. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11693. return;
  11694. }
  11695. returnErrorMsg("找不到订单");
  11696. return;
  11697. }
  11698. returnErrorMsg("找不到订单");
  11699. }
  11700. public void get_timeout_detail()
  11701. {
  11702. string poscode = CurrentUser.UserPost.Post.Code;
  11703. DataStruct dStruct = GetPostStruct();
  11704. List<string> lw = new List<string>();
  11705. string id = GetPostString("id");
  11706. string pay_date1 = GetPostString("pay_date1");
  11707. string pay_date2 = GetPostString("pay_date2");
  11708. int type = GetPostInt("type");
  11709. if (type == 0)
  11710. {
  11711. if (pay_date1.Length > 0)
  11712. {
  11713. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11714. }
  11715. if (pay_date2.Length > 0)
  11716. {
  11717. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11718. }
  11719. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11720. }
  11721. if (type == 1)
  11722. {
  11723. if (pay_date1.Length > 0)
  11724. {
  11725. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11726. }
  11727. if (pay_date2.Length > 0)
  11728. {
  11729. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11730. }
  11731. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11732. }
  11733. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11734. DataTable dt = null;
  11735. dt = WebCache.GetData("view_orderlist", dStruct);
  11736. writeGridDataTableJson(dStruct.TotalCount, dt);
  11737. }
  11738. public void saveUrgentChargePrice()
  11739. {
  11740. string ctid = GetPostString("ctid");
  11741. if (!string.IsNullOrEmpty(ctid))
  11742. {
  11743. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11744. if (ceErpTradeCell != null)
  11745. {
  11746. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11747. if (prices <= 100)
  11748. {
  11749. returnErrorMsg("此订单金额不足100元,无法加急。");
  11750. return;
  11751. }
  11752. double price = GetPostDouble("price");
  11753. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11754. if (ceErpTradeCellExtend == null)
  11755. {
  11756. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11757. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11758. }
  11759. ceErpTradeCellExtend.urgentCharge = price;
  11760. if (ceErpTradeCellExtend.ID > 0)
  11761. {
  11762. ceErpTradeCellExtend.Update();
  11763. }
  11764. else
  11765. {
  11766. ceErpTradeCellExtend.Save();
  11767. }
  11768. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11769. returnSuccessMsg("修改成功!");
  11770. return;
  11771. }
  11772. returnErrorMsg("找不到订单");
  11773. return;
  11774. }
  11775. returnErrorMsg("找不到订单");
  11776. }
  11777. public void finish_erp_order()
  11778. {
  11779. string ctid = GetPostString("ctid");
  11780. if (!string.IsNullOrEmpty(ctid))
  11781. {
  11782. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11783. {
  11784. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11785. if (ceErpTradeCell != null)
  11786. {
  11787. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11788. ceErpTradeCell.Update();
  11789. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11790. returnSuccessMsg("修改成功!");
  11791. return;
  11792. }
  11793. }
  11794. }
  11795. returnErrorMsg("找不到订单");
  11796. }
  11797. public void get_trade_order_list()
  11798. {
  11799. string tid = GetPostString("tid");
  11800. if (!string.IsNullOrEmpty(tid))
  11801. {
  11802. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11803. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11804. writeGridDataTableJson(data.Rows.Count, data);
  11805. return;
  11806. }
  11807. returnErrorMsg("找不到订单");
  11808. }
  11809. public void save_cell_spu()
  11810. {
  11811. string ctid = GetPostString("ctid");
  11812. string spu_id = GetPostString("spu_id");
  11813. if (!string.IsNullOrEmpty(ctid))
  11814. {
  11815. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11816. if (ceErpTradeCellExtend == null)
  11817. {
  11818. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11819. ceErpTradeCellExtend.ctid = ctid;
  11820. }
  11821. ceErpTradeCellExtend.spu_id = spu_id;
  11822. if (!string.IsNullOrEmpty(spu_id))
  11823. {
  11824. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11825. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11826. }
  11827. if (ceErpTradeCellExtend.ID == 0)
  11828. {
  11829. ceErpTradeCellExtend.Create();
  11830. }
  11831. else
  11832. {
  11833. ceErpTradeCellExtend.Update();
  11834. }
  11835. returnSuccessMsg("修改成功!");
  11836. return;
  11837. }
  11838. returnErrorMsg("找不到订单");
  11839. }
  11840. public void change_express_info()
  11841. {
  11842. string ctid = GetPostString("ctid");
  11843. string transNo = GetPostString("transNo");
  11844. string transCom = GetPostString("transCom");
  11845. if (!string.IsNullOrEmpty(ctid))
  11846. {
  11847. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11848. if (ceErpTradeCellExtend == null)
  11849. {
  11850. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11851. ceErpTradeCellExtend.ctid = ctid;
  11852. }
  11853. ceErpTradeCellExtend.modExpressNo = transNo;
  11854. ceErpTradeCellExtend.modExpressCom = transCom;
  11855. ceErpTradeCellExtend.readMod = 2;
  11856. if (ceErpTradeCellExtend.ID == 0)
  11857. {
  11858. ceErpTradeCellExtend.Create();
  11859. }
  11860. else
  11861. {
  11862. ceErpTradeCellExtend.Update();
  11863. }
  11864. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11865. returnSuccessMsg("修改成功!");
  11866. return;
  11867. }
  11868. returnErrorMsg("找不到订单");
  11869. }
  11870. public void get_change_express_list()
  11871. {
  11872. DataStruct dStruct = GetPostStruct();
  11873. List<string> lw = new List<string>();
  11874. int st = 2;
  11875. string tid = GetPostString("ctid");
  11876. if (tid.Length > 0)
  11877. {
  11878. string select_tid = getTidByCtid(tid);
  11879. lw.Add(string.Format("tid='{0}'", select_tid));
  11880. }
  11881. string shopname = GetPostString("shopname");
  11882. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11883. string buyernick = GetPostString("buyer_nick");
  11884. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11885. string sellermemo = GetPostString("seller_memo");
  11886. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11887. string supplier = GetPostString("supplier");
  11888. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11889. string customer = GetPostString("customer");
  11890. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11891. string design = GetPostString("design");
  11892. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11893. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11894. string poscode = CurrentUser.UserPost.Post.Code;
  11895. if (poscode != "SysAdmin")
  11896. {
  11897. string shopid = CurrentUser.User.pemShop;
  11898. lw.Add(string.Format("shopId in ({0})", shopid));
  11899. }
  11900. lw.Add("readMod = 2");
  11901. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11902. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11903. writeGridDataTableJson(dStruct.TotalCount, dt);
  11904. }
  11905. public void deal_express_complete()
  11906. {
  11907. string ctid = GetPostString("ctid");
  11908. if (!string.IsNullOrEmpty(ctid))
  11909. {
  11910. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11911. if (ceErpTradeCellExtend == null)
  11912. {
  11913. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11914. ceErpTradeCellExtend.ctid = ctid;
  11915. }
  11916. ceErpTradeCellExtend.readMod = 1;
  11917. if (ceErpTradeCellExtend.ID == 0)
  11918. {
  11919. ceErpTradeCellExtend.Create();
  11920. }
  11921. else
  11922. {
  11923. ceErpTradeCellExtend.Update();
  11924. }
  11925. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11926. returnSuccessMsg("修改成功!");
  11927. return;
  11928. }
  11929. returnErrorMsg("找不到订单");
  11930. }
  11931. public void aftersale_return_visit()
  11932. {
  11933. string ctid = GetPostString("ctid");
  11934. if (!string.IsNullOrEmpty(ctid))
  11935. {
  11936. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11937. if (ceErpTradeCellExtend == null)
  11938. {
  11939. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11940. ceErpTradeCellExtend.ctid = ctid;
  11941. }
  11942. ceErpTradeCellExtend.returnVisit = 1;
  11943. if (ceErpTradeCellExtend.ID == 0)
  11944. {
  11945. ceErpTradeCellExtend.Create();
  11946. }
  11947. else
  11948. {
  11949. ceErpTradeCellExtend.Update();
  11950. }
  11951. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11952. if (ceErpTradeAfterSaleExtend != null)
  11953. {
  11954. ceErpTradeAfterSaleExtend.TextResult = "";
  11955. ceErpTradeAfterSaleExtend.Update();
  11956. }
  11957. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11958. returnSuccessMsg("修改成功!");
  11959. return;
  11960. }
  11961. returnErrorMsg("找不到订单");
  11962. }
  11963. public void orderPlaceInfo()
  11964. {
  11965. string ctids = GetPostString("ctids");
  11966. string[] list = ctids.Split(',');
  11967. foreach (string ctid in list)
  11968. {
  11969. CeErpSukuraData.createInfo(ctid, 3);
  11970. }
  11971. StringBuilder sql = new StringBuilder();
  11972. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11973. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11974. designHelper.api_approveDesign(ctids); //approveDesign
  11975. returnSuccessMsg("");
  11976. }
  11977. public void get_issue_list()
  11978. {
  11979. DataStruct dStruct = GetPostStruct();
  11980. List<string> lw = new List<string>();
  11981. int st = 2;
  11982. string tid = GetPostString("ctid");
  11983. if (tid.Length > 0)
  11984. {
  11985. string select_tid = getTidByCtid(tid);
  11986. lw.Add(string.Format("tid='{0}'", select_tid));
  11987. }
  11988. string shopname = GetPostString("shopname");
  11989. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11990. string buyernick = GetPostString("buyer_nick");
  11991. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11992. string sellermemo = GetPostString("seller_memo");
  11993. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11994. string supplier = GetPostString("supplier");
  11995. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11996. string customer = GetPostString("customer");
  11997. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11998. string design = GetPostString("design");
  11999. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12000. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12001. string poscode = CurrentUser.UserPost.Post.Code;
  12002. if (poscode != "SysAdmin")
  12003. {
  12004. string shopid = CurrentUser.User.pemShop;
  12005. lw.Add(string.Format("shopId in ({0})", shopid));
  12006. }
  12007. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12008. {
  12009. lw.Add("IssueState = 1");
  12010. }
  12011. else
  12012. {
  12013. string iisstate = GetPostString("iisstate");
  12014. if ("1".Equals(iisstate))
  12015. {
  12016. lw.Add("IssueState =1");
  12017. }
  12018. else if ("2".Equals(iisstate))
  12019. {
  12020. lw.Add("IssueState = 2");
  12021. }
  12022. else
  12023. {
  12024. lw.Add("IssueState > 0");
  12025. }
  12026. }
  12027. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12028. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12029. writeGridDataTableJson(dStruct.TotalCount, dt);
  12030. }
  12031. public void saveIssueContent()
  12032. {
  12033. string ctid = GetPostString("ctid");
  12034. if (!string.IsNullOrEmpty(ctid))
  12035. {
  12036. string content = GetPostString("content");
  12037. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12038. if (ceErpTradeAfterSaleExtend == null)
  12039. {
  12040. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12041. ceErpTradeAfterSaleExtend.tid = ctid;
  12042. }
  12043. ceErpTradeAfterSaleExtend.IssueContent = content;
  12044. ceErpTradeAfterSaleExtend.IssueState = 1;
  12045. if (ceErpTradeAfterSaleExtend.ID > 0)
  12046. {
  12047. ceErpTradeAfterSaleExtend.Update();
  12048. }
  12049. else
  12050. {
  12051. ceErpTradeAfterSaleExtend.Create();
  12052. }
  12053. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12054. returnSuccessMsg("添加成功!");
  12055. return;
  12056. }
  12057. returnErrorMsg("找不到订单");
  12058. }
  12059. public void dealIssueContent()
  12060. {
  12061. string ctid = GetPostString("ctid");
  12062. if (!string.IsNullOrEmpty(ctid))
  12063. {
  12064. string content = GetPostString("content");
  12065. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12066. if (ceErpTradeAfterSaleExtend != null)
  12067. {
  12068. ceErpTradeAfterSaleExtend.IssueState = 2;
  12069. ceErpTradeAfterSaleExtend.Update();
  12070. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12071. returnSuccessMsg("修改完成!");
  12072. return;
  12073. }
  12074. }
  12075. returnErrorMsg("找不到订单");
  12076. }
  12077. public void set_tid_attachments()
  12078. {
  12079. string tid = GetPostString("tid");
  12080. string atta = GetPostString("atta");
  12081. if (!string.IsNullOrEmpty(tid))
  12082. {
  12083. if (string.IsNullOrEmpty(atta))
  12084. {
  12085. returnErrorMsg("文件地址为空");
  12086. return;
  12087. }
  12088. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12089. if (ceErpTradeCell != null)
  12090. {
  12091. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12092. if (ceErpTrade == null)
  12093. {
  12094. returnErrorMsg("找不到订单");
  12095. return;
  12096. }
  12097. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12098. bool isSend = false;
  12099. if (dt != null && dt.Rows.Count > 0)
  12100. {
  12101. foreach (DataRow row in dt.Rows)
  12102. {
  12103. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12104. {
  12105. isSend = true;
  12106. }
  12107. }
  12108. if (isSend)
  12109. {
  12110. returnErrorMsg("已发货无法修改");
  12111. return;
  12112. }
  12113. ceErpTrade.Attachments = atta;
  12114. ceErpTrade.Update();
  12115. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12116. returnSuccessMsg("上传成功!");
  12117. return;
  12118. }
  12119. }
  12120. }
  12121. returnErrorMsg("找不到订单");
  12122. }
  12123. public void get_tid_attachments()
  12124. {
  12125. string tid = GetPostString("tid");
  12126. if (!string.IsNullOrEmpty(tid))
  12127. {
  12128. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12129. if (ceErpTradeCell != null)
  12130. {
  12131. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12132. if (ceErpTrade == null)
  12133. {
  12134. returnErrorMsg("找不到订单");
  12135. return;
  12136. }
  12137. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12138. return;
  12139. }
  12140. }
  12141. returnErrorMsg("找不到订单");
  12142. }
  12143. public void check_erp_sameorders()
  12144. {
  12145. if (UrlPostParmsCheck("ctid"))
  12146. {
  12147. string eid = GetPostString("ctid");
  12148. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12149. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12150. if (entity != null && ceErpTrade != null)
  12151. {
  12152. if (entity.OrderState > 6)
  12153. {
  12154. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12155. return;
  12156. }
  12157. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12158. List<string> ids = new List<string>();
  12159. if (dt != null && dt.Rows.Count > 1)
  12160. {
  12161. bool needhe = true;
  12162. foreach (DataRow dr in dt.Rows)
  12163. {
  12164. ids.Add("'" + dr["ctid"] + "'");
  12165. /* //备注有合包
  12166. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12167. {
  12168. needhe = true;
  12169. }
  12170. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12171. {
  12172. needhe = true;
  12173. }
  12174. //顺丰快递
  12175. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12176. {
  12177. needhe = true;
  12178. }*/
  12179. }
  12180. if (!needhe)
  12181. {
  12182. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12183. return;
  12184. }
  12185. StringBuilder sql = new StringBuilder();
  12186. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12187. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12188. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12189. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12190. foreach (DataRow dr in dt.Rows)
  12191. {
  12192. dr["dstate"] = 0;
  12193. dr["dnumber"] = 0;
  12194. foreach (DataRow row in dt1.Rows)
  12195. {
  12196. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12197. {
  12198. dr["dstate"] = 2;
  12199. dr["default"] = 1;
  12200. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12201. }
  12202. }
  12203. if (eid.Equals(dr["ctid"].ToString()))
  12204. {
  12205. dr["dstate"] = 1;
  12206. dr["default"] = 1;
  12207. }
  12208. }
  12209. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12210. return;
  12211. }
  12212. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12213. return;
  12214. }
  12215. returnErrorMsg("未找到订单");
  12216. return;
  12217. }
  12218. returnErrorMsg("缺少必要的参数");
  12219. }
  12220. public void get_mark_number()
  12221. {
  12222. string eid = GetPostString("ctid");
  12223. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12224. if (entity != null)
  12225. {
  12226. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12227. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12228. int current = 1;
  12229. if (ceErpDeliverMark == null)
  12230. {
  12231. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12232. List<string> ids = new List<string>();
  12233. if (dt != null && dt.Rows.Count > 1)
  12234. {
  12235. foreach (DataRow dr in dt.Rows)
  12236. {
  12237. ids.Add("'" + dr["ctid"] + "'");
  12238. }
  12239. //查询已有的编号
  12240. StringBuilder sql = new StringBuilder();
  12241. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12242. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12243. if (dt1 == null || dt1.Rows.Count == 0)
  12244. {
  12245. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12246. List<int> list_number = new List<int>();
  12247. foreach (DataRow row in numbers.Rows)
  12248. {
  12249. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12250. }
  12251. //查询空余编号
  12252. for (int i = 0; i < list_number.Count + 2; i++)
  12253. {
  12254. if (!list_number.Contains(current))
  12255. {
  12256. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12257. //防止查询过程中有新数据生成
  12258. if (ceErpDeliverMark1 == null)
  12259. {
  12260. break;
  12261. }
  12262. }
  12263. current++;
  12264. }
  12265. }
  12266. else
  12267. {
  12268. foreach (DataRow row in dt1.Rows)
  12269. {
  12270. current = Convert.ToInt32(row["markNumber"]);
  12271. }
  12272. }
  12273. ceErpDeliverMark = new CeErpDeliverMark();
  12274. ceErpDeliverMark.ctid = eid;
  12275. ceErpDeliverMark.createtime = DateTime.Now;
  12276. if (ceErpTrade != null)
  12277. {
  12278. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12279. }
  12280. ceErpDeliverMark.markNumber = current;
  12281. ceErpDeliverMark.Create();
  12282. }
  12283. }
  12284. else
  12285. {
  12286. current = ceErpDeliverMark.markNumber;
  12287. }
  12288. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12289. return;
  12290. }
  12291. }
  12292. public void aftersaleCytSend()
  12293. {
  12294. string ctid = GetPostString("ctid");
  12295. if (!string.IsNullOrEmpty(ctid))
  12296. {
  12297. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12298. if (ceErpTradeCell != null)
  12299. {
  12300. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12301. }
  12302. returnSuccessMsg("推送成功");
  12303. return;
  12304. }
  12305. returnErrorMsg("缺少必要的参数");
  12306. }
  12307. public void packOrderInfo()
  12308. {
  12309. string ctids = GetPostString("ctids");
  12310. if (!string.IsNullOrEmpty(ctids))
  12311. {
  12312. string[] ctid_list = ctids.Split(',');
  12313. if (ctid_list.Length > 20)
  12314. {
  12315. returnErrorMsg("单次下载次数不能超过20个");
  12316. return;
  12317. }
  12318. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12319. StringBuilder sql = new StringBuilder();
  12320. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12321. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12322. int supplierId = 0;
  12323. StringBuilder insterSql = new StringBuilder();
  12324. for (int i = 0; i < dt.Rows.Count; i++)
  12325. {
  12326. DataRow row = dt.Rows[i];
  12327. if (i == 0)
  12328. {
  12329. supplierId = Convert.ToInt32(row["SupplierId"]);
  12330. }
  12331. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12332. {
  12333. returnErrorMsg("同车间的订单才能一起打包");
  12334. return;
  12335. }
  12336. int orderState = Convert.ToInt32(row["OrderState"]);
  12337. if (orderState != 5)
  12338. {
  12339. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12340. return;
  12341. }
  12342. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12343. }
  12344. CeErpPackData ceErpPackData = new CeErpPackData();
  12345. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12346. ceErpPackData.supplierId = supplierId;
  12347. ceErpPackData.createtime = DateTime.Now;
  12348. ceErpPackData.createBy = CurrentUser.UserID;
  12349. ceErpPackData.createName = CurrentUser.UserName;
  12350. ceErpPackData.Create();
  12351. if (ceErpPackData.ID > 0)
  12352. {
  12353. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12354. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12355. }
  12356. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12357. returnSuccessMsg("打包成功");
  12358. return;
  12359. }
  12360. returnErrorMsg("缺少必要的参数");
  12361. }
  12362. public void rePackOrderInfo()
  12363. {
  12364. string id = GetPostString("id");
  12365. if (!string.IsNullOrEmpty(id))
  12366. {
  12367. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12368. if (ceErpPackData == null)
  12369. {
  12370. returnSuccessMsg("查无数据");
  12371. return;
  12372. }
  12373. ceErpPackData.upStatus = 0;
  12374. ceErpPackData.message = "";
  12375. ceErpPackData.Update();
  12376. returnSuccessMsg("打包成功");
  12377. return;
  12378. }
  12379. returnErrorMsg("缺少必要的参数");
  12380. }
  12381. public void backPackOrderInfo()
  12382. {
  12383. string id = GetPostString("id");
  12384. if (!string.IsNullOrEmpty(id))
  12385. {
  12386. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12387. if (ceErpPackData == null)
  12388. {
  12389. returnSuccessMsg("查无数据");
  12390. return;
  12391. }
  12392. ceErpPackData.upStatus = 4;
  12393. ceErpPackData.Update();
  12394. List<string> list = new List<string>();
  12395. StringBuilder sql = new StringBuilder();
  12396. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12397. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12398. for (int i = 0; i < dt.Rows.Count; i++)
  12399. {
  12400. DataRow row = dt.Rows[i];
  12401. list.Add("'" + row["ctid"].ToString() + "'");
  12402. }
  12403. string textCtids = string.Join(",", list);
  12404. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12405. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12406. returnSuccessMsg("退回成功");
  12407. return;
  12408. }
  12409. returnErrorMsg("缺少必要的参数");
  12410. }
  12411. public void addPackDownNum()
  12412. {
  12413. string id = GetPostString("id");
  12414. if (!string.IsNullOrEmpty(id))
  12415. {
  12416. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12417. returnSuccessMsg("下载成功");
  12418. return;
  12419. }
  12420. returnErrorMsg("缺少必要的参数");
  12421. }
  12422. public void get_pack_list()
  12423. {
  12424. DataStruct dStruct = GetPostStruct();
  12425. List<string> lw = new List<string>();
  12426. string supplier = GetPostString("supplier");
  12427. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12428. string posTag = CurrentUser.UserPost.Post.Code;
  12429. if (posTag == "Supplier")
  12430. {
  12431. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12432. }
  12433. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12434. dStruct.Order = "createtime desc";
  12435. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12436. writeGridDataTableJson(dStruct.TotalCount, dt);
  12437. }
  12438. public void get_pack_order_list()
  12439. {
  12440. string packId = GetPostString("packId");
  12441. if (string.IsNullOrEmpty(packId))
  12442. {
  12443. returnErrorMsg("缺少必要的参数");
  12444. return;
  12445. }
  12446. StringBuilder sql = new StringBuilder();
  12447. 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);
  12448. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12449. if (dt == null || dt.Rows.Count == 0)
  12450. {
  12451. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12452. return;
  12453. }
  12454. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12455. return;
  12456. }
  12457. public void get_supplier_product_time_list()
  12458. {
  12459. DataStruct dStruct = GetPostStruct();
  12460. List<string> lw = new List<string>();
  12461. string supplier = GetPostString("supplier");
  12462. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12463. string posTag = CurrentUser.UserPost.Post.Code;
  12464. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12465. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12466. writeGridDataTableJson(dStruct.TotalCount, dt);
  12467. }
  12468. public void saveSupplierProductTime()
  12469. {
  12470. string productId = GetPostString("productId");
  12471. if (string.IsNullOrEmpty(productId))
  12472. {
  12473. returnErrorMsg("缺少必要的参数");
  12474. return;
  12475. }
  12476. string productName = GetPostString("productName");
  12477. int supplierId = GetPostInt("supplierId");
  12478. if (supplierId == 0)
  12479. {
  12480. returnErrorMsg("缺少必要的参数");
  12481. return;
  12482. }
  12483. int quantity = GetPostInt("quantity");
  12484. int sendDay = GetPostInt("sendTime");
  12485. string supplierName = GetPostString("supplierName");
  12486. string craft = GetPostString("craft");
  12487. string deadLine = GetPostString("deadLine");
  12488. string dayDeadLine = GetPostString("dayDeadLine");
  12489. try
  12490. {
  12491. int eid = GetPostInt("eid");
  12492. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12493. if (ceErpSupplierProductTime == null)
  12494. {
  12495. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12496. }
  12497. ceErpSupplierProductTime.productId = productId;
  12498. ceErpSupplierProductTime.productName = productName;
  12499. ceErpSupplierProductTime.supplierId = supplierId;
  12500. ceErpSupplierProductTime.supplierName = supplierName;
  12501. ceErpSupplierProductTime.craft = craft;
  12502. ceErpSupplierProductTime.sendDay = sendDay;
  12503. ceErpSupplierProductTime.quantity = quantity;
  12504. if (!string.IsNullOrEmpty(deadLine))
  12505. {
  12506. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12507. }
  12508. if (!string.IsNullOrEmpty(dayDeadLine))
  12509. {
  12510. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12511. }
  12512. if (ceErpSupplierProductTime.ID == 0)
  12513. {
  12514. ceErpSupplierProductTime.Save();
  12515. }
  12516. else
  12517. {
  12518. ceErpSupplierProductTime.Update();
  12519. }
  12520. }
  12521. catch (Exception e)
  12522. {
  12523. }
  12524. returnSuccessMsg("保存成功");
  12525. return;
  12526. }
  12527. public void delSupplierProductTime()
  12528. {
  12529. int eid = GetPostInt("eid");
  12530. if (eid > 0)
  12531. {
  12532. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12533. if (ceErpSupplierProductTime == null)
  12534. {
  12535. returnErrorMsg("查无数据");
  12536. return;
  12537. }
  12538. ceErpSupplierProductTime.Delete();
  12539. returnSuccessMsg("保存成功");
  12540. return;
  12541. }
  12542. returnErrorMsg("缺少必要的参数");
  12543. }
  12544. public void getExpressInfo()
  12545. {
  12546. string ctid = GetPostString("ctid");
  12547. if (!string.IsNullOrEmpty(ctid))
  12548. {
  12549. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12550. if (ceErpTradeCell != null)
  12551. {
  12552. string outSid = ceErpTradeCell.OutSid;
  12553. if (outSid.Length > 0)
  12554. {
  12555. 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);
  12556. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12557. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12558. return;
  12559. }
  12560. }
  12561. returnErrorMsg("查无记录");
  12562. return;
  12563. }
  12564. returnErrorMsg("缺少必要的参数");
  12565. }
  12566. public void getExpressPostData()
  12567. {
  12568. string express = GetPostString("express");
  12569. if (!string.IsNullOrEmpty(express))
  12570. {
  12571. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12572. if (ceErpExpressInfo != null)
  12573. {
  12574. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12575. return;
  12576. }
  12577. }
  12578. returnErrorMsg("缺少必要的参数");
  12579. }
  12580. public void checkSupplierOrder()
  12581. {
  12582. string ctids = GetPostString("ctids");
  12583. if (ctids != null)
  12584. {
  12585. List<string> list = new List<string>();
  12586. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12587. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12588. for (int i = 0; i < dt.Rows.Count; i++)
  12589. {
  12590. DataRow row = dt.Rows[i];
  12591. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12592. {
  12593. continue;
  12594. }
  12595. list.Add(row["seller_memo"].ToString());
  12596. }
  12597. if (list.Count > 0)
  12598. {
  12599. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12600. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12601. return;
  12602. }
  12603. }
  12604. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12605. return;
  12606. }
  12607. public void addPersonId()
  12608. {
  12609. string tid = GetPostString("tid");
  12610. string personId = GetPostString("personId");
  12611. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12612. if (ceErpTrade != null)
  12613. {
  12614. ceErpTrade.receiver_zip = personId;
  12615. ceErpTrade.Update();
  12616. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12617. returnSuccessMsg("保存成功");
  12618. return;
  12619. }
  12620. returnErrorMsg("缺少必要的参数");
  12621. }
  12622. public void addDeliveryPaymant()
  12623. {
  12624. string tid = GetPostString("tid");
  12625. string paymant = GetPostString("paymant");
  12626. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12627. if (ceErpTrade != null)
  12628. {
  12629. if (!string.IsNullOrEmpty(paymant))
  12630. {
  12631. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12632. }
  12633. ceErpTrade.Update();
  12634. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12635. returnSuccessMsg("保存成功");
  12636. return;
  12637. }
  12638. returnErrorMsg("缺少必要的参数");
  12639. }
  12640. public void saveCellFile()
  12641. {
  12642. string tid = GetPostString("tid");
  12643. string ctid = GetPostString("ctid");
  12644. string urls = GetPostString("urls");
  12645. string type = GetPostString("type");
  12646. string del = GetPostString("del");
  12647. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12648. {
  12649. if ("1".Equals(del))
  12650. {
  12651. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12652. }
  12653. string[] list = urls.Split(',');
  12654. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12655. {
  12656. foreach (string item in list)
  12657. {
  12658. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12659. ceErpTradeCellFile.Create();
  12660. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12661. }
  12662. }
  12663. returnSuccessMsg("保存成功");
  12664. return;
  12665. }
  12666. returnErrorMsg("缺少必要的参数");
  12667. }
  12668. public void getCellFile()
  12669. {
  12670. string tid = GetPostString("tid");
  12671. string ctid = GetPostString("ctid");
  12672. string type = GetPostString("type");
  12673. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12674. {
  12675. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12676. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12677. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12678. return;
  12679. }
  12680. returnErrorMsg("缺少必要的参数");
  12681. }
  12682. public void delCellFile()
  12683. {
  12684. string id = GetPostString("id");
  12685. if (string.IsNullOrEmpty(id))
  12686. {
  12687. returnErrorMsg("缺少必要的参数");
  12688. return;
  12689. }
  12690. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12691. CeErpTradeCellFile.delByID(id);
  12692. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12693. returnSuccessMsg("保存成功");
  12694. }
  12695. }
  12696. }